Skip to content

Commit

Permalink
Fix mixin incompat with Aquamirae (and likely other mods)
Browse files Browse the repository at this point in the history
  • Loading branch information
Luligabi1 committed Aug 21, 2023
1 parent 9a7d805 commit 8dfa27f
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 6 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def getChangeLog() {


repositories {
maven { url = "https://jitpack.io" }
maven { url = "https://maven.terraformersmc.com/releases/" }
}

Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ yarn_mappings=1.20.1+build.10
loader_version=0.14.22

#Fabric api
fabric_version=0.86.1+1.20.1
fabric_version=0.87.0+1.20.1
loom_version=1.3

# Mod Properties
Expand All @@ -30,6 +30,7 @@ libguiVersion=8.0.0-beta.1+1.20-rc1
palVersion=1.8.0
reiVersion=12.0.625
energyVersion=2.3.0
mixinextrasVersion=0.1.1
modmenuVersion=7.0.0

mcdUsername=mcd
Expand Down
10 changes: 10 additions & 0 deletions modular-armor/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
val palVersion: String by project
val libguiVersion: String by project
val mixinextrasVersion: String by project

repositories {
maven {
Expand All @@ -14,6 +15,10 @@ repositories {
name = "CottonMC"
url = uri("https://server.bbkr.space/artifactory/libs-release")
}
maven {
name = "JitPack"
url = uri("https://jitpack.io")
}
}

dependencies {
Expand All @@ -24,4 +29,9 @@ dependencies {

modApi("io.github.cottonmc:LibGui:${libguiVersion}")
include("io.github.cottonmc:LibGui:${libguiVersion}")


modApi("com.github.LlamaLad7:MixinExtras:${mixinextrasVersion}")
include("com.github.LlamaLad7:MixinExtras:${mixinextrasVersion}")
annotationProcessor("com.github.LlamaLad7:MixinExtras:${mixinextrasVersion}")
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
* along with Deep Mob Learning: Refabricated. If not, see <https://www.gnu.org/licenses/>.
*/

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import dev.nathanpb.dml.item.ItemEmeritusHat;
import dev.nathanpb.dml.modular_armor.EntityStatusEffectsKt;
import dev.nathanpb.dml.modular_armor.ItemModularGlitchArmor;
import dev.nathanpb.dml.modular_armor.effects.RotResistanceEffect;
import dev.nathanpb.dml.modular_armor.effects.TargetCancellationEffect;
import dev.nathanpb.dml.modular_armor.effects.UndyingEffect;
import net.minecraft.entity.DamageUtil;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
Expand Down Expand Up @@ -109,8 +110,11 @@ public List<Pair<StatusEffectInstance, Float>> applyFoodEffects(List<Pair<Status
.attemptToCancelHunger((LivingEntity) (Object) this, stack, effects);
}

@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/DamageUtil;getDamageLeft(FFF)F"), method = "applyArmorToDamage")
public float glitchArmorUncapProtection(float damage, float armor, float armorToughness, DamageSource source, float damage2) {
@WrapOperation(
method = "applyArmorToDamage",
at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/DamageUtil;getDamageLeft(FFF)F")
)
public float glitchArmorUncapProtection(float damage, float armor, float armorToughness, Operation<Float> original) {
boolean shouldUncap = StreamSupport.stream(((LivingEntity) (Object) this).getArmorItems().spliterator(), false)
.anyMatch(it -> it.getItem() instanceof ItemModularGlitchArmor);

Expand All @@ -119,7 +123,7 @@ public float glitchArmorUncapProtection(float damage, float armor, float armorTo
float g = Math.max(armor - damage / f, armor * 0.2F);
return damage * (1.0F - g / 25.0F);
} else {
return DamageUtil.getDamageLeft(damage, armor, armorToughness);
return original.call(damage, armor, armorToughness);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
*
* Copyright (C) 2021 Nathan P. Bombana, IterationFunk
*
* This file is part of Deep Mob Learning: Refabricated.
*
* Deep Mob Learning: Refabricated is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Deep Mob Learning: Refabricated is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Deep Mob Learning: Refabricated. If not, see <https://www.gnu.org/licenses/>.
*/

package dev.nathanpb.dml.modular_armor

import com.llamalad7.mixinextras.MixinExtrasBootstrap
import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint

class InitPreLaunch : PreLaunchEntrypoint {

override fun onPreLaunch() {
MixinExtrasBootstrap.init()
}

}
3 changes: 2 additions & 1 deletion modular-armor/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"environment": "*",
"entrypoints": {
"main": ["dev.nathanpb.dml.modular_armor.InitKt::init"],
"client": ["dev.nathanpb.dml.modular_armor.InitClientKt::initClient"]
"client": ["dev.nathanpb.dml.modular_armor.InitClientKt::initClient"],
"preLaunch": ["dev.nathanpb.dml.modular_armor.InitPreLaunch"]
},
"mixins": ["mixins.dml-refabricated-modular-armor.json"],
"depends": {
Expand Down

0 comments on commit 8dfa27f

Please sign in to comment.