From 9e4198fa797810acf28cfa9e6df8084de9deb3e4 Mon Sep 17 00:00:00 2001 From: grimmauld Date: Thu, 15 Jul 2021 11:39:37 +0200 Subject: [PATCH] fix mixins --- .../foundation/mixin/BreakProgressMixin.java | 6 +++--- .../EntityContraptionInteractionMixin.java | 20 +++++++++---------- .../mixin/FixNormalScalingMixin.java | 6 ++---- .../mixin/HeavyBootsOnPlayerMixin.java | 2 +- .../foundation/mixin/WindowResizeMixin.java | 6 +++--- 5 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/simibubi/create/foundation/mixin/BreakProgressMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/BreakProgressMixin.java index 477e8f081..1ff9b0efe 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/BreakProgressMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/BreakProgressMixin.java @@ -17,11 +17,11 @@ import net.minecraft.util.math.BlockPos; public class BreakProgressMixin { @Shadow @Final - private WorldRenderer worldRenderer; // levelRenderer + private WorldRenderer levelRenderer; // levelRenderer private final ClientWorld self = (ClientWorld) (Object) this; - @Inject(at = @At("HEAD"), method = "sendBlockBreakProgress") // levelRenderer + @Inject(at = @At("HEAD"), method = "destroyBlockProgress") private void onBreakProgress(int playerEntityId, BlockPos pos, int progress, CallbackInfo ci) { - BreakProgressHook.whenBreaking(self, this.worldRenderer, playerEntityId, pos, progress); + BreakProgressHook.whenBreaking(self, this.levelRenderer, playerEntityId, pos, progress); } } diff --git a/src/main/java/com/simibubi/create/foundation/mixin/EntityContraptionInteractionMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/EntityContraptionInteractionMixin.java index 6f4e0f089..ee082eac3 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/EntityContraptionInteractionMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/EntityContraptionInteractionMixin.java @@ -44,16 +44,16 @@ public abstract class EntityContraptionInteractionMixin extends CapabilityProvid @Final @Shadow - protected Random rand; // levelRenderer + protected Random random; @Shadow - private float nextStepDistance; // levelRenderer + private float nextStep; @Shadow - protected abstract float determineNextStepDistance(); // nextStep()F + protected abstract float nextStep(); @Shadow - protected abstract void playStepSound(BlockPos p_180429_1_, BlockState p_180429_2_); // nextStep()F + protected abstract void playStepSound(BlockPos p_180429_1_, BlockState p_180429_2_); private Set getIntersectingContraptions() { Set contraptions = ContraptionHandler.loadedContraptions.get(self.level) @@ -87,7 +87,7 @@ public abstract class EntityContraptionInteractionMixin extends CapabilityProvid } @Inject(at = @At(value = "JUMP", opcode = 154, // IFNE line 587 injecting before `!blockstate.isAir(this.world, blockpos)` - ordinal = 4), method = "move") // nextStep()F + ordinal = 4), method = "move") private void movementMixin(MoverType mover, Vector3d movement, CallbackInfo ci) { Vector3d worldPos = self.position() .add(0, -0.2, 0); @@ -101,10 +101,10 @@ public abstract class EntityContraptionInteractionMixin extends CapabilityProvid }); if (stepped.get()) - this.nextStepDistance = this.determineNextStepDistance(); + this.nextStep = this.nextStep(); } - @Inject(method = { "spawnSprintingParticles" }, at = @At(value = "TAIL")) // spawnSprintParticle()V + @Inject(method = { "spawnSprintParticle" }, at = @At(value = "TAIL")) private void createRunningParticlesMixin(CallbackInfo ci) { Vector3d worldPos = self.position() .add(0, -0.2, 0); @@ -115,14 +115,14 @@ public abstract class EntityContraptionInteractionMixin extends CapabilityProvid && blockstate.getRenderShape() != BlockRenderType.INVISIBLE) { Vector3d vec3d = self.getDeltaMovement(); self.level.addParticle(new BlockParticleData(ParticleTypes.BLOCK, blockstate).setPos(pos), - self.getX() + ((double) rand.nextFloat() - 0.5D) * (double) self.getBbWidth(), self.getY() + 0.1D, - self.getZ() + ((double) rand.nextFloat() - 0.5D) * (double) self.getBbWidth(), vec3d.x * -4.0D, 1.5D, + self.getX() + ((double) random.nextFloat() - 0.5D) * (double) self.getBbWidth(), self.getY() + 0.1D, + self.getZ() + ((double) random.nextFloat() - 0.5D) * (double) self.getBbWidth(), vec3d.x * -4.0D, 1.5D, vec3d.z * -4.0D); } }); } - @Inject(method = "playSound", at = @At("HEAD"), cancellable = true) // playSound(Lnet/minecraft/util/SoundEvent;FF)V + @Inject(method = "playSound", at = @At("HEAD"), cancellable = true) private void playSoundShifted(SoundEvent event, float pitch, float volume, CallbackInfo ci) { if (this.contraption != null && (!self.isSilent() || self instanceof PlayerEntity)) { double x = self.getX(); diff --git a/src/main/java/com/simibubi/create/foundation/mixin/FixNormalScalingMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/FixNormalScalingMixin.java index 12bb65618..b76f2ab3e 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/FixNormalScalingMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/FixNormalScalingMixin.java @@ -17,8 +17,7 @@ public class FixNormalScalingMixin { * applied, which negates the matrix again, resulting in the matrix being the * same as in the beginning. */ - @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/vector/Matrix3f;multiply(F)V", shift = Shift.AFTER), method = "scale(FFF)V", cancellable = true) - // At mul(F)V, method: scale(FFF)V + @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/vector/Matrix3f;mul(F)V", shift = Shift.AFTER), method = "scale(FFF)V", cancellable = true) private void returnAfterNegate(float x, float y, float z, CallbackInfo ci) { ci.cancel(); } @@ -30,8 +29,7 @@ public class FixNormalScalingMixin { * that would invert all normals. Additionally, Minecraft's fastInverseCbrt method * does not work for negative numbers. */ - @ModifyArg(at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;fastInverseCbrt(F)F"), method = "scale(FFF)V") - // at fastInvCubeRoot(F)F, method: fastInvCubeRoot(F)F + @ModifyArg(at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;fastInvCubeRoot(F)F"), method = "scale(FFF)V") private float absInvCbrtInput(float input) { return Math.abs(input); } diff --git a/src/main/java/com/simibubi/create/foundation/mixin/HeavyBootsOnPlayerMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/HeavyBootsOnPlayerMixin.java index 985b74d01..8561b404a 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/HeavyBootsOnPlayerMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/HeavyBootsOnPlayerMixin.java @@ -22,7 +22,7 @@ public abstract class HeavyBootsOnPlayerMixin extends AbstractClientPlayerEntity super(p_i50991_1_, p_i50991_2_); } - @Inject(at = @At("HEAD"), method = "canSwim", cancellable = true) // isUnderWater()Z + @Inject(at = @At("HEAD"), method = "isUnderWater", cancellable = true) public void noSwimmingWithHeavyBootsOn(CallbackInfoReturnable cir) { CompoundNBT persistentData = getPersistentData(); if (persistentData.contains("HeavyBoots")) diff --git a/src/main/java/com/simibubi/create/foundation/mixin/WindowResizeMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/WindowResizeMixin.java index 5d0a60b8c..4af9f1243 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/WindowResizeMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/WindowResizeMixin.java @@ -18,11 +18,11 @@ import net.minecraftforge.api.distmarker.OnlyIn; @Mixin(Minecraft.class) public class WindowResizeMixin { - @Shadow @Final private MainWindow mainWindow; + @Shadow @Final private MainWindow window; - @Inject(at = @At("TAIL"), method = "updateWindowSize") // resizeDisplay()V + @Inject(at = @At("TAIL"), method = "resizeDisplay") private void updateWindowSize(CallbackInfo ci) { - UIRenderHelper.updateWindowSize(mainWindow); + UIRenderHelper.updateWindowSize(window); } }