mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
fix PlayerUseUnknownEntityEvent patch (#5800)
This commit is contained in:
parent
961d6d7dac
commit
f1f57bd8e5
@ -13,28 +13,60 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
|
|
||||||
public class ServerboundInteractPacket implements Packet<ServerGamePacketListener> {
|
public class ServerboundInteractPacket implements Packet<ServerGamePacketListener> {
|
||||||
- private final int entityId;
|
- private final int entityId;
|
||||||
|
- private final ServerboundInteractPacket.Action action;
|
||||||
+ private final int entityId; public final int getEntityId() { return this.entityId; } // Paper - add accessor
|
+ private final int entityId; public final int getEntityId() { return this.entityId; } // Paper - add accessor
|
||||||
private final ServerboundInteractPacket.Action action;
|
+ private final ServerboundInteractPacket.Action action; public final ServerboundInteractPacket.ActionType getActionType() { return this.action.getType(); } // Paper - add accessor
|
||||||
private final boolean usingSecondaryAction;
|
private final boolean usingSecondaryAction;
|
||||||
static final ServerboundInteractPacket.Action ATTACK_ACTION = new ServerboundInteractPacket.Action() {
|
static final ServerboundInteractPacket.Action ATTACK_ACTION = new ServerboundInteractPacket.Action() {
|
||||||
|
@Override
|
||||||
|
@@ -0,0 +0,0 @@ public class ServerboundInteractPacket implements Packet<ServerGamePacketListene
|
||||||
|
void write(FriendlyByteBuf buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
- static enum ActionType {
|
||||||
|
+ public static enum ActionType { // Paper - package-private -> public
|
||||||
|
INTERACT(ServerboundInteractPacket.InteractionAction::new),
|
||||||
|
ATTACK((friendlyByteBuf) -> {
|
||||||
|
return ServerboundInteractPacket.ATTACK_ACTION;
|
||||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+ // Paper start - fire event
|
+ // Paper start - fire event
|
||||||
+ else {
|
+ else {
|
||||||
+ this.craftServer.getPluginManager().callEvent(new com.destroystokyo.paper.event.player.PlayerUseUnknownEntityEvent(
|
+ packet.dispatch(new net.minecraft.network.protocol.game.ServerboundInteractPacket.Handler() {
|
||||||
+ this.getPlayer(),
|
+ @Override
|
||||||
+ packet.getEntityId(),
|
+ public void onInteraction(net.minecraft.world.InteractionHand hand) {
|
||||||
+ packet.getAction() == ServerboundInteractPacket.Action.ATTACK,
|
+ ServerGamePacketListenerImpl.this.callPlayerUseUnknownEntityEvent(packet, hand);
|
||||||
+ packet.getHand() == InteractionHand.MAIN_HAND ? EquipmentSlot.HAND : EquipmentSlot.OFF_HAND
|
+ }
|
||||||
+ ));
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void onInteraction(net.minecraft.world.InteractionHand hand, net.minecraft.world.phys.Vec3 pos) {
|
||||||
|
+ ServerGamePacketListenerImpl.this.callPlayerUseUnknownEntityEvent(packet, hand);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void onAttack() {
|
||||||
|
+ ServerGamePacketListenerImpl.this.callPlayerUseUnknownEntityEvent(packet, net.minecraft.world.InteractionHand.MAIN_HAND);
|
||||||
|
+ }
|
||||||
|
+ });
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+
|
||||||
|
+ }
|
||||||
|
|
||||||
|
+ private void callPlayerUseUnknownEntityEvent(ServerboundInteractPacket packet, InteractionHand hand) {
|
||||||
|
+ this.cserver.getPluginManager().callEvent(new com.destroystokyo.paper.event.player.PlayerUseUnknownEntityEvent(
|
||||||
|
+ this.getCraftPlayer(),
|
||||||
|
+ packet.getEntityId(),
|
||||||
|
+ packet.getActionType() == ServerboundInteractPacket.ActionType.ATTACK,
|
||||||
|
+ hand == InteractionHand.MAIN_HAND ? EquipmentSlot.HAND : EquipmentSlot.OFF_HAND
|
||||||
|
+ ));
|
||||||
}
|
}
|
||||||
|
+ // Paper end
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleClientCommand(ServerboundClientCommandPacket packet) {
|
||||||
|
Loading…
Reference in New Issue
Block a user