From c8def523dc32ff62202aabb52f0626d2c0b6fa30 Mon Sep 17 00:00:00 2001 From: jchung01 Date: Sun, 22 Sep 2024 21:17:21 -0700 Subject: [PATCH 1/4] Add InControl mixin to fix various stat doubling - Implements McJtyMods/McJtyTools@9cd16506 --- dependencies.gradle | 2 + gradle.properties | 1 + repositories.gradle | 4 ++ .../universaltweaks/core/UTMixinLoader.java | 2 + .../mods/incontrol/Attributes.java | 20 ++++++++ .../mods/incontrol/mixin/UTRuleBaseMixin.java | 48 +++++++++++++++++++ src/main/resources/mixins.mods.incontrol.json | 7 +++ 7 files changed, 84 insertions(+) create mode 100644 src/main/java/mod/acgaming/universaltweaks/mods/incontrol/Attributes.java create mode 100644 src/main/java/mod/acgaming/universaltweaks/mods/incontrol/mixin/UTRuleBaseMixin.java create mode 100644 src/main/resources/mixins.mods.incontrol.json diff --git a/dependencies.gradle b/dependencies.gradle index ddf7ef4c..f88d89a6 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -49,6 +49,7 @@ final def mod_dependencies = [ 'codechicken:ChickenASM:1.12-1.0.2.9' : [debug_forgemultipartcbe, debug_project_red], 'com.blamejared:MTLib:3.0.5.15' : [debug_crafttweaker], 'com.enderio:endercore:0.5.78' : [debug_enderio], + 'com.github.mcjty:mcjtytools:1.12-0.0.21' : [debug_incontrol], 'com.teamacronymcoders.base:base:1.12.2-3.14.0' : [debug_crafttweaker], 'com.teamacronymcoders:ContentTweaker:1.12.2-4.10.0' : [debug_crafttweaker], 'crazypants:enderio:5.3.72' : [debug_enderio], @@ -90,6 +91,7 @@ final def mod_dependencies = [ 'curse.maven:geckolib-388172:4020277' : [debug_cqrepoured], 'curse.maven:guideapi-228832:2645992' : [debug_blood_magic], 'curse.maven:hwyla-253449:2568751' : [debug_hwyla], + 'curse.maven:incontrol-257356:3101719' : [debug_incontrol], 'curse.maven:industrialcraft-242638:3078604' : [debug_industrialcraft], 'curse.maven:ironbackpacks-227049:2564573' : [debug_iron_backpacks], 'curse.maven:ironchests-228756:2747935' : [debug_iron_chests], diff --git a/gradle.properties b/gradle.properties index 4c49b0ef..d997ff6a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -34,6 +34,7 @@ debug_extra_utilities_2 = false debug_forestry = false debug_forgemultipartcbe = false debug_hwyla = false +debug_incontrol = true debug_industrial_foregoing = false debug_industrialcraft = false debug_iron_backpacks = false diff --git a/repositories.gradle b/repositories.gradle index 5436dca9..640484d9 100644 --- a/repositories.gradle +++ b/repositories.gradle @@ -9,4 +9,8 @@ repositories { name 'ChickenASM' url 'https://nexus.covers1624.net/repository/maven-releases/' } + maven { + name 'McJty Tools' + url 'https://maven.k-4u.nl/' + } } \ No newline at end of file diff --git a/src/main/java/mod/acgaming/universaltweaks/core/UTMixinLoader.java b/src/main/java/mod/acgaming/universaltweaks/core/UTMixinLoader.java index 496e397b..909775ad 100644 --- a/src/main/java/mod/acgaming/universaltweaks/core/UTMixinLoader.java +++ b/src/main/java/mod/acgaming/universaltweaks/core/UTMixinLoader.java @@ -74,6 +74,8 @@ public class UTMixinLoader implements ILateMixinLoader put("mixins.mods.forestry.dupes.json", () -> loaded("forestry") && UTConfigMods.FORESTRY.utDuplicationFixesToggle); put("mixins.mods.forestry.extratrees.json", () -> loaded("extratrees")); put("mixins.mods.forestry.json", () -> loaded("forestry")); + // TODO: Add config + put("mixins.mods.incontrol.json", () -> loaded("incontrol")); put("mixins.mods.industrialcraft.dupes.json", () -> loaded("ic2") && UTConfigMods.INDUSTRIALCRAFT.utDuplicationFixesToggle); put("mixins.mods.industrialforegoing.dupes.json", () -> loaded("industrialforegoing") && UTConfigMods.INDUSTRIAL_FOREGOING.utDuplicationFixesToggle); put("mixins.mods.industrialforegoing.rangeaddon.json", () -> loaded("industrialforegoing") && UTConfigMods.INDUSTRIAL_FOREGOING.utRangeAddonNumberFix); diff --git a/src/main/java/mod/acgaming/universaltweaks/mods/incontrol/Attributes.java b/src/main/java/mod/acgaming/universaltweaks/mods/incontrol/Attributes.java new file mode 100644 index 00000000..fb15fc19 --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/mods/incontrol/Attributes.java @@ -0,0 +1,20 @@ +package mod.acgaming.universaltweaks.mods.incontrol; + +public enum Attributes +{ + HEALTH("ctrlHealth"), + SPEED("ctrlSpeed"), + DAMAGE("ctrlDamage"); + + final String tag; + + Attributes(String tag) + { + this.tag = tag; + } + + public String getTag() + { + return tag; + } +} diff --git a/src/main/java/mod/acgaming/universaltweaks/mods/incontrol/mixin/UTRuleBaseMixin.java b/src/main/java/mod/acgaming/universaltweaks/mods/incontrol/mixin/UTRuleBaseMixin.java new file mode 100644 index 00000000..3ff61d1e --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/mods/incontrol/mixin/UTRuleBaseMixin.java @@ -0,0 +1,48 @@ +package mod.acgaming.universaltweaks.mods.incontrol.mixin; + +import mcjty.tools.rules.RuleBase; +import mod.acgaming.universaltweaks.mods.incontrol.Attributes; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(value = RuleBase.class, remap = false) +public class UTRuleBaseMixin +{ + @Inject(method = "lambda$addHealthAction$23", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/SharedMonsterAttributes;MAX_HEALTH:Lnet/minecraft/entity/ai/attributes/IAttribute;", remap = true), cancellable = true) + private static void utCheckHealthTag(float m, float a, RuleBase.EventGetter event, CallbackInfo ci) + { + if (event.getEntityLiving().getTags().contains(Attributes.HEALTH.getTag())) ci.cancel(); + } + + @Inject(method = "lambda$addHealthAction$23", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/EntityLivingBase;setHealth(F)V", shift = At.Shift.AFTER, remap = true)) + private static void utAddHealthTag(float m, float a, RuleBase.EventGetter event, CallbackInfo ci) + { + event.getEntityLiving().addTag(Attributes.HEALTH.getTag()); + } + + @Inject(method = "lambda$addSpeedAction$24", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/SharedMonsterAttributes;MOVEMENT_SPEED:Lnet/minecraft/entity/ai/attributes/IAttribute;", remap = true), cancellable = true) + private static void utCheckSpeedTag(float m, float a, RuleBase.EventGetter event, CallbackInfo ci) + { + if (event.getEntityLiving().getTags().contains(Attributes.SPEED.getTag())) ci.cancel(); + } + + @Inject(method = "lambda$addSpeedAction$24", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/ai/attributes/IAttributeInstance;setBaseValue(D)V", shift = At.Shift.AFTER, remap = true)) + private static void utAddSpeedTag(float m, float a, RuleBase.EventGetter event, CallbackInfo ci) + { + event.getEntityLiving().addTag(Attributes.SPEED.getTag()); + } + + @Inject(method = "lambda$addDamageAction$26", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/SharedMonsterAttributes;ATTACK_DAMAGE:Lnet/minecraft/entity/ai/attributes/IAttribute;", remap = true), cancellable = true) + private static void utCheckDamageTag(float m, float a, RuleBase.EventGetter event, CallbackInfo ci) + { + if (event.getEntityLiving().getTags().contains(Attributes.DAMAGE.getTag())) ci.cancel(); + } + + @Inject(method = "lambda$addDamageAction$26", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/ai/attributes/IAttributeInstance;setBaseValue(D)V", shift = At.Shift.AFTER, remap = true)) + private static void utAddDamageTag(float m, float a, RuleBase.EventGetter event, CallbackInfo ci) + { + event.getEntityLiving().addTag(Attributes.DAMAGE.getTag()); + } +} diff --git a/src/main/resources/mixins.mods.incontrol.json b/src/main/resources/mixins.mods.incontrol.json new file mode 100644 index 00000000..9155d0a4 --- /dev/null +++ b/src/main/resources/mixins.mods.incontrol.json @@ -0,0 +1,7 @@ +{ + "package": "mod.acgaming.universaltweaks.mods.incontrol.mixin", + "refmap": "universaltweaks.refmap.json", + "minVersion": "0.8", + "compatibilityLevel": "JAVA_8", + "mixins": ["UTRuleBaseMixin"] +} \ No newline at end of file From f6f472619115c2284e0ebeb0e7b680b096ea3a19 Mon Sep 17 00:00:00 2001 From: jchung01 Date: Tue, 24 Sep 2024 14:53:36 -0700 Subject: [PATCH 2/4] Add same fix for SummonAid rules --- .../incontrol/mixin/UTSummonAidRuleMixin.java | 57 +++++++++++++++++++ src/main/resources/mixins.mods.incontrol.json | 2 +- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/main/java/mod/acgaming/universaltweaks/mods/incontrol/mixin/UTSummonAidRuleMixin.java diff --git a/src/main/java/mod/acgaming/universaltweaks/mods/incontrol/mixin/UTSummonAidRuleMixin.java b/src/main/java/mod/acgaming/universaltweaks/mods/incontrol/mixin/UTSummonAidRuleMixin.java new file mode 100644 index 00000000..1a70e565 --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/mods/incontrol/mixin/UTSummonAidRuleMixin.java @@ -0,0 +1,57 @@ +package mod.acgaming.universaltweaks.mods.incontrol.mixin; + +import org.apache.logging.log4j.Logger; + +import mcjty.incontrol.rules.SummonAidRule; +import mcjty.incontrol.rules.SummonEventGetter; +import mcjty.tools.rules.RuleBase; +import mod.acgaming.universaltweaks.mods.incontrol.Attributes; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(value = SummonAidRule.class, remap = false) +public abstract class UTSummonAidRuleMixin extends RuleBase +{ + private UTSummonAidRuleMixin(Logger logger) + { + super(logger); + } + + @Inject(method = "lambda$addHealthAction$6", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/SharedMonsterAttributes;MAX_HEALTH:Lnet/minecraft/entity/ai/attributes/IAttribute;", remap = true), cancellable = true) + private static void utCheckHealthTag(float m, float a, SummonEventGetter event, CallbackInfo ci) + { + if (event.getZombieHelper().getTags().contains(Attributes.HEALTH.getTag())) ci.cancel(); + } + + @Inject(method = "lambda$addHealthAction$6", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/monster/EntityZombie;setHealth(F)V", shift = At.Shift.AFTER, remap = true)) + private static void utAddHealthTag(float m, float a, SummonEventGetter event, CallbackInfo ci) + { + event.getZombieHelper().addTag(Attributes.HEALTH.getTag()); + } + + @Inject(method = "lambda$addSpeedAction$7", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/SharedMonsterAttributes;MOVEMENT_SPEED:Lnet/minecraft/entity/ai/attributes/IAttribute;", remap = true), cancellable = true) + private static void utCheckSpeedTag(float m, float a, SummonEventGetter event, CallbackInfo ci) + { + if (event.getZombieHelper().getTags().contains(Attributes.SPEED.getTag())) ci.cancel(); + } + + @Inject(method = "lambda$addSpeedAction$7", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/ai/attributes/IAttributeInstance;setBaseValue(D)V", shift = At.Shift.AFTER, remap = true)) + private static void utAddSpeedTag(float m, float a, SummonEventGetter event, CallbackInfo ci) + { + event.getZombieHelper().addTag(Attributes.SPEED.getTag()); + } + + @Inject(method = "lambda$addDamageAction$9", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/SharedMonsterAttributes;ATTACK_DAMAGE:Lnet/minecraft/entity/ai/attributes/IAttribute;", remap = true), cancellable = true) + private static void utCheckDamageTag(float m, float a, SummonEventGetter event, CallbackInfo ci) + { + if (event.getZombieHelper().getTags().contains(Attributes.DAMAGE.getTag())) ci.cancel(); + } + + @Inject(method = "lambda$addDamageAction$9", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/ai/attributes/IAttributeInstance;setBaseValue(D)V", shift = At.Shift.AFTER, remap = true)) + private static void utAddDamageTag(float m, float a, SummonEventGetter event, CallbackInfo ci) + { + event.getZombieHelper().addTag(Attributes.DAMAGE.getTag()); + } +} diff --git a/src/main/resources/mixins.mods.incontrol.json b/src/main/resources/mixins.mods.incontrol.json index 9155d0a4..696f1c92 100644 --- a/src/main/resources/mixins.mods.incontrol.json +++ b/src/main/resources/mixins.mods.incontrol.json @@ -3,5 +3,5 @@ "refmap": "universaltweaks.refmap.json", "minVersion": "0.8", "compatibilityLevel": "JAVA_8", - "mixins": ["UTRuleBaseMixin"] + "mixins": ["UTRuleBaseMixin", "UTSummonAidRuleMixin"] } \ No newline at end of file From a8781adb86fb21d75be78e3383949abf6ccb5e9b Mon Sep 17 00:00:00 2001 From: jchung01 Date: Tue, 24 Sep 2024 15:15:24 -0700 Subject: [PATCH 3/4] Update config/readme --- README.md | 2 ++ gradle.properties | 2 +- .../universaltweaks/config/UTConfigMods.java | 12 ++++++++++++ .../acgaming/universaltweaks/core/UTMixinLoader.java | 3 +-- .../resources/assets/universaltweaks/lang/en_us.lang | 1 + 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 773a5cf0..8af4b0d0 100644 --- a/README.md +++ b/README.md @@ -343,6 +343,8 @@ All changes are toggleable via config files. * **Replanting Cocoa Beans:** Allows Forestry farms to automatically replant cocoa beans * **HWYLA** * **Keybindings Fix:** Fixes crashes in all menus when changing HWYLA keybindings to unsupported values +* **In Control!** + * **Spawn Rule Stats Fix:** Fixes onJoin spawn rules repeatedly modifying mob attack/health/speed * **IndustrialCraft 2** * **Duplication Fixes:** Fixes various duplication exploits * **Industrial Foregoing** diff --git a/gradle.properties b/gradle.properties index d997ff6a..7bf61280 100644 --- a/gradle.properties +++ b/gradle.properties @@ -34,7 +34,7 @@ debug_extra_utilities_2 = false debug_forestry = false debug_forgemultipartcbe = false debug_hwyla = false -debug_incontrol = true +debug_incontrol = false debug_industrial_foregoing = false debug_industrialcraft = false debug_iron_backpacks = false diff --git a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java index 8b41c578..9e0e2b79 100644 --- a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java +++ b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java @@ -119,6 +119,10 @@ public class UTConfigMods @Config.Name("Forestry") public static final ForestryCategory FORESTRY = new ForestryCategory(); + @Config.LangKey("cfg.universaltweaks.modintegration.incontrol") + @Config.Name("In Control!") + public static final InControlCategory INCONTROL = new InControlCategory(); + @Config.LangKey("cfg.universaltweaks.modintegration.industrialcraft") @Config.Name("IndustrialCraft 2") public static final IndustrialCraftCategory INDUSTRIALCRAFT = new IndustrialCraftCategory(); @@ -615,6 +619,14 @@ public static class ForestryCategory public boolean utParticleFixesToggle = true; } + public static class InControlCategory + { + @Config.RequiresMcRestart + @Config.Name("Spawn Rule Stats Fix") + @Config.Comment("Fixes onJoin spawn rules repeatedly modifying mob attack/health/speed") + public boolean utStatsFixToggle = true; + } + public static class IndustrialCraftCategory { @Config.RequiresMcRestart diff --git a/src/main/java/mod/acgaming/universaltweaks/core/UTMixinLoader.java b/src/main/java/mod/acgaming/universaltweaks/core/UTMixinLoader.java index 909775ad..6ef26761 100644 --- a/src/main/java/mod/acgaming/universaltweaks/core/UTMixinLoader.java +++ b/src/main/java/mod/acgaming/universaltweaks/core/UTMixinLoader.java @@ -74,8 +74,7 @@ public class UTMixinLoader implements ILateMixinLoader put("mixins.mods.forestry.dupes.json", () -> loaded("forestry") && UTConfigMods.FORESTRY.utDuplicationFixesToggle); put("mixins.mods.forestry.extratrees.json", () -> loaded("extratrees")); put("mixins.mods.forestry.json", () -> loaded("forestry")); - // TODO: Add config - put("mixins.mods.incontrol.json", () -> loaded("incontrol")); + put("mixins.mods.incontrol.json", () -> loaded("incontrol") && UTConfigMods.INCONTROL.utStatsFixToggle); put("mixins.mods.industrialcraft.dupes.json", () -> loaded("ic2") && UTConfigMods.INDUSTRIALCRAFT.utDuplicationFixesToggle); put("mixins.mods.industrialforegoing.dupes.json", () -> loaded("industrialforegoing") && UTConfigMods.INDUSTRIAL_FOREGOING.utDuplicationFixesToggle); put("mixins.mods.industrialforegoing.rangeaddon.json", () -> loaded("industrialforegoing") && UTConfigMods.INDUSTRIAL_FOREGOING.utRangeAddonNumberFix); diff --git a/src/main/resources/assets/universaltweaks/lang/en_us.lang b/src/main/resources/assets/universaltweaks/lang/en_us.lang index eebc1188..86f0e7b2 100644 --- a/src/main/resources/assets/universaltweaks/lang/en_us.lang +++ b/src/main/resources/assets/universaltweaks/lang/en_us.lang @@ -74,6 +74,7 @@ cfg.universaltweaks.modintegration.erebus=The Erebus cfg.universaltweaks.modintegration.esm=Epic Siege Mod cfg.universaltweaks.modintegration.extrautilities=Extra Utilities 2 cfg.universaltweaks.modintegration.forestry=Forestry +cfg.universaltweaks.modintegration.incontrol=In Control! cfg.universaltweaks.modintegration.industrialcraft=IndustrialCraft 2 cfg.universaltweaks.modintegration.industrialforegoing=Industrial Foregoing cfg.universaltweaks.modintegration.infernalmobs=Infernal Mobs From dfe4aab5a4eaa1eb4e0a2451664986a419c867ab Mon Sep 17 00:00:00 2001 From: jchung01 Date: Tue, 24 Sep 2024 21:42:35 -0700 Subject: [PATCH 4/4] Add credits --- .../universaltweaks/mods/incontrol/mixin/UTRuleBaseMixin.java | 1 + .../mods/incontrol/mixin/UTSummonAidRuleMixin.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/mod/acgaming/universaltweaks/mods/incontrol/mixin/UTRuleBaseMixin.java b/src/main/java/mod/acgaming/universaltweaks/mods/incontrol/mixin/UTRuleBaseMixin.java index 3ff61d1e..22a04d73 100644 --- a/src/main/java/mod/acgaming/universaltweaks/mods/incontrol/mixin/UTRuleBaseMixin.java +++ b/src/main/java/mod/acgaming/universaltweaks/mods/incontrol/mixin/UTRuleBaseMixin.java @@ -7,6 +7,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +// Courtesy of jchung01, McJty @Mixin(value = RuleBase.class, remap = false) public class UTRuleBaseMixin { diff --git a/src/main/java/mod/acgaming/universaltweaks/mods/incontrol/mixin/UTSummonAidRuleMixin.java b/src/main/java/mod/acgaming/universaltweaks/mods/incontrol/mixin/UTSummonAidRuleMixin.java index 1a70e565..fe7c17c5 100644 --- a/src/main/java/mod/acgaming/universaltweaks/mods/incontrol/mixin/UTSummonAidRuleMixin.java +++ b/src/main/java/mod/acgaming/universaltweaks/mods/incontrol/mixin/UTSummonAidRuleMixin.java @@ -11,6 +11,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +// Courtesy of jchung01 @Mixin(value = SummonAidRule.class, remap = false) public abstract class UTSummonAidRuleMixin extends RuleBase {