From 96f25541fdcc00956681e13396bb23f2e0d7679c Mon Sep 17 00:00:00 2001 From: Mixces Date: Tue, 23 Jul 2024 21:40:36 -0500 Subject: [PATCH] change some config stuff + new features (i swear it existed in this mod before) --- .../config/LegacyAnimationsSettings.java | 35 ++++++++-- .../mixin/ArmorFeatureRendererMixin.java | 6 +- .../mixin/BipedEntityModelMixin.java | 10 +-- .../mixin/BuiltinModelItemRendererMixin.java | 2 +- .../legacyanimations/mixin/CameraMixin.java | 2 +- .../mixin/ClientPlayerEntityMixin.java | 45 +++++++++++++ .../ClientPlayerInteractionManagerMixin.java | 20 +++++- .../legacyanimations/mixin/DebugHudMixin.java | 4 +- .../legacyanimations/mixin/EntityMixin.java | 12 +++- .../FishingBobberEntityRendererMixin.java | 2 +- .../mixin/FlyingItemEntityRendererMixin.java | 6 +- .../mixin/GameRendererMixin.java | 2 +- .../mixin/HeldItemFeatureRendererMixin.java | 2 +- .../mixin/HeldItemRendererMixin.java | 16 ++--- .../mixin/InGameHudMixin.java | 7 +- .../mixin/ItemEntityRendererMixin.java | 4 +- .../mixin/ItemRendererMixin.java | 4 +- .../mixin/LivingEntityMixin.java | 4 +- .../mixin/LivingEntityRendererMixin.java | 4 +- .../mixin/MinecraftClientMixin.java | 8 +-- .../mixin/PlayerEntityMixin.java | 64 +++++++++---------- .../mixin/PlayerEntityRendererMixin.java | 4 +- .../mixin/ShieldItemMixin.java | 6 +- .../mixin/SwordItemMixin.java | 6 +- .../mixin/VertexConsumerMixin.java | 2 +- .../resources/legacyanimations.mixins.json | 1 + 26 files changed, 186 insertions(+), 92 deletions(-) create mode 100644 src/main/java/com/mixces/legacyanimations/mixin/ClientPlayerEntityMixin.java diff --git a/src/main/java/com/mixces/legacyanimations/config/LegacyAnimationsSettings.java b/src/main/java/com/mixces/legacyanimations/config/LegacyAnimationsSettings.java index 540329b..855982e 100644 --- a/src/main/java/com/mixces/legacyanimations/config/LegacyAnimationsSettings.java +++ b/src/main/java/com/mixces/legacyanimations/config/LegacyAnimationsSettings.java @@ -16,12 +16,6 @@ public class LegacyAnimationsSettings { //todo ugly as hell - public static final ConfigClassHandler CONFIG = ConfigClassHandler.createBuilder(LegacyAnimationsSettings.class) - .serializer(config -> GsonConfigSerializerBuilder.create(config) - .setPath(FabricLoader.getInstance().getConfigDir().resolve("legacyanimations.json")) - .build()) - .build(); - @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 @@ -29,6 +23,7 @@ public class LegacyAnimationsSettings { @SerialEntry public boolean hideShields = true; @SerialEntry public boolean hideShieldHotbar = true; @SerialEntry public boolean noCooldown = true; + @SerialEntry public boolean oldMovement = true; @SerialEntry public boolean oldSneaking = true; @SerialEntry public boolean oldWalking = true; @SerialEntry public boolean oldDeath = true; @@ -40,6 +35,7 @@ public class LegacyAnimationsSettings { @SerialEntry public boolean oldViewBob = true; @SerialEntry public boolean fastItems = true; @SerialEntry public boolean armorTint = true; + @SerialEntry public boolean oldBreakProgress = true; @SuppressWarnings("deprecation") @@ -165,6 +161,12 @@ 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"))) @@ -183,9 +185,30 @@ public static Screen configScreen(Screen parent) { .binding(defaults.fastItems, () -> config.fastItems, newVal -> config.fastItems = newVal) .controller(TickBoxControllerBuilder::create) .build()) + .option(Option.createBuilder(boolean.class) + .name(Text.literal("Old Block Break Progress")) + .description(OptionDescription.of(Text.of("Delays the block breaking animation."))) + .binding(defaults.oldBreakProgress, () -> config.oldBreakProgress, newVal -> config.oldBreakProgress = newVal) + .controller(TickBoxControllerBuilder::create) + .build()) .build()) )).generateScreen(parent); } + public static final ConfigClassHandler CONFIG = ConfigClassHandler + .createBuilder(LegacyAnimationsSettings.class) + .serializer(config -> + GsonConfigSerializerBuilder.create(config) + .setPath(FabricLoader.getInstance() + .getConfigDir() + .resolve("legacyanimations.json")) + .build()) + .build(); + + public static LegacyAnimationsSettings getInstance() + { + return CONFIG.instance(); + } + } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/ArmorFeatureRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/ArmorFeatureRendererMixin.java index eadb901..308d50a 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/ArmorFeatureRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/ArmorFeatureRendererMixin.java @@ -48,7 +48,7 @@ public abstract class ArmorFeatureRendererMixin original, @Local(ordinal = 0, argsOnly = true) VertexConsumerProvider vertexConsumers) { - if (!LegacyAnimationsSettings.CONFIG.instance().armorTint) + if (!LegacyAnimationsSettings.getInstance().armorTint) { return original.call(instance, consumer); } @@ -88,7 +88,7 @@ public abstract class ArmorFeatureRendererMixin ) 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.getInstance().oldSneaking) { return; } @@ -171,7 +171,7 @@ 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.getInstance().oldSneaking) { return; } @@ -203,7 +203,7 @@ public abstract class BipedEntityModelMixin ) public boolean legacyAnimations$removeConflictingFields1(ModelPart instance, float value) { - return !LegacyAnimationsSettings.CONFIG.instance().oldSneaking; + return !LegacyAnimationsSettings.getInstance().oldSneaking; } @WrapWithCondition( @@ -230,7 +230,7 @@ public abstract class BipedEntityModelMixin ) public boolean legacyAnimations$removeConflictingFields2(ModelPart instance, float value) { - return !LegacyAnimationsSettings.CONFIG.instance().oldSneaking; + return !LegacyAnimationsSettings.getInstance().oldSneaking; } @Inject( @@ -241,7 +241,7 @@ public abstract class BipedEntityModelMixin ) public void legacyAnimations$oldBlockingArm(ModelPart arm, boolean rightArm, CallbackInfo ci) { - if (!LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock) + if (!LegacyAnimationsSettings.getInstance().oldSwordBlock) { return; } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/BuiltinModelItemRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/BuiltinModelItemRendererMixin.java index 49b3c7b..34fab93 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/BuiltinModelItemRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/BuiltinModelItemRendererMixin.java @@ -27,7 +27,7 @@ public abstract class BuiltinModelItemRendererMixin ) private boolean legacyAnimations$disableShieldRendering(boolean original, ItemStack stack, ModelTransformationMode mode, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) { - if (!LegacyAnimationsSettings.CONFIG.instance().hideShields || !TransformationModeUtils.isValidPerspective(mode)) + if (!LegacyAnimationsSettings.getInstance().hideShields || !TransformationModeUtils.isValidPerspective(mode)) { return original; } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/CameraMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/CameraMixin.java index 7820c1d..057df91 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/CameraMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/CameraMixin.java @@ -27,7 +27,7 @@ public abstract class CameraMixin ) private void legacyAnimations$addOldSneakCalculation(Camera instance, float value, Operation original) { - if (!LegacyAnimationsSettings.CONFIG.instance().oldSneaking) + if (!LegacyAnimationsSettings.getInstance().oldSneaking) { original.call(instance, value); } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/ClientPlayerEntityMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/ClientPlayerEntityMixin.java new file mode 100644 index 0000000..05e972c --- /dev/null +++ b/src/main/java/com/mixces/legacyanimations/mixin/ClientPlayerEntityMixin.java @@ -0,0 +1,45 @@ +package com.mixces.legacyanimations.mixin; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.mixces.legacyanimations.config.LegacyAnimationsSettings; +import net.minecraft.client.input.Input; +import net.minecraft.client.network.ClientPlayerEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(ClientPlayerEntity.class) +public class ClientPlayerEntityMixin { + + @WrapOperation( + method = "tickMovement", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/input/Input;hasForwardMovement()Z" + ) + ) + public boolean legacyAnimations$revertMovement2(Input instance, Operation original) { + if (!LegacyAnimationsSettings.getInstance().oldMovement) + { + return original.call(instance); + } + return instance.movementForward >= 0.8; + } + + @ModifyExpressionValue( + method = "isWalking", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/network/ClientPlayerEntity;isSubmergedInWater()Z" + ) + ) + public boolean legacyAnimations$revertMovement3(boolean original) { + if (!LegacyAnimationsSettings.getInstance().oldMovement) + { + return original; + } + return false; + } + +} diff --git a/src/main/java/com/mixces/legacyanimations/mixin/ClientPlayerInteractionManagerMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/ClientPlayerInteractionManagerMixin.java index 5552295..9c4309f 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/ClientPlayerInteractionManagerMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/ClientPlayerInteractionManagerMixin.java @@ -32,7 +32,7 @@ public abstract class ClientPlayerInteractionManagerMixin ) public boolean legacyAnimations$fixBreakingBlockCheck(boolean original) { - if (!LegacyAnimationsSettings.CONFIG.instance().punchDuringUsage) + if (!LegacyAnimationsSettings.getInstance().punchDuringUsage) { return original; } @@ -49,7 +49,7 @@ public abstract class ClientPlayerInteractionManagerMixin cancellable = true) public void legacyAnimations$cancelIllegalDestroy(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { - if (!LegacyAnimationsSettings.CONFIG.instance().punchDuringUsage) + if (!LegacyAnimationsSettings.getInstance().punchDuringUsage) { return; } @@ -72,4 +72,20 @@ public abstract class ClientPlayerInteractionManagerMixin } } + @Inject( + method = "getBlockBreakingProgress", + at = @At( + value = "HEAD" + ), + cancellable = true + ) + private void legacyAnimations$oldMiningProgress(CallbackInfoReturnable cir) + { + if (!LegacyAnimationsSettings.getInstance().oldBreakProgress) + { + return; + } + cir.setReturnValue((int)(this.currentBreakingProgress * 10.0f) - 1); + } + } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/DebugHudMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/DebugHudMixin.java index c4b3be8..d02f47c 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/DebugHudMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/DebugHudMixin.java @@ -21,7 +21,7 @@ public abstract class DebugHudMixin ) private boolean legacyAnimations$removeDebugBackground(DrawContext instance, int x1, int y1, int x2, int y2, int color) { - return !LegacyAnimationsSettings.CONFIG.instance().oldDebug; + return !LegacyAnimationsSettings.getInstance().oldDebug; } @ModifyArg( @@ -34,7 +34,7 @@ public abstract class DebugHudMixin ) private boolean legacyAnimations$addDebugShadow(boolean shadow) { - return LegacyAnimationsSettings.CONFIG.instance().oldDebug; + return LegacyAnimationsSettings.getInstance().oldDebug; } } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/EntityMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/EntityMixin.java index 751915b..f05c64b 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/EntityMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/EntityMixin.java @@ -8,6 +8,7 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -32,7 +33,7 @@ public abstract class EntityMixin implements EntityInterface ) public EntityPose legacyAnimations$revertSwimPose(EntityPose original) { - if (!LegacyAnimationsSettings.CONFIG.instance().oldSwim) + if (!LegacyAnimationsSettings.getInstance().oldSwim) { return original; } @@ -55,4 +56,13 @@ public abstract class EntityMixin implements EntityInterface return new Vec3d(d, e, f); } +// /** +// * @author Mixces +// * @reason Old hitbox margin +// */ +// @Overwrite +// public float getTargetingMargin() { +// return 0.1f; +// } + } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/FishingBobberEntityRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/FishingBobberEntityRendererMixin.java index a0f27f0..c226b25 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/FishingBobberEntityRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/FishingBobberEntityRendererMixin.java @@ -42,7 +42,7 @@ protected FishingBobberEntityRendererMixin(EntityRendererFactory.Context ctx) ) public void legacyAnimations$shiftRodBob(FishingBobberEntity fishingBobberEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) { - if (!LegacyAnimationsSettings.CONFIG.instance().oldProjectiles) + if (!LegacyAnimationsSettings.getInstance().oldProjectiles) { return; } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/FlyingItemEntityRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/FlyingItemEntityRendererMixin.java index f10ee7f..f8ba996 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/FlyingItemEntityRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/FlyingItemEntityRendererMixin.java @@ -39,7 +39,7 @@ protected FlyingItemEntityRendererMixin(EntityRendererFactory.Context ctx) ) public int legacyAnimations$disableDelay(Entity instance, Operation original) { - if (!LegacyAnimationsSettings.CONFIG.instance().oldProjectiles) + if (!LegacyAnimationsSettings.getInstance().oldProjectiles) { return original.call(instance); } @@ -55,7 +55,7 @@ protected FlyingItemEntityRendererMixin(EntityRendererFactory.Context ctx) ) public void legacyAnimations$shiftProjectile(T entity, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { - if (!LegacyAnimationsSettings.CONFIG.instance().oldProjectiles) + if (!LegacyAnimationsSettings.getInstance().oldProjectiles) { return; } @@ -75,7 +75,7 @@ protected FlyingItemEntityRendererMixin(EntityRendererFactory.Context ctx) ) private float legacyAnimations$rotateProjectileAccordingly(float deg) { - if (LegacyAnimationsSettings.CONFIG.instance().oldProjectiles) + if (LegacyAnimationsSettings.getInstance().oldProjectiles) { return deg; } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/GameRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/GameRendererMixin.java index d971756..9470e90 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/GameRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/GameRendererMixin.java @@ -28,7 +28,7 @@ public class GameRendererMixin ) private void legacyAnimations$addOldPitchRotation(MatrixStack matrices, float tickDelta, CallbackInfo ci, @Local(ordinal = 0) PlayerEntity playerEntity) { - if (!LegacyAnimationsSettings.CONFIG.instance().oldViewBob) + if (!LegacyAnimationsSettings.getInstance().oldViewBob) { return; } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/HeldItemFeatureRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/HeldItemFeatureRendererMixin.java index 52a207f..2c16b2a 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/HeldItemFeatureRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/HeldItemFeatureRendererMixin.java @@ -29,7 +29,7 @@ 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.CONFIG.instance().oldSwordBlock) + if (!LegacyAnimationsSettings.getInstance().oldSwordBlock) { return; } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/HeldItemRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/HeldItemRendererMixin.java index 67df065..a1ea48a 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/HeldItemRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/HeldItemRendererMixin.java @@ -44,7 +44,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.CONFIG.instance().itemPositions) + if (!LegacyAnimationsSettings.getInstance().itemPositions) { return; } @@ -65,7 +65,7 @@ public abstract class HeldItemRendererMixin ) ) private void legacyAnimations$postBowTransform(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { - if (!LegacyAnimationsSettings.CONFIG.instance().itemPositions) + if (!LegacyAnimationsSettings.getInstance().itemPositions) { return; } @@ -96,7 +96,7 @@ public abstract class HeldItemRendererMixin ) private void legacyAnimations$addSwingOffset(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci, @Local Arm arm) { - if (!LegacyAnimationsSettings.CONFIG.instance().punchDuringUsage) + if (!LegacyAnimationsSettings.getInstance().punchDuringUsage) { return; } @@ -115,7 +115,7 @@ public abstract class HeldItemRendererMixin ) private void legacyAnimations$addBlockTranslation(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { - if (!LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock) + if (!LegacyAnimationsSettings.getInstance().oldSwordBlock) { return; } @@ -143,7 +143,7 @@ public abstract class HeldItemRendererMixin ) private void legacyAnimations$oldItemPositions(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { - if (!LegacyAnimationsSettings.CONFIG.instance().itemPositions) + if (!LegacyAnimationsSettings.getInstance().itemPositions) { return; } @@ -171,7 +171,7 @@ public abstract class HeldItemRendererMixin ) public float legacyAnimations$removeCoolDownSpeed(float original) { - if (!LegacyAnimationsSettings.CONFIG.instance().noCooldown) { + if (!LegacyAnimationsSettings.getInstance().noCooldown) { return original; } return 1.0f; @@ -186,7 +186,7 @@ public abstract class HeldItemRendererMixin ) private void legacyAnimations$removeStartDelay(Hand hand, CallbackInfo ci) { - if (!LegacyAnimationsSettings.CONFIG.instance().noCooldown) { + if (!LegacyAnimationsSettings.getInstance().noCooldown) { return; } @@ -206,7 +206,7 @@ public abstract class HeldItemRendererMixin // ) // private float legacyAnimations$conditionallyUpdateShield(float value, @Local(ordinal = 0) ItemStack itemStack) // { -// if (LegacyAnimationsSettings.CONFIG.instance().hideShields && ItemUtils.INSTANCE.isShieldInOffHand(offHand)) +// if (LegacyAnimationsSettings.getInstance().hideShields && ItemUtils.INSTANCE.isShieldInOffHand(offHand)) // { // return (mainHand == itemStack ? 1.0F : 0.0F) - equipProgressOffHand; // } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/InGameHudMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/InGameHudMixin.java index ba3fdd2..352a5a3 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/InGameHudMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/InGameHudMixin.java @@ -15,7 +15,6 @@ import net.minecraft.util.UseAction; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; @Mixin(InGameHud.class) public abstract class InGameHudMixin @@ -29,7 +28,7 @@ public abstract class InGameHudMixin // if (player != null) { // ItemStack mainStack = player.getMainHandStack(); // UseAction action = mainStack.getUseAction(); -// if (LegacyAnimationsSettings.CONFIG.instance().hideShieldHotbar && ItemUtils.INSTANCE.isValidItem(mainStack, action)) +// if (LegacyAnimationsSettings.getInstance().hideShieldHotbar && ItemUtils.INSTANCE.isValidItem(mainStack, action)) // { // return original.call(itemStack) || itemStack.isOf(Items.SHIELD); // } @@ -47,7 +46,7 @@ public abstract class InGameHudMixin ) private boolean legacyAnimations$cancelFlash(InGameHud instance, DrawContext context, InGameHud.HeartType type, int x, int y, boolean hardcore, boolean blinking, boolean half) { - return !LegacyAnimationsSettings.CONFIG.instance().oldHearts; + return !LegacyAnimationsSettings.getInstance().oldHearts; } @ModifyExpressionValue( @@ -59,7 +58,7 @@ public abstract class InGameHudMixin ) private boolean legacyAnimations$removePerspectiveCheck(boolean original) { - if (!LegacyAnimationsSettings.CONFIG.instance().perspectiveCrosshair) + if (!LegacyAnimationsSettings.getInstance().perspectiveCrosshair) { return original; } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/ItemEntityRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/ItemEntityRendererMixin.java index d5d4d9f..659b6a7 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/ItemEntityRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/ItemEntityRendererMixin.java @@ -36,7 +36,7 @@ protected ItemEntityRendererMixin(EntityRendererFactory.Context ctx) ) private Quaternionf legacyAnimations$facePlayer(Quaternionf quaternion, @Local(ordinal = 0) boolean bl) { - if (!LegacyAnimationsSettings.CONFIG.instance().fastItems) { + if (!LegacyAnimationsSettings.getInstance().fastItems) { return quaternion; } @@ -57,7 +57,7 @@ protected ItemEntityRendererMixin(EntityRendererFactory.Context ctx) ) private void legacyAnimations$rotateItemAccordingly(ItemEntity itemEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci, @Local(ordinal = 0) boolean bl) { - if (!LegacyAnimationsSettings.CONFIG.instance().fastItems) + if (!LegacyAnimationsSettings.getInstance().fastItems) { return; } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/ItemRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/ItemRendererMixin.java index 1c5b5f9..e83f59a 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/ItemRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/ItemRendererMixin.java @@ -59,7 +59,7 @@ public class ItemRendererMixin ) 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.CONFIG.instance().itemPositions) + if (!LegacyAnimationsSettings.getInstance().itemPositions) { return; } @@ -92,7 +92,7 @@ public class ItemRendererMixin @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.CONFIG.instance().fastItems) { + if (!LegacyAnimationsSettings.getInstance().fastItems) { return quads; } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityMixin.java index 80b215a..a50128f 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityMixin.java @@ -63,7 +63,7 @@ public abstract class LivingEntityMixin implements PlayerPitchInterface ) private float legacyAnimations$revertBackwardsWalk(float constant) { - if (!LegacyAnimationsSettings.CONFIG.instance().oldWalking) + if (!LegacyAnimationsSettings.getInstance().oldWalking) { return constant; } @@ -81,7 +81,7 @@ public abstract class LivingEntityMixin implements PlayerPitchInterface ) private void legacyAnimations$setPrevCameraPitch(CallbackInfo ci) { - if (!LegacyAnimationsSettings.CONFIG.instance().oldViewBob) + if (!LegacyAnimationsSettings.getInstance().oldViewBob) { return; } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityRendererMixin.java index a64caf9..b6574d8 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityRendererMixin.java @@ -28,7 +28,7 @@ public abstract class LivingEntityRendererMixin ) private boolean legacyAnimations$oldDeathLimbs(boolean original) { - if (!LegacyAnimationsSettings.CONFIG.instance().oldDeath) + if (!LegacyAnimationsSettings.getInstance().oldDeath) { return true; } @@ -46,7 +46,7 @@ public abstract class LivingEntityRendererMixin ) private void legacyAnimations$modelSneak(T livingEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) { - if (!LegacyAnimationsSettings.CONFIG.instance().oldSneaking) { + if (!LegacyAnimationsSettings.getInstance().oldSneaking) { return; } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/MinecraftClientMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/MinecraftClientMixin.java index 003b85d..74690a9 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/MinecraftClientMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/MinecraftClientMixin.java @@ -38,7 +38,7 @@ public class MinecraftClientMixin { ) private boolean legacyAnimations$interruptBlockBreaking(boolean original) { - if (!LegacyAnimationsSettings.CONFIG.instance().punchDuringUsage) + if (!LegacyAnimationsSettings.getInstance().punchDuringUsage) { return original; } @@ -54,7 +54,7 @@ public class MinecraftClientMixin { ) private boolean legacyAnimations$allowWhileUsingItem(boolean original) { - if (!LegacyAnimationsSettings.CONFIG.instance().punchDuringUsage) + if (!LegacyAnimationsSettings.getInstance().punchDuringUsage) { return original; } @@ -70,7 +70,7 @@ public class MinecraftClientMixin { ) private void legacyAnimations$swapForFakeSwing(ClientPlayerEntity instance, Hand hand, Operation original) { - if (!LegacyAnimationsSettings.CONFIG.instance().punchDuringUsage) + if (!LegacyAnimationsSettings.getInstance().punchDuringUsage) { original.call(instance, hand); @@ -117,7 +117,7 @@ public class MinecraftClientMixin { ) private boolean legacyAnimations$removeCondition(boolean original) { - if (!LegacyAnimationsSettings.CONFIG.instance().punchDuringUsage) + if (!LegacyAnimationsSettings.getInstance().punchDuringUsage) { return original; } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityMixin.java index a806037..787a6f5 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityMixin.java @@ -22,49 +22,49 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin { //todo: hypixel -// @ModifyReturnValue( -// method = "getEquippedStack", -// at = @At( -// value = "RETURN", -// ordinal = 1 -// ) -// ) -// private ItemStack legacyAnimations$fakeShield(ItemStack original) -// { + @ModifyReturnValue( + method = "getEquippedStack", + at = @At( + value = "RETURN", + ordinal = 1 + ) + ) + private ItemStack legacyAnimations$fakeShield(ItemStack original) + { // if (!ServerUtils.INSTANCE.isValidServer()) // { // return original; // } -// + // if (isBlocking()) // { // 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 (!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(); -// } + + ci.cancel(); + } @Inject( method = "tickMovement", @@ -77,7 +77,7 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin ) private void legacyAnimations$getPitchFromVelocity(CallbackInfo ci) { - if (!LegacyAnimationsSettings.CONFIG.instance().oldViewBob) + if (!LegacyAnimationsSettings.getInstance().oldViewBob) { return; } @@ -101,7 +101,7 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin ) private EntityDimensions legacyAnimations$modifyStandingEyeHeight(EntityDimensions original, EntityPose pose) { - if (!LegacyAnimationsSettings.CONFIG.instance().oldSneaking) + if (!LegacyAnimationsSettings.getInstance().oldSneaking) { return original; } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityRendererMixin.java index 1ce5a47..4436f23 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityRendererMixin.java @@ -25,7 +25,7 @@ public class PlayerEntityRendererMixin cancellable = true ) private static void legacyAnimations$removeShieldArm(AbstractClientPlayerEntity player, Hand hand, CallbackInfoReturnable cir) { - if (!LegacyAnimationsSettings.CONFIG.instance().hideShields) + if (!LegacyAnimationsSettings.getInstance().hideShields) { return; } @@ -56,7 +56,7 @@ public class PlayerEntityRendererMixin ) ) private boolean legacyAnimations$disableSneakOffset(AbstractClientPlayerEntity player) { - if (!LegacyAnimationsSettings.CONFIG.instance().oldSneaking) + if (!LegacyAnimationsSettings.getInstance().oldSneaking) { return player.isInSneakingPose(); } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/ShieldItemMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/ShieldItemMixin.java index f8fcacf..ddacc5b 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/ShieldItemMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/ShieldItemMixin.java @@ -26,7 +26,7 @@ public class ShieldItemMixin { ) public void legacyAnimations$getUseAction(ItemStack stack, CallbackInfoReturnable cir) { - if (!LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock) + if (!LegacyAnimationsSettings.getInstance().oldSwordBlock) { return; } @@ -48,7 +48,7 @@ public class ShieldItemMixin { ) public void legacyAnimations$lowerMaxUseTime(ItemStack stack, CallbackInfoReturnable cir) { - if (!LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock) + if (!LegacyAnimationsSettings.getInstance().oldSwordBlock) { return; } @@ -70,7 +70,7 @@ public class ShieldItemMixin { ) public void disableUseWithSword(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable> cir) { - if (!LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock) + if (!LegacyAnimationsSettings.getInstance().oldSwordBlock) { return; } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/SwordItemMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/SwordItemMixin.java index 7723711..3d6d352 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/SwordItemMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/SwordItemMixin.java @@ -22,7 +22,7 @@ public SwordItemMixin(Settings settings) @Override public UseAction getUseAction(ItemStack stack) { - if (!LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock) + if (!LegacyAnimationsSettings.getInstance().oldSwordBlock) { return UseAction.NONE; } @@ -37,7 +37,7 @@ public UseAction getUseAction(ItemStack stack) @Override public int getMaxUseTime(ItemStack stack) { - if (!LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock) + if (!LegacyAnimationsSettings.getInstance().oldSwordBlock) { return 0; } @@ -52,7 +52,7 @@ public int getMaxUseTime(ItemStack stack) @Override public TypedActionResult use(World world, PlayerEntity user, Hand hand) { - if (!LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock) + if (!LegacyAnimationsSettings.getInstance().oldSwordBlock) { 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 12c2314..08112cf 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/VertexConsumerMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/VertexConsumerMixin.java @@ -25,7 +25,7 @@ public interface VertexConsumerMixin { ) default void legacyAnimations$modifyNormal(Args args, @Local(ordinal = 0) Vec3i vec3i) { - if (!LegacyAnimationsSettings.CONFIG.instance().fastItems) + if (!LegacyAnimationsSettings.getInstance().fastItems) { return; } diff --git a/src/main/resources/legacyanimations.mixins.json b/src/main/resources/legacyanimations.mixins.json index 2bbf09d..13a1d18 100644 --- a/src/main/resources/legacyanimations.mixins.json +++ b/src/main/resources/legacyanimations.mixins.json @@ -7,6 +7,7 @@ "BipedEntityModelMixin", "BuiltinModelItemRendererMixin", "CameraMixin", + "ClientPlayerEntityMixin", "ClientPlayerInteractionManagerMixin", "DebugHudMixin", "EntityMixin",