Skip to content

Commit 355766f

Browse files
author
Nep Nep
authored
Fix compatibility with a bunch of utility mods (#356)
* Attempt to fix impact/phobos/whatever * Tiny code improvement
1 parent 9df3dd6 commit 355766f

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/main/java/com/lambda/mixin/entity/MixinEntityLivingBase.java

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package com.lambda.mixin.entity;
22

33
import com.lambda.client.module.modules.movement.ElytraFlight;
4-
import com.lambda.mixin.accessor.AccessorEntityFireworkRocket;
54
import net.minecraft.client.entity.EntityPlayerSP;
65
import net.minecraft.entity.Entity;
76
import net.minecraft.entity.EntityLivingBase;
87
import net.minecraft.entity.item.EntityFireworkRocket;
98
import net.minecraft.util.math.MathHelper;
109
import net.minecraft.util.math.Vec3d;
1110
import net.minecraft.world.World;
11+
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
1212
import org.objectweb.asm.Opcodes;
1313
import org.spongepowered.asm.mixin.Mixin;
1414
import org.spongepowered.asm.mixin.Unique;
@@ -19,10 +19,19 @@
1919
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
2020
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
2121

22+
import java.lang.reflect.Field;
23+
2224
@Mixin(EntityLivingBase.class)
2325
public abstract class MixinEntityLivingBase extends Entity {
2426
@Unique
2527
private Vec3d modifiedVec = null;
28+
// This is a bit silly and bad for performance but fixes compatibility with old mixin versions like the one used by impact
29+
@Unique
30+
private static final Field boostedEntity;
31+
32+
static {
33+
boostedEntity = ObfuscationReflectionHelper.findField(EntityFireworkRocket.class, "field_191513_e");
34+
}
2635

2736
public MixinEntityLivingBase(World worldIn) {
2837
super(worldIn);
@@ -117,8 +126,12 @@ private boolean shouldWork() {
117126
private boolean shouldModify() {
118127
return shouldWork() && world.loadedEntityList.stream().anyMatch(entity -> {
119128
if (entity instanceof EntityFireworkRocket) {
120-
EntityLivingBase boosted = ((AccessorEntityFireworkRocket) entity).getBoostedEntity();
121-
return boosted != null && boosted.equals(this);
129+
try {
130+
EntityLivingBase boosted = (EntityLivingBase) boostedEntity.get(entity);
131+
return boosted != null && boosted.equals(this);
132+
} catch (IllegalAccessException e) {
133+
throw new RuntimeException(e); // This should absolutely never happen
134+
}
122135
}
123136
return false;
124137
}

0 commit comments

Comments
 (0)