Skip to content

Commit

Permalink
Add InControl mixin to fix various stat doubling
Browse files Browse the repository at this point in the history
  • Loading branch information
jchung01 committed Sep 23, 2024
1 parent d006e13 commit c8def52
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 0 deletions.
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 = true
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 @@ -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);
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,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());
}
}
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"]
}

0 comments on commit c8def52

Please sign in to comment.