[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

@@ -1,5 +1,6 @@
package net.minecraft.server;
import java.util.ArrayList; // CraftBukkit
import java.util.Random;
import org.bukkit.craftbukkit.event.CraftEventFactory;
@@ -54,19 +55,32 @@ public class BlockSnow extends Block {
}
public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
/* CraftBukkit start - This logic is exactly the same as in the superclass method, so defer it there
int i1 = Item.SNOW_BALL.id;
float f = 0.7F;
double d0 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
double d1 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
double d2 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
EntityItem entityitem = new EntityItem(world, (double) i + d0, (double) j + d1, (double) k + d2, new ItemStack(i1, 1, 0));
// This is done so that getDrops() in the BlockBreakEvent works properly.
entityitem.pickupDelay = 10;
world.addEntity(entityitem);
// */
super.doActualDrop(world, entityhuman, i, j, k, l);
// CraftBukkit end
world.setTypeId(i, j, k, 0);
entityhuman.a(StatisticList.C[this.id], 1);
}
// CraftBukkit start - Calculate drops
public ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
super.dropList = new ArrayList<ItemStack>();
this.a(world, i, j, k, new ItemStack(Item.SNOW_BALL.id, 1, 1));
return super.dropList;
}
// CraftBukkit end
public int getDropType(int i, Random random, int j) {
return Item.SNOW_BALL.id;
}