2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Jedediah Smith <jedediah@silencegreys.com>
|
|
|
|
Date: Sat, 2 Apr 2016 05:09:16 -0400
|
|
|
|
Subject: [PATCH] Add PlayerUseUnknownEntityEvent
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundInteractPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundInteractPacket.java
|
2021-06-12 05:07:57 +02:00
|
|
|
index 1b316ecf2d8725b9c91a4869e6c2362c1443160d..964101d314f182574efba09bfe3907fbbf97fb13 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/network/protocol/game/ServerboundInteractPacket.java
|
|
|
|
+++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundInteractPacket.java
|
2021-06-12 05:07:57 +02:00
|
|
|
@@ -10,7 +10,7 @@ import net.minecraft.world.entity.Entity;
|
|
|
|
import net.minecraft.world.phys.Vec3;
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
public class ServerboundInteractPacket implements Packet<ServerGamePacketListener> {
|
2021-06-12 05:07:57 +02:00
|
|
|
- private final int entityId;
|
|
|
|
+ private final int entityId; public final int getEntityId() { return this.entityId; } // Paper - add accessor
|
|
|
|
private final ServerboundInteractPacket.Action action;
|
|
|
|
private final boolean usingSecondaryAction;
|
|
|
|
static final ServerboundInteractPacket.Action ATTACK_ACTION = new ServerboundInteractPacket.Action() {
|
2021-06-11 14:02:28 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2021-06-12 05:07:57 +02:00
|
|
|
index 714fb0d766b654ad05134dea9b1e1b628a939993..c8f17466fe4ccfd8fa727e15281d015c2de2aaee 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2021-06-12 05:07:57 +02:00
|
|
|
@@ -1630,6 +1630,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+ // Paper start - fire event
|
|
|
|
+ else {
|
|
|
|
+ this.craftServer.getPluginManager().callEvent(new com.destroystokyo.paper.event.player.PlayerUseUnknownEntityEvent(
|
|
|
|
+ this.getPlayer(),
|
|
|
|
+ packet.getEntityId(),
|
|
|
|
+ packet.getAction() == ServerboundInteractPacket.Action.ATTACK,
|
|
|
|
+ packet.getHand() == InteractionHand.MAIN_HAND ? EquipmentSlot.HAND : EquipmentSlot.OFF_HAND
|
|
|
|
+ ));
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
|
|
|
|
}
|
|
|
|
|