From 87824dabacaa3f3fa9435301dbcdc5a42141fd1d Mon Sep 17 00:00:00 2001 From: Mixces Date: Thu, 2 May 2024 05:21:49 -0500 Subject: [PATCH] Update various features! --- build.gradle | 1 + .../legacyanimations/hook/EntityHook.java | 13 -- .../mixin/ArmorFeatureRendererMixin.java | 44 ++++-- .../mixin/BipedEntityModelMixin.java | 149 +++++++++++------- .../mixin/BuiltinModelItemRendererMixin.java | 11 +- .../legacyanimations/mixin/CameraMixin.java | 12 +- .../ClientPlayerInteractionManagerMixin.java | 4 +- .../legacyanimations/mixin/DebugHudMixin.java | 4 +- .../legacyanimations/mixin/EntityMixin.java | 2 +- .../mixin/EntityRenderDispatcherMixin.java | 30 ---- .../FishingBobberEntityRendererMixin.java | 31 ++-- .../mixin/FlyingItemEntityRendererMixin.java | 6 +- .../mixin/FoodComponentAccessor.java | 12 -- .../mixin/GameRendererMixin.java | 2 +- .../mixin/HeldItemRendererMixin.java | 12 +- .../mixin/InGameHudMixin.java | 10 +- .../mixin/ItemRendererMixin.java | 6 +- .../mixin/LivingEntityMixin.java | 6 +- .../mixin/LivingEntityRendererMixin.java | 4 +- .../mixin/MinecraftClientMixin.java | 8 +- .../mixin/PlayerEntityMixin.java | 57 ++++--- .../mixin/PlayerEntityRendererMixin.java | 8 + .../mixin/ShieldItemMixin.java | 69 -------- .../mixin/SwordItemMixin.java | 53 ------- .../legacyanimations/util/ItemUtils.java | 6 +- .../util/TransformationModeUtils.java | 14 +- src/main/resources/fabric.mod.json | 2 +- .../resources/legacyanimations.mixins.json | 6 +- 28 files changed, 248 insertions(+), 334 deletions(-) delete mode 100644 src/main/java/com/mixces/legacyanimations/hook/EntityHook.java delete mode 100644 src/main/java/com/mixces/legacyanimations/mixin/EntityRenderDispatcherMixin.java delete mode 100644 src/main/java/com/mixces/legacyanimations/mixin/FoodComponentAccessor.java delete mode 100644 src/main/java/com/mixces/legacyanimations/mixin/ShieldItemMixin.java delete mode 100644 src/main/java/com/mixces/legacyanimations/mixin/SwordItemMixin.java diff --git a/build.gradle b/build.gradle index ec78de2..fc04d3e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,7 @@ plugins { id 'fabric-loom' version '1.6-SNAPSHOT' id 'maven-publish' + id 'io.freefair.lombok' version '8.6' } version = project.mod_version diff --git a/src/main/java/com/mixces/legacyanimations/hook/EntityHook.java b/src/main/java/com/mixces/legacyanimations/hook/EntityHook.java deleted file mode 100644 index 4abc06b..0000000 --- a/src/main/java/com/mixces/legacyanimations/hook/EntityHook.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.mixces.legacyanimations.hook; - -import net.minecraft.entity.LivingEntity; - -public class EntityHook { - - public static LivingEntity entity; - - public static boolean isEntityDying() { - return entity.deathTime > 0 || entity.hurtTime > 0; - } - -} diff --git a/src/main/java/com/mixces/legacyanimations/mixin/ArmorFeatureRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/ArmorFeatureRendererMixin.java index 40c6e5e..1232aba 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/ArmorFeatureRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/ArmorFeatureRendererMixin.java @@ -1,31 +1,50 @@ package com.mixces.legacyanimations.mixin; +import com.llamalad7.mixinextras.sugar.Local; import com.mixces.legacyanimations.config.LegacyAnimationsSettings; -import com.mixces.legacyanimations.hook.EntityHook; import net.minecraft.client.render.OverlayTexture; import net.minecraft.client.render.RenderLayer; +import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.feature.ArmorFeatureRenderer; +import net.minecraft.client.render.entity.model.BipedEntityModel; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.LivingEntity; import net.minecraft.util.Identifier; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ArmorFeatureRenderer.class) -public abstract class ArmorFeatureRendererMixin { +public abstract class ArmorFeatureRendererMixin> { - @Redirect( + @Unique public T legacyAnimations$entity; + + @Inject( + method = "renderArmor", + at = @At( + value = "HEAD" + ) + ) + private void legacyAnimations$setEntity(MatrixStack matrices, VertexConsumerProvider vertexConsumers, T entity, EquipmentSlot armorSlot, int light, A model, CallbackInfo ci) { + legacyAnimations$entity = entity; + } + + @ModifyArg( method = "renderArmorParts", at = @At( value = "INVOKE", - target = "Lnet/minecraft/client/render/RenderLayer;getArmorCutoutNoCull(Lnet/minecraft/util/Identifier;)Lnet/minecraft/client/render/RenderLayer;" + target = "Lnet/minecraft/client/render/VertexConsumerProvider;getBuffer(Lnet/minecraft/client/render/RenderLayer;)Lnet/minecraft/client/render/VertexConsumer;" ) ) - private RenderLayer useEntityLayerRenderer(Identifier texture) { + private RenderLayer legacyAnimations$useEntityLayerRenderer(RenderLayer var1, @Local(ordinal = 0, argsOnly = true) Identifier overlay) { if (LegacyAnimationsSettings.CONFIG.instance().armorTint) { - return RenderLayer.getEntityCutoutNoCullZOffset(texture); + return RenderLayer.getEntityCutoutNoCullZOffset(overlay); } - return RenderLayer.getArmorCutoutNoCull(texture); + return var1; } @ModifyArg( @@ -36,11 +55,16 @@ private RenderLayer useEntityLayerRenderer(Identifier texture) { ), index = 3 ) - private int useDamageUVOverlay(int par3) { + private int legacyAnimations$useDamageUVOverlay(int par3) { if (LegacyAnimationsSettings.CONFIG.instance().armorTint) { - return OverlayTexture.packUv(OverlayTexture.getU(0.0F), OverlayTexture.getV(EntityHook.isEntityDying())); + return OverlayTexture.packUv(OverlayTexture.getU(0.0F), OverlayTexture.getV(isEntityDying(legacyAnimations$entity))); } return par3; } + @Unique + private boolean isEntityDying(T entity) { + return entity.deathTime > 0 || entity.hurtTime > 0; + } + } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/BipedEntityModelMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/BipedEntityModelMixin.java index ef1c558..1f062d5 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/BipedEntityModelMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/BipedEntityModelMixin.java @@ -20,16 +20,19 @@ public abstract class BipedEntityModelMixin { @Shadow @Final public ModelPart rightArm; @Shadow @Final public ModelPart leftArm; @Shadow @Final public ModelPart head; + @Shadow @Final public ModelPart rightLeg; + @Shadow @Final public ModelPart leftLeg; @Inject( method = "setAngles(Lnet/minecraft/entity/LivingEntity;FFFFF)V", at = @At( - value = "JUMP", - opcode = Opcodes.IF_ACMPEQ, - ordinal = 0 + value = "FIELD", + target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel;rightArmPose:Lnet/minecraft/client/render/entity/model/BipedEntityModel$ArmPose;", + opcode = Opcodes.GETFIELD, + ordinal = 1 ) ) - private void fixIncorrectArmPlacement(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci) { + private void legacyAnimations$fixIncorrectArmPlacement(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci) { if (LegacyAnimationsSettings.CONFIG.instance().punchDuringUsage) { rightArm.roll = 0.0F; leftArm.roll = 0.0F; @@ -48,48 +51,105 @@ private void fixIncorrectArmPlacement(T livingEntity, float f, float g, float h, } } - @ModifyConstant( + @Inject( method = "setAngles(Lnet/minecraft/entity/LivingEntity;FFFFF)V", - constant = @Constant( - floatValue = 12.2F + at = @At( + value = "FIELD", + opcode = Opcodes.GETFIELD, + target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel;leftLeg:Lnet/minecraft/client/model/ModelPart;" + ), + slice = @Slice( + from = @At( + value = "FIELD", + opcode = Opcodes.GETFIELD, + target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel;rightLeg:Lnet/minecraft/client/model/ModelPart;", + ordinal = 7 + ), + to = @At( + value = "FIELD", + opcode = Opcodes.GETFIELD, + target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel;body:Lnet/minecraft/client/model/ModelPart;", + ordinal = 2 + ) ) ) - private float oldSneakValue1(float constant) { - return LegacyAnimationsSettings.CONFIG.instance().oldSneaking ? 9.0F : constant; + private void legacyAnimations$oldSneakValue1(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci) { + if (LegacyAnimationsSettings.CONFIG.instance().oldSneaking) { + rightLeg.pivotY = 9.0f; + } } - @ModifyConstant( + @Inject( method = "setAngles(Lnet/minecraft/entity/LivingEntity;FFFFF)V", + at = @At( + value = "FIELD", + opcode = Opcodes.GETFIELD, + target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel;head:Lnet/minecraft/client/model/ModelPart;" + ), slice = @Slice( from = @At( value = "FIELD", - opcode = Opcodes.PUTFIELD, - target = "Lnet/minecraft/client/model/ModelPart;pitch:F", - ordinal = 15 + opcode = Opcodes.GETFIELD, + target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel;leftLeg:Lnet/minecraft/client/model/ModelPart;", + ordinal = 7 ), to = @At( value = "FIELD", - opcode = Opcodes.PUTFIELD, - target = "Lnet/minecraft/client/model/ModelPart;pivotY:F", - ordinal = 6 + opcode = Opcodes.GETFIELD, + target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel;leftArm:Lnet/minecraft/client/model/ModelPart;", + ordinal = 7 ) - ), - constant = @Constant( - floatValue = 0.0F ) ) - private float oldSneakValue2(float constant) { - return LegacyAnimationsSettings.CONFIG.instance().oldSneaking ? 0.1F : constant; + private void legacyAnimations$oldSneakValue2(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci) { + if (LegacyAnimationsSettings.CONFIG.instance().oldSneaking) { + leftLeg.pivotY = 9.0f; + } } - @ModifyConstant( + @Inject( method = "setAngles(Lnet/minecraft/entity/LivingEntity;FFFFF)V", - constant = @Constant( - floatValue = 4.2F + at = @At( + value = "FIELD", + opcode = Opcodes.GETFIELD, + target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel;leftLeg:Lnet/minecraft/client/model/ModelPart;", + ordinal = 9 ) ) - private float oldSneakValue3(float constant) { - return LegacyAnimationsSettings.CONFIG.instance().oldSneaking ? 1.0F : constant; + private void legacyAnimations$oldSneakValue3(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci) { + if (LegacyAnimationsSettings.CONFIG.instance().oldSneaking) { + rightLeg.pivotZ = 0.1f; + } + } + + @Inject( + method = "setAngles(Lnet/minecraft/entity/LivingEntity;FFFFF)V", + at = @At( + value = "FIELD", + opcode = Opcodes.GETFIELD, + target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel;head:Lnet/minecraft/client/model/ModelPart;", + ordinal = 5 + ) + ) + private void legacyAnimations$oldSneakValue4(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci) { + if (LegacyAnimationsSettings.CONFIG.instance().oldSneaking) { + leftLeg.pivotZ = 0.1f; + } + } + + @Inject( + method = "setAngles(Lnet/minecraft/entity/LivingEntity;FFFFF)V", + at = @At( + value = "FIELD", + opcode = Opcodes.GETFIELD, + target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel;body:Lnet/minecraft/client/model/ModelPart;", + ordinal = 2 + ) + ) + private void legacyAnimations$oldSneakValue5(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci) { + if (LegacyAnimationsSettings.CONFIG.instance().oldSneaking) { + head.pivotY = 1.0f; + } } @WrapWithCondition( @@ -114,7 +174,7 @@ private float oldSneakValue3(float constant) { target = "Lnet/minecraft/client/model/ModelPart;pivotY:F" ) ) - public boolean removeConflictingFields(ModelPart instance, float value) { + public boolean legacyAnimations$removeConflictingFields1(ModelPart instance, float value) { return !LegacyAnimationsSettings.CONFIG.instance().oldSneaking; } @@ -140,39 +200,20 @@ public boolean removeConflictingFields(ModelPart instance, float value) { target = "Lnet/minecraft/client/model/ModelPart;pivotY:F" ) ) - public boolean removeFields2(ModelPart instance, float value) { + public boolean legacyAnimations$removeConflictingFields2(ModelPart instance, float value) { return !LegacyAnimationsSettings.CONFIG.instance().oldSneaking; } - @Redirect( - method = "positionBlockingArm", - at = @At( - value = "FIELD", - opcode = Opcodes.PUTFIELD, - target = "Lnet/minecraft/client/model/ModelPart;pitch:F" - ) - ) - public void oldBlockingArmPitch(ModelPart instance, float value) { - if (LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock) { - instance.pitch = instance.pitch * 0.5F - (float) (Math.PI / 3); - } else { - instance.pitch = value; - } - } - - @Redirect( + @Inject( method = "positionBlockingArm", at = @At( - value = "FIELD", - opcode = Opcodes.PUTFIELD, - target = "Lnet/minecraft/client/model/ModelPart;yaw:F" + value = "TAIL" ) ) - public void oldBlockingArmYaw(ModelPart instance, float value) { + public void legacyAnimations$oldBlockingArm(ModelPart arm, boolean rightArm, CallbackInfo ci) { if (LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock) { - instance.yaw = 0.0F; - } else { - instance.yaw = value; + arm.pitch = arm.pitch * 0.5F - (float) (Math.PI / 3); + arm.yaw = 0.0F; } } @@ -184,7 +225,7 @@ public void oldBlockingArmYaw(ModelPart instance, float value) { ), index = 0 ) - private ModelPart switchBlockingArm(ModelPart arm) { + private ModelPart legacyAnimations$switchBlockingArm1(ModelPart arm) { return LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock ? rightArm : arm; } @@ -196,7 +237,7 @@ private ModelPart switchBlockingArm(ModelPart arm) { ), index = 0 ) - private ModelPart switchBlockingArm2(ModelPart arm) { + private ModelPart legacyAnimations$switchBlockingArm2(ModelPart arm) { return LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock ? leftArm : arm; } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/BuiltinModelItemRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/BuiltinModelItemRendererMixin.java index ab62e73..b80e5cd 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/BuiltinModelItemRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/BuiltinModelItemRendererMixin.java @@ -4,13 +4,11 @@ import com.mixces.legacyanimations.config.LegacyAnimationsSettings; import com.mixces.legacyanimations.util.ItemUtils; import com.mixces.legacyanimations.util.TransformationModeUtils; -import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.item.BuiltinModelItemRenderer; import net.minecraft.client.render.model.json.ModelTransformationMode; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.ItemStack; -import net.minecraft.util.UseAction; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -25,12 +23,9 @@ public class BuiltinModelItemRendererMixin { ordinal = 0 ) ) - private boolean disableShieldRendering(boolean original, ItemStack stack, ModelTransformationMode mode, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) { - if (LegacyAnimationsSettings.CONFIG.instance().hideShields && MinecraftClient.getInstance().player != null && TransformationModeUtils.isValidPerspective(mode)) { - ItemStack heldStack = MinecraftClient.getInstance().player.getMainHandStack(); - UseAction action = heldStack.getUseAction(); - if (ItemUtils.INSTANCE.isValidItem(heldStack, action)) - return false; + 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 !ItemUtils.INSTANCE.isValidItem(stack, stack.getUseAction()); } return original; } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/CameraMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/CameraMixin.java index bbd30a9..dd912b4 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/CameraMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/CameraMixin.java @@ -16,8 +16,16 @@ public abstract class CameraMixin { @Shadow private float cameraY; @Shadow private Entity focusedEntity; - @Inject(method = "updateEyeHeight", at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD, target = "Lnet/minecraft/client/render/Camera;cameraY:F"), cancellable = true) - private void addOldSneakCalculation(CallbackInfo ci) { + @Inject( + method = "updateEyeHeight", + at = @At( + value = "FIELD", + opcode = Opcodes.PUTFIELD, + target = "Lnet/minecraft/client/render/Camera;cameraY:F" + ), + cancellable = true + ) + private void legacyAnimations$addOldSneakCalculation(CallbackInfo ci) { if (LegacyAnimationsSettings.CONFIG.instance().oldSneaking && focusedEntity.getStandingEyeHeight() < cameraY) { cameraY = focusedEntity.getStandingEyeHeight(); ci.cancel(); diff --git a/src/main/java/com/mixces/legacyanimations/mixin/ClientPlayerInteractionManagerMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/ClientPlayerInteractionManagerMixin.java index 7ca1d9b..8a59f63 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/ClientPlayerInteractionManagerMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/ClientPlayerInteractionManagerMixin.java @@ -26,7 +26,7 @@ public abstract class ClientPlayerInteractionManagerMixin { target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;isCurrentlyBreaking(Lnet/minecraft/util/math/BlockPos;)Z" ) ) - public boolean fixBreakingBlockCheck(boolean original) { + public boolean legacyAnimations$fixBreakingBlockCheck(boolean original) { return (!LegacyAnimationsSettings.CONFIG.instance().punchDuringUsage || isBreakingBlock()) && original; } @@ -38,7 +38,7 @@ public boolean fixBreakingBlockCheck(boolean original) { shift = At.Shift.AFTER ), cancellable = true) - public void cancelIllegalDestroy(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { + public void legacyAnimations$cancelIllegalDestroy(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { if (LegacyAnimationsSettings.CONFIG.instance().punchDuringUsage && client.player != null && client.player.isUsingItem()) { cir.setReturnValue(true); } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/DebugHudMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/DebugHudMixin.java index 52281b9..8ddf8ab 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/DebugHudMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/DebugHudMixin.java @@ -18,7 +18,7 @@ public class DebugHudMixin { target = "Lnet/minecraft/client/gui/DrawContext;fill(IIIII)V" ) ) - private boolean removeDebugBackground(DrawContext instance, int x1, int y1, int x2, int y2, int color) { + private boolean legacyAnimations$removeDebugBackground(DrawContext instance, int x1, int y1, int x2, int y2, int color) { return !LegacyAnimationsSettings.CONFIG.instance().oldDebug; } @@ -30,7 +30,7 @@ private boolean removeDebugBackground(DrawContext instance, int x1, int y1, int ), index = 5 ) - private boolean addDebugShadow(boolean shadow) { + private boolean legacyAnimations$addDebugShadow(boolean shadow) { return LegacyAnimationsSettings.CONFIG.instance().oldDebug; } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/EntityMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/EntityMixin.java index 0fe06a3..5de7b75 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/EntityMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/EntityMixin.java @@ -25,7 +25,7 @@ public class EntityMixin { value = "RETURN" ) ) - public EntityPose revertSwimPose(EntityPose original) { + public EntityPose legacyAnimations$revertSwimPose(EntityPose original) { Entity entity = (Entity) (Object) this; if (LegacyAnimationsSettings.CONFIG.instance().oldSwim && type == EntityType.PLAYER && entity.isSwimming()) { EntityPose pose = dataTracker.get(POSE); diff --git a/src/main/java/com/mixces/legacyanimations/mixin/EntityRenderDispatcherMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/EntityRenderDispatcherMixin.java deleted file mode 100644 index df21211..0000000 --- a/src/main/java/com/mixces/legacyanimations/mixin/EntityRenderDispatcherMixin.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.mixces.legacyanimations.mixin; - -import com.mixces.legacyanimations.config.LegacyAnimationsSettings; -import com.mixces.legacyanimations.hook.EntityHook; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.entity.EntityRenderDispatcher; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -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(EntityRenderDispatcher.class) -public class EntityRenderDispatcherMixin { - - @Inject( - method = "render", - at = @At( - value = "HEAD" - ) - ) - private void getLivingEntity(E entity, double x, double y, double z, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { - if (LegacyAnimationsSettings.CONFIG.instance().armorTint && entity instanceof LivingEntity) { - EntityHook.entity = (LivingEntity) entity; - } - } - -} diff --git a/src/main/java/com/mixces/legacyanimations/mixin/FishingBobberEntityRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/FishingBobberEntityRendererMixin.java index ac6db2b..3c6a465 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/FishingBobberEntityRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/FishingBobberEntityRendererMixin.java @@ -1,7 +1,6 @@ package com.mixces.legacyanimations.mixin; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import com.llamalad7.mixinextras.sugar.Local; import com.mixces.legacyanimations.config.LegacyAnimationsSettings; import com.mixces.legacyanimations.util.HandUtils; import net.minecraft.client.MinecraftClient; @@ -14,11 +13,9 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.projectile.FishingBobberEntity; import net.minecraft.item.Items; -import net.minecraft.util.math.MathHelper; 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) @@ -36,33 +33,33 @@ protected FishingBobberEntityRendererMixin(EntityRendererFactory.Context ctx) { ordinal = 0 ) ) - public void shiftRodBob(FishingBobberEntity fishingBobberEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) { + public void legacyAnimations$shiftRodBob(FishingBobberEntity fishingBobberEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) { ClientPlayerEntity player = MinecraftClient.getInstance().player; if (LegacyAnimationsSettings.CONFIG.instance().oldProjectiles && player != null) { matrixStack.translate(HandUtils.INSTANCE.handMultiplier(player, dispatcher) * 0.25F, 0.0F, 0.0F); } } - @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(), ((AccessorCamera) dispatcher.camera).getLastCameraY(), ((AccessorCamera) dispatcher.camera).getCameraY()); - } +// @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(), ((AccessorCamera) dispatcher.camera).getLastCameraY(), ((AccessorCamera) dispatcher.camera).getCameraY()); +// } @ModifyExpressionValue( - method = "render(Lnet/minecraft/entity/projectile/FishingBobberEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", + method = "getHandPos", at = @At( value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;isOf(Lnet/minecraft/item/Item;)Z" ) ) - public boolean fixWrongRodLine(boolean original, @Local(ordinal = 0) PlayerEntity playerEntity) { - return original || !playerEntity.getOffHandStack().isOf(Items.FISHING_ROD); + public boolean legacyAnimations$fixWrongRodLine(boolean original, PlayerEntity player, float f, float tickDelta) { + return original || !player.getOffHandStack().isOf(Items.FISHING_ROD); } } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/FlyingItemEntityRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/FlyingItemEntityRendererMixin.java index e984e72..624e28d 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/FlyingItemEntityRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/FlyingItemEntityRendererMixin.java @@ -34,7 +34,7 @@ protected FlyingItemEntityRendererMixin(EntityRendererFactory.Context ctx) { target = "Lnet/minecraft/entity/Entity;age:I" ) ) - public int disableCleanView(Entity instance, Operation original) { + public int legacyAnimations$disableCleanView(Entity instance, Operation original) { return LegacyAnimationsSettings.CONFIG.instance().oldProjectiles ? original.call(instance) + 2 : original.call(instance); } @@ -45,7 +45,7 @@ public int disableCleanView(Entity instance, Operation original) { target = "Lnet/minecraft/client/render/item/ItemRenderer;renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformationMode;IILnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/world/World;I)V" ) ) - public void shiftProjectile(T entity, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { + public void legacyAnimations$shiftProjectile(T entity, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { if (LegacyAnimationsSettings.CONFIG.instance().oldProjectiles) { matrices.translate((!dispatcher.gameOptions.getPerspective().isFrontView() ? 1 : -1) * 0.25F, 0.0F, 0.0F); } @@ -59,7 +59,7 @@ public void shiftProjectile(T entity, float yaw, float tickDelta, MatrixStack ma ), index = 0 ) - private float rotateProjectileAccordingly(float deg) { + private float legacyAnimations$rotateProjectileAccordingly(float deg) { if (LegacyAnimationsSettings.CONFIG.instance().oldProjectiles && MinecraftClient.getInstance().player != null) { boolean isLeftHand = HandUtils.INSTANCE.isLeftHand(MinecraftClient.getInstance().player, dispatcher); if (!dispatcher.gameOptions.getPerspective().isFrontView()) { diff --git a/src/main/java/com/mixces/legacyanimations/mixin/FoodComponentAccessor.java b/src/main/java/com/mixces/legacyanimations/mixin/FoodComponentAccessor.java deleted file mode 100644 index 0869353..0000000 --- a/src/main/java/com/mixces/legacyanimations/mixin/FoodComponentAccessor.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.mixces.legacyanimations.mixin; - -import net.minecraft.item.FoodComponent; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(FoodComponent.class) -public interface FoodComponentAccessor { - - @Accessor boolean getAlwaysEdible(); - -} \ No newline at end of file diff --git a/src/main/java/com/mixces/legacyanimations/mixin/GameRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/GameRendererMixin.java index c326d09..87eabb4 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/GameRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/GameRendererMixin.java @@ -25,7 +25,7 @@ public class GameRendererMixin { shift = At.Shift.AFTER ) ) - private void addOldPitchRotation(MatrixStack matrices, float tickDelta, CallbackInfo ci, @Local(ordinal = 0) PlayerEntity playerEntity) { + private void legacyAnimations$addOldPitchRotation(MatrixStack matrices, float tickDelta, CallbackInfo ci, @Local(ordinal = 0) PlayerEntity playerEntity) { if (LegacyAnimationsSettings.CONFIG.instance().oldViewBob) { float h = MathHelper.lerp( tickDelta, diff --git a/src/main/java/com/mixces/legacyanimations/mixin/HeldItemRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/HeldItemRendererMixin.java index 04fde06..34cf351 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/HeldItemRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/HeldItemRendererMixin.java @@ -51,7 +51,7 @@ public abstract class HeldItemRendererMixin { ) ) ) - private void addSwingOffset(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci, @Local Arm arm) { + private void legacyAnimations$addSwingOffset(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci, @Local Arm arm) { if (LegacyAnimationsSettings.CONFIG.instance().punchDuringUsage) { applySwingOffset(matrices, arm, swingProgress); } @@ -65,7 +65,7 @@ private void addSwingOffset(AbstractClientPlayerEntity player, float tickDelta, ordinal = 1 ) ) - private void addSwordBlock(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { + private void legacyAnimations$addSwordBlock(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { if (LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock && item.getItem() instanceof SwordItem && player.getOffHandStack().getItem() instanceof ShieldItem && ItemUtils.INSTANCE.isUsing((ClientPlayerEntity) player)) { boolean bl = hand == Hand.MAIN_HAND; Arm arm = bl ? player.getMainArm() : player.getMainArm().getOpposite(); @@ -86,7 +86,7 @@ private void addSwordBlock(AbstractClientPlayerEntity player, float tickDelta, f ordinal = 12 ) ) - private boolean disableSwingTranslation(MatrixStack instance, float x, float y, float z, AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) { + private boolean legacyAnimations$disableSwingTranslation(MatrixStack instance, float x, float y, float z, AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) { return !LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock || !(item.getItem() instanceof SwordItem) || !(player.getOffHandStack().getItem() instanceof ShieldItem) || !ItemUtils.INSTANCE.isUsing((ClientPlayerEntity) player); } @@ -97,14 +97,14 @@ private boolean disableSwingTranslation(MatrixStack instance, float x, float y, target = "Lnet/minecraft/client/network/ClientPlayerEntity;getAttackCooldownProgress(F)F" ) ) - public float removeCoolDownSpeed(ClientPlayerEntity instance, float v, Operation original) { + public float legacyAnimations$removeCoolDownSpeed(ClientPlayerEntity instance, float v, Operation original) { if (LegacyAnimationsSettings.CONFIG.instance().noCooldown) return 1.0F; return original.call(instance, v); } @Inject(method = "resetEquipProgress", at = @At("HEAD"), cancellable = true) - private void removeStartDelay(Hand hand, CallbackInfo ci) { + private void legacyAnimations$removeStartDelay(Hand hand, CallbackInfo ci) { if (LegacyAnimationsSettings.CONFIG.instance().noCooldown) { ci.cancel(); } @@ -119,7 +119,7 @@ private void removeStartDelay(Hand hand, CallbackInfo ci) { ), index = 0 ) - private float conditionallyUpdateShield(float value, @Local(ordinal = 0) ItemStack itemStack) { + private float legacyAnimations$conditionallyUpdateShield(float value, @Local(ordinal = 0) ItemStack itemStack) { if (LegacyAnimationsSettings.CONFIG.instance().hideShields && offHand.getItem() instanceof ShieldItem) { return (mainHand == itemStack ? 1.0F : 0.0F) - equipProgressOffHand; } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/InGameHudMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/InGameHudMixin.java index dd106e3..81fbe41 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/InGameHudMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/InGameHudMixin.java @@ -23,10 +23,10 @@ public abstract class InGameHudMixin { private boolean cancelOffhandHotbar(ItemStack itemStack, Operation original) { ClientPlayerEntity player = MinecraftClient.getInstance().player; if (player != null) { - ItemStack stack = player.getMainHandStack(); - UseAction action = stack.getUseAction(); - if (LegacyAnimationsSettings.CONFIG.instance().hideShieldHotbar && ItemUtils.INSTANCE.isValidItem(stack, action)) { - return original.call(itemStack) || player.getOffHandStack().isOf(Items.SHIELD); + ItemStack mainStack = player.getMainHandStack(); + UseAction action = mainStack.getUseAction(); + if (LegacyAnimationsSettings.CONFIG.instance().hideShieldHotbar && ItemUtils.INSTANCE.isValidItem(mainStack, action)) { + return original.call(itemStack) || itemStack.isOf(Items.SHIELD); } } return original.call(itemStack); @@ -51,7 +51,7 @@ private boolean cancelOffhandHotbar(ItemStack itemStack, Operation orig target = "Lnet/minecraft/client/option/Perspective;isFirstPerson()Z" ) ) - private boolean removePerspectiveCheck(boolean original) { + private boolean legacyAnimations$removePerspectiveCheck(boolean original) { return LegacyAnimationsSettings.CONFIG.instance().perspectiveCrosshair || original; } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/ItemRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/ItemRendererMixin.java index a28a17d..1d59736 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/ItemRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/ItemRendererMixin.java @@ -31,7 +31,7 @@ public class ItemRendererMixin { @Shadow @Final private MinecraftClient client; @ModifyArg(method = "renderBakedItemModel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/ItemRenderer;renderBakedItemQuads(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;Ljava/util/List;Lnet/minecraft/item/ItemStack;II)V", ordinal = 1), index = 2) - private List changeToSprite(List quads, @Local(ordinal = 0) BakedModel model) { + private List legacyAnimations$changeToSprite(List quads, @Local(ordinal = 0, argsOnly = true) BakedModel model) { if (LegacyAnimationsSettings.CONFIG.instance().fastItems && client.player != null && TransformationModeUtils.shouldBeSprite() && !model.hasDepth()) { boolean isLeftHand = HandUtils.INSTANCE.isLeftHand(client.player, client.getEntityRenderDispatcher()); boolean isFrontView = client.getEntityRenderDispatcher().gameOptions.getPerspective().isFrontView(); @@ -50,9 +50,9 @@ private List changeToSprite(List quads, @Local(ordinal = 0 value = "HEAD" ) ) - private void getTransformationMode(ItemStack stack, ModelTransformationMode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model, CallbackInfo ci) { + private void legacyAnimations$getTransformationMode(ItemStack stack, ModelTransformationMode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model, CallbackInfo ci) { if (LegacyAnimationsSettings.CONFIG.instance().fastItems) { - TransformationModeUtils.transformationMode = renderMode; + TransformationModeUtils.setTransformationMode(renderMode); } } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityMixin.java index 94f743a..6082ba7 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityMixin.java @@ -21,7 +21,7 @@ public abstract class LivingEntityMixin implements PlayerPitchInterface { @Unique public float legacyAnimations$cameraPitch; @ModifyConstant(method = "isBlocking", constant = @Constant(intValue = 5)) - private int isBlocking_fixSync(int constant) { + private int legacyAnimations$fixSync(int constant) { if (ServerUtils.INSTANCE.isOnHypixel()) { return 0; } @@ -45,7 +45,7 @@ private int isBlocking_fixSync(int constant) { ) ) ) - private float revertBackwardsWalk(float constant) { + private float legacyAnimations$revertBackwardsWalk(float constant) { if (LegacyAnimationsSettings.CONFIG.instance().oldWalking) return 0.0F; return constant; @@ -60,7 +60,7 @@ private float revertBackwardsWalk(float constant) { ordinal = 0 ) ) - private void setPrevCameraPitch(CallbackInfo ci) { + private void legacyAnimations$setPrevCameraPitch(CallbackInfo ci) { if (LegacyAnimationsSettings.CONFIG.instance().oldViewBob) { legacyAnimations$prevCameraPitch = legacyAnimations$cameraPitch; } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityRendererMixin.java index 4dc5e5a..e9256c8 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityRendererMixin.java @@ -25,7 +25,7 @@ public abstract class LivingEntityRendererMixin cir) { + private void legacyAnimations$removeMissPenalty(CallbackInfoReturnable cir) { if (ServerUtils.INSTANCE.isOnHypixel()) { attackCooldown = 0; } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityMixin.java index f4e872c..7362c9b 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityMixin.java @@ -3,12 +3,16 @@ import com.llamalad7.mixinextras.injector.ModifyReturnValue; import com.mixces.legacyanimations.config.LegacyAnimationsSettings; import com.mixces.legacyanimations.util.ServerUtils; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayerEntity; +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 net.minecraft.util.Arm; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -20,31 +24,46 @@ @Mixin(PlayerEntity.class) public abstract class PlayerEntityMixin extends LivingEntityMixin { + @Shadow protected abstract boolean canChangeIntoPose(EntityPose pose); + @Inject(method = "resetLastAttackedTicks", at = @At("HEAD"), cancellable = true) - private void resetLastAttackedTicks_removeDelay(CallbackInfo ci) { + private void legacyAnimations$removeAttackDelay(CallbackInfo ci) { if (ServerUtils.INSTANCE.isOnHypixel()) { ci.cancel(); } } - @Shadow protected abstract boolean canChangeIntoPose(EntityPose pose); +// @ModifyReturnValue( +// method = "getActiveEyeHeight", +// at = @At( +// value = "RETURN", +// ordinal = 1 +// ) +// ) +// private float modifyEyeHeight(float constant) { +// if (LegacyAnimationsSettings.CONFIG.instance().oldSneaking) { +// if (!canChangeIntoPose(EntityPose.STANDING)) { +// return constant; +// } else { +// return constant + 0.27F; +// } +// } +// return constant; +// } - @ModifyReturnValue( - method = "getActiveEyeHeight", - at = @At( - value = "RETURN", - ordinal = 1 - ) - ) - private float modifyEyeHeight(float constant) { - if (LegacyAnimationsSettings.CONFIG.instance().oldSneaking) { - if (!canChangeIntoPose(EntityPose.STANDING)) { - return constant; - } else { - return constant + 0.27F; - } +// @Inject(method = "getBaseDimensions", at = @At("HEAD"), cancellable = true) +// private void modifyDimensions(EntityPose pose, CallbackInfoReturnable cir) { +// if (pose == EntityPose.CROUCHING) { +// cir.setReturnValue(EntityDimensions.changing(0.6F, 1.62F).withEyeHeight(1.54F)); +// } +// } + + @Inject(method = "getMainArm", at = @At("HEAD"), cancellable = true) + public void legacyAnimations$correctHandSide(CallbackInfoReturnable cir) { + PlayerEntity entity = (PlayerEntity) (Object) this; + if (entity instanceof ClientPlayerEntity && ServerUtils.INSTANCE.isOnHypixel()) { + cir.setReturnValue(MinecraftClient.getInstance().options.getMainArm().getValue()); } - return constant; } @Inject( @@ -56,7 +75,7 @@ private float modifyEyeHeight(float constant) { shift = At.Shift.AFTER ) ) - private void getPitchFromVelocity(CallbackInfo ci) { + private void legacyAnimations$getPitchFromVelocity(CallbackInfo ci) { if (LegacyAnimationsSettings.CONFIG.instance().oldViewBob) { PlayerEntity entity = (PlayerEntity) (Object) this; double velocityY = ((InvokerEntity) entity).invokeGetVelocity().y; @@ -75,7 +94,7 @@ private void getPitchFromVelocity(CallbackInfo ci) { ordinal = 1 ), cancellable = true) - private void hypixelShieldBug(EquipmentSlot slot, CallbackInfoReturnable cir) { + private void legacyAnimations$hypixelShieldBug(EquipmentSlot slot, CallbackInfoReturnable cir) { if (ServerUtils.INSTANCE.isOnHypixel() && getMainHandStack().getItem() instanceof SwordItem && !isUsingItem()) { cir.setReturnValue(new ItemStack(Items.SHIELD)); } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityRendererMixin.java index 4ba065f..5b97678 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityRendererMixin.java @@ -3,11 +3,13 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.sugar.Local; import com.mixces.legacyanimations.config.LegacyAnimationsSettings; +import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.render.entity.PlayerEntityRenderer; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(PlayerEntityRenderer.class) public class PlayerEntityRendererMixin { @@ -33,4 +35,10 @@ public class PlayerEntityRendererMixin { // return original; // } +// @Redirect(method = "getPositionOffset(Lnet/minecraft/client/network/AbstractClientPlayerEntity;F)Lnet/minecraft/util/math/Vec3d;", +// at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;isInSneakingPose()Z")) +// private boolean disableSneakPositionOffset(AbstractClientPlayerEntity player) { +// return false && player.isInSneakingPose(); +// } + } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/ShieldItemMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/ShieldItemMixin.java deleted file mode 100644 index 2a7914e..0000000 --- a/src/main/java/com/mixces/legacyanimations/mixin/ShieldItemMixin.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.mixces.legacyanimations.mixin; - -import com.mixces.legacyanimations.config.LegacyAnimationsSettings; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ShieldItem; -import net.minecraft.item.SwordItem; -import net.minecraft.util.Hand; -import net.minecraft.util.TypedActionResult; -import net.minecraft.util.UseAction; -import net.minecraft.world.World; -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.CallbackInfoReturnable; - -@Mixin(ShieldItem.class) -public class ShieldItemMixin extends Item { - - public ShieldItemMixin(Settings settings) { - super(settings); - } - -// @Inject( -// method = "getUseAction", -// at = @At( -// value = "HEAD" -// ), -// cancellable = true -// ) -// public void getUseAction(ItemStack stack, CallbackInfoReturnable cir) { -// ClientPlayerEntity player = MinecraftClient.getInstance().player; -// if (LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock && player != null && player.getMainHandStack().getItem() instanceof SwordItem) { -// cir.setReturnValue(UseAction.NONE); -// } -// } -// -// @Inject( -// method = "getMaxUseTime", -// at = @At( -// value = "HEAD" -// ), -// cancellable = true -// ) -// public void lowerMaxUseTime(ItemStack stack, CallbackInfoReturnable cir) { -// ClientPlayerEntity player = MinecraftClient.getInstance().player; -// if (LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock && player != null && player.getMainHandStack().getItem() instanceof SwordItem) { -// cir.setReturnValue(0); -// } -// } -// -// @Inject( -// method = "use", -// at = @At( -// value = "HEAD" -// ), -// cancellable = true -// ) -// public void disableUseWithSword(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable> cir) { -// ClientPlayerEntity player = MinecraftClient.getInstance().player; -// if (LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock && player != null && player.getMainHandStack().getItem() instanceof SwordItem) { -// cir.setReturnValue(TypedActionResult.pass(user.getStackInHand(hand))); -// } -// } - -} diff --git a/src/main/java/com/mixces/legacyanimations/mixin/SwordItemMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/SwordItemMixin.java deleted file mode 100644 index 722ffe5..0000000 --- a/src/main/java/com/mixces/legacyanimations/mixin/SwordItemMixin.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.mixces.legacyanimations.mixin; - -import com.mixces.legacyanimations.config.LegacyAnimationsSettings; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ShieldItem; -import net.minecraft.item.SwordItem; -import net.minecraft.util.Hand; -import net.minecraft.util.TypedActionResult; -import net.minecraft.util.UseAction; -import net.minecraft.world.World; -import org.spongepowered.asm.mixin.Mixin; - -@Mixin(SwordItem.class) -public class SwordItemMixin extends Item { - - public SwordItemMixin(Settings settings) { - super(settings); - } - -// @Override -// public UseAction getUseAction(ItemStack stack) { -// ClientPlayerEntity player = MinecraftClient.getInstance().player; -// if (LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock && player != null && player.getOffHandStack().getItem() instanceof ShieldItem) { -// return UseAction.BLOCK; -// } -// return UseAction.NONE; -// } -// -// @Override -// public int getMaxUseTime(ItemStack stack) { -// ClientPlayerEntity player = MinecraftClient.getInstance().player; -// if (LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock && player != null && player.getOffHandStack().getItem() instanceof ShieldItem) { -// return 72000; -// } -// return 0; -// } -// -// @Override -// public TypedActionResult use(World world, PlayerEntity user, Hand hand) { -// ClientPlayerEntity player = MinecraftClient.getInstance().player; -// if (LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock && player != null && player.getOffHandStack().getItem() instanceof ShieldItem) { -// ItemStack itemStack = user.getStackInHand(hand); -// user.setCurrentHand(hand); -// return TypedActionResult.consume(itemStack); -// } -// return TypedActionResult.pass(user.getStackInHand(hand)); -// } - -} diff --git a/src/main/java/com/mixces/legacyanimations/util/ItemUtils.java b/src/main/java/com/mixces/legacyanimations/util/ItemUtils.java index 6edd0e2..178f648 100644 --- a/src/main/java/com/mixces/legacyanimations/util/ItemUtils.java +++ b/src/main/java/com/mixces/legacyanimations/util/ItemUtils.java @@ -1,8 +1,8 @@ package com.mixces.legacyanimations.util; -import com.mixces.legacyanimations.mixin.FoodComponentAccessor; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.component.DataComponentTypes; import net.minecraft.item.FishingRodItem; import net.minecraft.item.ItemStack; import net.minecraft.item.SwordItem; @@ -14,8 +14,8 @@ public class ItemUtils { public boolean isValidItem(ItemStack heldStack, UseAction action) { if (ItemUtils.INSTANCE.isValidHeldItem(heldStack) || - (action == UseAction.EAT && heldStack.getItem().getFoodComponent() != null && - ((FoodComponentAccessor) heldStack.getItem().getFoodComponent()).getAlwaysEdible())) { + (action == UseAction.EAT && heldStack.get(DataComponentTypes.FOOD) != null && + heldStack.get(DataComponentTypes.FOOD).canAlwaysEat())) { return true; } else if (action != UseAction.EAT) { return action != UseAction.NONE; diff --git a/src/main/java/com/mixces/legacyanimations/util/TransformationModeUtils.java b/src/main/java/com/mixces/legacyanimations/util/TransformationModeUtils.java index 8d718ed..614392e 100644 --- a/src/main/java/com/mixces/legacyanimations/util/TransformationModeUtils.java +++ b/src/main/java/com/mixces/legacyanimations/util/TransformationModeUtils.java @@ -1,12 +1,18 @@ package com.mixces.legacyanimations.util; +import lombok.Getter; +import lombok.Setter; import net.minecraft.client.render.model.json.ModelTransformationMode; import java.util.EnumSet; + public class TransformationModeUtils { + @Setter + @Getter public static ModelTransformationMode transformationMode; + private static final EnumSet cameraTypes = EnumSet.of( ModelTransformationMode.GROUND, @@ -20,20 +26,16 @@ public static boolean isValidPerspective(ModelTransformationMode mode) { mode == ModelTransformationMode.THIRD_PERSON_RIGHT_HAND; } - public static ModelTransformationMode getTransformationMode() { - return transformationMode; - } - public static boolean shouldBeSprite() { return shouldNotHaveGlint() || isRenderingInGUI(); } public static boolean isRenderingInGUI() { - return transformationMode == ModelTransformationMode.GUI; + return getTransformationMode() == ModelTransformationMode.GUI; } public static boolean shouldNotHaveGlint() { - return cameraTypes.contains(transformationMode); + return cameraTypes.contains(getTransformationMode()); } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 132d392..2c0e0b2 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -32,7 +32,7 @@ ], "depends": { "fabricloader": ">=0.15.10", - "minecraft": "~1.20.5", + "minecraft": ">=1.20.5 <=1.20.6", "java": ">=21", "fabric-api": "*", "yet_another_config_lib_v3": "*" diff --git a/src/main/resources/legacyanimations.mixins.json b/src/main/resources/legacyanimations.mixins.json index e143285..afb0f10 100644 --- a/src/main/resources/legacyanimations.mixins.json +++ b/src/main/resources/legacyanimations.mixins.json @@ -11,10 +11,8 @@ "ClientPlayerInteractionManagerMixin", "DebugHudMixin", "EntityMixin", - "EntityRenderDispatcherMixin", "FishingBobberEntityRendererMixin", "FlyingItemEntityRendererMixin", - "FoodComponentAccessor", "GameRendererMixin", "HeldItemRendererMixin", "InGameHudMixin", @@ -26,9 +24,7 @@ "LivingEntityRendererMixin", "MinecraftClientMixin", "PlayerEntityMixin", - "PlayerEntityRendererMixin", - "ShieldItemMixin", - "SwordItemMixin" + "PlayerEntityRendererMixin" ], "injectors": { "defaultRequire": 1