diff --git a/gradle.properties b/gradle.properties index b60d1d8..83dd15b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,6 +15,6 @@ archives_base_name=legacyanimations # Dependencies fabric_version=0.100.1+1.21 -modmenu_version=10.0.0-beta.1 -yacl_version=3.4.2+1.20.5 +modmenu_version=11.0.1 +yacl_version=3.5.0+1.21 devauth_version=1.2.0 \ No newline at end of file diff --git a/src/main/java/com/mixces/legacyanimations/LegacyAnimations.java b/src/main/java/com/mixces/legacyanimations/LegacyAnimations.java index 17caee0..0aa4bde 100644 --- a/src/main/java/com/mixces/legacyanimations/LegacyAnimations.java +++ b/src/main/java/com/mixces/legacyanimations/LegacyAnimations.java @@ -11,37 +11,26 @@ import net.minecraft.server.command.CommandManager; import net.minecraft.text.Text; -public class LegacyAnimations implements ModInitializer -{ +public class LegacyAnimations implements ModInitializer { @Override - public void onInitialize() - { + public void onInitialize() { LegacyAnimationsSettings.CONFIG.load(); updatePlayerState(); registerCommands(); } - private void updatePlayerState() - { - ClientTickEvents.END_WORLD_TICK.register(world -> - { + private void updatePlayerState() { + ClientTickEvents.END_WORLD_TICK.register(world -> { final ClientPlayerEntity player = MinecraftClient.getInstance().player; - - if (player == null) - { - return; - } - + if (player == null) return; player.calculateDimensions(); }); } - private void registerCommands() - { + private void registerCommands() { CommandRegistrationCallback.EVENT.register( - (dispatcher, registryAccess, environment) -> - { + (dispatcher, registryAccess, environment) -> { dispatcher.register(CommandManager.literal("legacyanimations") .then(CommandManager.argument("x", FloatArgumentType.floatArg()) .executes(context -> { @@ -80,7 +69,7 @@ private void registerCommands() TransformHook.translationY = value2; TransformHook.translationZ = value3; TransformHook.rotationX = value4; - context.getSource().sendFeedback(() -> Text.literal("x: " + value + " y: " + value2 + " z: " + value3 + " yaw: " + value4), false); + context.getSource().sendFeedback(() -> Text.literal("x: " + value + " y: " + value2 + " z: " + value3 + " pitch: " + value4), false); return 1; }) .then(CommandManager.argument("yaw", FloatArgumentType.floatArg()) @@ -95,7 +84,7 @@ private void registerCommands() 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); + context.getSource().sendFeedback(() -> Text.literal("x: " + value + " y: " + value2 + " z: " + value3 + " pitch: " + value4 + " yaw: " + value5), false); return 1; }) .then(CommandManager.argument("roll", FloatArgumentType.floatArg()) @@ -112,12 +101,11 @@ private void registerCommands() 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); + context.getSource().sendFeedback(() -> Text.literal("x: " + value + " y: " + value2 + " z: " + value3 + " pitch: " + value4 + " yaw: " + value5 + " roll: " + value6), false); return 1; }) ))))))); }); } - } \ No newline at end of file diff --git a/src/main/java/com/mixces/legacyanimations/config/LegacyAnimationsSettings.java b/src/main/java/com/mixces/legacyanimations/config/LegacyAnimationsSettings.java index 64ded46..8956256 100644 --- a/src/main/java/com/mixces/legacyanimations/config/LegacyAnimationsSettings.java +++ b/src/main/java/com/mixces/legacyanimations/config/LegacyAnimationsSettings.java @@ -18,14 +18,13 @@ public class LegacyAnimationsSettings { @SerialEntry public boolean punchDuringUsage = true; @SerialEntry public boolean itemPositions = true; - @SerialEntry public boolean oldSwordBlock = true; // TODO: this prevents an item in offhand (e.g., bow) from being used. Also causes to walk slow despite not actually blocking, may trigger ACs -// @SerialEntry public boolean blockWithShieldOnly = true; // this fixes the aforementioned issue by requiring a shield in offhand + @SerialEntry public boolean oldSwordBlock = true; @SerialEntry public boolean hideShields = true; @SerialEntry public boolean hideShieldHotbar = true; @SerialEntry public boolean noCooldown = true; -// @SerialEntry public boolean oldMovement = true; // already in viafabric @SerialEntry public boolean oldSneaking = true; @SerialEntry public boolean oldWalking = true; + @SerialEntry public boolean oldCape = true; @SerialEntry public boolean oldDeath = true; @SerialEntry public boolean oldSwim = true; @SerialEntry public boolean oldHearts = true; @@ -37,7 +36,6 @@ public class LegacyAnimationsSettings { @SerialEntry public boolean armorTint = true; @SerialEntry public boolean oldBreakProgress = true; @SerialEntry public boolean oldDamageTilt = true; -// @SerialEntry public boolean noSwing = true; @SerialEntry public boolean oldPotionGlint = true; @SerialEntry public boolean noShieldDelay = true; @@ -73,12 +71,6 @@ public static Screen configScreen(Screen parent) { .binding(defaults.oldSwordBlock, () -> config.oldSwordBlock, newVal -> config.oldSwordBlock = newVal) .controller(TickBoxControllerBuilder::create) .build()) -// .option(Option.createBuilder(boolean.class) -// .name(Text.literal("Block Only when Holding Shield")) -// .description(OptionDescription.of(Text.of("Only blocks with your sword when you hold a shield in your offhand."))) -// .binding(defaults.blockWithShieldOnly, () -> config.blockWithShieldOnly, newVal -> config.blockWithShieldOnly = newVal) -// .controller(TickBoxControllerBuilder::create) -// .build()) .option(Option.createBuilder(boolean.class) .name(Text.literal("Hide Shield Model")) .description(OptionDescription.of(Text.of("Hides the shield model from rendering."))) @@ -148,6 +140,12 @@ public static Screen configScreen(Screen parent) { .binding(defaults.oldWalking, () -> config.oldWalking, newVal -> config.oldWalking = newVal) .controller(TickBoxControllerBuilder::create) .build()) + .option(Option.createBuilder(boolean.class) + .name(Text.literal("Old Cape Physics")) + .description(OptionDescription.of(Text.of("Reverts the cape physics to it's former glory."))) + .binding(defaults.oldCape, () -> config.oldCape, newVal -> config.oldCape = newVal) + .controller(TickBoxControllerBuilder::create) + .build()) .option(Option.createBuilder(boolean.class) .name(Text.literal("Old Entity Death Animation")) .description(OptionDescription.of(Text.of("Allows dead entity corpse limbs to move."))) @@ -171,12 +169,6 @@ public static Screen configScreen(Screen parent) { .binding(defaults.noCooldown, () -> config.noCooldown, newVal -> config.noCooldown = newVal) .controller(TickBoxControllerBuilder::create) .build()) - .option(Option.createBuilder(boolean.class) - .name(Text.literal("Old Movement")) - .description(OptionDescription.of(Text.of("Completely stops the player's sprint while blocking, drawing a bow, or consuming a consumable item."))) - .binding(defaults.oldMovement, () -> config.oldMovement, newVal -> config.oldMovement = newVal) - .controller(TickBoxControllerBuilder::create) - .build()) .option(Option.createBuilder(boolean.class) .name(Text.literal("Old View Bobbing")) .description(OptionDescription.of(Text.of("Changes the held item's position while moving based on the player's yaw"))) diff --git a/src/main/java/com/mixces/legacyanimations/mixin/BipedEntityModelMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/BipedEntityModelMixin.java index 87a703e..45cff01 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/BipedEntityModelMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/BipedEntityModelMixin.java @@ -6,9 +6,7 @@ import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.llamalad7.mixinextras.sugar.Local; import com.mixces.legacyanimations.config.LegacyAnimationsSettings; -import net.minecraft.client.MinecraftClient; import net.minecraft.client.model.ModelPart; -import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.render.entity.model.BipedEntityModel; import net.minecraft.entity.LivingEntity; import net.minecraft.util.Arm; @@ -305,17 +303,4 @@ public abstract class BipedEntityModelMixin { arm.yaw = (rightArm ? -1.0f : 1.0f) * (float) (-Math.PI / 6); } } - -// @WrapOperation( -// method = "positionRightArm", -// at = @At( -// value = "INVOKE", -// target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel$ArmPose;ordinal()I" -// ) -// ) -// private int shit(BipedEntityModel.ArmPose instance, Operation original) -// { -// return 2; -// } - } \ No newline at end of file diff --git a/src/main/java/com/mixces/legacyanimations/mixin/CapeFeatureRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/CapeFeatureRendererMixin.java new file mode 100644 index 0000000..deaed7d --- /dev/null +++ b/src/main/java/com/mixces/legacyanimations/mixin/CapeFeatureRendererMixin.java @@ -0,0 +1,35 @@ +package com.mixces.legacyanimations.mixin; + +import com.mixces.legacyanimations.config.LegacyAnimationsSettings; +import net.minecraft.client.render.entity.feature.CapeFeatureRenderer; +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.Redirect; + +@Mixin(value = CapeFeatureRenderer.class) +public class CapeFeatureRendererMixin { + + @Redirect( + method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/network/AbstractClientPlayerEntity;FFFFFF)V", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/util/math/MathHelper;lerpAngleDegrees(FFF)F" + ) + ) + private float legacyAnimations$useLerp(float delta, float start, float end) { + return LegacyAnimationsSettings.getInstance().oldCape ? MathHelper.lerp(delta, start, end) : MathHelper.lerpAngleDegrees(delta, start, end); + } + + @Redirect( + method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/network/AbstractClientPlayerEntity;FFFFFF)V", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/util/math/MathHelper;clamp(FFF)F", + ordinal = 2 + ) + ) + private float legacyAnimations$removeClamp(float value, float min, float max) { + return LegacyAnimationsSettings.getInstance().oldCape ? value : MathHelper.clamp(value, min, max); + } +} diff --git a/src/main/java/com/mixces/legacyanimations/mixin/HeldItemFeatureRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/HeldItemFeatureRendererMixin.java index 8ee27dd..89d6ed2 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/HeldItemFeatureRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/HeldItemFeatureRendererMixin.java @@ -1,7 +1,7 @@ package com.mixces.legacyanimations.mixin; +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; import com.mixces.legacyanimations.config.LegacyAnimationsSettings; -import com.mixces.legacyanimations.hook.TransformHook; import com.mixces.legacyanimations.util.ItemUtils; import com.mixces.legacyanimations.util.MatrixUtil; import net.minecraft.client.render.VertexConsumerProvider; @@ -10,17 +10,55 @@ import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.BlockItem; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import net.minecraft.util.Arm; -import net.minecraft.util.math.RotationAxis; +import org.joml.Quaternionf; 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.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.invoke.arg.Args; @Mixin(HeldItemFeatureRenderer.class) public class HeldItemFeatureRendererMixin { + @ModifyArgs( + method = "renderItem", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/util/math/MatrixStack;translate(FFF)V" + ) + ) + private void legacyAnimations$revertTranslation(Args args) { + args.setAll((float) args.get(0) * -1.0F, 0.4375F, (float) args.get(2) / 10 * -1.0F); + } + + @WrapWithCondition( + method = "renderItem", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/util/math/MatrixStack;multiply(Lorg/joml/Quaternionf;)V", + ordinal = 0 + ) + ) + private boolean legacyAnimations$removeExtraMultiply(MatrixStack instance, Quaternionf quaternion) { + return !LegacyAnimationsSettings.getInstance().itemPositions; + } + + @WrapWithCondition( + method = "renderItem", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/util/math/MatrixStack;multiply(Lorg/joml/Quaternionf;)V", + ordinal = 1 + ) + ) + private boolean legacyAnimations$removeExtraMultiply2(MatrixStack instance, Quaternionf quaternion) { + return !LegacyAnimationsSettings.getInstance().itemPositions; + } + @Inject( method = "renderItem", at = @At( @@ -29,14 +67,61 @@ public class HeldItemFeatureRendererMixin { ) ) private void legacyAnimations$swordBlockTransform(LivingEntity entity, ItemStack stack, ModelTransformationMode transformationMode, Arm arm, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { - if (LegacyAnimationsSettings.getInstance().oldSwordBlock && entity.isBlocking() && - ItemUtils.INSTANCE.isShieldInOffHand(entity.getOffHandStack()) && - ItemUtils.INSTANCE.isSwordInMainHand(entity.getMainHandStack())) { - final MatrixUtil matrix = new MatrixUtil(matrices); +// if (LegacyAnimationsSettings.getInstance().oldSwordBlock && entity.isBlocking() && +// ItemUtils.INSTANCE.isShieldInOffHand(entity.getOffHandStack()) && +// ItemUtils.INSTANCE.isSwordInMainHand(entity.getMainHandStack())) { +// +// matrices.translate(TransformHook.translationX, TransformHook.translationY, TransformHook.translationZ); +// matrix.yaw(TransformHook.rotationX).pitch(TransformHook.rotationY).roll(TransformHook.rotationZ); +// } + final MatrixUtil matrix = new MatrixUtil(matrices); +// matrix.yaw(TransformHook.rotationX).pitch(TransformHook.rotationY).roll(TransformHook.rotationZ); +// matrices.translate(TransformHook.translationX, TransformHook.translationY, TransformHook.translationZ); - matrices.translate(TransformHook.translationX, TransformHook.translationY, TransformHook.translationZ); - matrix.yaw(TransformHook.rotationX).pitch(TransformHook.rotationY).roll(TransformHook.rotationZ); + Item item = stack.getItem(); + float var7; + if (item instanceof BlockItem) { + var7 = 0.375F; + matrices.translate(0.0F, 0.1875F, -0.3125F); + matrix.pitch(20.0F).yaw(45.0F); + matrices.scale(-var7, -var7, var7); + } else if (item == Items.BOW) { + var7 = 0.625F; + matrices.translate(0.0F, 0.125F, 0.3125F); + matrix.yaw(-20.0F); + matrices.scale(var7, -var7, var7); + matrix.pitch(-100.0F).yaw(45.0F); + } else if (ItemUtils.INSTANCE.isFull3d(stack)) { + var7 = 0.625F; + if (ItemUtils.INSTANCE.shouldRotateAroundWhenRendering(stack, true)) { + matrix.roll(180.0F); + matrices.translate(0.0F, -0.125F, 0.0F); + } + if (entity instanceof PlayerEntity && entity.getItemUseTime() > 0 && entity.isBlocking()) { + matrices.translate(0.05F, 0.0F, -0.1F); + matrix.yaw(-50.0F).pitch(-10.0F).roll(-60.0F); + } + matrices.translate(0.0F, 0.1875F, 0.0F); + matrices.scale(var7, var7, var7); + matrix.pitch(-100.0F).yaw(45.0F); + } else { + var7 = 0.375F; + matrices.translate(0.25F, 0.1875F, -0.1875F); + matrices.scale(var7, var7, var7); + matrix.roll(60.0F).pitch(-90.0F).roll(20.0F); } // x: -0.2 y: 0.0 z: 0.1 yaw: 21.0 pitch: 90.0 roll: -90.0 } + + @ModifyArg( + method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/entity/LivingEntity;FFFFFF)V", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/render/entity/feature/HeldItemFeatureRenderer;renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformationMode;Lnet/minecraft/util/Arm;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V" + ), + index = 2 + ) + private ModelTransformationMode legacyAnimations$changeTransformType(ModelTransformationMode renderMode) { + return LegacyAnimationsSettings.getInstance().itemPositions ? ModelTransformationMode.NONE : renderMode; + } } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/HeldItemRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/HeldItemRendererMixin.java index c50254b..b795e04 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/HeldItemRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/HeldItemRendererMixin.java @@ -1,8 +1,10 @@ package com.mixces.legacyanimations.mixin; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; 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.MatrixUtil; @@ -11,11 +13,14 @@ import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.item.HeldItemRenderer; +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.Hand; import net.minecraft.util.math.RotationAxis; +import org.joml.Quaternionf; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -42,6 +47,26 @@ public abstract class HeldItemRendererMixin { @Final private EntityRenderDispatcher entityRenderDispatcher; + @Inject( + method = "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", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/render/item/ItemRenderer;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;Lnet/minecraft/world/World;III)V" + ) + ) + private void legacyAnimations$oldItemTransformations(LivingEntity entity, ItemStack stack, ModelTransformationMode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { + if (LegacyAnimationsSettings.getInstance().oldSwordBlock) { + final MatrixUtil matrix = new MatrixUtil(matrices); + matrices.translate(0.0F, -0.3F, 0.0F); + matrices.scale(1.5F, 1.5F, 1.5F); + matrix.yaw(50.0F).roll(335.0F); + matrices.translate(-0.9375F, -0.0625F, 0.0F); + /* idk */ + matrix.yaw(180.0F); + matrices.translate(-0.5F, 0.5F, 0.03125F); + } + } + @Inject( method = "renderFirstPersonItem", at = @At( @@ -53,6 +78,7 @@ public abstract class HeldItemRendererMixin { private void legacyAnimations$preBowTransform(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { if (LegacyAnimationsSettings.getInstance().itemPositions) { final int l = HandUtils.INSTANCE.handMultiplier((ClientPlayerEntity) player, entityRenderDispatcher); + //todo: fix this matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(l * -335)); matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(l * -50.0F)); } @@ -99,6 +125,17 @@ public abstract class HeldItemRendererMixin { } } + @Inject( + method = "applySwingOffset", + at = @At("TAIL") + ) + private void legacyAnimations$addOldScale(MatrixStack matrices, Arm arm, float swingProgress, CallbackInfo ci) { + if (LegacyAnimationsSettings.getInstance().itemPositions) { + matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(45.0F)); + matrices.scale(0.4F, 0.4F, 0.4F); + } + } + @Inject( method = "renderFirstPersonItem", at = @At( @@ -113,8 +150,11 @@ public abstract class HeldItemRendererMixin { if (!ItemUtils.INSTANCE.isSwordInMainHand(mainHand) || !ItemUtils.INSTANCE.isShieldInOffHand(offHand)) return; final int l = HandUtils.INSTANCE.handMultiplier((ClientPlayerEntity) player, entityRenderDispatcher); final MatrixUtil matrix = new MatrixUtil(matrices); - matrices.translate(l * -0.14142136F, 0.08F, 0.14142136F); - matrix.pitch(-102.25F).yaw(l * 13.365F).roll(l * 78.05F); +// matrices.translate(l * -0.14142136F, 0.08F, 0.14142136F); +// matrix.pitch(-102.25F).yaw(l * 13.365F).roll(l * 78.05F); + + matrices.translate(-0.5F, 0.2F, 0.0F); + matrix.yaw(30.0F).pitch(-80.0F).yaw(60.0F); } } @@ -132,13 +172,27 @@ public abstract class HeldItemRendererMixin { if (ItemUtils.INSTANCE.shouldRotateAroundWhenRendering(item, true)) { matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(l * 180.0F)); } - final float scale = 0.7585F / 0.86F; - matrices.scale(scale, scale, scale); - matrices.translate(l * -0.084F, 0.059F, 0.08F); - matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(l * 5.0F)); +// final MatrixUtil matrix = new MatrixUtil(matrices); +// final float scale = 0.7585F / 0.86F; +// matrices.scale(scale, scale, scale); +// matrices.translate(l * -0.084F, 0.059F, 0.08F); +// matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(l * 5.0F)); + } } + @ModifyArg( + method = "renderFirstPersonItem", + 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" + ), + index = 2 + ) + private ModelTransformationMode legacyAnimations$changeTransformType(ModelTransformationMode renderMode) { + return LegacyAnimationsSettings.getInstance().itemPositions ? ModelTransformationMode.NONE : renderMode; + } + @ModifyExpressionValue( method = "updateHeldItems", at = @At( @@ -164,7 +218,6 @@ public abstract class HeldItemRendererMixin { } //todo: old re-equip logic needed frfr - // @ModifyArg( // method = "updateHeldItems", // at = @At( diff --git a/src/main/java/com/mixces/legacyanimations/mixin/ItemRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/ItemRendererMixin.java index 082d4b6..4a22a62 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/ItemRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/ItemRendererMixin.java @@ -26,10 +26,11 @@ import java.util.stream.Collectors; @Mixin(ItemRenderer.class) -public abstract class ItemRendererMixin -{ +public abstract class ItemRendererMixin { - @Shadow @Final private MinecraftClient client; + @Shadow + @Final + private MinecraftClient client; @Inject( method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IILnet/minecraft/client/render/model/BakedModel;)V", @@ -37,94 +38,71 @@ public abstract class ItemRendererMixin value = "HEAD" ) ) - private void legacyAnimations$getTransformationMode(ItemStack stack, ModelTransformationMode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model, CallbackInfo ci) - { - TransformationModeUtils.setTransformationMode(renderMode); - ItemUtils.INSTANCE.setModel(model); + private void legacyAnimations$getTransformationMode(ItemStack stack, ModelTransformationMode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model, CallbackInfo ci) { + TransformationModeUtils.transformationMode = renderMode; + ItemUtils.INSTANCE.model = model; } - @Inject( - method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IILnet/minecraft/client/render/model/BakedModel;)V", +// @Inject( +// method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IILnet/minecraft/client/render/model/BakedModel;)V", +// at = @At( +// value = "INVOKE", +// target = "Lnet/minecraft/client/render/model/json/Transformation;apply(ZLnet/minecraft/client/util/math/MatrixStack;)V", +// shift = At.Shift.AFTER +// ) +// ) +// private void legacyAnimations$modelTransforms(ItemStack stack, ModelTransformationMode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model, CallbackInfo ci, @Local(ordinal = 1, index = 9) boolean bl) { +// if (LegacyAnimationsSettings.getInstance().itemPositions) { +// if (bl) 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 +// } +// } +// } +// } + + //todo: unfuck left handed sprites and re-write code + @ModifyArg( + method = "renderBakedItemModel", at = @At( value = "INVOKE", - target = "Lnet/minecraft/client/render/model/json/Transformation;apply(ZLnet/minecraft/client/util/math/MatrixStack;)V", - shift = At.Shift.AFTER - ) + 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 void legacyAnimations$modelTransforms(ItemStack stack, ModelTransformationMode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model, CallbackInfo ci, @Local(ordinal = 1, index = 9) boolean bl) - { - if (!LegacyAnimationsSettings.getInstance().itemPositions) - { - return; - } - - if (bl) - { - 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 + private List legacyAnimations$changeToSprite(List quads, @Local(ordinal = 0, argsOnly = true) BakedModel model) { + if (LegacyAnimationsSettings.getInstance().fastItems) { + if (client.player == null) return quads; + if (!TransformationModeUtils.shouldBeSprite() || model.hasDepth()) return quads; + final boolean isLeftHand = HandUtils.INSTANCE.isLeftHand(client.player, client.getEntityRenderDispatcher()); + final boolean isFrontView = client.getEntityRenderDispatcher().gameOptions.getPerspective().isFrontView(); + final Direction perspectiveFace = legacyAnimations$determineDirection(isFrontView, isLeftHand); + if (TransformationModeUtils.transformationMode == ModelTransformationMode.GROUND) { + return legacyAnimations$filterQuadsByDirection(quads, perspectiveFace); } + return legacyAnimations$filterQuadsByDirection(quads, Direction.SOUTH); } + return quads; } - //todo: unfuck left handed sprites and re-write code - @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 legacyAnimations$changeToSprite(List quads, @Local(ordinal = 0, argsOnly = true) BakedModel model) - { - if (!LegacyAnimationsSettings.getInstance().fastItems) { - return quads; - } - - if (client.player == null) - { - return quads; - } - - if (!TransformationModeUtils.shouldBeSprite() || model.hasDepth()) - { - return quads; - } - - final boolean isLeftHand = HandUtils.INSTANCE.isLeftHand(client.player, client.getEntityRenderDispatcher()); - final boolean isFrontView = client.getEntityRenderDispatcher().gameOptions.getPerspective().isFrontView(); - final Direction perspectiveFace = legacyAnimations$determineDirection(isFrontView, isLeftHand); - - if (TransformationModeUtils.getTransformationMode() == ModelTransformationMode.GROUND) - { - return legacyAnimations$filterQuadsByDirection(quads, perspectiveFace); - } - return legacyAnimations$filterQuadsByDirection(quads, Direction.SOUTH); - } - + //todo: write this more concisely @Unique - private static Direction legacyAnimations$determineDirection(boolean isFrontView, boolean isLeftHand) - { - if (isFrontView) - { + private static Direction legacyAnimations$determineDirection(boolean isFrontView, boolean isLeftHand) { + if (isFrontView) { return isLeftHand ? Direction.SOUTH : Direction.NORTH; } return isLeftHand ? Direction.NORTH : Direction.SOUTH; } @Unique - private static List legacyAnimations$filterQuadsByDirection(List quads, Direction face) - { + private static List legacyAnimations$filterQuadsByDirection(List quads, Direction face) { return quads.stream().filter(baked -> baked.getFace() == face).collect(Collectors.toList()); } - } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityMixin.java index 4a95bde..2bf880e 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityMixin.java @@ -1,5 +1,7 @@ package com.mixces.legacyanimations.mixin; +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.PlayerPitchInterface; import com.mixces.legacyanimations.util.ServerUtils; @@ -8,9 +10,11 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.UseAction; +import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.*; @@ -18,19 +22,27 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(LivingEntity.class) -public abstract class LivingEntityMixin extends Entity implements PlayerPitchInterface -{ +public abstract class LivingEntityMixin extends Entity implements PlayerPitchInterface { + + @Shadow + public abstract boolean isUsingItem(); + + @Shadow + protected ItemStack activeItemStack; + + @Shadow + public float bodyYaw; + + @Unique + public float legacyAnimations$prevCameraPitch; + + @Unique + public float legacyAnimations$cameraPitch; public LivingEntityMixin(EntityType type, World world) { super(type, world); } - @Shadow public abstract boolean isUsingItem(); - @Shadow protected ItemStack activeItemStack; - @Shadow public float bodyYaw; - @Unique public float legacyAnimations$prevCameraPitch; - @Unique public float legacyAnimations$cameraPitch; - //todo: hypixel rahh @Inject( method = "isBlocking", @@ -39,42 +51,22 @@ public LivingEntityMixin(EntityType type, World world) { ), cancellable = true ) - private void legacyAnimations$fixSync(CallbackInfoReturnable cir) - { - if (!LegacyAnimationsSettings.getInstance().noShieldDelay) - { - return; + private void legacyAnimations$fixSync(CallbackInfoReturnable cir) { + if (LegacyAnimationsSettings.getInstance().noShieldDelay) { + final UseAction action = activeItemStack.getItem().getUseAction(activeItemStack); + cir.setReturnValue(isUsingItem() && action == UseAction.BLOCK); } - - final UseAction action = activeItemStack.getItem().getUseAction(activeItemStack); - - cir.setReturnValue(isUsingItem() && action == UseAction.BLOCK); } - @ModifyConstant( + @WrapOperation( method = "tick", - constant = @Constant( - floatValue = 180.0f - ), - slice = @Slice( - from = @At( - value = "INVOKE", - target = "Lnet/minecraft/util/math/MathHelper;abs(F)F" - ), - to = @At( - value = "FIELD", - opcode = Opcodes.GETFIELD, - target = "Lnet/minecraft/entity/LivingEntity;handSwingProgress:F" - ) + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/util/math/MathHelper;abs(F)F" ) ) - private float legacyAnimations$revertBackwardsWalk(float constant) - { - if (!LegacyAnimationsSettings.getInstance().oldWalking) - { - return constant; - } - return 0.0F; + private float legacyAnimations$revertBackwardsWalk(float value, Operation original) { + return LegacyAnimationsSettings.getInstance().oldWalking ? 0.0F : original.call(value); } @Inject( @@ -86,51 +78,31 @@ public LivingEntityMixin(EntityType type, World world) { ordinal = 0 ) ) - private void legacyAnimations$setPrevCameraPitch(CallbackInfo ci) - { - if (!LegacyAnimationsSettings.getInstance().oldViewBob) - { - return; + private void legacyAnimations$setPrevCameraPitch(CallbackInfo ci) { + if (LegacyAnimationsSettings.getInstance().oldViewBob) { + legacyAnimations$prevCameraPitch = legacyAnimations$cameraPitch; } - legacyAnimations$prevCameraPitch = legacyAnimations$cameraPitch; } -// /** -// * @author Mixces -// * @reason Head movement -// */ -// @Overwrite -// public float turnHead(float bodyRotation, float headRotation) -// { -// final float f = MathHelper.wrapDegrees(bodyRotation - bodyYaw); -// bodyYaw += f * 0.3F; -// float f1 = MathHelper.wrapDegrees(getYaw() - bodyYaw); -// final boolean flag = f1 < -90.0F || f1 >= 90.0F; -// -// if (f1 < -75.0F) -// { -// f1 = -75.0F; -// } -// -// if (f1 >= 75.0F) -// { -// f1 = 75.0F; -// } -// -// bodyYaw = getYaw() - f1; -// -// if (f1 * f1 > 2500.0F) -// { -// bodyYaw += f1 * 0.2F; -// } -// -// if (flag) -// { -// headRotation *= -1.0F; -// } -// -// return headRotation; -// } + //todo: make this not be overwritten + //note for lowercasebtw: this code right here is necessary to make the old backwards walk to look 1:1 with 1.8 + /** + * @author Mixces + * @reason Head movement + */ + @Overwrite + public float turnHead(float bodyRotation, float headRotation) { + final float f = MathHelper.wrapDegrees(bodyRotation - bodyYaw); + bodyYaw += f * 0.3F; + float f1 = MathHelper.wrapDegrees(getYaw() - bodyYaw); + final boolean flag = f1 < -90.0F || f1 >= 90.0F; + if (f1 < -75.0F) f1 = -75.0F; + if (f1 >= 75.0F) f1 = 75.0F; + bodyYaw = getYaw() - f1; + if (f1 * f1 > 2500.0F) bodyYaw += f1 * 0.2F; + if (flag) headRotation *= -1.0F; + return headRotation; + } // // @ModifyExpressionValue( // method = "tickMovement", @@ -157,15 +129,12 @@ public LivingEntityMixin(EntityType type, World world) { // } @Override - public float legacyAnimations$getPrevPlayerPitch() - { + public float legacyAnimations$getPrevPlayerPitch() { return legacyAnimations$prevCameraPitch; } @Override - public float legacyAnimations$getPlayerPitch() - { + public float legacyAnimations$getPlayerPitch() { return 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 98ecd11..8bd11d5 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityRendererMixin.java @@ -16,8 +16,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(LivingEntityRenderer.class) -public abstract class LivingEntityRendererMixin -{ +public abstract class LivingEntityRendererMixin { @ModifyExpressionValue( method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", @@ -26,13 +25,8 @@ public abstract class LivingEntityRendererMixin target = "Lnet/minecraft/entity/LivingEntity;isAlive()Z" ) ) - private boolean legacyAnimations$oldDeathLimbs(boolean original) - { - if (!LegacyAnimationsSettings.getInstance().oldDeath) - { - return true; - } - return original; + private boolean legacyAnimations$oldDeathLimbs(boolean original) { + return LegacyAnimationsSettings.getInstance().oldDeath || original; } //todo: re-write this mess @@ -44,26 +38,16 @@ public abstract class LivingEntityRendererMixin ordinal = 1 ) ) - private void legacyAnimations$modelSneak(T livingEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) - { - if (!LegacyAnimationsSettings.getInstance().oldSneaking) { - return; - } - - final PlayerEntity clientPlayer = MinecraftClient.getInstance().player; - final boolean entityPlayer = livingEntity instanceof PlayerEntity; - - if (!entityPlayer || clientPlayer == null) { - return; + private void legacyAnimations$modelSneak(T livingEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) { + if (LegacyAnimationsSettings.getInstance().oldSneaking) { + final PlayerEntity clientPlayer = MinecraftClient.getInstance().player; + final boolean entityPlayer = livingEntity instanceof PlayerEntity; + if (!entityPlayer || clientPlayer == null) return; + final Camera camera = MinecraftClient.getInstance().gameRenderer.getCamera(); + final boolean player = livingEntity.getName().equals(clientPlayer.getName()); + 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); } - - final Camera camera = MinecraftClient.getInstance().gameRenderer.getCamera(); - final boolean player = livingEntity.getName().equals(clientPlayer.getName()); - - 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 435c61b..0b5efcc 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/MinecraftClientMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/MinecraftClientMixin.java @@ -24,11 +24,22 @@ @Mixin(MinecraftClient.class) public class MinecraftClientMixin { - @Shadow public ClientPlayerEntity player; - @Shadow public int attackCooldown; - @Shadow public Screen currentScreen; - @Shadow @Final public GameOptions options; - @Shadow @Final public Mouse mouse; + @Shadow + public ClientPlayerEntity player; + + @Shadow + public int attackCooldown; + + @Shadow + public Screen currentScreen; + + @Shadow + @Final + public GameOptions options; + + @Shadow + @Final + public Mouse mouse; @ModifyExpressionValue( method = "doItemUse", @@ -37,13 +48,8 @@ public class MinecraftClientMixin { target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;isBreakingBlock()Z" ) ) - private boolean legacyAnimations$interruptBlockBreaking(boolean original) - { - if (!LegacyAnimationsSettings.getInstance().punchDuringUsage) - { - return original; - } - return false; + private boolean legacyAnimations$interruptBlockBreaking(boolean original) { + return !LegacyAnimationsSettings.getInstance().punchDuringUsage && original; } @ModifyExpressionValue( @@ -53,13 +59,8 @@ public class MinecraftClientMixin { target = "Lnet/minecraft/client/network/ClientPlayerEntity;isUsingItem()Z" ) ) - private boolean legacyAnimations$allowWhileUsingItem(boolean original) - { - if (!LegacyAnimationsSettings.getInstance().punchDuringUsage) - { - return original; - } - return false; + private boolean legacyAnimations$allowWhileUsingItem(boolean original) { + return !LegacyAnimationsSettings.getInstance().punchDuringUsage && original; } @WrapOperation( @@ -69,24 +70,17 @@ public class MinecraftClientMixin { target = "Lnet/minecraft/client/network/ClientPlayerEntity;swingHand(Lnet/minecraft/util/Hand;)V" ) ) - private void legacyAnimations$swapForFakeSwing(ClientPlayerEntity instance, Hand hand, Operation original) - { - if (!LegacyAnimationsSettings.getInstance().punchDuringUsage) - { - original.call(instance, hand); - - } - - if (instance.isUsingItem()) - { - legacyAnimations$fakeSwingHand(instance, hand); - } - else - { - original.call(instance, hand); + private void legacyAnimations$swapForFakeSwing(ClientPlayerEntity instance, Hand hand, Operation original) { + if (LegacyAnimationsSettings.getInstance().punchDuringUsage) { + if (instance.isUsingItem()) { + legacyAnimations$fakeSwingHand(instance, hand); + } else { + original.call(instance, hand); + } } } + //todo: hmm @Inject( method = "handleInputEvents", at = @At( @@ -95,17 +89,14 @@ public class MinecraftClientMixin { ordinal = 0 ) ) - private void legacyAnimations$addLeftClickCheck(CallbackInfo ci) - { - if (!ServerUtils.INSTANCE.isValidServer()) - { - return; - } + private void legacyAnimations$addLeftClickCheck(CallbackInfo ci) { +// if (!ServerUtils.INSTANCE.isValidServer()) { +// return; +// } - if (currentScreen != null || !options.attackKey.isPressed() || !mouse.isCursorLocked()) - { +// if (currentScreen != null || !options.attackKey.isPressed() || !mouse.isCursorLocked()) { attackCooldown = 0; - } +// } } //todo: find better way to do this? @@ -116,28 +107,20 @@ public class MinecraftClientMixin { target = "Lnet/minecraft/client/MinecraftClient;handleBlockBreaking(Z)V" ) ) - private boolean legacyAnimations$removeCondition(boolean original) - { - if (!LegacyAnimationsSettings.getInstance().punchDuringUsage) - { - return original; + private boolean legacyAnimations$removeCondition(boolean original) { + if (LegacyAnimationsSettings.getInstance().punchDuringUsage) { + return currentScreen == null && options.attackKey.isPressed() && mouse.isCursorLocked(); } - return currentScreen == null && options.attackKey.isPressed() && mouse.isCursorLocked(); + return original; } @Unique - private static void legacyAnimations$fakeSwingHand(ClientPlayerEntity player, Hand hand) - { + private static void legacyAnimations$fakeSwingHand(ClientPlayerEntity player, Hand hand) { final int handSwingDuration = ((ILivingEntityMixin) player).invokeGetHandSwingDuration(); - - if (player.handSwinging && player.handSwingTicks < handSwingDuration / 2 && player.handSwingTicks >= 0) - { - return; + if (!player.handSwinging || player.handSwingTicks >= handSwingDuration / 2 || player.handSwingTicks < 0) { + player.handSwingTicks = -1; + player.handSwinging = true; + player.preferredHand = hand; } - - player.handSwingTicks = -1; - player.handSwinging = true; - player.preferredHand = hand; } - } \ No newline at end of file diff --git a/src/main/java/com/mixces/legacyanimations/mixin/OtherClientPlayerEntityMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/OtherClientPlayerEntityMixin.java index f7a9926..cc2eccd 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/OtherClientPlayerEntityMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/OtherClientPlayerEntityMixin.java @@ -9,6 +9,7 @@ @Mixin(OtherClientPlayerEntity.class) public class OtherClientPlayerEntityMixin { + //todo: fix this // @ModifyExpressionValue( // method = "tickMovement", // at = @At( diff --git a/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityMixin.java index c75513d..22b097c 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityMixin.java @@ -18,53 +18,40 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(PlayerEntity.class) -public abstract class PlayerEntityMixin extends LivingEntityMixin -{ +public abstract class PlayerEntityMixin extends LivingEntityMixin { public PlayerEntityMixin(EntityType type, World world) { super(type, world); } //todo: hypixel - - @ModifyReturnValue( - method = "getEquippedStack", - at = @At( - value = "RETURN", - ordinal = 1 - ) - ) - private ItemStack legacyAnimations$fakeShield(ItemStack original) - { - if (!ServerUtils.INSTANCE.isValidServer()) - { - return original; - } - - if (!ItemUtils.INSTANCE.isSwordInMainHand(null)) - { - return original; - } - - return new ItemStack(Items.SHIELD); - } - - @Inject( - method = "resetLastAttackedTicks", - at = @At( - value = "HEAD" - ), - cancellable = true - ) - private void legacyAnimations$removeAttackDelay(CallbackInfo ci) - { - if (!ServerUtils.INSTANCE.isValidServer()) - { - return; - } - - ci.cancel(); - } +// @ModifyReturnValue( +// method = "getEquippedStack", +// at = @At( +// value = "RETURN", +// ordinal = 1 +// ) +// ) +// private ItemStack legacyAnimations$fakeShield(ItemStack original) { +// if (ItemUtils.INSTANCE.isSwordInMainHand(null) && ServerUtils.INSTANCE.isValidServer()) { +// return new ItemStack(Items.SHIELD); +// } +// return original; +// } + + //todo: viaversion +// @Inject( +// method = "resetLastAttackedTicks", +// at = @At( +// value = "HEAD" +// ), +// cancellable = true +// ) +// private void legacyAnimations$removeAttackDelay(CallbackInfo ci) { +// if (ServerUtils.INSTANCE.isValidServer()) { +// ci.cancel(); +// } +// } @Inject( method = "tickMovement", @@ -75,45 +62,30 @@ public PlayerEntityMixin(EntityType type, World world) { shift = At.Shift.AFTER ) ) - private void legacyAnimations$getPitchFromVelocity(CallbackInfo ci) - { - if (!LegacyAnimationsSettings.getInstance().oldViewBob) - { - return; - } - - final PlayerEntity entity = (PlayerEntity) (Object) this; - final double velocityY = ((IEntityMixin) entity).invokeGetVelocity().y; - float f1 = (float) (Math.atan(-velocityY * 0.2F) * 15.0F); - - if (((IEntityMixin) entity).invokeIsOnGround() || ((ILivingEntityMixin) entity).invokeGetHealth() <= 0.0F) - { - f1 = 0.0F; + private void legacyAnimations$getPitchFromVelocity(CallbackInfo ci) { + if (LegacyAnimationsSettings.getInstance().oldViewBob) { + final PlayerEntity entity = (PlayerEntity) (Object) this; + final double velocityY = ((IEntityMixin) entity).invokeGetVelocity().y; + float f1 = (float) (Math.atan(-velocityY * 0.2F) * 15.0F); + if (((IEntityMixin) entity).invokeIsOnGround() || ((ILivingEntityMixin) entity).invokeGetHealth() <= 0.0F) { + f1 = 0.0F; + } + legacyAnimations$cameraPitch += (f1 - legacyAnimations$cameraPitch) * 0.8F; } - legacyAnimations$cameraPitch += (f1 - legacyAnimations$cameraPitch) * 0.8F; } + //todo: add toggle for eyeheight && eyeheight under slabs @ModifyReturnValue( method = "getBaseDimensions", at = @At( value = "RETURN" ) ) - private EntityDimensions legacyAnimations$modifyStandingEyeHeight(EntityDimensions original, EntityPose pose) - { - if (!LegacyAnimationsSettings.getInstance().oldSneaking) - { - return original; - } - - //todo: eyeheight under slabs - - if (pose != EntityPose.CROUCHING) { - return original; + private EntityDimensions legacyAnimations$modifyStandingEyeHeight(EntityDimensions original, EntityPose pose) { + if (LegacyAnimationsSettings.getInstance().oldSneaking && pose == EntityPose.CROUCHING) { + return original.withEyeHeight(original.eyeHeight() + 0.27F); } - return original.withEyeHeight(original.eyeHeight() + 0.27F); - + return original; // EntityDimensions.changing(0.6f, 1.5f).withEyeHeight(original.eyeHeight() + 0.27F).withAttachments(EntityAttachments.builder().add(EntityAttachmentType.VEHICLE, VEHICLE_ATTACHMENT_POS)) } - } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityRendererMixin.java index 4436f23..b6411fe 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityRendererMixin.java @@ -1,5 +1,6 @@ package com.mixces.legacyanimations.mixin; +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.mixces.legacyanimations.config.LegacyAnimationsSettings; import com.mixces.legacyanimations.util.ItemUtils; import net.minecraft.client.network.AbstractClientPlayerEntity; @@ -13,8 +14,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(PlayerEntityRenderer.class) -public class PlayerEntityRendererMixin -{ +public class PlayerEntityRendererMixin { //todo: holding sword, eating, and bow fixes needed! @Inject( @@ -25,42 +25,23 @@ public class PlayerEntityRendererMixin cancellable = true ) private static void legacyAnimations$removeShieldArm(AbstractClientPlayerEntity player, Hand hand, CallbackInfoReturnable cir) { - if (!LegacyAnimationsSettings.getInstance().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); + if (LegacyAnimationsSettings.getInstance().hideShields) { + 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( + //todo: creative fly lowercasebtw + @ModifyExpressionValue( 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.getInstance().oldSneaking) - { - return player.isInSneakingPose(); - } - return false; + private boolean legacyAnimations$disableSneakOffset(boolean original) { + return !LegacyAnimationsSettings.getInstance().oldSneaking && original; } - } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/PotionItemMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/PotionItemMixin.java index c902900..7c99cd0 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/PotionItemMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/PotionItemMixin.java @@ -15,21 +15,16 @@ public PotionItemMixin(Item.Settings settings) { super(settings); } + //todo: better way to write this? @Override public boolean hasGlint(ItemStack stack) { - if (LegacyAnimationsSettings.getInstance().oldPotionGlint) - { + if (LegacyAnimationsSettings.getInstance().oldPotionGlint) { final PotionContentsComponent potionContents = stack.get(DataComponentTypes.POTION_CONTENTS); - - if (potionContents == null) - { - return false; + if (potionContents != null) { + return potionContents.hasEffects(); } - - return potionContents.hasEffects(); + return false; } - return super.hasGlint(stack); } - } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/RenderPhaseMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/RenderPhaseMixin.java index ccf6ed4..363f665 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/RenderPhaseMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/RenderPhaseMixin.java @@ -7,13 +7,13 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(RenderPhase.class) -public class RenderPhaseMixin -{ +public class RenderPhaseMixin { - @Inject(method = "setupGlintTexturing", at = @At(value = "HEAD")) - private static void legacyAnimations$injectGlint(float scale, CallbackInfo ci) - { + @Inject( + method = "setupGlintTexturing", + at = @At("HEAD") + ) + private static void legacyAnimations$injectGlint(float scale, CallbackInfo ci) { // System.out.println("glint rendering"); } - } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/ShieldItemMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/ShieldItemMixin.java index ff6940d..ba06388 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/ShieldItemMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/ShieldItemMixin.java @@ -25,19 +25,10 @@ public class ShieldItemMixin { ), cancellable = true ) - public void legacyAnimations$getUseAction(ItemStack stack, CallbackInfoReturnable cir) - { - if (!LegacyAnimationsSettings.getInstance().oldSwordBlock) - { - return; + public void legacyAnimations$getUseAction(ItemStack stack, CallbackInfoReturnable cir) { + if (LegacyAnimationsSettings.getInstance().oldSwordBlock && ItemUtils.INSTANCE.isSwordInMainHand(null)) { + cir.setReturnValue(UseAction.NONE); } - - if (!ItemUtils.INSTANCE.isSwordInMainHand(null)) - { - return; - } - - cir.setReturnValue(UseAction.NONE); } @Inject( @@ -47,19 +38,10 @@ public class ShieldItemMixin { ), cancellable = true ) - public void legacyAnimations$lowerMaxUseTime(ItemStack stack, LivingEntity user, CallbackInfoReturnable cir) - { - if (!LegacyAnimationsSettings.getInstance().oldSwordBlock) - { - return; - } - - if (!ItemUtils.INSTANCE.isSwordInMainHand(null)) - { - return; + public void legacyAnimations$lowerMaxUseTime(ItemStack stack, LivingEntity user, CallbackInfoReturnable cir) { + if (LegacyAnimationsSettings.getInstance().oldSwordBlock && ItemUtils.INSTANCE.isSwordInMainHand(null)) { + cir.setReturnValue(0); } - - cir.setReturnValue(0); } @Inject( @@ -69,19 +51,9 @@ public class ShieldItemMixin { ), cancellable = true ) - public void disableUseWithSword(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable> cir) - { - if (!LegacyAnimationsSettings.getInstance().oldSwordBlock) - { - return; - } - - if (!ItemUtils.INSTANCE.isSwordInMainHand(null)) - { - return; + public void disableUseWithSword(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable> cir) { + if (LegacyAnimationsSettings.getInstance().oldSwordBlock && ItemUtils.INSTANCE.isSwordInMainHand(null)) { + cir.setReturnValue(TypedActionResult.pass(user.getStackInHand(hand))); } - - 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 index 7808c42..deb6e31 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/SwordItemMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/SwordItemMixin.java @@ -12,59 +12,35 @@ import org.spongepowered.asm.mixin.Mixin; @Mixin(SwordItem.class) -public class SwordItemMixin extends Item -{ +public class SwordItemMixin extends Item { - public SwordItemMixin(Settings settings) - { + public SwordItemMixin(Settings settings) { super(settings); } @Override - public UseAction getUseAction(ItemStack stack) - { - if (!LegacyAnimationsSettings.getInstance().oldSwordBlock) - { - return UseAction.NONE; - } - - if (ItemUtils.INSTANCE.isShieldInOffHand(null)) - { + public UseAction getUseAction(ItemStack stack) { + if (LegacyAnimationsSettings.getInstance().oldSwordBlock && ItemUtils.INSTANCE.isShieldInOffHand(null)) { return UseAction.BLOCK; } return UseAction.NONE; } @Override - public int getMaxUseTime(ItemStack stack, LivingEntity user) - { - if (!LegacyAnimationsSettings.getInstance().oldSwordBlock) - { - return 0; - } - - if (ItemUtils.INSTANCE.isShieldInOffHand(null)) - { + public int getMaxUseTime(ItemStack stack, LivingEntity user) { + if (LegacyAnimationsSettings.getInstance().oldSwordBlock && ItemUtils.INSTANCE.isShieldInOffHand(null)) { return 72000; } return 0; } @Override - public TypedActionResult use(World world, PlayerEntity user, Hand hand) - { - if (!LegacyAnimationsSettings.getInstance().oldSwordBlock) - { - return TypedActionResult.pass(user.getStackInHand(hand)); - } - - if (ItemUtils.INSTANCE.isShieldInOffHand(null)) - { + public TypedActionResult use(World world, PlayerEntity user, Hand hand) { + if (LegacyAnimationsSettings.getInstance().oldSwordBlock && ItemUtils.INSTANCE.isShieldInOffHand(null)) { 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/mixin/VertexConsumerMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/VertexConsumerMixin.java index 07398f7..6fd5dba 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/VertexConsumerMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/VertexConsumerMixin.java @@ -15,7 +15,7 @@ @Mixin(VertexConsumer.class) public interface VertexConsumerMixin { -// //todo: maybe there's a better way? + //todo: maybe there's a better way? // @ModifyArgs( // method = "quad(Lnet/minecraft/client/util/math/MatrixStack$Entry;Lnet/minecraft/client/render/model/BakedQuad;[FFFFF[IIZ)V", // at = @At( diff --git a/src/main/java/com/mixces/legacyanimations/util/HandUtils.java b/src/main/java/com/mixces/legacyanimations/util/HandUtils.java index b7a39ea..187c518 100644 --- a/src/main/java/com/mixces/legacyanimations/util/HandUtils.java +++ b/src/main/java/com/mixces/legacyanimations/util/HandUtils.java @@ -7,8 +7,7 @@ import net.minecraft.util.Hand; //todo: simplify -public class HandUtils -{ +public class HandUtils { public static HandUtils INSTANCE = new HandUtils(); @@ -19,15 +18,13 @@ public class HandUtils * @param dispatcher Used to help determine the perspective of the player! * @return Returns the multiplier for which we can use to achieve perfect symmetry between hands! */ - public int handMultiplier(ClientPlayerEntity player, EntityRenderDispatcher dispatcher) - { + public int handMultiplier(ClientPlayerEntity player, EntityRenderDispatcher dispatcher) { final Hand hand = MoreObjects.firstNonNull(player.preferredHand, Hand.MAIN_HAND); final boolean bl = hand == Hand.MAIN_HAND; final Arm arm = bl ? player.getMainArm() : player.getMainArm().getOpposite(); final boolean bl2 = arm == Arm.RIGHT; final boolean isFirstPerson = dispatcher.gameOptions.getPerspective().isFirstPerson(); final int perspectiveMultiplier = isFirstPerson ? 1 : -1; - return bl2 ? perspectiveMultiplier : -perspectiveMultiplier; } @@ -38,8 +35,7 @@ public int handMultiplier(ClientPlayerEntity player, EntityRenderDispatcher disp * @param dispatcher Used to help determine the perspective of the player! * @return Returns whether the player is left-handed or not! */ - public boolean isLeftHand(ClientPlayerEntity player, EntityRenderDispatcher dispatcher) - { + public boolean isLeftHand(ClientPlayerEntity player, EntityRenderDispatcher dispatcher) { return handMultiplier(player, dispatcher) == -1; } @@ -50,8 +46,7 @@ public boolean isLeftHand(ClientPlayerEntity player, EntityRenderDispatcher disp * @param dispatcher Used to help determine the perspective of the player! * @return Returns whether the player is right-handed or not! */ - public boolean isRightHand(ClientPlayerEntity player, EntityRenderDispatcher dispatcher) - { + public boolean isRightHand(ClientPlayerEntity player, EntityRenderDispatcher dispatcher) { return handMultiplier(player, dispatcher) == 1; } diff --git a/src/main/java/com/mixces/legacyanimations/util/ItemBlacklist.java b/src/main/java/com/mixces/legacyanimations/util/ItemBlacklist.java new file mode 100644 index 0000000..01c03d2 --- /dev/null +++ b/src/main/java/com/mixces/legacyanimations/util/ItemBlacklist.java @@ -0,0 +1,23 @@ +package com.mixces.legacyanimations.util; + +import net.minecraft.block.SkullBlock; +import net.minecraft.item.BannerItem; +import net.minecraft.item.ItemStack; + +import java.util.HashMap; +import java.util.Map; + +public class ItemBlacklist { + + // Map to store blacklisted items + // Some items are not quite compatible with the generic item position (crossbows, banners, skull items, etc) + private static final Map, Boolean> blacklistedItems = new HashMap<>() {{ + put(SkullBlock.class, true); + put(BannerItem.class, true); + }}; + + // Method to check if an item is blacklisted + public static boolean isPresent(ItemStack stack) { + return blacklistedItems.containsKey(stack.getItem().getClass()); + } +} \ No newline at end of file diff --git a/src/main/java/com/mixces/legacyanimations/util/ItemUtils.java b/src/main/java/com/mixces/legacyanimations/util/ItemUtils.java index 7213efa..b2fc829 100644 --- a/src/main/java/com/mixces/legacyanimations/util/ItemUtils.java +++ b/src/main/java/com/mixces/legacyanimations/util/ItemUtils.java @@ -8,13 +8,12 @@ import net.minecraft.item.*; import net.minecraft.util.UseAction; -public class ItemUtils -{ +public class ItemUtils { public static ItemUtils INSTANCE = new ItemUtils(); //todo: move this - private BakedModel model; + public BakedModel model; /** * In order to smartly hide the shield, we need to check which items are capable of rendering the shield useless. @@ -22,28 +21,13 @@ public class ItemUtils * * @return Returns whether the main hand item can be used, and if so, it is a valid item. */ - public boolean isValidItem(ItemStack heldStack, UseAction action) - { - if (!ItemUtils.INSTANCE.isValidHeldItem()) - { - return false; - } - - final boolean isEating = action == UseAction.EAT; - final FoodComponent foodItem = heldStack.get(DataComponentTypes.FOOD); - - if (foodItem == null) - { - return false; - } - - if (isEating && foodItem.canAlwaysEat()) - { - return true; - } - else if (!isEating) - { - return action != UseAction.NONE; + public boolean isValidItem(ItemStack heldStack, UseAction action) { + if (ItemUtils.INSTANCE.isValidHeldItem()) { + final boolean isEating = action == UseAction.EAT; + final FoodComponent foodItem = heldStack.get(DataComponentTypes.FOOD); + if (foodItem == null) return false; + if (isEating && foodItem.canAlwaysEat()) return true; + else if (!isEating) return action != UseAction.NONE; } return false; } @@ -53,81 +37,64 @@ else if (!isEating) * * @return Returns whether the main hand item is a sword, a fishing rod, or a fishing rod variant. */ - public boolean isValidHeldItem() - { - return isSwordInMainHand(null) || shouldRotateAroundWhenRendering(null,false); + public boolean isValidHeldItem() { + return isSwordInMainHand(null) || shouldRotateAroundWhenRendering(null, false); } /** * Are you a sword!? * - * @param stack We need the currently held item! - * @return Returns whether the main hand item is a sword or not. + * @param stack We need the currently held item! + * @return Returns whether the main hand item is a sword or not. */ public boolean isSwordInMainHand(ItemStack stack) { final ClientPlayerEntity player = MinecraftClient.getInstance().player; - - if (player == null) - { - return false; - } - + if (player == null) return false; final Item item = stack == null ? player.getMainHandStack().getItem() : stack.getItem(); - - if (item == null) - { - return false; - } - + if (item == null) return false; return item instanceof SwordItem; } /** * This name of this method should be a throwback! * - * @param stack We need the currently held item! - * @param allowVariant If carrot on a stick or warped fungus on a stick should be included. - * @return Returns whether the main hand item is a fishing rod or a variant of one. + * @param stack We need the currently held item! + * @param allowVariant If carrot on a stick or warped fungus on a stick should be included. + * @return Returns whether the main hand item is a fishing rod or a variant of one. */ public boolean shouldRotateAroundWhenRendering(ItemStack stack, boolean allowVariant) { final ClientPlayerEntity player = MinecraftClient.getInstance().player; - - if (player == null) - { - return false; - } - + if (player == null) return false; final Item item = stack == null ? player.getMainHandStack().getItem() : stack.getItem(); - - if (item == null) - { - return false; - } - + if (item == null) return false; return item instanceof FishingRodItem || (item instanceof OnAStickItem && allowVariant); } + /** + * This name of this method should be a throwback! + * + * @param stack We need the currently held item! + * @return Returns whether the main hand item is a rod, tool, trident or item along those lines. + */ + public boolean isFull3d(ItemStack stack) { + final ClientPlayerEntity player = MinecraftClient.getInstance().player; + if (player == null) return false; + final Item item = stack == null ? player.getMainHandStack().getItem() : stack.getItem(); + if (item == null) return false; + return shouldRotateAroundWhenRendering(stack, true) || item instanceof ToolItem || item instanceof TridentItem; + } + /** * Shields?! * - * @param stack We need the currently held item! - * @return Returns whether the offhand item is a shield or not. + * @param stack We need the currently held item! + * @return Returns whether the offhand item is a shield or not. */ public boolean isShieldInOffHand(ItemStack stack) { final ClientPlayerEntity player = MinecraftClient.getInstance().player; - - if (player == null) - { - return false; - } - + if (player == null) return false; final Item item = stack == null ? player.getOffHandStack().getItem() : stack.getItem(); - - if (item == null) - { - return false; - } - + if (item == null) return false; return item instanceof ShieldItem; } @@ -135,15 +102,9 @@ public boolean isShieldInOffHand(ItemStack stack) { * Hypixel parity. * * @return If the player is on Hypixel, let the blocking animation play when right-clicking rather than while the item is in usage. - * This visually bypasses Hypixel's buggy shield. + * This visually bypasses Hypixel's buggy shield. */ - public boolean isUsing(ClientPlayerEntity player) - { - if (ServerUtils.INSTANCE.isValidServer()) - { - return MinecraftClient.getInstance().options.useKey.isPressed(); - } - return player.isUsingItem(); + public boolean isUsing(ClientPlayerEntity player) { + return ServerUtils.INSTANCE.isValidServer() ? MinecraftClient.getInstance().options.useKey.isPressed() : player.isUsingItem(); } - } diff --git a/src/main/java/com/mixces/legacyanimations/util/MatrixUtil.java b/src/main/java/com/mixces/legacyanimations/util/MatrixUtil.java index ad1407f..7c43634 100644 --- a/src/main/java/com/mixces/legacyanimations/util/MatrixUtil.java +++ b/src/main/java/com/mixces/legacyanimations/util/MatrixUtil.java @@ -3,6 +3,9 @@ import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.math.RotationAxis; +/** + * This was made purely for fun lol :p + */ public class MatrixUtil { private final MatrixStack stack; diff --git a/src/main/java/com/mixces/legacyanimations/util/ServerUtils.java b/src/main/java/com/mixces/legacyanimations/util/ServerUtils.java index c6766bb..978216b 100644 --- a/src/main/java/com/mixces/legacyanimations/util/ServerUtils.java +++ b/src/main/java/com/mixces/legacyanimations/util/ServerUtils.java @@ -3,16 +3,11 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ServerInfo; -public class ServerUtils -{ - +public class ServerUtils { public static ServerUtils INSTANCE = new ServerUtils(); - private final ServerInfo server = MinecraftClient.getInstance().getCurrentServerEntry(); - public boolean isValidServer() - { + public boolean isValidServer() { return server != null && (server.address.endsWith("hypixel.net") || server.address.endsWith("bedwarspractice.club")); } - } diff --git a/src/main/java/com/mixces/legacyanimations/util/TransformationModeUtils.java b/src/main/java/com/mixces/legacyanimations/util/TransformationModeUtils.java index 3b2ea21..b675c98 100644 --- a/src/main/java/com/mixces/legacyanimations/util/TransformationModeUtils.java +++ b/src/main/java/com/mixces/legacyanimations/util/TransformationModeUtils.java @@ -5,10 +5,9 @@ import java.util.EnumSet; -public class TransformationModeUtils -{ +public class TransformationModeUtils { - private static ModelTransformationMode transformationMode; + public static ModelTransformationMode transformationMode; private static final EnumSet cameraTypes = EnumSet.of( @@ -16,27 +15,22 @@ public class TransformationModeUtils ModelTransformationMode.FIXED ); - public static boolean isValidPerspective(ModelTransformationMode mode) - { + public static boolean isValidPerspective(ModelTransformationMode mode) { return mode == ModelTransformationMode.FIRST_PERSON_LEFT_HAND || mode == ModelTransformationMode.FIRST_PERSON_RIGHT_HAND || mode == ModelTransformationMode.THIRD_PERSON_LEFT_HAND || mode == ModelTransformationMode.THIRD_PERSON_RIGHT_HAND; } - public static boolean shouldBeSprite() - { + public static boolean shouldBeSprite() { return shouldNotHaveGlint() || isRenderingInGUI(); } - public static boolean isRenderingInGUI() - { - return getTransformationMode() == ModelTransformationMode.GUI; + public static boolean isRenderingInGUI() { + return transformationMode == ModelTransformationMode.GUI; } - public static boolean shouldNotHaveGlint() - { - return cameraTypes.contains(getTransformationMode()); + public static boolean shouldNotHaveGlint() { + return cameraTypes.contains(transformationMode); } - } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index db2f549..701fd2e 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -4,9 +4,9 @@ "version": "${version}", "name": "Legacy Animations", "description": "Brings back the legacy animations and visuals from versions before 1.9!", - "authors": - [ + "authors": [ "Mixces", + "lowercasebtw", "Wyvest", "Microcontrollers", "Adrenix (NostalgicTweaks)", @@ -14,8 +14,7 @@ "redth", "Cecer (CecerMCProjects)" ], - "contact": - { + "contact": { "homepage": "https://github.com/Mixces", "sources": "https://github.com/Mixces/Legacy-Animations", "issues": "https://github.com/Mixces/Legacy-Animations/issues" @@ -23,35 +22,27 @@ "license": "LGPLV3", "icon": "assets/legacyanimations/icon.png", "environment": "*", - "entrypoints": - { - "main": - [ + "entrypoints": { + "main": [ "com.mixces.legacyanimations.LegacyAnimations" ], - "modmenu": - [ + "modmenu": [ "com.mixces.legacyanimations.config.ModMenuIntegration" ] }, - "mixins": - [ + "mixins": [ "legacyanimations.mixins.json" ], - "depends": - { + "depends": { "fabricloader": ">=0.15.11", "minecraft": "~1.21", "java": ">=21", "fabric-api": "*", "yet_another_config_lib_v3": "*" }, - "custom": - { - "modmenu": - { - "links": - { + "custom": { + "modmenu": { + "links": { "modmenu.discord": "https://discord.gg/polyfrost" }, "update_checker": true diff --git a/src/main/resources/legacyanimations.accesswidener b/src/main/resources/legacyanimations.accesswidener index cde06d8..f0a90a2 100644 --- a/src/main/resources/legacyanimations.accesswidener +++ b/src/main/resources/legacyanimations.accesswidener @@ -2,3 +2,4 @@ accessWidener v2 named accessible class net/minecraft/client/render/model/BasicBakedModel$Builder accessible class net/minecraft/client/gui/hud/InGameHud$HeartType +accessible field net/minecraft/client/util/math/MatrixStack$Entry canSkipNormalization Z diff --git a/src/main/resources/legacyanimations.mixins.json b/src/main/resources/legacyanimations.mixins.json index 25e8e3a..89c58cb 100644 --- a/src/main/resources/legacyanimations.mixins.json +++ b/src/main/resources/legacyanimations.mixins.json @@ -7,7 +7,7 @@ "BipedEntityModelMixin", "BuiltinModelItemRendererMixin", "CameraMixin", - "ClientPlayerEntityMixin", + "CapeFeatureRendererMixin", "ClientPlayerInteractionManagerMixin", "DebugHudMixin", "EntityMixin",