Skip to content

Commit

Permalink
add option to hand view to disable the eating animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Wide-Cat committed Aug 21, 2023
1 parent 1101e84 commit 775939d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
import net.minecraft.client.render.item.HeldItemRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Arm;
import net.minecraft.util.Hand;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

Expand Down Expand Up @@ -83,6 +85,13 @@ private void onRenderArm(AbstractClientPlayerEntity player, float tickDelta, flo
MeteorClient.EVENT_BUS.post(ArmRenderEvent.get(hand, matrices));
}

@Inject(method = "applyEatOrDrinkTransformation", at = @At(value = "INVOKE", target = "Ljava/lang/Math;pow(DD)D", shift = At.Shift.BEFORE), cancellable = true)
private void cancelTransformations(MatrixStack matrices, float tickDelta, Arm arm, ItemStack stack, CallbackInfo ci) {
if (Modules.get().get(HandView.class).disableFoodAnimation()) ci.cancel();
}


@Unique
private boolean showSwapping(ItemStack stack1, ItemStack stack2) {
return !Modules.get().get(HandView.class).showSwapping() || ItemStack.areEqual(stack1, stack2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,27 @@ public class HandView extends Module {
.build()
);

public final Setting<Boolean> oldAnimations = sgGeneral.add(new BoolSetting.Builder()
.name("old-animations")
.description("Changes hit animations to those like 1.8")
.defaultValue(false)
.build()
);

public final Setting<Boolean> showSwapping = sgGeneral.add(new BoolSetting.Builder()
.name("show-swapping")
.description("Whether or not to show the item swapping animation")
.defaultValue(true)
.build()
);

private final Setting<Boolean> disableFoodAnimation = sgGeneral.add(new BoolSetting.Builder()
.name("disable-eating-animation")
.description("Disables the eating animation. Potentially desirable if it goes offscreen.")
.defaultValue(false)
.build()
);

public final Setting<SwingMode> swingMode = sgGeneral.add(new EnumSetting.Builder<SwingMode>()
.name("swing-mode")
.description("Modifies your client & server hand swinging.")
Expand Down Expand Up @@ -66,20 +87,6 @@ public class HandView extends Module {
.build()
);

public final Setting<Boolean> oldAnimations = sgGeneral.add(new BoolSetting.Builder()
.name("old-animations")
.description("Changes hit animations to those like 1.8")
.defaultValue(false)
.build()
);

public final Setting<Boolean> showSwapping = sgGeneral.add(new BoolSetting.Builder()
.name("show-swapping")
.description("Whether or not to show the item swapping animation")
.defaultValue(true)
.build()
);

// Main Hand

private final Setting<Vector3d> scaleMain = sgMainHand.add(new Vector3dSetting.Builder()
Expand Down Expand Up @@ -109,7 +116,7 @@ public class HandView extends Module {
.build()
);

// Off Hand
// Offhand

private final Setting<Vector3d> scaleOff = sgOffHand.add(new Vector3dSetting.Builder()
.name("scale")
Expand Down Expand Up @@ -220,6 +227,10 @@ public boolean showSwapping() {
return isActive() && showSwapping.get();
}

public boolean disableFoodAnimation() {
return isActive() && disableFoodAnimation.get();
}

public enum SwingMode {
Offhand,
Mainhand,
Expand Down

0 comments on commit 775939d

Please sign in to comment.