Skip to content

Commit 1a4034f

Browse files
Release 1.0.5
Fix Animatium equip/swap compatibility and simplify animation handling. Co-authored-by: lowercasebtw <jejojora2@gmail.com>
1 parent f5a63db commit 1a4034f

2 files changed

Lines changed: 9 additions & 20 deletions

File tree

‎gradle.properties‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ fabric_api_version=0.154.0+26.2
1919
midnightlib_version=1.9.3+26.2-fabric
2020

2121
# Mod Properties
22-
mod_version=1.0.4-26.2-fabric
22+
mod_version=1.0.5-26.2-fabric
2323
maven_group=net.i_no_am.view_model
2424
archives_base_name=view-model

‎src/main/java/net/i_no_am/viewmodel/mixin/MixinItemInHandRenderer.java‎

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package net.i_no_am.viewmodel.mixin;
22

3+
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
34
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
45
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
56
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
7+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
68
import com.mojang.blaze3d.vertex.PoseStack;
79
import com.mojang.math.Axis;
810
import net.i_no_am.viewmodel.Global;
@@ -29,10 +31,6 @@
2931
public abstract class MixinItemInHandRenderer implements Global {
3032

3133
@Shadow private ItemStack mainHandItem;
32-
@Shadow private ItemStack offHandItem;
33-
@Shadow private float offHandHeight;
34-
@Shadow protected abstract boolean shouldInstantlyReplaceVisibleItem(ItemStack currentlyVisibleItem, ItemStack expectedItem);
35-
@Shadow private float mainHandHeight;
3634

3735
@Inject(method = "submitArmWithItem", at = @At("HEAD"))
3836
private void onRenderHandsPos(AbstractClientPlayer player, float frameInterp, float xRot, InteractionHand hand, float attack, ItemStack itemStack, float inverseArmHeight, PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords, CallbackInfo ci) {
@@ -92,23 +90,14 @@ private boolean skipSwapAnimation(boolean original) {
9290
return original || Config.skipSwapping;
9391
}
9492

95-
@ModifyArg(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Mth;clamp(FFF)F", ordinal = 2), index = 0)
96-
private float modifyEquipProgressMainHand(float value) {
97-
if (mc.player == null) return value;
98-
99-
ItemStack currentStack = mc.player.getMainHandItem();
100-
if (Config.oldAnimations && !Config.skipSwapping) {
101-
mainHandItem = currentStack;
102-
}
103-
104-
float progress = Config.oldAnimations ? 1 : (float) Math.pow(mc.player.getItemSwapScale(1), 3);
105-
106-
return (ItemStack.matches(mainHandItem, currentStack) ? progress : 0) - mainHandHeight;
93+
@WrapOperation(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ItemInHandRenderer;shouldInstantlyReplaceVisibleItem(Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/item/ItemStack;)Z", ordinal = 0))
94+
private boolean skipMainHandSwapAnimation(ItemInHandRenderer instance, ItemStack currentlyVisibleItem, ItemStack expectedItem, Operation<Boolean> original) {
95+
return Config.oldAnimations || original.call(instance, currentlyVisibleItem, expectedItem);
10796
}
10897

109-
@ModifyArg(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Mth;clamp(FFF)F", ordinal = 3), index = 0)
110-
private float skipOffHandSwapAnim(float value) {
111-
return Config.skipSwapping ? (shouldInstantlyReplaceVisibleItem(offHandItem, mc.player.getOffhandItem()) ? 1 : 0) - offHandHeight : value;
98+
@ModifyExpressionValue(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;getItemSwapScale(F)F"))
99+
private float removeItemSwapScale(float original) {
100+
return Config.oldAnimations ? 1.0F : original;
112101
}
113102

114103
@WrapMethod(method = "applyEatTransform")

0 commit comments

Comments
 (0)