From cf8602eafb60a12602ce6662ad03107961b742a1 Mon Sep 17 00:00:00 2001 From: lowercasebtw Date: Sat, 14 Dec 2024 17:51:34 -0500 Subject: [PATCH] Cleanup methods --- .../mixins/MixinFishingBobberEntityRenderer.java | 6 +++--- .../animatium/mixins/MixinFlyingItemEntityRenderer.java | 2 +- src/main/java/me/mixces/animatium/util/PlayerUtils.java | 9 +++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/me/mixces/animatium/mixins/MixinFishingBobberEntityRenderer.java b/src/main/java/me/mixces/animatium/mixins/MixinFishingBobberEntityRenderer.java index 8105f5b..b85bf13 100644 --- a/src/main/java/me/mixces/animatium/mixins/MixinFishingBobberEntityRenderer.java +++ b/src/main/java/me/mixces/animatium/mixins/MixinFishingBobberEntityRenderer.java @@ -35,8 +35,8 @@ protected MixinFishingBobberEntityRenderer(EntityRendererFactory.Context ctx) { private void animatium$oldFishingBobberPosition(FishingBobberEntityState fishingBobberEntityState, MatrixStack matrices, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) { if (AnimatiumConfig.oldFishingBobberPosition) { assert MinecraftClient.getInstance().player != null; - int multiplier = PlayerUtils.handMultiplier(MinecraftClient.getInstance().player, dispatcher); - //TODO: Fix line + int multiplier = PlayerUtils.getHandMultiplier(MinecraftClient.getInstance().player); + // TODO: Fix line matrices.translate(multiplier * 0.5F, 0.0F, 0.0F); } } @@ -70,7 +70,7 @@ protected MixinFishingBobberEntityRenderer(EntityRendererFactory.Context ctx) { @ModifyArg(method = "updateRenderState(Lnet/minecraft/entity/projectile/FishingBobberEntity;Lnet/minecraft/client/render/entity/state/FishingBobberEntityState;F)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/FishingBobberEntityRenderer;getHandPos(Lnet/minecraft/entity/player/PlayerEntity;FF)Lnet/minecraft/util/math/Vec3d;"), index = 1) private float animatium$fixCastLineSwing(float f) { assert MinecraftClient.getInstance().player != null; - int multiplier = PlayerUtils.handMultiplier(MinecraftClient.getInstance().player, dispatcher); + int multiplier = PlayerUtils.getHandMultiplier(MinecraftClient.getInstance().player); return f * (AnimatiumConfig.fixCastLineSwing ? multiplier : 1); } } diff --git a/src/main/java/me/mixces/animatium/mixins/MixinFlyingItemEntityRenderer.java b/src/main/java/me/mixces/animatium/mixins/MixinFlyingItemEntityRenderer.java index e6abcb9..7a6faaf 100644 --- a/src/main/java/me/mixces/animatium/mixins/MixinFlyingItemEntityRenderer.java +++ b/src/main/java/me/mixces/animatium/mixins/MixinFlyingItemEntityRenderer.java @@ -26,7 +26,7 @@ protected MixinFlyingItemEntityRenderer(EntityRendererFactory.Context ctx) { private void animatium$oldProjectilePosition(FlyingItemEntityRenderState flyingItemEntityRenderState, MatrixStack matrices, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) { if (AnimatiumConfig.oldProjectilePosition) { assert MinecraftClient.getInstance().player != null; - int direction = PlayerUtils.handMultiplier(MinecraftClient.getInstance().player, dispatcher); + int direction = PlayerUtils.getHandMultiplier(MinecraftClient.getInstance().player); matrices.translate(direction * 0.25F, 0.0F, 0.25F); } } diff --git a/src/main/java/me/mixces/animatium/util/PlayerUtils.java b/src/main/java/me/mixces/animatium/util/PlayerUtils.java index 517b90c..d588b8f 100644 --- a/src/main/java/me/mixces/animatium/util/PlayerUtils.java +++ b/src/main/java/me/mixces/animatium/util/PlayerUtils.java @@ -1,18 +1,19 @@ package me.mixces.animatium.util; import com.google.common.base.MoreObjects; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.client.MinecraftClient; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.Arm; import net.minecraft.util.Hand; import net.minecraft.util.math.Vec3d; public class PlayerUtils { - public static int handMultiplier(ClientPlayerEntity player, EntityRenderDispatcher dispatcher) { + public static int getHandMultiplier(PlayerEntity player) { Hand hand = MoreObjects.firstNonNull(player.preferredHand, Hand.MAIN_HAND); Arm arm = hand == Hand.MAIN_HAND ? player.getMainArm() : player.getMainArm().getOpposite(); - int i = dispatcher.gameOptions.getPerspective().isFirstPerson() ? 1 : -1; + MinecraftClient client = MinecraftClient.getInstance(); + assert client != null; + int i = client.options.getPerspective().isFirstPerson() ? 1 : -1; return arm == Arm.RIGHT ? i : -i; }