[Bleeding] Added getting and setting drops to all appropriate events. Fixes BUKKIT-397 and fixes BUKKIT-1252

- Allows drops in creative mode by adding items to the getDrops() list
- Contents of containers are not reported
- Contents of storage minecarts are not reported
This commit is contained in:
Celtic Minstrel
2012-03-05 14:21:43 -05:00
committed by EvilSeph
parent 8d62de7055
commit 5ba8928041
20 changed files with 344 additions and 60 deletions

View File

@@ -13,9 +13,28 @@ public class BlockPistonExtension extends Block {
this.c(0.5F);
}
// CraftBukkit start - Support getDrops() in BlockBreakEvent
public ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int d) {
super.calculateDrops(world, entityhuman, i, j, k, d);
int l = world.getData(i, j, k) & 0x7;
if (l > 5 || l < 0) return super.dropList;
int i1 = Facing.OPPOSITE_FACING[b(l)];
i += Facing.b[i1];
j += Facing.c[i1];
k += Facing.d[i1];
int j1 = world.getTypeId(i, j, k);
if (j1 == Block.PISTON.id || j1 == Block.PISTON_STICKY.id) {
super.dropList.add(new ItemStack(Block.byId[j1], 1));
}
return super.dropList;
}
// CraftBukkit end
public void remove(World world, int i, int j, int k) {
super.remove(world, i, j, k);
int l = world.getData(i, j, k);
int l = world.getData(i, j, k) & 0x7;
if (l > 5 || l < 0) return; // CraftBukkit - fixed a piston AIOOBE issue.
int i1 = Facing.OPPOSITE_FACING[b(l)];
@@ -27,7 +46,7 @@ public class BlockPistonExtension extends Block {
if (j1 == Block.PISTON.id || j1 == Block.PISTON_STICKY.id) {
l = world.getData(i, j, k);
if (BlockPiston.e(l)) {
Block.byId[j1].b(world, i, j, k, l, 0);
//Block.byId[j1].b(world, i, j, k, l, 0); // CraftBukkit - drop moved into drop list
world.setTypeId(i, j, k, 0);
}
}