From 899f4969c145d680651074919a136ae057d3e5c9 Mon Sep 17 00:00:00 2001 From: BillyGalbreath Date: Sun, 11 Jun 2017 19:43:59 -0500 Subject: [PATCH] PlayerPickupItemEvent#setFlyAtPlayer (#683) * PlayerPickupItemEvent#setFlyAtPlayer --- ...PlayerPickupItemEvent-setFlyAtPlayer.patch | 54 +++++++++++++++++++ ...PlayerPickupItemEvent-setFlyAtPlayer.patch | 47 ++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 Spigot-API-Patches/PlayerPickupItemEvent-setFlyAtPlayer.patch create mode 100644 Spigot-Server-Patches/PlayerPickupItemEvent-setFlyAtPlayer.patch diff --git a/Spigot-API-Patches/PlayerPickupItemEvent-setFlyAtPlayer.patch b/Spigot-API-Patches/PlayerPickupItemEvent-setFlyAtPlayer.patch new file mode 100644 index 0000000000..ad9956d003 --- /dev/null +++ b/Spigot-API-Patches/PlayerPickupItemEvent-setFlyAtPlayer.patch @@ -0,0 +1,54 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: BillyGalbreath +Date: Sun, 7 May 2017 06:26:01 -0500 +Subject: [PATCH] PlayerPickupItemEvent#setFlyAtPlayer + + +diff --git a/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java b/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java +index dfba8163..fd97ea21 100644 +--- a/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java ++++ b/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java +@@ -0,0 +0,0 @@ import org.bukkit.event.HandlerList; + public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); + private final Item item; ++ private boolean flyAtPlayer = true; // Paper + private boolean cancel = false; + private final int remaining; + +@@ -0,0 +0,0 @@ public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable { + return remaining; + } + ++ // Paper Start ++ /** ++ * Set if the item will fly at the player ++ *

Cancelling the event will set this value to false.

++ * ++ * @param flyAtPlayer True for item to fly at player ++ */ ++ public void setFlyAtPlayer(boolean flyAtPlayer) { ++ this.flyAtPlayer = flyAtPlayer; ++ } ++ ++ /** ++ * Gets if the item will fly at the player ++ * ++ * @return True if the item will fly at the player ++ */ ++ public boolean getFlyAtPlayer() { ++ return flyAtPlayer; ++ } ++ // Paper End ++ + public boolean isCancelled() { + return cancel; + } + + public void setCancelled(boolean cancel) { + this.cancel = cancel; ++ this.flyAtPlayer = !cancel; // Paper + } + + @Override +-- \ No newline at end of file diff --git a/Spigot-Server-Patches/PlayerPickupItemEvent-setFlyAtPlayer.patch b/Spigot-Server-Patches/PlayerPickupItemEvent-setFlyAtPlayer.patch new file mode 100644 index 0000000000..9f3f76acc2 --- /dev/null +++ b/Spigot-Server-Patches/PlayerPickupItemEvent-setFlyAtPlayer.patch @@ -0,0 +1,47 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: BillyGalbreath +Date: Sun, 7 May 2017 06:26:09 -0500 +Subject: [PATCH] PlayerPickupItemEvent#setFlyAtPlayer + + +diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java +index 95ca1b8e..2dd27d1c 100644 +--- a/src/main/java/net/minecraft/server/EntityItem.java ++++ b/src/main/java/net/minecraft/server/EntityItem.java +@@ -0,0 +0,0 @@ public class EntityItem extends Entity implements HopperPusher { + // CraftBukkit start - fire PlayerPickupItemEvent + int canHold = entityhuman.inventory.canHold(itemstack); + int remaining = i - canHold; ++ boolean flyAtPlayer = false; // Paper + + if (this.pickupDelay <= 0 && canHold > 0) { + itemstack.setCount(canHold); +@@ -0,0 +0,0 @@ public class EntityItem extends Entity implements HopperPusher { + // event.setCancelled(!entityhuman.canPickUpLoot); TODO + this.world.getServer().getPluginManager().callEvent(event); + itemstack.setCount(canHold + remaining); ++ flyAtPlayer = event.getFlyAtPlayer(); // Paper + + if (event.isCancelled()) { ++ // Paper Start ++ if (flyAtPlayer) { ++ entityhuman.receive(this, i); ++ } ++ // Paper End + return; + } + +@@ -0,0 +0,0 @@ public class EntityItem extends Entity implements HopperPusher { + } + } + +- entityhuman.receive(this, i); ++ // Paper Start ++ if (flyAtPlayer) { ++ entityhuman.receive(this, i); ++ } ++ // Paper End + if (itemstack.isEmpty()) { + this.die(); + itemstack.setCount(i); +-- \ No newline at end of file