diff --git a/src/main/java/com/mixces/legacyanimations/LegacyAnimations.java b/src/main/java/com/mixces/legacyanimations/LegacyAnimations.java index a16aa71..17caee0 100644 --- a/src/main/java/com/mixces/legacyanimations/LegacyAnimations.java +++ b/src/main/java/com/mixces/legacyanimations/LegacyAnimations.java @@ -7,6 +7,7 @@ import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.server.command.CommandManager; import net.minecraft.text.Text; @@ -17,16 +18,27 @@ public class LegacyAnimations implements ModInitializer public void onInitialize() { LegacyAnimationsSettings.CONFIG.load(); + updatePlayerState(); + registerCommands(); + } + + private void updatePlayerState() + { ClientTickEvents.END_WORLD_TICK.register(world -> { - if (MinecraftClient.getInstance().player == null) + final ClientPlayerEntity player = MinecraftClient.getInstance().player; + + if (player == null) { return; } - MinecraftClient.getInstance().player.calculateDimensions(); + player.calculateDimensions(); }); + } + private void registerCommands() + { CommandRegistrationCallback.EVENT.register( (dispatcher, registryAccess, environment) -> { diff --git a/src/main/java/com/mixces/legacyanimations/config/LegacyAnimationsSettings.java b/src/main/java/com/mixces/legacyanimations/config/LegacyAnimationsSettings.java index 855982e..8a709f8 100644 --- a/src/main/java/com/mixces/legacyanimations/config/LegacyAnimationsSettings.java +++ b/src/main/java/com/mixces/legacyanimations/config/LegacyAnimationsSettings.java @@ -36,6 +36,10 @@ public class LegacyAnimationsSettings { @SerialEntry public boolean fastItems = true; @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; @SuppressWarnings("deprecation") @@ -87,6 +91,12 @@ public static Screen configScreen(Screen parent) { .binding(defaults.hideShieldHotbar, () -> config.hideShieldHotbar, newVal -> config.hideShieldHotbar = newVal) .controller(TickBoxControllerBuilder::create) .build()) + .option(Option.createBuilder(boolean.class) + .name(Text.literal("Remove Shield Delay")) + .description(OptionDescription.of(Text.of("Removes the 5ms delay preventing you from instantly activating your shield."))) + .binding(defaults.noShieldDelay, () -> config.noShieldDelay, newVal -> config.noShieldDelay = newVal) + .controller(TickBoxControllerBuilder::create) + .build()) .build()) .category(ConfigCategory.createBuilder() @@ -173,6 +183,12 @@ public static Screen configScreen(Screen parent) { .binding(defaults.oldViewBob, () -> config.oldViewBob, newVal -> config.oldViewBob = newVal) .controller(TickBoxControllerBuilder::create) .build()) + .option(Option.createBuilder(boolean.class) + .name(Text.literal("Old Damage Tilt")) + .description(OptionDescription.of(Text.of("Changes the yaw component of the damage tilt."))) + .binding(defaults.oldViewBob, () -> config.oldViewBob, newVal -> config.oldViewBob = newVal) + .controller(TickBoxControllerBuilder::create) + .build()) .option(Option.createBuilder(boolean.class) .name(Text.literal("Old Projectiles")) .description(OptionDescription.of(Text.of("Reverts the projectile's positions back to the older style."))) @@ -191,6 +207,18 @@ public static Screen configScreen(Screen parent) { .binding(defaults.oldBreakProgress, () -> config.oldBreakProgress, newVal -> config.oldBreakProgress = newVal) .controller(TickBoxControllerBuilder::create) .build()) +// .option(Option.createBuilder(boolean.class) +// .name(Text.literal("Old Item Throw/Drop")) +// .description(OptionDescription.of(Text.of("Disables the swing animation while throwing/dropping items."))) +// .binding(defaults.noSwing, () -> config.noSwing, newVal -> config.noSwing = newVal) +// .controller(TickBoxControllerBuilder::create) +// .build()) + .option(Option.createBuilder(boolean.class) + .name(Text.literal("Old Potion Glint")) + .description(OptionDescription.of(Text.of("Brings back the enchantment glint on potions!"))) + .binding(defaults.oldPotionGlint, () -> config.oldPotionGlint, newVal -> config.oldPotionGlint = newVal) + .controller(TickBoxControllerBuilder::create) + .build()) .build()) )).generateScreen(parent); diff --git a/src/main/java/com/mixces/legacyanimations/handler/FakeSwingHandler.java b/src/main/java/com/mixces/legacyanimations/handler/FakeSwingHandler.java new file mode 100644 index 0000000..bb4b0c1 --- /dev/null +++ b/src/main/java/com/mixces/legacyanimations/handler/FakeSwingHandler.java @@ -0,0 +1,83 @@ +package com.mixces.legacyanimations.handler; + +import com.mixces.legacyanimations.mixin.access.ILivingEntityMixin; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.network.packet.c2s.play.HandSwingC2SPacket; +import net.minecraft.network.packet.s2c.play.EntityAnimationS2CPacket; +import net.minecraft.server.world.ServerChunkManager; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.Hand; + +public class FakeSwingHandler { + +// public static FakeSwingHandler INSTANCE = new FakeSwingHandler(); +// +// public boolean handSwinging; +// public Hand preferredHand; +// public int handSwingTicks; +// public float lastHandSwingProgress; +// public float handSwingProgress; +// +// public void swingHand2(ClientPlayerEntity player, Hand hand) { +// this.swingHand(player, hand); +// +// if (MinecraftClient.getInstance().getNetworkHandler() == null) +// { +// return; +// } +// +// MinecraftClient.getInstance().getNetworkHandler().sendPacket(new HandSwingC2SPacket(hand)); +// } +// +// public void swingHand(ClientPlayerEntity player, Hand hand) { +// this.swingHand(player, hand, false); +// } +// +// public void swingHand(ClientPlayerEntity player, Hand hand, boolean fromServerPlayer) { +// final int handSwingDuration = ((ILivingEntityMixin) player).invokeGetHandSwingDuration(); +// +// if (!this.handSwinging || this.handSwingTicks >= handSwingDuration / 2 || this.handSwingTicks < 0) { +// this.handSwingTicks = -1; +// this.handSwinging = true; +// this.preferredHand = hand; +// if (MinecraftClient.getInstance().g instanceof ServerWorld) { +// EntityAnimationS2CPacket entityAnimationS2CPacket = new EntityAnimationS2CPacket(this, hand == Hand.MAIN_HAND ? EntityAnimationS2CPacket.SWING_MAIN_HAND : EntityAnimationS2CPacket.SWING_OFF_HAND); +// ServerChunkManager serverChunkManager = ((ServerWorld)this.getWorld()).getChunkManager(); +// if (fromServerPlayer) { +// serverChunkManager.sendToNearbyPlayers(this, entityAnimationS2CPacket); +// } else { +// serverChunkManager.sendToOtherNearbyPlayers(this, entityAnimationS2CPacket); +// } +// } +// } +// } +// +// protected void tickHandSwing(ClientPlayerEntity player) { +// int i = ((ILivingEntityMixin) player).invokeGetHandSwingDuration(); +// if (this.handSwinging) { +// ++this.handSwingTicks; +// if (this.handSwingTicks >= i) { +// this.handSwingTicks = 0; +// this.handSwinging = false; +// } +// } else { +// this.handSwingTicks = 0; +// } +// this.handSwingProgress = (float)this.handSwingTicks / (float)i; +// } +// +// public float getHandSwingProgress(float tickDelta) { +// float f = this.handSwingProgress - this.lastHandSwingProgress; +// if (f < 0.0f) { +// f += 1.0f; +// } +// return this.lastHandSwingProgress + f * tickDelta; +// } +// +// public void setHandSwingProgress() +// { +// this.lastHandSwingProgress = this.handSwingProgress; +// } + +} diff --git a/src/main/java/com/mixces/legacyanimations/mixin/BipedEntityModelMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/BipedEntityModelMixin.java index 129fe5d..b7b29bb 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/BipedEntityModelMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/BipedEntityModelMixin.java @@ -32,8 +32,6 @@ public abstract class BipedEntityModelMixin @Shadow @Final public ModelPart leftLeg; @Shadow protected abstract ModelPart getArm(Arm arm); - @Shadow @Final public ModelPart body; - @Inject( method = "setAngles(Lnet/minecraft/entity/LivingEntity;FFFFF)V", at = @At( @@ -276,7 +274,7 @@ public abstract class BipedEntityModelMixin return !LegacyAnimationsSettings.getInstance().oldSneaking; } - @WrapOperation( + @ModifyExpressionValue( method = "animateArms", at = @At( value = "FIELD", @@ -285,23 +283,23 @@ public abstract class BipedEntityModelMixin ordinal = 9 ) ) - public float legacyAnimations$removeConflictingFields3(ModelPart instance, Operation original) + public float legacyAnimations$mirrorSwing1(float original, @Local Arm arm) { - return 0.0F; + return (arm == Arm.LEFT ? -1 : 1) * original; } - @Inject( + @WrapOperation( method = "animateArms", at = @At( value = "FIELD", opcode = Opcodes.GETFIELD, - target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel;handSwingProgress:F", - ordinal = 2 + target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel;leftArm:Lnet/minecraft/client/model/ModelPart;", + ordinal = 3 ) ) - public void legacyAnimations$mirrorSwing(T entity, float animationProgress, CallbackInfo ci, @Local Arm arm, @Local ModelPart modelPart) + public ModelPart legacyAnimations$mirrorSwing2(BipedEntityModel instance, Operation original, @Local ModelPart modelPart) { - modelPart.pitch += (arm == Arm.LEFT ? -1 : 1) * body.yaw; + return modelPart; } @ModifyExpressionValue( @@ -312,7 +310,7 @@ public abstract class BipedEntityModelMixin ordinal = 5 ) ) - public float legacyAnimations$mirrorSwing2(float original, @Local Arm arm) + public float legacyAnimations$mirrorSwing3(float original, @Local Arm arm) { return (arm == Arm.LEFT ? -1 : 1) * original; } @@ -334,4 +332,16 @@ 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/FishingBobberEntityRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/FishingBobberEntityRendererMixin.java index c226b25..0459692 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/FishingBobberEntityRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/FishingBobberEntityRendererMixin.java @@ -5,7 +5,7 @@ import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.mixces.legacyanimations.config.LegacyAnimationsSettings; import com.mixces.legacyanimations.duck.EntityInterface; -import com.mixces.legacyanimations.mixin.interfaces.ICameraMixin; +import com.mixces.legacyanimations.mixin.access.ICameraMixin; import com.mixces.legacyanimations.util.HandUtils; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; diff --git a/src/main/java/com/mixces/legacyanimations/mixin/GameRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/GameRendererMixin.java index 9470e90..a881254 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/GameRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/GameRendererMixin.java @@ -1,10 +1,13 @@ package com.mixces.legacyanimations.mixin; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.llamalad7.mixinextras.sugar.Local; import com.mixces.legacyanimations.config.LegacyAnimationsSettings; import com.mixces.legacyanimations.duck.PlayerPitchInterface; import net.minecraft.client.render.GameRenderer; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RotationAxis; @@ -17,6 +20,21 @@ public class GameRendererMixin { + @WrapOperation( + method = "tiltViewWhenHurt", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/entity/LivingEntity;getDamageTiltYaw()F" + ) + ) + private float legacyAnimations$revertYaw(LivingEntity instance, Operation original) { + if (!LegacyAnimationsSettings.getInstance().oldDamageTilt) + { + return original.call(instance); + } + return 0.0F; + } + @Inject( method = "bobView", at = @At( diff --git a/src/main/java/com/mixces/legacyanimations/mixin/HeldItemFeatureRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/HeldItemFeatureRendererMixin.java index 7cedaa3..09e2ec3 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/HeldItemFeatureRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/HeldItemFeatureRendererMixin.java @@ -3,6 +3,7 @@ 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; import net.minecraft.client.render.entity.feature.HeldItemFeatureRenderer; import net.minecraft.client.render.model.json.ModelTransformationMode; @@ -29,30 +30,15 @@ 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) - { - return; - } +// if (LegacyAnimationsSettings.getInstance().oldSwordBlock && entity.isBlocking() && +// ItemUtils.INSTANCE.isShieldInOffHand(entity.getOffHandStack()) && +// ItemUtils.INSTANCE.isSwordInMainHand(entity.getMainHandStack())) +// { + final MatrixUtil matrix = new MatrixUtil(matrices); - if (!entity.isBlocking()) - { - return; - } - - if (ItemUtils.INSTANCE.isShieldInOffHand(entity.getOffHandStack()) && ItemUtils.INSTANCE.isSwordInMainHand(entity.getMainHandStack())) - { matrices.translate(TransformHook.translationX, TransformHook.translationY, TransformHook.translationZ); - matrices.multiply(RotationAxis.POSITIVE_X.rotation(TransformHook.rotationX)); - matrices.multiply(RotationAxis.POSITIVE_Y.rotation(TransformHook.rotationY)); - matrices.multiply(RotationAxis.POSITIVE_Z.rotation(TransformHook.rotationZ)); - } - -// matrices.translate(TransformHook.translationX, TransformHook.translationY, TransformHook.translationZ); -// matrices.multiply(RotationAxis.POSITIVE_X.rotation(TransformHook.rotationX)); -// matrices.multiply(RotationAxis.POSITIVE_Y.rotation(TransformHook.rotationY)); -// matrices.multiply(RotationAxis.POSITIVE_Z.rotation(TransformHook.rotationZ)); - - + matrix.yaw(TransformHook.rotationX).pitch(TransformHook.rotationY).roll(TransformHook.rotationZ); +// } // x: -0.2 y: 0.0 z: 0.1 yaw: 21.0 pitch: 90.0 roll: -90.0 } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/HeldItemRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/HeldItemRendererMixin.java index a1ea48a..3c69560 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/HeldItemRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/HeldItemRendererMixin.java @@ -5,6 +5,7 @@ import com.mixces.legacyanimations.config.LegacyAnimationsSettings; import com.mixces.legacyanimations.util.HandUtils; import com.mixces.legacyanimations.util.ItemUtils; +import com.mixces.legacyanimations.util.MatrixUtil; import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.render.VertexConsumerProvider; @@ -18,10 +19,7 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.Slice; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(HeldItemRenderer.class) @@ -126,11 +124,10 @@ public abstract class HeldItemRendererMixin } final int l = HandUtils.INSTANCE.handMultiplier((ClientPlayerEntity) player, entityRenderDispatcher); + final MatrixUtil matrix = new MatrixUtil(matrices); matrices.translate(l * -0.14142136F, 0.08F, 0.14142136F); - matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(-102.25F)); - matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(l * 13.365F)); - matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(l * 78.05F)); + matrix.pitch(-102.25F).yaw(l * 13.365F).roll(l * 78.05F); } @Inject( diff --git a/src/main/java/com/mixces/legacyanimations/mixin/ItemRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/ItemRendererMixin.java index e83f59a..082d4b6 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/ItemRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/ItemRendererMixin.java @@ -2,7 +2,6 @@ import com.llamalad7.mixinextras.sugar.Local; import com.mixces.legacyanimations.config.LegacyAnimationsSettings; -import com.mixces.legacyanimations.hook.TransformHook; import com.mixces.legacyanimations.util.HandUtils; import com.mixces.legacyanimations.util.ItemUtils; import com.mixces.legacyanimations.util.TransformationModeUtils; @@ -13,26 +12,21 @@ import net.minecraft.client.render.model.BakedModel; import net.minecraft.client.render.model.BakedQuad; import net.minecraft.client.render.model.json.ModelTransformationMode; -import net.minecraft.client.render.model.json.Transformation; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.ItemStack; import net.minecraft.util.math.Direction; import net.minecraft.util.math.RotationAxis; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.*; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.List; import java.util.stream.Collectors; @Mixin(ItemRenderer.class) -public class ItemRendererMixin +public abstract class ItemRendererMixin { @Shadow @Final private MinecraftClient client; diff --git a/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityMixin.java index a50128f..4a95bde 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityMixin.java @@ -2,9 +2,13 @@ import com.mixces.legacyanimations.config.LegacyAnimationsSettings; import com.mixces.legacyanimations.duck.PlayerPitchInterface; +import com.mixces.legacyanimations.util.ServerUtils; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.UseAction; +import net.minecraft.world.World; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -14,11 +18,16 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(LivingEntity.class) -public abstract class LivingEntityMixin implements PlayerPitchInterface +public abstract class LivingEntityMixin extends Entity implements PlayerPitchInterface { + 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; @@ -32,12 +41,10 @@ public abstract class LivingEntityMixin implements PlayerPitchInterface ) private void legacyAnimations$fixSync(CallbackInfoReturnable cir) { -// if (!ServerUtils.INSTANCE.isValidServer()) -// { -// return; -// } - - //todo: shield delay? + if (!LegacyAnimationsSettings.getInstance().noShieldDelay) + { + return; + } final UseAction action = activeItemStack.getItem().getUseAction(activeItemStack); @@ -88,6 +95,67 @@ public abstract class LivingEntityMixin implements PlayerPitchInterface 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; +// } +// +// @ModifyExpressionValue( +// method = "tickMovement", +// at = @At( +// value = "FIELD", +// opcode = Opcodes.GETFIELD, +// target = "Lnet/minecraft/entity/LivingEntity;headTrackingIncrements:I", +// ordinal = 0 +// ) +// ) +// private int legacyAnimations$cancelHeadUpdate(int original) { +// return 0; +// } +// +// @Inject( +// method = "updateTrackedHeadRotation", +// at = @At( +// value = "HEAD" +// ), +// cancellable = true +// ) +// public void legacyAnimations$cancelHeadUpdate2(float yaw, int interpolationSteps, CallbackInfo ci) { +// ci.cancel(); +// } + @Override public float legacyAnimations$getPrevPlayerPitch() { diff --git a/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityRendererMixin.java index b6574d8..98ecd11 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/LivingEntityRendererMixin.java @@ -2,7 +2,7 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.mixces.legacyanimations.config.LegacyAnimationsSettings; -import com.mixces.legacyanimations.mixin.interfaces.ICameraMixin; +import com.mixces.legacyanimations.mixin.access.ICameraMixin; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.*; import net.minecraft.client.render.entity.LivingEntityRenderer; diff --git a/src/main/java/com/mixces/legacyanimations/mixin/MinecraftClientMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/MinecraftClientMixin.java index 74690a9..435c61b 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/MinecraftClientMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/MinecraftClientMixin.java @@ -4,7 +4,8 @@ import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.mixces.legacyanimations.config.LegacyAnimationsSettings; -import com.mixces.legacyanimations.mixin.interfaces.ILivingEntityMixin; +import com.mixces.legacyanimations.mixin.access.ILivingEntityMixin; +import com.mixces.legacyanimations.util.ServerUtils; import net.minecraft.client.MinecraftClient; import net.minecraft.client.Mouse; import net.minecraft.client.gui.screen.Screen; @@ -96,10 +97,10 @@ public class MinecraftClientMixin { ) private void legacyAnimations$addLeftClickCheck(CallbackInfo ci) { -// if (!ServerUtils.INSTANCE.isOnHypixel()) -// { -// return; -// } + if (!ServerUtils.INSTANCE.isValidServer()) + { + return; + } if (currentScreen != null || !options.attackKey.isPressed() || !mouse.isCursorLocked()) { diff --git a/src/main/java/com/mixces/legacyanimations/mixin/OtherClientPlayerEntityMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/OtherClientPlayerEntityMixin.java new file mode 100644 index 0000000..f7a9926 --- /dev/null +++ b/src/main/java/com/mixces/legacyanimations/mixin/OtherClientPlayerEntityMixin.java @@ -0,0 +1,25 @@ +package com.mixces.legacyanimations.mixin; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import net.minecraft.client.network.OtherClientPlayerEntity; +import org.objectweb.asm.Opcodes; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(OtherClientPlayerEntity.class) +public class OtherClientPlayerEntityMixin { + +// @ModifyExpressionValue( +// method = "tickMovement", +// at = @At( +// value = "FIELD", +// opcode = Opcodes.GETFIELD, +// target = "Lnet/minecraft/client/network/OtherClientPlayerEntity;headTrackingIncrements:I", +// ordinal = 0 +// ) +// ) +// private int legacyAnimations$cancelHeadUpdate(int original) { +// return 0; +// } + +} diff --git a/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityMixin.java index 787a6f5..c75513d 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/PlayerEntityMixin.java @@ -2,15 +2,15 @@ import com.llamalad7.mixinextras.injector.ModifyReturnValue; import com.mixces.legacyanimations.config.LegacyAnimationsSettings; -import com.mixces.legacyanimations.mixin.interfaces.IEntityMixin; -import com.mixces.legacyanimations.mixin.interfaces.ILivingEntityMixin; +import com.mixces.legacyanimations.mixin.access.IEntityMixin; +import com.mixces.legacyanimations.mixin.access.ILivingEntityMixin; import com.mixces.legacyanimations.util.ItemUtils; import com.mixces.legacyanimations.util.ServerUtils; -import net.minecraft.entity.EntityDimensions; -import net.minecraft.entity.EntityPose; +import net.minecraft.entity.*; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; +import net.minecraft.world.World; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -20,6 +20,11 @@ @Mixin(PlayerEntity.class) public abstract class PlayerEntityMixin extends LivingEntityMixin { + + public PlayerEntityMixin(EntityType type, World world) { + super(type, world); + } + //todo: hypixel @ModifyReturnValue( @@ -31,15 +36,10 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin ) private ItemStack legacyAnimations$fakeShield(ItemStack original) { -// if (!ServerUtils.INSTANCE.isValidServer()) -// { -// return original; -// } - -// if (isBlocking()) -// { -// return original; -// } + if (!ServerUtils.INSTANCE.isValidServer()) + { + return original; + } if (!ItemUtils.INSTANCE.isSwordInMainHand(null)) { @@ -58,10 +58,10 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin ) private void legacyAnimations$removeAttackDelay(CallbackInfo ci) { -// if (!ServerUtils.INSTANCE.isValidServer()) -// { -// return; -// } + if (!ServerUtils.INSTANCE.isValidServer()) + { + return; + } ci.cancel(); } @@ -112,6 +112,8 @@ public abstract class PlayerEntityMixin extends LivingEntityMixin return original; } return original.withEyeHeight(original.eyeHeight() + 0.27F); + +// 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/PotionItemMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/PotionItemMixin.java new file mode 100644 index 0000000..c902900 --- /dev/null +++ b/src/main/java/com/mixces/legacyanimations/mixin/PotionItemMixin.java @@ -0,0 +1,35 @@ +package com.mixces.legacyanimations.mixin; + +import com.mixces.legacyanimations.config.LegacyAnimationsSettings; +import net.minecraft.component.DataComponentTypes; +import net.minecraft.component.type.PotionContentsComponent; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.PotionItem; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(PotionItem.class) +public class PotionItemMixin extends Item { + + public PotionItemMixin(Item.Settings settings) { + super(settings); + } + + @Override + public boolean hasGlint(ItemStack stack) { + if (LegacyAnimationsSettings.getInstance().oldPotionGlint) + { + final PotionContentsComponent potionContents = stack.get(DataComponentTypes.POTION_CONTENTS); + + if (potionContents == null) + { + return false; + } + + return potionContents.hasEffects(); + } + + return super.hasGlint(stack); + } + +} diff --git a/src/main/java/com/mixces/legacyanimations/mixin/VertexConsumerMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/VertexConsumerMixin.java index 08112cf..07398f7 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/VertexConsumerMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/VertexConsumerMixin.java @@ -15,33 +15,33 @@ @Mixin(VertexConsumer.class) public interface VertexConsumerMixin { - //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( - value = "INVOKE", - target = "Lnet/minecraft/client/util/math/MatrixStack$Entry;transformNormal(FFFLorg/joml/Vector3f;)Lorg/joml/Vector3f;" - ) - ) - default void legacyAnimations$modifyNormal(Args args, @Local(ordinal = 0) Vec3i vec3i) - { - if (!LegacyAnimationsSettings.getInstance().fastItems) - { - return; - } - - if (TransformationModeUtils.getTransformationMode() != ModelTransformationMode.GROUND) - { - return; - } - - if (ItemUtils.INSTANCE.getModel().hasDepth()) - { - return; - } - - args.set(1, (float) args.get(2)); - args.set(2, (float) args.get(1)); - } +// //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( +// value = "INVOKE", +// target = "Lnet/minecraft/client/util/math/MatrixStack$Entry;transformNormal(FFFLorg/joml/Vector3f;)Lorg/joml/Vector3f;" +// ) +// ) +// default void legacyAnimations$modifyNormal(Args args, @Local(ordinal = 0) Vec3i vec3i) +// { +// if (!LegacyAnimationsSettings.getInstance().fastItems) +// { +// return; +// } +// +// if (TransformationModeUtils.getTransformationMode() != ModelTransformationMode.GROUND) +// { +// return; +// } +// +// if (ItemUtils.INSTANCE.getModel().hasDepth()) +// { +// return; +// } +// +// args.set(1, (float) args.get(2)); +// args.set(2, (float) args.get(1)); +// } } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/interfaces/IBasicBakedModelMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/access/IBasicBakedModelMixin.java similarity index 92% rename from src/main/java/com/mixces/legacyanimations/mixin/interfaces/IBasicBakedModelMixin.java rename to src/main/java/com/mixces/legacyanimations/mixin/access/IBasicBakedModelMixin.java index b94efdb..bd6cc75 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/interfaces/IBasicBakedModelMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/access/IBasicBakedModelMixin.java @@ -1,4 +1,4 @@ -package com.mixces.legacyanimations.mixin.interfaces; +package com.mixces.legacyanimations.mixin.access; import net.minecraft.client.render.model.BasicBakedModel; import net.minecraft.client.render.model.json.ModelOverrideList; diff --git a/src/main/java/com/mixces/legacyanimations/mixin/interfaces/ICameraMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/access/ICameraMixin.java similarity index 83% rename from src/main/java/com/mixces/legacyanimations/mixin/interfaces/ICameraMixin.java rename to src/main/java/com/mixces/legacyanimations/mixin/access/ICameraMixin.java index 86afcd3..7590b2a 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/interfaces/ICameraMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/access/ICameraMixin.java @@ -1,4 +1,4 @@ -package com.mixces.legacyanimations.mixin.interfaces; +package com.mixces.legacyanimations.mixin.access; import net.minecraft.client.render.Camera; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/com/mixces/legacyanimations/mixin/interfaces/IEntityMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/access/IEntityMixin.java similarity index 84% rename from src/main/java/com/mixces/legacyanimations/mixin/interfaces/IEntityMixin.java rename to src/main/java/com/mixces/legacyanimations/mixin/access/IEntityMixin.java index ef977d0..075f693 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/interfaces/IEntityMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/access/IEntityMixin.java @@ -1,4 +1,4 @@ -package com.mixces.legacyanimations.mixin.interfaces; +package com.mixces.legacyanimations.mixin.access; import net.minecraft.entity.Entity; import net.minecraft.util.math.Vec3d; diff --git a/src/main/java/com/mixces/legacyanimations/mixin/interfaces/ILivingEntityMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/access/ILivingEntityMixin.java similarity index 84% rename from src/main/java/com/mixces/legacyanimations/mixin/interfaces/ILivingEntityMixin.java rename to src/main/java/com/mixces/legacyanimations/mixin/access/ILivingEntityMixin.java index 506ed59..be5ccac 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/interfaces/ILivingEntityMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/access/ILivingEntityMixin.java @@ -1,4 +1,4 @@ -package com.mixces.legacyanimations.mixin.interfaces; +package com.mixces.legacyanimations.mixin.access; import net.minecraft.entity.LivingEntity; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/com/mixces/legacyanimations/util/MatrixUtil.java b/src/main/java/com/mixces/legacyanimations/util/MatrixUtil.java new file mode 100644 index 0000000..00b68fc --- /dev/null +++ b/src/main/java/com/mixces/legacyanimations/util/MatrixUtil.java @@ -0,0 +1,33 @@ +package com.mixces.legacyanimations.util; + +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.util.math.RotationAxis; + +public class MatrixUtil { + + private final MatrixStack stack; + + public MatrixUtil (MatrixStack stack) + { + this.stack = stack; + } + + public MatrixUtil pitch(float pitch) + { + stack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(pitch)); + return this; + } + + public MatrixUtil yaw(float yaw) + { + stack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(yaw)); + return this; + } + + public MatrixUtil roll(float roll) + { + stack.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(roll)); + return this; + } + +} diff --git a/src/main/resources/legacyanimations.mixins.json b/src/main/resources/legacyanimations.mixins.json index 13a1d18..25e8e3a 100644 --- a/src/main/resources/legacyanimations.mixins.json +++ b/src/main/resources/legacyanimations.mixins.json @@ -22,16 +22,18 @@ "LivingEntityMixin", "LivingEntityRendererMixin", "MinecraftClientMixin", + "OtherClientPlayerEntityMixin", "PlayerEntityMixin", "PlayerEntityRendererMixin", + "PotionItemMixin", "RenderPhaseMixin", "ShieldItemMixin", "SwordItemMixin", "VertexConsumerMixin", - "interfaces.IBasicBakedModelMixin", - "interfaces.ICameraMixin", - "interfaces.IEntityMixin", - "interfaces.ILivingEntityMixin" + "access.IBasicBakedModelMixin", + "access.ICameraMixin", + "access.IEntityMixin", + "access.ILivingEntityMixin" ], "injectors": { "defaultRequire": 1