3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-16 21:10:17 +01:00

[Bleeding] Fixed item duping in certain occasions. Fixes BUKKIT-1310

Dieser Commit ist enthalten in:
feildmaster 2012-03-25 17:53:59 -05:00 committet von Warren Loo
Ursprung 0c9b59e071
Commit c30e339af6
3 geänderte Dateien mit 9 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -164,7 +164,7 @@ public class Block {
public final Material material;
public float frictionFactor;
private String name;
protected ArrayList<ItemStack> dropList = new ArrayList<ItemStack>(); // CraftBukkit
public ArrayList<ItemStack> dropList = new ArrayList<ItemStack>(1); // CraftBukkit
protected Block(int i, Material material) {
this.bR = true;
@ -338,6 +338,7 @@ public class Block {
}
public final void b(World world, int i, int j, int k, int l, int i1) {
this.dropList.clear(); // CraftBukkit
this.dropNaturally(world, i, j, k, l, 1.0F, i1);
this.doActualDrop(world, i, j, k); // CraftBukkit
}
@ -549,10 +550,6 @@ public class Block {
this.dropList.clear();
}
public void setDrops(ArrayList<ItemStack> drops) {
this.dropList = drops;
}
public ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
// CraftBukkit end
if (this.h() && EnchantmentManager.hasSilkTouchEnchantment(entityhuman.inventory)) {

Datei anzeigen

@ -300,9 +300,8 @@ public class BlockVine extends Block {
// CraftBukkit start - Calculate drops
public ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
if (!world.isStatic && entityhuman.U() != null && entityhuman.U().id == Item.SHEARS.id) {
super.dropList = new ArrayList<ItemStack>();
this.a(world, i, j, k, new ItemStack(Block.VINE, 1, 0));
return super.dropList;
return this.dropList;
} else {
return super.calculateDrops(world, entityhuman, i, j, k, l);
}

Datei anzeigen

@ -528,9 +528,10 @@ public class CraftEventFactory {
((EntityPlayer) player).netServerHandler.sendPacket(packet);
}
List<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>();
List<ItemStack> calculatedDrops = blockType.calculateDrops(world, player, x, y, z, data);
List<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>(calculatedDrops.size());
if (!creative && player.b(blockType)) {
for (ItemStack stack : blockType.calculateDrops(world, player, x, y, z, data)) {
for (ItemStack stack : calculatedDrops) {
drops.add(new CraftItemStack(stack));
}
}
@ -539,17 +540,17 @@ public class CraftEventFactory {
world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
blockType.setDrops(new ArrayList<ItemStack>());
blockType.dropList.clear();
// Let the client know the block still exists
((EntityPlayer) player).netServerHandler.sendPacket(new Packet53BlockChange(x, y, z, world));
return true;
}
ArrayList<ItemStack> toDrop = new ArrayList<ItemStack>();
ArrayList<ItemStack> toDrop = new ArrayList<ItemStack>(drops.size());
for (org.bukkit.inventory.ItemStack stack : drops) {
toDrop.add(CraftItemStack.createNMSItemStack(stack));
}
blockType.setDrops(toDrop);
blockType.dropList = toDrop;
return false; // Event not cancelled
}