diff --git a/src/main/java/net/atlas/combatify/CombatifyClient.java b/src/main/java/net/atlas/combatify/CombatifyClient.java index 02a42b5..d5ec8f0 100644 --- a/src/main/java/net/atlas/combatify/CombatifyClient.java +++ b/src/main/java/net/atlas/combatify/CombatifyClient.java @@ -63,7 +63,7 @@ public class CombatifyClient implements ClientModInitializer { OptionInstance.noTooltip(), OptionInstance.forOptionEnum(), new OptionInstance.Enum<>(Arrays.asList(ShieldIndicatorStatus.values()), Codec.INT.xmap(ShieldIndicatorStatus::byId, ShieldIndicatorStatus::getId)), - ShieldIndicatorStatus.CROSSHAIR, + ShieldIndicatorStatus.OFF, value -> { } ); diff --git a/src/main/java/net/atlas/combatify/mixin/ItemInHandMixin.java b/src/main/java/net/atlas/combatify/mixin/ItemInHandMixin.java index d60145f..3cad664 100644 --- a/src/main/java/net/atlas/combatify/mixin/ItemInHandMixin.java +++ b/src/main/java/net/atlas/combatify/mixin/ItemInHandMixin.java @@ -97,10 +97,13 @@ public void onRenderArmWithItem(AbstractClientPlayer abstractClientPlayer, float } } if (Combatify.CONFIG.swordBlocking()) { - if (abstractClientPlayer.getUsedItemHand() == interactionHand && ((ItemExtensions) blockingItem.getItem()).getBlockingType().isToolBlocker()) { + if (!blockingItem.isEmpty() && MethodHandler.getBlockingItem(abstractClientPlayer).useHand() == interactionHand && ((ItemExtensions) blockingItem.getItem()).getBlockingType().isToolBlocker()) { poseStack.pushPose(); applyItemArmTransform(poseStack, humanoidArm, i); applyItemBlockTransform(poseStack, humanoidArm); + if (animationsCategory.swingAndUseItem().get()) { + this.applyItemArmAttackTransform(poseStack, humanoidArm, h); + } boolean isRightHand = humanoidArm == HumanoidArm.RIGHT; renderItem(abstractClientPlayer, itemStack, isRightHand ? ItemDisplayContext.FIRST_PERSON_RIGHT_HAND : ItemDisplayContext.FIRST_PERSON_LEFT_HAND, !isRightHand, poseStack, multiBufferSource, j); @@ -175,9 +178,9 @@ private int modifyUseItemRemainingCheck(int original, @Share("isFakingUsingItem" return original; } @ModifyExpressionValue(method = "renderArmWithItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/AbstractClientPlayer;getUsedItemHand()Lnet/minecraft/world/InteractionHand;", ordinal = 1)) - private InteractionHand modifyUseHandCheck(InteractionHand original, @Local(ordinal = 0, argsOnly = true) AbstractClientPlayer abstractClientPlayer, @Local(ordinal = 0, argsOnly = true) InteractionHand interactionHand, @Share("isFakingUsingItem") LocalBooleanRef fakeUsingItem) { + private InteractionHand modifyUseHandCheck(InteractionHand original, @Local(ordinal = 0, argsOnly = true) InteractionHand interactionHand, @Share("isFakingUsingItem") LocalBooleanRef fakeUsingItem) { if (fakeUsingItem.get()) - return MethodHandler.getBlockingItem(abstractClientPlayer).useHand(); + return interactionHand; return original; } @Redirect(method = "renderArmWithItem", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(FFF)V", ordinal = 5)) @@ -197,7 +200,7 @@ private void modifyBowCode1(PoseStack instance, float x, float y, float z, @Loca @Inject(method = "applyItemArmTransform", at = @At(value = "HEAD"), cancellable = true) public void injectSwordBlocking(PoseStack matrices, HumanoidArm arm, float equipProgress, CallbackInfo ci) { assert minecraft.player != null; - if(MethodHandler.getBlockingItem(minecraft.player).getItem() instanceof ItemExtensions shieldItem && shieldItem.getBlockingType().isToolBlocker() && !shieldItem.getBlockingType().isEmpty()) { + if(MethodHandler.getBlockingItem(minecraft.player).getItem() instanceof ItemExtensions blocker && blocker.getBlockingType().isToolBlocker() && !blocker.getBlockingType().isEmpty()) { int i = arm == HumanoidArm.RIGHT ? 1 : -1; matrices.translate(((float)i * 0.56F), (-0.52F + 0.0 * -0.6F), -0.72F); ci.cancel(); diff --git a/src/main/java/net/atlas/combatify/mixin/LocalPlayerMixin.java b/src/main/java/net/atlas/combatify/mixin/LocalPlayerMixin.java index 4cf9436..0cf5b46 100644 --- a/src/main/java/net/atlas/combatify/mixin/LocalPlayerMixin.java +++ b/src/main/java/net/atlas/combatify/mixin/LocalPlayerMixin.java @@ -19,6 +19,7 @@ import net.minecraft.network.protocol.game.ServerboundSwingPacket; import net.minecraft.stats.StatsCounter; import net.minecraft.world.InteractionHand; +import org.jetbrains.annotations.NotNull; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -29,8 +30,6 @@ import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import static net.atlas.combatify.util.MethodHandler.getBlockingItem; - @Mixin(LocalPlayer.class) public abstract class LocalPlayerMixin extends AbstractClientPlayer implements PlayerExtensions, LivingEntityExtensions { public LocalPlayerMixin(ClientLevel clientLevel, GameProfile gameProfile) { @@ -38,12 +37,10 @@ public LocalPlayerMixin(ClientLevel clientLevel, GameProfile gameProfile) { } @Shadow - public abstract void startUsingItem(InteractionHand interactionHand); + public abstract void startUsingItem(@NotNull InteractionHand interactionHand); @Unique boolean wasShieldBlocking = false; @Unique - InteractionHand shieldBlockingHand = InteractionHand.OFF_HAND; - @Unique BooleanOption force100PercentRecharge; @Shadow @@ -52,8 +49,7 @@ public LocalPlayerMixin(ClientLevel clientLevel, GameProfile gameProfile) { @Unique @Final public Minecraft minecraft = Minecraft.getInstance(); - @Unique - LocalPlayer thisPlayer = (LocalPlayer)(Object)this; + @Inject(method = "", at = @At("TAIL")) private void injectOptions(Minecraft minecraft, ClientLevel clientLevel, ClientPacketListener clientPacketListener, StatsCounter statsCounter, ClientRecipeBook clientRecipeBook, boolean bl, boolean bl2, CallbackInfo ci) { force100PercentRecharge = CombatifyClient.getInstance().getConfig().misc().force100PercentRecharge(); @@ -64,10 +60,6 @@ public void injectSneakShield(CallbackInfo ci) { boolean isBlocking = isBlocking(); if (isBlocking != wasShieldBlocking) { wasShieldBlocking = isBlocking; - InteractionHand hand = getBlockingItem(thisPlayer).useHand(); - if (isBlocking) - shieldBlockingHand = hand; - minecraft.gameRenderer.itemInHandRenderer.itemUsed(hand != null ? hand : shieldBlockingHand); } } diff --git a/src/main/java/net/atlas/combatify/mixin/compatibility/viafabricplus/ProtocolCombatTest8cTo1_16_2PacketHandlersMixin.java b/src/main/java/net/atlas/combatify/mixin/compatibility/viafabricplus/ProtocolCombatTest8cTo1_16_2PacketHandlersMixin.java index ebcc8ce..87774a6 100644 --- a/src/main/java/net/atlas/combatify/mixin/compatibility/viafabricplus/ProtocolCombatTest8cTo1_16_2PacketHandlersMixin.java +++ b/src/main/java/net/atlas/combatify/mixin/compatibility/viafabricplus/ProtocolCombatTest8cTo1_16_2PacketHandlersMixin.java @@ -11,11 +11,10 @@ @Mixin(targets = {"net.raphimc.viaaprilfools.protocol.scombattest8ctov1_16_2.ProtocolCombatTest8cTo1_16_2$1"}) @ModSpecific("viafabricplus") public class ProtocolCombatTest8cTo1_16_2PacketHandlersMixin { - @SuppressWarnings("unchecked") @ModifyArg(method = "register", at = @At(value = "INVOKE", target = "Lnet/raphimc/viaaprilfools/protocol/scombattest8ctov1_16_2/ProtocolCombatTest8cTo1_16_2$1;create(Lcom/viaversion/viaversion/api/type/Type;Ljava/lang/Object;)V"), index = 1, remap = false) - public T writeUseShieldOnCrouch(T value) { + public Object writeUseShieldOnCrouch(Object value) { if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) - return (T) CombatifyClient.shieldCrouch.get(); + return CombatifyClient.shieldCrouch.get(); return value; }