From 04403a0c3f150610675fcf572d0e6e4af39b2661 Mon Sep 17 00:00:00 2001 From: Mixces Date: Sat, 20 Jul 2024 13:55:34 -0500 Subject: [PATCH] some more progress!! --- .../legacyanimations/LegacyAnimations.java | 29 +++++---- .../duck/EntityInterface.java | 10 +++ .../legacyanimations/hook/GlintModelHook.java | 7 +- .../mixin/BuiltinModelItemRendererMixin.java | 32 ++++----- .../legacyanimations/mixin/EntityMixin.java | 22 ++++++- .../FishingBobberEntityRendererMixin.java | 65 ++++++++++++++----- .../mixin/HeldItemFeatureRendererMixin.java | 46 +++++++++++++ .../mixin/HeldItemRendererMixin.java | 15 ++--- .../mixin/ItemRendererMixin.java | 11 +++- .../mixin/LivingEntityRendererMixin.java | 4 +- .../mixin/MinecraftClientMixin.java | 7 +- .../mixin/PlayerEntityMixin.java | 14 ++-- ...erface.java => IBasicBakedModelMixin.java} | 2 +- ...CameraInterface.java => ICameraMixin.java} | 2 +- ...EntityInterface.java => IEntityMixin.java} | 2 +- ...Interface.java => ILivingEntityMixin.java} | 2 +- .../resources/legacyanimations.mixins.json | 9 +-- 17 files changed, 193 insertions(+), 86 deletions(-) create mode 100644 src/main/java/com/mixces/legacyanimations/duck/EntityInterface.java create mode 100644 src/main/java/com/mixces/legacyanimations/mixin/HeldItemFeatureRendererMixin.java rename src/main/java/com/mixces/legacyanimations/mixin/interfaces/{BasicBakedModelInterface.java => IBasicBakedModelMixin.java} (93%) rename src/main/java/com/mixces/legacyanimations/mixin/interfaces/{CameraInterface.java => ICameraMixin.java} (89%) rename src/main/java/com/mixces/legacyanimations/mixin/interfaces/{EntityInterface.java => IEntityMixin.java} (90%) rename src/main/java/com/mixces/legacyanimations/mixin/interfaces/{LivingEntityInterface.java => ILivingEntityMixin.java} (88%) diff --git a/src/main/java/com/mixces/legacyanimations/LegacyAnimations.java b/src/main/java/com/mixces/legacyanimations/LegacyAnimations.java index c6260ff..2c7e933 100644 --- a/src/main/java/com/mixces/legacyanimations/LegacyAnimations.java +++ b/src/main/java/com/mixces/legacyanimations/LegacyAnimations.java @@ -56,20 +56,21 @@ public void onInitialize() context.getSource().sendFeedback(() -> Text.literal("x: " + value + " y: " + value2 + " z: " + value3), false); return 1; }) - .then(CommandManager.argument("roll", FloatArgumentType.floatArg()) - .executes(context -> { - final float value = FloatArgumentType.getFloat(context, "x"); - final float value2 = FloatArgumentType.getFloat(context, "y"); - final float value3 = FloatArgumentType.getFloat(context, "z"); - final float value4 = FloatArgumentType.getFloat(context, "roll"); - TransformHook.translationX = value; - TransformHook.translationY = value2; - TransformHook.translationZ = value3; - TransformHook.rotationY = value4; - context.getSource().sendFeedback(() -> Text.literal("x: " + value + " y: " + value2 + " z: " + value3 + " roll: " + value4), false); - return 1; - }) - ))))); +// .then(CommandManager.argument("roll", FloatArgumentType.floatArg()) +// .executes(context -> { +// final float value = FloatArgumentType.getFloat(context, "x"); +// final float value2 = FloatArgumentType.getFloat(context, "y"); +// final float value3 = FloatArgumentType.getFloat(context, "z"); +// final float value4 = FloatArgumentType.getFloat(context, "roll"); +// TransformHook.translationX = value; +// TransformHook.translationY = value2; +// TransformHook.translationZ = value3; +// TransformHook.rotationY = value4; +// context.getSource().sendFeedback(() -> Text.literal("x: " + value + " y: " + value2 + " z: " + value3 + " roll: " + value4), false); +// return 1; +// }) +// ) + )))); }); } diff --git a/src/main/java/com/mixces/legacyanimations/duck/EntityInterface.java b/src/main/java/com/mixces/legacyanimations/duck/EntityInterface.java new file mode 100644 index 0000000..f473c3e --- /dev/null +++ b/src/main/java/com/mixces/legacyanimations/duck/EntityInterface.java @@ -0,0 +1,10 @@ +package com.mixces.legacyanimations.duck; + +import net.minecraft.util.math.Vec3d; + +public interface EntityInterface +{ + + Vec3d legacyAnimations$getCameraPosVec(float tickDelta, float eyeHeight); + +} diff --git a/src/main/java/com/mixces/legacyanimations/hook/GlintModelHook.java b/src/main/java/com/mixces/legacyanimations/hook/GlintModelHook.java index edbd648..6e03de8 100644 --- a/src/main/java/com/mixces/legacyanimations/hook/GlintModelHook.java +++ b/src/main/java/com/mixces/legacyanimations/hook/GlintModelHook.java @@ -1,17 +1,12 @@ package com.mixces.legacyanimations.hook; -import com.mixces.legacyanimations.mixin.interfaces.BasicBakedModelInterface; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.client.render.model.BasicBakedModel; -import net.minecraft.client.texture.Sprite; - public class GlintModelHook { //todo: hijack model with custom sprite :/ // public static BakedModel getGlint(BakedModel model) // { -// return (BakedModel) BasicBakedModelInterface.Builder(model.useAmbientOcclusion(), model.isSideLit(), model.hasDepth(), model.getTransformation(), model.getOverrides()); +// return (BakedModel) IBasicBakedModelMixin.Builder(model.useAmbientOcclusion(), model.isSideLit(), model.hasDepth(), model.getTransformation(), model.getOverrides()); // } // // public static class JustUV extends Sprite diff --git a/src/main/java/com/mixces/legacyanimations/mixin/BuiltinModelItemRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/BuiltinModelItemRendererMixin.java index ae42631..49b3c7b 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/BuiltinModelItemRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/BuiltinModelItemRendererMixin.java @@ -17,21 +17,21 @@ public abstract class BuiltinModelItemRendererMixin { //todo: re-write shields -// @ModifyExpressionValue( -// method = "render", -// at = @At( -// value = "INVOKE", -// target = "Lnet/minecraft/item/ItemStack;isOf(Lnet/minecraft/item/Item;)Z", -// ordinal = 0 -// ) -// ) -// private boolean legacyAnimations$disableShieldRendering(boolean original, ItemStack stack, ModelTransformationMode mode, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) -// { -// if (LegacyAnimationsSettings.CONFIG.instance().hideShields && TransformationModeUtils.isValidPerspective(mode)) -// { -// return original; -// } -// return !ItemUtils.INSTANCE.isValidItem(stack, stack.getUseAction()); -// } + @ModifyExpressionValue( + method = "render", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/item/ItemStack;isOf(Lnet/minecraft/item/Item;)Z", + ordinal = 0 + ) + ) + private boolean legacyAnimations$disableShieldRendering(boolean original, ItemStack stack, ModelTransformationMode mode, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) + { + if (!LegacyAnimationsSettings.CONFIG.instance().hideShields || !TransformationModeUtils.isValidPerspective(mode)) + { + return original; + } + return ItemUtils.INSTANCE.isValidItem(stack, stack.getUseAction()); + } } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/EntityMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/EntityMixin.java index c261a00..751915b 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/EntityMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/EntityMixin.java @@ -2,17 +2,28 @@ import com.llamalad7.mixinextras.injector.ModifyReturnValue; import com.mixces.legacyanimations.config.LegacyAnimationsSettings; +import com.mixces.legacyanimations.duck.EntityInterface; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityPose; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3d; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @Mixin(Entity.class) -public abstract class EntityMixin +public abstract class EntityMixin implements EntityInterface { //todo: revert swimming mechanic (double jump to leave) + @Shadow public double prevX; + @Shadow public double prevY; + @Shadow public double prevZ; + @Shadow public abstract double getX(); + @Shadow public abstract double getY(); + @Shadow public abstract double getZ(); + @ModifyReturnValue( method = "getPose", at = @At( @@ -35,4 +46,13 @@ public abstract class EntityMixin return original; } + @Override + public Vec3d legacyAnimations$getCameraPosVec(float tickDelta, float eyeHeight) { + final double d = MathHelper.lerp(tickDelta, prevX, getX()); + final double e = MathHelper.lerp(tickDelta, prevY, getY()) + (double) eyeHeight; + final double f = MathHelper.lerp(tickDelta, prevZ, getZ()); + + return new Vec3d(d, e, f); + } + } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/FishingBobberEntityRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/FishingBobberEntityRendererMixin.java index 3d2da56..a0f27f0 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/FishingBobberEntityRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/FishingBobberEntityRendererMixin.java @@ -1,7 +1,11 @@ package com.mixces.legacyanimations.mixin; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.mixces.legacyanimations.config.LegacyAnimationsSettings; +import com.mixces.legacyanimations.duck.EntityInterface; +import com.mixces.legacyanimations.mixin.interfaces.ICameraMixin; import com.mixces.legacyanimations.util.HandUtils; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; @@ -12,12 +16,11 @@ import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.projectile.FishingBobberEntity; -import net.minecraft.item.Items; import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3d; 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.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(FishingBobberEntityRenderer.class) @@ -54,17 +57,21 @@ protected FishingBobberEntityRendererMixin(EntityRendererFactory.Context ctx) matrixStack.translate(HandUtils.INSTANCE.handMultiplier(player, dispatcher) * 0.25F, 0.0F, 0.0F); } - //todo: cameraVecPos bullshit and left handed rod line -// @Redirect( -// method = "render(Lnet/minecraft/entity/projectile/FishingBobberEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", -// at = @At( -// value = "INVOKE", -// target = "Lnet/minecraft/entity/player/PlayerEntity;getStandingEyeHeight()F" -// ) -// ) -// public float useInterpolatedEyeHeight(PlayerEntity instance) { -// return MathHelper.lerp(dispatcher.camera.getLastTickDelta(), ((CameraInterface) dispatcher.camera).getLastCameraY(), ((CameraInterface) dispatcher.camera).getCameraY()); -// } + @WrapOperation( + method = "getHandPos", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/entity/player/PlayerEntity;getCameraPosVec(F)Lnet/minecraft/util/math/Vec3d;" + ) + ) + public Vec3d legacyAnimations$useInterpolatedEyeHeight(PlayerEntity instance, float v, Operation original) + { + final float lastCameraY = ((ICameraMixin) dispatcher.camera).getLastCameraY(); + final float cameraY = ((ICameraMixin) dispatcher.camera).getCameraY(); + final float eyeHeight = MathHelper.lerp(v, lastCameraY, cameraY); + + return ((EntityInterface) instance).legacyAnimations$getCameraPosVec(v, eyeHeight); + } @ModifyExpressionValue( method = "getHandPos", @@ -73,9 +80,37 @@ protected FishingBobberEntityRendererMixin(EntityRendererFactory.Context ctx) target = "Lnet/minecraft/item/ItemStack;isOf(Lnet/minecraft/item/Item;)Z" ) ) - public boolean legacyAnimations$fixWrongRodLine(boolean original, PlayerEntity player, float f, float tickDelta) + public boolean legacyAnimations$removeUselessCondition(boolean original, PlayerEntity player, float f, float tickDelta) { - return original || !player.getOffHandStack().isOf(Items.FISHING_ROD); + return true; } +// /** +// * @author a +// * @reason a +// */ +// @Overwrite +// private Vec3d getHandPos(PlayerEntity player, float f, float tickDelta) +// { +// final float eyeHeight = MathHelper.lerp(dispatcher.camera.getLastTickDelta(), ((ICameraMixin) dispatcher.camera).getLastCameraY(), ((ICameraMixin) dispatcher.camera).getCameraY()); +// +// int i = player.getMainArm() == Arm.RIGHT ? 1 : -1; +// if (!this.dispatcher.gameOptions.getPerspective().isFirstPerson() || player != MinecraftClient.getInstance().player) +// { +// float g = MathHelper.lerp(tickDelta, player.prevBodyYaw, player.bodyYaw) * ((float)Math.PI / 180); +// double d = MathHelper.sin(g); +// double e = MathHelper.cos(g); +// float h = player.getScale(); +// double j = (double)i * 0.35 * (double)h; +// double k = 0.8 * (double)h; +// float l = player.isInSneakingPose() ? -0.1875f : 0.0f; +// return ((EntityInterface) player).legacyAnimations$getCameraPosVec(tickDelta, eyeHeight).add(-e * j - d * k, (double)l - 0.45 * (double)h, -d * j + e * k); +// } +// double m = 960.0 / (double) this.dispatcher.gameOptions.getFov().getValue(); +// Vec3d vec3d = this.dispatcher.camera.getProjection().getPosition((float)i * 0.525f, -0.1F).multiply(m).rotateY(f * 0.5f).rotateX(-f * 0.7f).rotateZ(f * 0.5f).add(TransformHook.translationX, TransformHook.translationY, TransformHook.translationZ); +//// vec3d; +// +// return ((EntityInterface) player).legacyAnimations$getCameraPosVec(tickDelta, eyeHeight).add(vec3d); +// } + } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/HeldItemFeatureRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/HeldItemFeatureRendererMixin.java new file mode 100644 index 0000000..2873b59 --- /dev/null +++ b/src/main/java/com/mixces/legacyanimations/mixin/HeldItemFeatureRendererMixin.java @@ -0,0 +1,46 @@ +package com.mixces.legacyanimations.mixin; + +import com.mixces.legacyanimations.config.LegacyAnimationsSettings; +import com.mixces.legacyanimations.util.ItemUtils; +import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.render.entity.feature.HeldItemFeatureRenderer; +import net.minecraft.client.render.model.json.ModelTransformationMode; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.LivingEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Arm; +import net.minecraft.util.math.RotationAxis; +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(HeldItemFeatureRenderer.class) +public class HeldItemFeatureRendererMixin { + +// @Inject( +// method = "renderItem", +// at = @At( +// value = "INVOKE", +// target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V" +// ) +// ) +// private void legacyAnimations$swordBlockTransform(LivingEntity entity, ItemStack stack, ModelTransformationMode transformationMode, Arm arm, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) +// { +// if (!LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock) +// { +// return; +// } +// +// if (!ItemUtils.INSTANCE.isSwordInMainHand(stack) || !ItemUtils.INSTANCE.isShieldInOffHand(stack)) +// { +// return; +// } +// +// matrices.translate(0.05f, 0.0f, -0.1f); +// matrices.multiply(RotationAxis.POSITIVE_Y.rotation(-50.0F)); +// matrices.multiply(RotationAxis.POSITIVE_X.rotation(-10.0F)); +// matrices.multiply(RotationAxis.POSITIVE_Z.rotation(-60.0F)); +// } + +} diff --git a/src/main/java/com/mixces/legacyanimations/mixin/HeldItemRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/HeldItemRendererMixin.java index 617822b..70a1565 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/HeldItemRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/HeldItemRendererMixin.java @@ -11,7 +11,6 @@ import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.item.HeldItemRenderer; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.item.FishingRodItem; import net.minecraft.item.ItemStack; import net.minecraft.util.Arm; import net.minecraft.util.Hand; @@ -36,7 +35,6 @@ public abstract class HeldItemRendererMixin @Shadow private ItemStack offHand; @Shadow @Final private EntityRenderDispatcher entityRenderDispatcher; - //todo: unfuck bow position! @Inject( method = "renderFirstPersonItem", at = @At( @@ -53,9 +51,8 @@ public abstract class HeldItemRendererMixin final int l = HandUtils.INSTANCE.handMultiplier((ClientPlayerEntity) player, entityRenderDispatcher); + matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(l * -335)); matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(l * -50.0F)); - matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(l * -335.0F)); - matrices.translate(0.0F, 0.5F, 0.0F); } @Inject( @@ -75,9 +72,8 @@ public abstract class HeldItemRendererMixin final int l = HandUtils.INSTANCE.handMultiplier((ClientPlayerEntity) player, entityRenderDispatcher); - matrices.translate(0.0F, -0.5F, 0.0F); matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(l * 50.0F)); - matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(l * 335.0F)); + matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(l * 335)); } @Inject( @@ -152,12 +148,13 @@ public abstract class HeldItemRendererMixin return; } + final int l = HandUtils.INSTANCE.handMultiplier((ClientPlayerEntity) player, entityRenderDispatcher); + if (ItemUtils.INSTANCE.shouldRotateAroundWhenRendering(item, true)) { - matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180.0F)); + matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(l * 180.0F)); } - final int l = HandUtils.INSTANCE.handMultiplier((ClientPlayerEntity) player, entityRenderDispatcher); final float scale = 0.7585F / 0.86F; matrices.scale(scale, scale, scale); @@ -207,7 +204,7 @@ public abstract class HeldItemRendererMixin // ) // private float legacyAnimations$conditionallyUpdateShield(float value, @Local(ordinal = 0) ItemStack itemStack) // { -// if (LegacyAnimationsSettings.CONFIG.instance().hideShields && ItemUtils.INSTANCE.isShieldInOffHand()) +// if (LegacyAnimationsSettings.CONFIG.instance().hideShields && ItemUtils.INSTANCE.isShieldInOffHand(offHand)) // { // return (mainHand == itemStack ? 1.0F : 0.0F) - equipProgressOffHand; // } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/ItemRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/ItemRendererMixin.java index 5db429f..1c5b5f9 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/ItemRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/ItemRendererMixin.java @@ -2,10 +2,12 @@ import com.llamalad7.mixinextras.sugar.Local; import com.mixces.legacyanimations.config.LegacyAnimationsSettings; +import com.mixces.legacyanimations.hook.TransformHook; import com.mixces.legacyanimations.util.HandUtils; import com.mixces.legacyanimations.util.ItemUtils; import com.mixces.legacyanimations.util.TransformationModeUtils; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.item.ItemRenderer; import net.minecraft.client.render.model.BakedModel; @@ -67,13 +69,20 @@ public class ItemRendererMixin return; } + final ClientPlayerEntity player = client.player; + + if (player == null) + { + return; + } + if (ItemUtils.INSTANCE.shouldRotateAroundWhenRendering(stack,true)) { if (renderMode == ModelTransformationMode.FIRST_PERSON_LEFT_HAND || renderMode == ModelTransformationMode.FIRST_PERSON_RIGHT_HAND) { matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180.0F)); matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(50.0F)); - + matrices.translate(0.096F, 0.117F, -0.097F); //todo: add more translations } } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityRendererMixin.java index 675f6a8..a64caf9 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityRendererMixin.java @@ -2,7 +2,7 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.mixces.legacyanimations.config.LegacyAnimationsSettings; -import com.mixces.legacyanimations.mixin.interfaces.CameraInterface; +import com.mixces.legacyanimations.mixin.interfaces.ICameraMixin; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.*; import net.minecraft.client.render.entity.LivingEntityRenderer; @@ -60,7 +60,7 @@ public abstract class LivingEntityRendererMixin final Camera camera = MinecraftClient.getInstance().gameRenderer.getCamera(); final boolean player = livingEntity.getName().equals(clientPlayer.getName()); - final float lerpCamera = MathHelper.lerp(g, ((CameraInterface) camera).getLastCameraY(), ((CameraInterface) camera).getCameraY()); + final float lerpCamera = MathHelper.lerp(g, ((ICameraMixin) camera).getLastCameraY(), ((ICameraMixin) camera).getCameraY()); final float eyeHeight = player ? lerpCamera : livingEntity.getStandingEyeHeight(); matrixStack.translate(0.0F, 1.62F - eyeHeight, 0.0F); diff --git a/src/main/java/com/mixces/legacyanimations/mixin/MinecraftClientMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/MinecraftClientMixin.java index b730bd2..003b85d 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/MinecraftClientMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/MinecraftClientMixin.java @@ -4,8 +4,7 @@ import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.mixces.legacyanimations.config.LegacyAnimationsSettings; -import com.mixces.legacyanimations.mixin.interfaces.LivingEntityInterface; -import com.mixces.legacyanimations.util.ServerUtils; +import com.mixces.legacyanimations.mixin.interfaces.ILivingEntityMixin; import net.minecraft.client.MinecraftClient; import net.minecraft.client.Mouse; import net.minecraft.client.gui.screen.Screen; @@ -95,7 +94,7 @@ public class MinecraftClientMixin { ordinal = 0 ) ) - private void mixcesAnimations$addLeftClickCheck(CallbackInfo ci) + private void legacyAnimations$addLeftClickCheck(CallbackInfo ci) { // if (!ServerUtils.INSTANCE.isOnHypixel()) // { @@ -128,7 +127,7 @@ public class MinecraftClientMixin { @Unique private static void legacyAnimations$fakeSwingHand(ClientPlayerEntity player, Hand hand) { - final int handSwingDuration = ((LivingEntityInterface) player).invokeGetHandSwingDuration(); + final int handSwingDuration = ((ILivingEntityMixin) player).invokeGetHandSwingDuration(); if (player.handSwinging && player.handSwingTicks < handSwingDuration / 2 && player.handSwingTicks >= 0) { diff --git a/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityMixin.java index d0e2133..a7e6bba 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityMixin.java @@ -2,22 +2,16 @@ import com.llamalad7.mixinextras.injector.ModifyReturnValue; import com.mixces.legacyanimations.config.LegacyAnimationsSettings; -import com.mixces.legacyanimations.mixin.interfaces.EntityInterface; -import com.mixces.legacyanimations.mixin.interfaces.LivingEntityInterface; -import com.mixces.legacyanimations.util.ServerUtils; +import com.mixces.legacyanimations.mixin.interfaces.IEntityMixin; +import com.mixces.legacyanimations.mixin.interfaces.ILivingEntityMixin; import net.minecraft.entity.EntityDimensions; import net.minecraft.entity.EntityPose; -import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.item.SwordItem; import org.objectweb.asm.Opcodes; 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; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(PlayerEntity.class) public abstract class PlayerEntityMixin extends LivingEntityMixin @@ -62,10 +56,10 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin } final PlayerEntity entity = (PlayerEntity) (Object) this; - final double velocityY = ((EntityInterface) entity).invokeGetVelocity().y; + final double velocityY = ((IEntityMixin) entity).invokeGetVelocity().y; float f1 = (float) (Math.atan(-velocityY * 0.2F) * 15.0F); - if (((EntityInterface) entity).invokeIsOnGround() || ((LivingEntityInterface) entity).invokeGetHealth() <= 0.0F) + if (((IEntityMixin) entity).invokeIsOnGround() || ((ILivingEntityMixin) entity).invokeGetHealth() <= 0.0F) { f1 = 0.0F; } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/interfaces/BasicBakedModelInterface.java b/src/main/java/com/mixces/legacyanimations/mixin/interfaces/IBasicBakedModelMixin.java similarity index 93% rename from src/main/java/com/mixces/legacyanimations/mixin/interfaces/BasicBakedModelInterface.java rename to src/main/java/com/mixces/legacyanimations/mixin/interfaces/IBasicBakedModelMixin.java index 72a4da5..b94efdb 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/interfaces/BasicBakedModelInterface.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/interfaces/IBasicBakedModelMixin.java @@ -7,7 +7,7 @@ import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(BasicBakedModel.Builder.class) -public interface BasicBakedModelInterface { +public interface IBasicBakedModelMixin { @SuppressWarnings("unused") @Invoker("") diff --git a/src/main/java/com/mixces/legacyanimations/mixin/interfaces/CameraInterface.java b/src/main/java/com/mixces/legacyanimations/mixin/interfaces/ICameraMixin.java similarity index 89% rename from src/main/java/com/mixces/legacyanimations/mixin/interfaces/CameraInterface.java rename to src/main/java/com/mixces/legacyanimations/mixin/interfaces/ICameraMixin.java index 6289ad8..86afcd3 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/interfaces/CameraInterface.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/interfaces/ICameraMixin.java @@ -5,7 +5,7 @@ import org.spongepowered.asm.mixin.gen.Accessor; @Mixin(Camera.class) -public interface CameraInterface +public interface ICameraMixin { @Accessor float getCameraY(); diff --git a/src/main/java/com/mixces/legacyanimations/mixin/interfaces/EntityInterface.java b/src/main/java/com/mixces/legacyanimations/mixin/interfaces/IEntityMixin.java similarity index 90% rename from src/main/java/com/mixces/legacyanimations/mixin/interfaces/EntityInterface.java rename to src/main/java/com/mixces/legacyanimations/mixin/interfaces/IEntityMixin.java index 3ad2c4b..ef977d0 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/interfaces/EntityInterface.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/interfaces/IEntityMixin.java @@ -6,7 +6,7 @@ import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(Entity.class) -public interface EntityInterface +public interface IEntityMixin { @Invoker Vec3d invokeGetVelocity(); diff --git a/src/main/java/com/mixces/legacyanimations/mixin/interfaces/LivingEntityInterface.java b/src/main/java/com/mixces/legacyanimations/mixin/interfaces/ILivingEntityMixin.java similarity index 88% rename from src/main/java/com/mixces/legacyanimations/mixin/interfaces/LivingEntityInterface.java rename to src/main/java/com/mixces/legacyanimations/mixin/interfaces/ILivingEntityMixin.java index 8e04eb8..506ed59 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/interfaces/LivingEntityInterface.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/interfaces/ILivingEntityMixin.java @@ -5,7 +5,7 @@ import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(LivingEntity.class) -public interface LivingEntityInterface +public interface ILivingEntityMixin { @Invoker int invokeGetHandSwingDuration(); diff --git a/src/main/resources/legacyanimations.mixins.json b/src/main/resources/legacyanimations.mixins.json index d669171..2bbf09d 100644 --- a/src/main/resources/legacyanimations.mixins.json +++ b/src/main/resources/legacyanimations.mixins.json @@ -13,6 +13,7 @@ "FishingBobberEntityRendererMixin", "FlyingItemEntityRendererMixin", "GameRendererMixin", + "HeldItemFeatureRendererMixin", "HeldItemRendererMixin", "InGameHudMixin", "ItemEntityRendererMixin", @@ -26,10 +27,10 @@ "ShieldItemMixin", "SwordItemMixin", "VertexConsumerMixin", - "interfaces.BasicBakedModelInterface", - "interfaces.CameraInterface", - "interfaces.EntityInterface", - "interfaces.LivingEntityInterface" + "interfaces.IBasicBakedModelMixin", + "interfaces.ICameraMixin", + "interfaces.IEntityMixin", + "interfaces.ILivingEntityMixin" ], "injectors": { "defaultRequire": 1