diff --git a/README.md b/README.md index 3cde4ca0..9940d5d0 100644 --- a/README.md +++ b/README.md @@ -345,6 +345,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/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..7bf61280 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 = false 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/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 496e397b..6ef26761 100644 --- a/src/main/java/mod/acgaming/universaltweaks/core/UTMixinLoader.java +++ b/src/main/java/mod/acgaming/universaltweaks/core/UTMixinLoader.java @@ -74,6 +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")); + 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/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..22a04d73 --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/mods/incontrol/mixin/UTRuleBaseMixin.java @@ -0,0 +1,49 @@ +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; + +// Courtesy of jchung01, McJty +@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/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..fe7c17c5 --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/mods/incontrol/mixin/UTSummonAidRuleMixin.java @@ -0,0 +1,58 @@ +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; + +// Courtesy of jchung01 +@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/assets/universaltweaks/lang/en_us.lang b/src/main/resources/assets/universaltweaks/lang/en_us.lang index 97a7e814..44f21f4e 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 diff --git a/src/main/resources/mixins.mods.incontrol.json b/src/main/resources/mixins.mods.incontrol.json new file mode 100644 index 00000000..696f1c92 --- /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", "UTSummonAidRuleMixin"] +} \ No newline at end of file