Skip to content

Commit

Permalink
Combatify 1.2.2 1.21 Fabric - unreal
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandra-Myers committed Jul 31, 2024
1 parent d4a973a commit b3c667f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/atlas/combatify/CombatifyClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 -> {
}
);
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/net/atlas/combatify/mixin/ItemInHandMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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))
Expand All @@ -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();
Expand Down
14 changes: 3 additions & 11 deletions src/main/java/net/atlas/combatify/mixin/LocalPlayerMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -29,21 +30,17 @@
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) {
super(clientLevel, 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
Expand All @@ -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 = "<init>", 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();
Expand All @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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> 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;
}

Expand Down

0 comments on commit b3c667f

Please sign in to comment.