Skip to content

Commit

Permalink
Cleanup methods
Browse files Browse the repository at this point in the history
  • Loading branch information
lowercasebtw committed Dec 14, 2024
1 parent 545ad8c commit cf8602e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/me/mixces/animatium/util/PlayerUtils.java
Original file line number Diff line number Diff line change
@@ -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;
}

Expand Down

0 comments on commit cf8602e

Please sign in to comment.