diff --git a/patches/api/Add-PlayerUseUnknownEntityEvent.patch b/patches/api/Add-PlayerUseUnknownEntityEvent.patch index 5f7142b179..c1f2d49c72 100644 --- a/patches/api/Add-PlayerUseUnknownEntityEvent.patch +++ b/patches/api/Add-PlayerUseUnknownEntityEvent.patch @@ -3,6 +3,10 @@ From: Jedediah Smith Date: Sat, 2 Apr 2016 05:08:36 -0400 Subject: [PATCH] Add PlayerUseUnknownEntityEvent +Adds the PlayerUseUnknownEntityEvent to be used by plugins dealing with +virtual entities/entities that are not actually known to the server. + +Co-authored-by: Nassim Jahnke diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerUseUnknownEntityEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerUseUnknownEntityEvent.java new file mode 100644 @@ -16,43 +20,79 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; +import org.bukkit.inventory.EquipmentSlot; ++import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; ++import org.jetbrains.annotations.Nullable; + ++/** ++ * Represents an event that is called when a player right-clicks an unknown entity. ++ * Useful for plugins dealing with virtual entities (entities that don't actually spawned on the server). ++ *
++ * This event may be called multiple times per interaction with different interaction hands ++ * and with or without the clicked position. ++ */ +public class PlayerUseUnknownEntityEvent extends PlayerEvent { + -+ private static final HandlerList handlers = new HandlerList(); ++ private static final HandlerList HANDLERS = new HandlerList(); + private final int entityId; + private final boolean attack; -+ @NotNull private final EquipmentSlot hand; ++ private final @NotNull EquipmentSlot hand; ++ private final @Nullable Vector clickedPosition; + -+ public PlayerUseUnknownEntityEvent(@NotNull Player who, int entityId, boolean attack, @NotNull EquipmentSlot hand) { ++ public PlayerUseUnknownEntityEvent(@NotNull Player who, int entityId, boolean attack, @NotNull EquipmentSlot hand, @Nullable Vector clickedPosition) { + super(who); + this.entityId = entityId; + this.attack = attack; + this.hand = hand; ++ this.clickedPosition = clickedPosition; + } + ++ /** ++ * Returns the entity id of the unknown entity that was interacted with. ++ * ++ * @return the entity id of the entity that was interacted with ++ */ + public int getEntityId() { + return this.entityId; + } + ++ /** ++ * Returns whether the interaction was an attack. ++ * ++ * @return true if the player is attacking the entity, false if the player is interacting with the entity ++ */ + public boolean isAttack() { + return this.attack; + } + -+ @NotNull -+ public EquipmentSlot getHand() { ++ /** ++ * Returns the hand used to perform this interaction. ++ * ++ * @return the hand used to interact ++ */ ++ public @NotNull EquipmentSlot getHand() { + return this.hand; + } + ++ /** ++ * Returns the position relative to the entity that was clicked, or null if not available. ++ * See {@link org.bukkit.event.player.PlayerInteractAtEntityEvent} for more details. ++ * ++ * @return the position relative to the entity that was clicked, or null if not available ++ * @see org.bukkit.event.player.PlayerInteractAtEntityEvent ++ */ ++ public @Nullable Vector getClickedRelativePosition() { ++ return clickedPosition.clone(); ++ } ++ + @NotNull + @Override + public HandlerList getHandlers() { -+ return handlers; ++ return HANDLERS; + } + + @NotNull + public static HandlerList getHandlerList() { -+ return handlers; ++ return HANDLERS; + } +} diff --git a/patches/server/Add-PlayerUseUnknownEntityEvent.patch b/patches/server/Add-PlayerUseUnknownEntityEvent.patch index 5c15202c7d..0c9fc55745 100644 --- a/patches/server/Add-PlayerUseUnknownEntityEvent.patch +++ b/patches/server/Add-PlayerUseUnknownEntityEvent.patch @@ -3,24 +3,30 @@ From: Jedediah Smith Date: Sat, 2 Apr 2016 05:09:16 -0400 Subject: [PATCH] Add PlayerUseUnknownEntityEvent -== AT == -public net.minecraft.network.protocol.game.ServerboundInteractPacket$ActionType +Adds the PlayerUseUnknownEntityEvent to be used by plugins dealing with +virtual entities/entities that are not actually known to the server. + +Co-authored-by: Nassim Jahnke 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 { -- 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 ServerboundInteractPacket.Action action; public final ServerboundInteractPacket.ActionType getActionType() { return this.action.getType(); } // Paper - add accessor - private final boolean usingSecondaryAction; - static final ServerboundInteractPacket.Action ATTACK_ACTION = new ServerboundInteractPacket.Action() { - @Override +@@ -0,0 +0,0 @@ public class ServerboundInteractPacket implements Packet