diff --git a/src/main/java/com/mixces/legacyanimations/LegacyAnimations.java b/src/main/java/com/mixces/legacyanimations/LegacyAnimations.java index 2c7e933..1501028 100644 --- a/src/main/java/com/mixces/legacyanimations/LegacyAnimations.java +++ b/src/main/java/com/mixces/legacyanimations/LegacyAnimations.java @@ -4,7 +4,9 @@ import com.mixces.legacyanimations.hook.TransformHook; import com.mojang.brigadier.arguments.FloatArgumentType; import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; +import net.minecraft.client.MinecraftClient; import net.minecraft.server.command.CommandManager; import net.minecraft.text.Text; @@ -15,15 +17,15 @@ public class LegacyAnimations implements ModInitializer public void onInitialize() { LegacyAnimationsSettings.CONFIG.load(); -// ClientTickEvents.END_WORLD_TICK.register(world -> -// { -// if (MinecraftClient.getInstance().player == null) -// { -// return; -// } -// -// MinecraftClient.getInstance().player.calculateDimensions(); -// }); + ClientTickEvents.END_WORLD_TICK.register(world -> + { + if (MinecraftClient.getInstance().player == null) + { + return; + } + + MinecraftClient.getInstance().player.calculateDimensions(); + }); CommandRegistrationCallback.EVENT.register( (dispatcher, registryAccess, environment) -> @@ -56,21 +58,53 @@ 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("yaw", 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, "yaw"); + TransformHook.translationX = value; + TransformHook.translationY = value2; + TransformHook.translationZ = value3; + TransformHook.rotationX = value4; + context.getSource().sendFeedback(() -> Text.literal("x: " + value + " y: " + value2 + " z: " + value3 + " yaw: " + value4), false); + return 1; + }) + .then(CommandManager.argument("pitch", 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"); + final float value5 = FloatArgumentType.getFloat(context, "pitch"); + TransformHook.translationX = value; + TransformHook.translationY = value2; + TransformHook.translationZ = value3; + TransformHook.rotationX = value4; + TransformHook.rotationY = value5; + context.getSource().sendFeedback(() -> Text.literal("x: " + value + " y: " + value2 + " z: " + value3 + " yaw: " + value4 + " pitch: " + value5), 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, "yaw"); + final float value5 = FloatArgumentType.getFloat(context, "pitch"); + final float value6 = FloatArgumentType.getFloat(context, "roll"); + TransformHook.translationX = value; + TransformHook.translationY = value2; + TransformHook.translationZ = value3; + TransformHook.rotationX = value4; + TransformHook.rotationY = value5; + TransformHook.rotationZ = value6; + context.getSource().sendFeedback(() -> Text.literal("x: " + value + " y: " + value2 + " z: " + value3 + " yaw: " + value4 + " pitch: " + value5 + " roll: " + value6), false); + return 1; + }) + + ))))))); }); } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/BipedEntityModelMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/BipedEntityModelMixin.java index c1dd09e..3634b04 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/BipedEntityModelMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/BipedEntityModelMixin.java @@ -16,8 +16,6 @@ public abstract class BipedEntityModelMixin { - //todo: thorough investigation needed - @Shadow public BipedEntityModel.ArmPose leftArmPose; @Shadow public BipedEntityModel.ArmPose rightArmPose; @Shadow @Final public ModelPart rightArm; @@ -37,24 +35,26 @@ public abstract class BipedEntityModelMixin ) private void legacyAnimations$fixIncorrectArmPlacement(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci) { - if (LegacyAnimationsSettings.CONFIG.instance().punchDuringUsage) + if (!LegacyAnimationsSettings.CONFIG.instance().punchDuringUsage) + { + return; + } + + rightArm.roll = 0.0F; + leftArm.roll = 0.0F; + if (rightArmPose == BipedEntityModel.ArmPose.BOW_AND_ARROW) + { + rightArm.yaw = -0.1F + head.yaw; + leftArm.yaw = 0.1F + head.yaw + 0.4F; + rightArm.pitch = (float) (-Math.PI / 2) + head.pitch; + leftArm.pitch = (float) (-Math.PI / 2) + head.pitch; + } + if (leftArmPose == BipedEntityModel.ArmPose.BOW_AND_ARROW) { - rightArm.roll = 0.0F; - leftArm.roll = 0.0F; - if (rightArmPose == BipedEntityModel.ArmPose.BOW_AND_ARROW) - { - rightArm.yaw = -0.1F + head.yaw; - leftArm.yaw = 0.1F + head.yaw + 0.4F; - rightArm.pitch = (float) (-Math.PI / 2) + head.pitch; - leftArm.pitch = (float) (-Math.PI / 2) + head.pitch; - } - if (leftArmPose == BipedEntityModel.ArmPose.BOW_AND_ARROW) - { - rightArm.yaw = -0.1F + head.yaw - 0.4F; - leftArm.yaw = 0.1F + head.yaw; - rightArm.pitch = (float) (-Math.PI / 2) + head.pitch; - leftArm.pitch = (float) (-Math.PI / 2) + head.pitch; - } + rightArm.yaw = -0.1F + head.yaw - 0.4F; + leftArm.yaw = 0.1F + head.yaw; + rightArm.pitch = (float) (-Math.PI / 2) + head.pitch; + leftArm.pitch = (float) (-Math.PI / 2) + head.pitch; } } @@ -82,10 +82,12 @@ public abstract class BipedEntityModelMixin ) private void legacyAnimations$oldSneakValue1(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci) { - if (LegacyAnimationsSettings.CONFIG.instance().oldSneaking) + if (!LegacyAnimationsSettings.CONFIG.instance().oldSneaking) { - rightLeg.pivotY = 9.0f; + return; } + + rightLeg.pivotY = 9.0f; } @Inject( @@ -112,10 +114,12 @@ public abstract class BipedEntityModelMixin ) private void legacyAnimations$oldSneakValue2(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci) { - if (LegacyAnimationsSettings.CONFIG.instance().oldSneaking) + if (!LegacyAnimationsSettings.CONFIG.instance().oldSneaking) { - leftLeg.pivotY = 9.0f; + return; } + + leftLeg.pivotY = 9.0f; } @Inject( @@ -129,10 +133,12 @@ public abstract class BipedEntityModelMixin ) private void legacyAnimations$oldSneakValue3(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci) { - if (LegacyAnimationsSettings.CONFIG.instance().oldSneaking) + if (!LegacyAnimationsSettings.CONFIG.instance().oldSneaking) { - rightLeg.pivotZ = 0.1f; + return; } + + rightLeg.pivotZ = 0.1f; } @Inject( @@ -146,10 +152,12 @@ public abstract class BipedEntityModelMixin ) private void legacyAnimations$oldSneakValue4(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci) { - if (LegacyAnimationsSettings.CONFIG.instance().oldSneaking) + if (!LegacyAnimationsSettings.CONFIG.instance().oldSneaking) { - leftLeg.pivotZ = 0.1f; + return; } + + leftLeg.pivotZ = 0.1f; } @Inject( @@ -163,10 +171,12 @@ public abstract class BipedEntityModelMixin ) private void legacyAnimations$oldSneakValue5(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci) { - if (LegacyAnimationsSettings.CONFIG.instance().oldSneaking) + if (!LegacyAnimationsSettings.CONFIG.instance().oldSneaking) { - head.pivotY = 1.0f; + return; } + + head.pivotY = 1.0f; } @WrapWithCondition( @@ -231,37 +241,13 @@ public abstract class BipedEntityModelMixin ) public void legacyAnimations$oldBlockingArm(ModelPart arm, boolean rightArm, CallbackInfo ci) { - if (LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock) + if (!LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock) { - arm.pitch = arm.pitch * 0.5F - (float) (Math.PI / 3); - arm.yaw = 0.0F; + return; } - } - @ModifyArg( - method = "positionLeftArm", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel;positionBlockingArm(Lnet/minecraft/client/model/ModelPart;Z)V" - ), - index = 0 - ) - private ModelPart legacyAnimations$switchBlockingArm1(ModelPart arm) - { - return LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock ? rightArm : arm; - } - - @ModifyArg( - method = "positionRightArm", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel;positionBlockingArm(Lnet/minecraft/client/model/ModelPart;Z)V" - ), - index = 0 - ) - private ModelPart legacyAnimations$switchBlockingArm2(ModelPart arm) - { - return LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock ? leftArm : arm; + arm.pitch = arm.pitch * 0.5F - (float) (Math.PI / 3); + arm.yaw = 0.0F; } } \ No newline at end of file diff --git a/src/main/java/com/mixces/legacyanimations/mixin/HeldItemFeatureRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/HeldItemFeatureRendererMixin.java index 2873b59..5869d85 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/HeldItemFeatureRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/HeldItemFeatureRendererMixin.java @@ -1,12 +1,14 @@ package com.mixces.legacyanimations.mixin; import com.mixces.legacyanimations.config.LegacyAnimationsSettings; +import com.mixces.legacyanimations.hook.TransformHook; 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.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.Arm; import net.minecraft.util.math.RotationAxis; @@ -18,29 +20,36 @@ @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)); -// } + @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 (!entity.isBlocking()) + { + return; + } + + if (!ItemUtils.INSTANCE.isShieldInOffHand(entity.getOffHandStack()) || !ItemUtils.INSTANCE.isSwordInMainHand(entity.getMainHandStack())) + { + return; + } + + matrices.translate(TransformHook.translationX, TransformHook.translationY, TransformHook.translationZ); + matrices.multiply(RotationAxis.POSITIVE_X.rotation(TransformHook.rotationX)); + matrices.multiply(RotationAxis.POSITIVE_Y.rotation(TransformHook.rotationY)); + matrices.multiply(RotationAxis.POSITIVE_Z.rotation(TransformHook.rotationZ)); + + // x: -0.2 y: 0.0 z: 0.1 yaw: 21.0 pitch: 90.0 roll: -90.0 + } } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityMixin.java index 3a9d2c9..80b215a 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityMixin.java @@ -2,35 +2,47 @@ import com.mixces.legacyanimations.config.LegacyAnimationsSettings; import com.mixces.legacyanimations.duck.PlayerPitchInterface; -import com.mixces.legacyanimations.util.ServerUtils; import net.minecraft.entity.LivingEntity; import net.minecraft.item.ItemStack; +import net.minecraft.util.UseAction; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(LivingEntity.class) public abstract class LivingEntityMixin implements PlayerPitchInterface { - @Shadow public abstract ItemStack getMainHandStack(); @Shadow public abstract boolean isUsingItem(); + @Shadow protected ItemStack activeItemStack; @Unique public float legacyAnimations$prevCameraPitch; @Unique public float legacyAnimations$cameraPitch; //todo: hypixel rahh -// @ModifyConstant(method = "isBlocking", constant = @Constant(intValue = 5)) -// private int legacyAnimations$fixSync(int constant) -// { -// if (ServerUtils.INSTANCE.isOnHypixel()) + @Inject( + method = "isBlocking", + at = @At( + value = "HEAD" + ), + cancellable = true + ) + private void legacyAnimations$fixSync(CallbackInfoReturnable cir) + { +// if (!ServerUtils.INSTANCE.isValidServer()) // { -// return 0; +// return; // } -// return constant; -// } + + //todo: shield delay? + + final UseAction action = activeItemStack.getItem().getUseAction(activeItemStack); + + cir.setReturnValue(isUsingItem() && action == UseAction.BLOCK); + } @ModifyConstant( method = "tick", @@ -51,7 +63,7 @@ public abstract class LivingEntityMixin implements PlayerPitchInterface ) private float legacyAnimations$revertBackwardsWalk(float constant) { - if (LegacyAnimationsSettings.CONFIG.instance().oldWalking) + if (!LegacyAnimationsSettings.CONFIG.instance().oldWalking) { return constant; } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityMixin.java index a7e6bba..a806037 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityMixin.java @@ -4,9 +4,13 @@ import com.mixces.legacyanimations.config.LegacyAnimationsSettings; import com.mixces.legacyanimations.mixin.interfaces.IEntityMixin; import com.mixces.legacyanimations.mixin.interfaces.ILivingEntityMixin; +import com.mixces.legacyanimations.util.ItemUtils; +import com.mixces.legacyanimations.util.ServerUtils; import net.minecraft.entity.EntityDimensions; import net.minecraft.entity.EntityPose; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -16,27 +20,50 @@ @Mixin(PlayerEntity.class) public abstract class PlayerEntityMixin extends LivingEntityMixin { - //todo: hypixel -// @Inject(method = "resetLastAttackedTicks", at = @At("HEAD"), cancellable = true) -// private void legacyAnimations$removeAttackDelay(CallbackInfo ci) + +// @ModifyReturnValue( +// method = "getEquippedStack", +// at = @At( +// value = "RETURN", +// ordinal = 1 +// ) +// ) +// private ItemStack legacyAnimations$fakeShield(ItemStack original) // { -// if (ServerUtils.INSTANCE.isOnHypixel()) +// if (!ServerUtils.INSTANCE.isValidServer()) +// { +// return original; +// } +// +// if (isBlocking()) +// { +// return original; +// } +// +// if (!ItemUtils.INSTANCE.isSwordInMainHand(null)) // { -// ci.cancel(); +// return original; // } +// +// return new ItemStack(Items.SHIELD); // } - //todo: hypixel -// @Inject(method = "getMainArm", at = @At("HEAD"), cancellable = true) -// public void legacyAnimations$correctHandSide(CallbackInfoReturnable cir) +// @Inject( +// method = "resetLastAttackedTicks", +// at = @At( +// value = "HEAD" +// ), +// cancellable = true +// ) +// private void legacyAnimations$removeAttackDelay(CallbackInfo ci) // { -// final PlayerEntity entity = (PlayerEntity) (Object) this; -// -// if (entity instanceof ClientPlayerEntity && ServerUtils.INSTANCE.isOnHypixel()) +// if (!ServerUtils.INSTANCE.isValidServer()) // { -// cir.setReturnValue(MinecraftClient.getInstance().options.getMainArm().getValue()); +// return; // } +// +// ci.cancel(); // } @Inject( @@ -66,21 +93,6 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin legacyAnimations$cameraPitch += (f1 - legacyAnimations$cameraPitch) * 0.8F; } -// @Inject( -// method = "getEquippedStack", -// at = @At( -// value = "RETURN", -// ordinal = 1 -// ), -// cancellable = true) -// private void legacyAnimations$hypixelShieldBug(EquipmentSlot slot, CallbackInfoReturnable cir) -// { -// if (ServerUtils.INSTANCE.isOnHypixel() && getMainHandStack().getItem() instanceof SwordItem && !isUsingItem()) -// { -// cir.setReturnValue(new ItemStack(Items.SHIELD)); -// } -// } - @ModifyReturnValue( method = "getBaseDimensions", at = @At( diff --git a/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityRendererMixin.java index bb53c16..30fae46 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityRendererMixin.java @@ -1,46 +1,65 @@ 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.ItemUtils; import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.render.entity.PlayerEntityRenderer; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; +import net.minecraft.client.render.entity.model.BipedEntityModel; +import net.minecraft.util.Hand; 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.CallbackInfoReturnable; @Mixin(PlayerEntityRenderer.class) public class PlayerEntityRendererMixin { - //todo: shield shit -// @Inject(method = "getArmPose", at = @At(value = "HEAD"), cancellable = true) -// private static void getArmPose_blockArm(AbstractClientPlayerEntity player, Hand hand, CallbackInfoReturnable cir) { -// if (LegacyAnimationsSettings.CONFIG.instance().hideShields && player.getStackInHand(hand).getItem() instanceof ShieldItem) { -// cir.setReturnValue(BipedEntityModel.ArmPose.EMPTY); -// } -// } - -// @ModifyExpressionValue( -// method = "getArmPose", -// at = @At( -// value = "INVOKE", -// target = "Lnet/minecraft/item/ItemStack;isEmpty()Z" -// ) -// ) -// private static boolean removeBlockArm(boolean original, @Local(ordinal = 0) ItemStack itemStack) { -// if (LegacyAnimationsSettings.CONFIG.instance().hideShields) { -// return original || itemStack.isOf(Items.SHIELD); -// } -// 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(); -// } + @Inject( + method = "getArmPose", + at = @At( + value = "HEAD" + ), + cancellable = true + ) + private static void legacyAnimations$removeShieldArm(AbstractClientPlayerEntity player, Hand hand, CallbackInfoReturnable cir) { + if (!LegacyAnimationsSettings.CONFIG.instance().hideShields) + { + return; + } + + final Hand offhand = Hand.OFF_HAND; + + if (!ItemUtils.INSTANCE.isShieldInOffHand(player.getStackInHand(offhand))) + { + return; + } + + if (!ItemUtils.INSTANCE.isSwordInMainHand(player.getStackInHand(Hand.MAIN_HAND))) + { + return; + } + + if (hand == offhand) + { + cir.setReturnValue(BipedEntityModel.ArmPose.EMPTY); + } + } + + @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 legacyAnimations$disableSneakOffset(AbstractClientPlayerEntity player) { + if (!LegacyAnimationsSettings.CONFIG.instance().oldSneaking) + { + return player.isInSneakingPose(); + } + return false; + } } diff --git a/src/main/java/com/mixces/legacyanimations/util/ItemUtils.java b/src/main/java/com/mixces/legacyanimations/util/ItemUtils.java index e8d27b2..1355ffe 100644 --- a/src/main/java/com/mixces/legacyanimations/util/ItemUtils.java +++ b/src/main/java/com/mixces/legacyanimations/util/ItemUtils.java @@ -143,7 +143,7 @@ public boolean isShieldInOffHand(ItemStack stack) { */ public boolean isUsing(ClientPlayerEntity player) { - if (ServerUtils.INSTANCE.isOnHypixel()) + if (ServerUtils.INSTANCE.isValidServer()) { return MinecraftClient.getInstance().options.useKey.isPressed(); } diff --git a/src/main/java/com/mixces/legacyanimations/util/ServerUtils.java b/src/main/java/com/mixces/legacyanimations/util/ServerUtils.java index e3ed6af..c6766bb 100644 --- a/src/main/java/com/mixces/legacyanimations/util/ServerUtils.java +++ b/src/main/java/com/mixces/legacyanimations/util/ServerUtils.java @@ -10,9 +10,9 @@ public class ServerUtils private final ServerInfo server = MinecraftClient.getInstance().getCurrentServerEntry(); - public boolean isOnHypixel() + public boolean isValidServer() { - return server != null && server.address.endsWith("hypixel.net"); + return server != null && (server.address.endsWith("hypixel.net") || server.address.endsWith("bedwarspractice.club")); } }