|
1 | 1 | package com.lambda.mixin.entity; |
2 | 2 |
|
3 | 3 | import com.lambda.client.module.modules.movement.ElytraFlight; |
4 | | -import com.lambda.mixin.accessor.AccessorEntityFireworkRocket; |
5 | 4 | import net.minecraft.client.entity.EntityPlayerSP; |
6 | 5 | import net.minecraft.entity.Entity; |
7 | 6 | import net.minecraft.entity.EntityLivingBase; |
8 | 7 | import net.minecraft.entity.item.EntityFireworkRocket; |
9 | 8 | import net.minecraft.util.math.MathHelper; |
10 | 9 | import net.minecraft.util.math.Vec3d; |
11 | 10 | import net.minecraft.world.World; |
| 11 | +import net.minecraftforge.fml.common.ObfuscationReflectionHelper; |
12 | 12 | import org.objectweb.asm.Opcodes; |
13 | 13 | import org.spongepowered.asm.mixin.Mixin; |
14 | 14 | import org.spongepowered.asm.mixin.Unique; |
|
19 | 19 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
20 | 20 | import org.spongepowered.asm.mixin.injection.callback.LocalCapture; |
21 | 21 |
|
| 22 | +import java.lang.reflect.Field; |
| 23 | + |
22 | 24 | @Mixin(EntityLivingBase.class) |
23 | 25 | public abstract class MixinEntityLivingBase extends Entity { |
24 | 26 | @Unique |
25 | 27 | 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 | + } |
26 | 35 |
|
27 | 36 | public MixinEntityLivingBase(World worldIn) { |
28 | 37 | super(worldIn); |
@@ -117,8 +126,12 @@ private boolean shouldWork() { |
117 | 126 | private boolean shouldModify() { |
118 | 127 | return shouldWork() && world.loadedEntityList.stream().anyMatch(entity -> { |
119 | 128 | 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 | + } |
122 | 135 | } |
123 | 136 | return false; |
124 | 137 | } |
|
0 commit comments