PaperMC/patches/server/Add-PlayerUseUnknownEntityEvent.patch
Jason Penilla 961d6d7dac patches
2021-06-11 20:07:57 -07:00

40 lines
2.2 KiB
Diff

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
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ServerboundInteractPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundInteractPacket.java
@@ -0,0 +0,0 @@ import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.Vec3;
public class ServerboundInteractPacket implements Packet<ServerGamePacketListener> {
- 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() {
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
--- a/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
}
}
}
+ // 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
}