Fixed PlayerPickupItem event returning wrong amount picked up and added function to get the amount remaining on the ground.

Dieser Commit ist enthalten in:
EvilSeph 2011-07-02 14:05:31 -04:00
Ursprung 22097a9962
Commit f7e17b68de
2 geänderte Dateien mit 7 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -292,7 +292,7 @@ public class EntityArrow extends Entity {
if (this.inGround && this.fromPlayer && this.shake <= 0 && entityhuman.inventory.canHold(itemstack) > 0) { if (this.inGround && this.fromPlayer && this.shake <= 0 && entityhuman.inventory.canHold(itemstack) > 0) {
net.minecraft.server.EntityItem item = new net.minecraft.server.EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack); net.minecraft.server.EntityItem item = new net.minecraft.server.EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack);
PlayerPickupItemEvent event = new PlayerPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.world.getServer(), item)); PlayerPickupItemEvent event = new PlayerPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.world.getServer(), item), 0);
this.world.getServer().getPluginManager().callEvent(event); this.world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {

Datei anzeigen

@ -124,9 +124,13 @@ public class EntityItem extends Entity {
int i = this.itemStack.count; int i = this.itemStack.count;
// CraftBukkit start // CraftBukkit start
if (this.pickupDelay <= 0 && entityhuman.inventory.canHold(this.itemStack) > 0) { int canHold = entityhuman.inventory.canHold(this.itemStack);
PlayerPickupItemEvent event = new PlayerPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity()); int remaining = this.itemStack.count - canHold;
if (this.pickupDelay <= 0 && canHold > 0) {
this.itemStack.count = canHold;
PlayerPickupItemEvent event = new PlayerPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining);
this.world.getServer().getPluginManager().callEvent(event); this.world.getServer().getPluginManager().callEvent(event);
this.itemStack.count = canHold + remaining;
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;