Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add InControl mixin to fix various stat doubling #557

Merged
merged 4 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
2 changes: 2 additions & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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],
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions repositories.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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/'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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());
}
}
Original file line number Diff line number Diff line change
@@ -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<SummonEventGetter>
{
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());
}
}
1 change: 1 addition & 0 deletions src/main/resources/assets/universaltweaks/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/mixins.mods.incontrol.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"package": "mod.acgaming.universaltweaks.mods.incontrol.mixin",
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": ["UTRuleBaseMixin", "UTSummonAidRuleMixin"]
}