Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-16 21:10:17 +01:00
Fixed cancelling the PlayerPickup event, getAmount(), item duping issue.
Dieser Commit ist enthalten in:
Ursprung
b4c0492b15
Commit
f0402d9d6c
@ -127,16 +127,20 @@ 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)) { // <-- == to <=
|
if (this.pickupDelay <= 0 && entityhuman.inventory.canPickup(this.itemStack) > 0) {
|
||||||
Player player = (Player) entityhuman.getBukkitEntity();
|
PlayerPickupItemEvent event = new PlayerPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity());
|
||||||
PlayerPickupItemEvent event = new PlayerPickupItemEvent(player, (org.bukkit.entity.Item) this.getBukkitEntity());
|
this.world.getServer().getPluginManager().callEvent(event);
|
||||||
world.getServer().getPluginManager().callEvent(event);
|
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Possibly < 0; fix here so we do not have to modify code below
|
||||||
|
this.pickupDelay = 0;
|
||||||
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
|
if (this.pickupDelay == 0 && entityhuman.inventory.canHold(this.itemStack)) {
|
||||||
if (this.itemStack.id == Block.LOG.id) {
|
if (this.itemStack.id == Block.LOG.id) {
|
||||||
entityhuman.a((Statistic) AchievementList.g);
|
entityhuman.a((Statistic) AchievementList.g);
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,22 @@ public class InventoryPlayer implements IInventory {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CraftBukkit start - watch method above! :D
|
||||||
|
public int canPickup(ItemStack itemstack) {
|
||||||
|
int remains = itemstack.count;
|
||||||
|
for (int i = 0; i < this.items.length; ++i) {
|
||||||
|
if (this.items[i] == null) return itemstack.count;
|
||||||
|
|
||||||
|
// Taken from d(ItemStack)I
|
||||||
|
if (this.items[i] != null && this.items[i].id == itemstack.id && this.items[i].c() && this.items[i].count < this.items[i].b() && this.items[i].count < this.getMaxStackSize() && (!this.items[i].e() || this.items[i].getData() == itemstack.getData())) {
|
||||||
|
remains -= (this.items[i].b() < this.getMaxStackSize() ? this.items[i].b() : this.getMaxStackSize()) - this.items[i].count;
|
||||||
|
}
|
||||||
|
if (remains <= 0) return itemstack.count;
|
||||||
|
}
|
||||||
|
return itemstack.count - remains;
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
private int k() {
|
private int k() {
|
||||||
for (int i = 0; i < this.items.length; ++i) {
|
for (int i = 0; i < this.items.length; ++i) {
|
||||||
if (this.items[i] == null) {
|
if (this.items[i] == null) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren