Paper/Spigot-Server-Patches/0100-Add-PlayerUseUnknownEntityEvent.patch
2017-09-18 12:04:01 +01:00

44 lines
1.8 KiB
Diff

From c2f58a2ac9c540c526780ff1af9fb6ae849276b3 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/server/PacketPlayInUseEntity.java b/src/main/java/net/minecraft/server/PacketPlayInUseEntity.java
index c67cb54a3..521f46262 100644
--- a/src/main/java/net/minecraft/server/PacketPlayInUseEntity.java
+++ b/src/main/java/net/minecraft/server/PacketPlayInUseEntity.java
@@ -5,7 +5,7 @@ import javax.annotation.Nullable;
public class PacketPlayInUseEntity implements Packet<PacketListenerPlayIn> {
- private int a;
+ private int a; public int getEntityId() { return this.a; } // Paper - add accessor
private PacketPlayInUseEntity.EnumEntityUseAction action;
private Vec3D c;
private EnumHand d;
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 7a721ffc6..4830dd581 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -1652,6 +1652,16 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
}
}
}
+ // Paper start - fire event
+ else {
+ this.server.getPluginManager().callEvent(new com.destroystokyo.paper.event.player.PlayerUseUnknownEntityEvent(
+ this.getPlayer(),
+ packetplayinuseentity.getEntityId(),
+ packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.ATTACK,
+ packetplayinuseentity.b() == EnumHand.MAIN_HAND ? EquipmentSlot.HAND : EquipmentSlot.OFF_HAND
+ ));
+ }
+ // Paper end
}
--
2.14.1