diff --git a/src/main/java/com/mixces/legacyanimations/mixin/ArmorFeatureRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/ArmorFeatureRendererMixin.java index 84f917e..5875119 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/ArmorFeatureRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/ArmorFeatureRendererMixin.java @@ -1,12 +1,16 @@ 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 net.minecraft.client.render.OverlayTexture; import net.minecraft.client.render.RenderLayer; +import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.feature.ArmorFeatureRenderer; import net.minecraft.client.render.entity.model.BipedEntityModel; +import net.minecraft.client.texture.Sprite; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.LivingEntity; @@ -51,8 +55,31 @@ public abstract class ArmorFeatureRendererMixin original, @Local(ordinal = 0, argsOnly = true) VertexConsumerProvider vertexConsumers) + { + if (!LegacyAnimationsSettings.CONFIG.instance().armorTint) + { + return original.call(instance, consumer); + } + + if (legacyAnimations$entity.deathTime > 0 || legacyAnimations$entity.hurtTime > 0) { + return instance.getTextureSpecificVertexConsumer(vertexConsumers.getBuffer(RenderLayer.getEntityCutoutNoCullZOffset(instance.getAtlasId()))); + } + return original.call(instance, consumer); + } + @ModifyArg( - method = "renderArmorParts", + method = { + "renderArmorParts", + "renderTrim" + }, at = @At( value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel;render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;IIFFFF)V" @@ -65,13 +92,10 @@ public abstract class ArmorFeatureRendererMixin 0 || entity.hurtTime > 0; + return OverlayTexture.packUv( + OverlayTexture.getU(0.0F), + OverlayTexture.getV(legacyAnimations$entity.deathTime > 0 || legacyAnimations$entity.hurtTime > 0) + ); } } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/BipedEntityModelMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/BipedEntityModelMixin.java index b61f542..c1dd09e 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/BipedEntityModelMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/BipedEntityModelMixin.java @@ -16,6 +16,8 @@ public abstract class BipedEntityModelMixin { + //todo: thorough investigation needed + @Shadow public BipedEntityModel.ArmPose leftArmPose; @Shadow public BipedEntityModel.ArmPose rightArmPose; @Shadow @Final public ModelPart rightArm; diff --git a/src/main/java/com/mixces/legacyanimations/mixin/BuiltinModelItemRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/BuiltinModelItemRendererMixin.java index 45126bd..d72ddab 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/BuiltinModelItemRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/BuiltinModelItemRendererMixin.java @@ -13,9 +13,11 @@ import org.spongepowered.asm.mixin.injection.At; @Mixin(BuiltinModelItemRenderer.class) -public class BuiltinModelItemRendererMixin +public abstract class BuiltinModelItemRendererMixin { + //todo: re-write shields + @ModifyExpressionValue( method = "render", at = @At( diff --git a/src/main/java/com/mixces/legacyanimations/mixin/CameraMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/CameraMixin.java index 60ba1b2..7820c1d 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/CameraMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/CameraMixin.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 net.minecraft.client.render.Camera; import net.minecraft.entity.Entity; @@ -7,8 +9,6 @@ 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.callback.CallbackInfo; @Mixin(Camera.class) public abstract class CameraMixin @@ -17,20 +17,28 @@ public abstract class CameraMixin @Shadow private float cameraY; @Shadow private Entity focusedEntity; - @Inject( + @WrapOperation( method = "updateEyeHeight", at = @At( value = "FIELD", opcode = Opcodes.PUTFIELD, target = "Lnet/minecraft/client/render/Camera;cameraY:F" - ), - cancellable = true + ) ) - private void legacyAnimations$addOldSneakCalculation(CallbackInfo ci) { - if (LegacyAnimationsSettings.CONFIG.instance().oldSneaking && focusedEntity.getStandingEyeHeight() < cameraY) + private void legacyAnimations$addOldSneakCalculation(Camera instance, float value, Operation original) + { + if (!LegacyAnimationsSettings.CONFIG.instance().oldSneaking) + { + original.call(instance, value); + } + + if (focusedEntity.getStandingEyeHeight() < cameraY) { cameraY = focusedEntity.getStandingEyeHeight(); - ci.cancel(); + } + else + { + original.call(instance, value); } } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/ClientPlayerInteractionManagerMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/ClientPlayerInteractionManagerMixin.java index ca04a72..ba25a0f 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/ClientPlayerInteractionManagerMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/ClientPlayerInteractionManagerMixin.java @@ -3,6 +3,7 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.mixces.legacyanimations.config.LegacyAnimationsSettings; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.network.ClientPlayerInteractionManager; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; @@ -19,6 +20,8 @@ public abstract class ClientPlayerInteractionManagerMixin @Shadow @Final private MinecraftClient client; @Shadow public abstract boolean isBreakingBlock(); + @Shadow public abstract void cancelBlockBreaking(); + @Shadow private float currentBreakingProgress; @ModifyExpressionValue( method = "updateBlockBreakingProgress", @@ -29,7 +32,11 @@ public abstract class ClientPlayerInteractionManagerMixin ) public boolean legacyAnimations$fixBreakingBlockCheck(boolean original) { - return (!LegacyAnimationsSettings.CONFIG.instance().punchDuringUsage || isBreakingBlock()) && original; + if (!LegacyAnimationsSettings.CONFIG.instance().punchDuringUsage) + { + return original; + } + return original && isBreakingBlock(); } @Inject( @@ -42,8 +49,25 @@ public abstract class ClientPlayerInteractionManagerMixin cancellable = true) public void legacyAnimations$cancelIllegalDestroy(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { - if (LegacyAnimationsSettings.CONFIG.instance().punchDuringUsage && client.player != null && client.player.isUsingItem()) + if (!LegacyAnimationsSettings.CONFIG.instance().punchDuringUsage) + { + return; + } + + final ClientPlayerEntity player = MinecraftClient.getInstance().player; + + if (player == null) { + return; + } + + if (player.isUsingItem() && player.canModifyBlocks()) + { + if (currentBreakingProgress > 0.0f) + { + cancelBlockBreaking(); + } + cir.setReturnValue(true); } } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/DebugHudMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/DebugHudMixin.java index 73bb82f..c4b3be8 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/DebugHudMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/DebugHudMixin.java @@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.ModifyArg; @Mixin(DebugHud.class) -public class DebugHudMixin +public abstract class DebugHudMixin { @WrapWithCondition( diff --git a/src/main/java/com/mixces/legacyanimations/mixin/EntityMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/EntityMixin.java index b069954..8dcb132 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/EntityMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/EntityMixin.java @@ -4,21 +4,14 @@ import com.mixces.legacyanimations.config.LegacyAnimationsSettings; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityPose; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.data.DataTracker; -import net.minecraft.entity.data.TrackedData; -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; @Mixin(Entity.class) -public class EntityMixin +public abstract class EntityMixin { - @Final @Shadow private EntityType type; - @Final @Shadow protected DataTracker dataTracker; - @Final @Shadow protected static TrackedData POSE; + //todo: revert swimming mechanic @ModifyReturnValue( method = "getPose", @@ -28,14 +21,16 @@ public class EntityMixin ) public EntityPose legacyAnimations$revertSwimPose(EntityPose original) { - Entity entity = (Entity) (Object) this; - if (LegacyAnimationsSettings.CONFIG.instance().oldSwim && type == EntityType.PLAYER && entity.isSwimming()) + if (!LegacyAnimationsSettings.CONFIG.instance().oldSwim) { - EntityPose pose = dataTracker.get(POSE); - if (pose == EntityPose.SWIMMING) { - pose = EntityPose.STANDING; - } - return pose; + return original; + } + + final Entity entity = (Entity) (Object) this; + + if (entity.isSwimming()) + { + return EntityPose.STANDING; } return original; } diff --git a/src/main/java/com/mixces/legacyanimations/mixin/FishingBobberEntityRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/FishingBobberEntityRendererMixin.java index c42785e..d0681a2 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/FishingBobberEntityRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/FishingBobberEntityRendererMixin.java @@ -13,9 +13,11 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.projectile.FishingBobberEntity; import net.minecraft.item.Items; +import net.minecraft.util.math.MathHelper; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(FishingBobberEntityRenderer.class) @@ -37,13 +39,22 @@ protected FishingBobberEntityRendererMixin(EntityRendererFactory.Context ctx) ) public void legacyAnimations$shiftRodBob(FishingBobberEntity fishingBobberEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) { - ClientPlayerEntity player = MinecraftClient.getInstance().player; - if (LegacyAnimationsSettings.CONFIG.instance().oldProjectiles && player != null) + if (!LegacyAnimationsSettings.CONFIG.instance().oldProjectiles) { - matrixStack.translate(HandUtils.INSTANCE.handMultiplier(player, dispatcher) * 0.25F, 0.0F, 0.0F); + return; } + + final ClientPlayerEntity player = MinecraftClient.getInstance().player; + + if (player == null) + { + return; + } + + matrixStack.translate(HandUtils.INSTANCE.handMultiplier(player, dispatcher) * 0.25F, 0.0F, 0.0F); } + //todo: cameraVecPos bullshit and left handed rod line // @Redirect( // method = "render(Lnet/minecraft/entity/projectile/FishingBobberEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", // at = @At( diff --git a/src/main/java/com/mixces/legacyanimations/mixin/FlyingItemEntityRendererMixin.java b/src/main/java/com/mixces/legacyanimations/mixin/FlyingItemEntityRendererMixin.java index 49a2f27..f10ee7f 100644 --- a/src/main/java/com/mixces/legacyanimations/mixin/FlyingItemEntityRendererMixin.java +++ b/src/main/java/com/mixces/legacyanimations/mixin/FlyingItemEntityRendererMixin.java @@ -5,6 +5,7 @@ import com.mixces.legacyanimations.config.LegacyAnimationsSettings; import com.mixces.legacyanimations.util.HandUtils; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.EntityRenderer; import net.minecraft.client.render.entity.EntityRendererFactory; @@ -36,9 +37,13 @@ protected FlyingItemEntityRendererMixin(EntityRendererFactory.Context ctx) target = "Lnet/minecraft/entity/Entity;age:I" ) ) - public int legacyAnimations$disableCleanView(Entity instance, Operation original) + public int legacyAnimations$disableDelay(Entity instance, Operation original) { - return LegacyAnimationsSettings.CONFIG.instance().oldProjectiles ? original.call(instance) + 2 : original.call(instance); + if (!LegacyAnimationsSettings.CONFIG.instance().oldProjectiles) + { + return original.call(instance); + } + return original.call(instance) + 2; } @Inject( @@ -50,12 +55,16 @@ 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.CONFIG.instance().oldProjectiles) { - matrices.translate((!dispatcher.gameOptions.getPerspective().isFrontView() ? 1 : -1) * 0.25F, 0.0F, 0.0F); + return; } + + matrices.translate((!dispatcher.gameOptions.getPerspective().isFrontView() ? 1 : -1) * 0.25F, 0.0F, 0.0F); } + //todo: shit is missing in left handed mode + @ModifyArg( method = "render", at = @At( @@ -66,19 +75,28 @@ protected FlyingItemEntityRendererMixin(EntityRendererFactory.Context ctx) ) private float legacyAnimations$rotateProjectileAccordingly(float deg) { - if (LegacyAnimationsSettings.CONFIG.instance().oldProjectiles && MinecraftClient.getInstance().player != null) + if (LegacyAnimationsSettings.CONFIG.instance().oldProjectiles) + { + return deg; + } + + final ClientPlayerEntity player = MinecraftClient.getInstance().player; + + if (player == null) + { + return deg; + } + + final boolean isLeftHand = HandUtils.INSTANCE.isLeftHand(MinecraftClient.getInstance().player, dispatcher); + + if (dispatcher.gameOptions.getPerspective().isFrontView()) + { + return isLeftHand ? deg : deg - 180.0F; + } + else { - boolean isLeftHand = HandUtils.INSTANCE.isLeftHand(MinecraftClient.getInstance().player, dispatcher); - if (!dispatcher.gameOptions.getPerspective().isFrontView()) - { - return isLeftHand ? deg - 180.0F : deg; - } - else - { - return isLeftHand ? deg : deg - 180.0F; - } + return isLeftHand ? deg - 180.0F : deg; } - return deg; } }