Skip to content

Commit

Permalink
fix offhand swing for other players
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyfts committed Jan 26, 2025
1 parent 8a52501 commit 381541c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 13 deletions.
7 changes: 2 additions & 5 deletions src/main/java/xonin/backhand/CommonProxy.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package xonin.backhand;

import javax.annotation.Nullable;

import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.FakePlayer;

import com.gtnewhorizon.gtnhlib.eventbus.EventBusSubscriber;
import com.gtnewhorizon.gtnhlib.keybind.SyncedKeybind;
Expand Down Expand Up @@ -43,7 +39,8 @@ public static void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent event) {
@SubscribeEvent
public static void addTracking(net.minecraftforge.event.entity.player.PlayerEvent.StartTracking event) {
if (BackhandUtils.isValidPlayer(event.entityPlayer) && BackhandUtils.isValidPlayer(event.target)) {
BackhandPacketHandler.sendPacketToPlayer(new OffhandSyncItemPacket((EntityPlayer) event.target), event.entityPlayer);
BackhandPacketHandler
.sendPacketToPlayer(new OffhandSyncItemPacket((EntityPlayer) event.target), event.entityPlayer);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import com.llamalad7.mixinextras.sugar.Local;

import xonin.backhand.Backhand;
import xonin.backhand.api.core.BackhandUtils;
import xonin.backhand.packet.BackhandPacketHandler;
import xonin.backhand.packet.OffhandSyncItemPacket;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;

import xonin.backhand.Backhand;
import xonin.backhand.api.core.BackhandUtils;
import xonin.backhand.api.core.IBackhandPlayer;
import xonin.backhand.api.core.IOffhandInventory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
Expand All @@ -20,9 +19,6 @@
@Mixin(EntityPlayer.class)
public abstract class MixinEntityPlayerClient extends EntityLivingBase implements IBackhandPlayer {

@Shadow
public InventoryPlayer inventory;

@Shadow
private ItemStack itemInUse;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ public abstract class MixinNetHandlerPlayClient {

@Inject(
method = "handleAnimation",
at = @At(value = "INVOKE", target = "Lnet/minecraft/network/play/server/S0BPacketAnimation;func_148977_d()I"))
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/network/play/server/S0BPacketAnimation;func_148977_d()I",
ordinal = 0))
private void backhand$handleOffhandSwing(S0BPacketAnimation packetIn, CallbackInfo ci, @Local Entity entity) {
if (!(entity instanceof IBackhandPlayer player)) return;
if (packetIn.func_148978_c() == 99) {
if (packetIn.func_148977_d() == 99) {
player.swingOffItem();
}
}
Expand Down

0 comments on commit 381541c

Please sign in to comment.