Skip to content

Commit

Permalink
make sword block instant on hypixel
Browse files Browse the repository at this point in the history
  • Loading branch information
Mixces committed Mar 18, 2024
1 parent f864325 commit ff206f7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mixces.legacyanimations.mixin;

import com.llamalad7.mixinextras.sugar.Local;
import com.mixces.legacyanimations.config.LegacyAnimationsSettings;
import com.mixces.legacyanimations.util.HandUtils;
import net.minecraft.client.MinecraftClient;
Expand All @@ -11,10 +12,12 @@
import net.minecraft.client.util.math.MatrixStack;
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.ModifyArg;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

Expand Down Expand Up @@ -51,4 +54,17 @@ public float useInterpolatedEyeHeight(PlayerEntity instance) {
return MathHelper.lerp(dispatcher.camera.getLastTickDelta(), ((AccessorCamera) dispatcher.camera).getLastCameraY(), ((AccessorCamera) dispatcher.camera).getCameraY());
}

// todo Fix rod line
// @ModifyArg(
// method = "render(Lnet/minecraft/entity/projectile/FishingBobberEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V",
// at = @At(
// value = "INVOKE",
// target = "Lnet/minecraft/client/render/Camera$Projection;getPosition(FF)Lnet/minecraft/util/math/Vec3d;"
// ),
// index = 0
// )
// public float fixWrongRod(float factorX, @Local(ordinal = 0) PlayerEntity playerEntity) {
// return (playerEntity.getOffHandStack().isOf(Items.FISHING_ROD) ? -1 : 1) * factorX;
// }

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import com.mixces.legacyanimations.config.LegacyAnimationsSettings;
import com.mixces.legacyanimations.util.ServerUtils;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.render.VertexConsumerProvider;
Expand All @@ -28,7 +30,6 @@
public abstract class HeldItemRendererMixin {

@Shadow protected abstract void applySwingOffset(MatrixStack matrices, Arm arm, float swingProgress);
@Shadow protected abstract void applyEquipOffset(MatrixStack matrices, Arm arm, float equipProgress);
@Shadow private float equipProgressOffHand;
@Shadow private ItemStack mainHand;
@Shadow private ItemStack offHand;
Expand Down Expand Up @@ -66,7 +67,8 @@ private void addSwingOffset(AbstractClientPlayerEntity player, float tickDelta,
)
)
private void addSwordBlock(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
if (LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock && item.getItem() instanceof SwordItem && player.getOffHandStack().getItem() instanceof ShieldItem && player.isUsingItem()) {
boolean isUsing = ServerUtils.INSTANCE.isOnHypixel() ? MinecraftClient.getInstance().options.useKey.isPressed() : player.isUsingItem();
if (LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock && item.getItem() instanceof SwordItem && player.getOffHandStack().getItem() instanceof ShieldItem && isUsing) {
boolean bl = hand == Hand.MAIN_HAND;
Arm arm = bl ? player.getMainArm() : player.getMainArm().getOpposite();
boolean bl2 = arm == Arm.RIGHT;
Expand All @@ -87,7 +89,8 @@ private void addSwordBlock(AbstractClientPlayerEntity player, float tickDelta, f
)
)
private boolean disableSwingTranslation(MatrixStack instance, float x, float y, float z, AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) {
return !LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock || !(item.getItem() instanceof SwordItem) || !(player.getOffHandStack().getItem() instanceof ShieldItem) || !player.isUsingItem();
boolean isUsing = ServerUtils.INSTANCE.isOnHypixel() ? MinecraftClient.getInstance().options.useKey.isPressed() : player.isUsingItem();
return !LegacyAnimationsSettings.CONFIG.instance().oldSwordBlock || !(item.getItem() instanceof SwordItem) || !(player.getOffHandStack().getItem() instanceof ShieldItem) || !isUsing;
}

@WrapOperation(
Expand Down

0 comments on commit ff206f7

Please sign in to comment.