Reverting the Drop API for now, we need to re-evalute this as it is causing too many issues and blocking releases.

This reverts commits:
- d2d03afc8854394aeefb40ea5ebf224c8032b19f
- 6245746e91123dd8ef70e5f15b7cdfc7e36d8e8c
- 41fae5c613e9e69a8f6bdf33b23bb09d7f407433
- c34bdecab42cf4098054a5ea43e1c2958d44ae92
- d7445084ac9a90fa0b66d8b050b8d0d2a062eaf3
- 6a6ed2e6ae2328a8a791bcc6857c44dc6c6a7030
- a783bc4dc95da8e26c673abe48fad96b550aba28
- cb50fd68766df8e07631ba5be85759f8257e8068
- 34dfff2ad5c407c712b2783f02960aac5e8649f2
- f33b513820de987b49a4338e85df80968217a601
- 5fd9fdfde055e6eb6a83db246d009b69377b7c94
- 2795b116f40d06551fbb7b96d1963c0ddbeac384
Dieser Commit ist enthalten in:
Warren Loo 2012-03-27 11:37:00 -04:00
Ursprung c16bf07e85
Commit c100e20d60
23 geänderte Dateien mit 65 neuen und 901 gelöschten Zeilen

Datei anzeigen

@ -164,7 +164,6 @@ public class Block {
public final Material material;
public float frictionFactor;
private String name;
public final ArrayList<ItemStack> dropList = new ArrayList<ItemStack>(1); // CraftBukkit
protected Block(int i, Material material) {
this.bR = true;
@ -338,9 +337,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
}
public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) {
@ -361,13 +358,6 @@ public class Block {
}
protected void a(World world, int i, int j, int k, ItemStack itemstack) {
// CraftBukkit start - the logic of this function is moved into finishDrop
// This is such a hackish change it's ridiculous.
this.dropList.add(itemstack);
}
public final void finishDrop(World world, int i, int j, int k, ItemStack itemstack) {
// CraftBukkit end
if (!world.isStatic) {
float f = 0.7F;
double d0 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
@ -539,20 +529,7 @@ public class Block {
public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
entityhuman.a(StatisticList.C[this.id], 1);
entityhuman.c(0.025F);
// CraftBukkit start - A way to separate statistics from the logic of determining what to drop
this.doActualDrop(world, i, j, k);
}
public void doActualDrop(World world, int i, int j, int k) {
for (ItemStack stack : this.dropList) {
finishDrop(world, i, j, k, stack);
}
this.dropList.clear();
}
// Blocks that have different drops in certain situations need to override this. IE: Sheers on BlockLeaves
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)) {
ItemStack itemstack = this.a_(l);
@ -562,10 +539,8 @@ public class Block {
} else {
int i1 = EnchantmentManager.getBonusBlockLootEnchantmentLevel(entityhuman.inventory);
this.dropNaturally(world, i, j, k, l, 1.0F, i1); // CraftBukkit
this.b(world, i, j, k, l, i1);
}
return this.dropList;
}
protected boolean h() {

Datei anzeigen

@ -1,203 +0,0 @@
package net.minecraft.server;
import java.util.Iterator;
import java.util.Random;
public class BlockBed extends BlockDirectional {
public static final int[][] a = new int[][] { { 0, 1}, { -1, 0}, { 0, -1}, { 1, 0}};
public BlockBed(int i) {
super(i, 134, Material.CLOTH);
this.t();
}
public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {
if (world.isStatic) {
return true;
} else {
int l = world.getData(i, j, k);
if (!d(l)) {
int i1 = b(l);
i += a[i1][0];
k += a[i1][1];
if (world.getTypeId(i, j, k) != this.id) {
return true;
}
l = world.getData(i, j, k);
}
if (!world.worldProvider.c()) {
double d0 = (double) i + 0.5D;
double d1 = (double) j + 0.5D;
double d2 = (double) k + 0.5D;
world.setTypeId(i, j, k, 0);
int j1 = b(l);
i += a[j1][0];
k += a[j1][1];
if (world.getTypeId(i, j, k) == this.id) {
world.setTypeId(i, j, k, 0);
d0 = (d0 + (double) i + 0.5D) / 2.0D;
d1 = (d1 + (double) j + 0.5D) / 2.0D;
d2 = (d2 + (double) k + 0.5D) / 2.0D;
}
world.createExplosion((Entity) null, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), 5.0F, true);
return true;
} else {
if (e(l)) {
EntityHuman entityhuman1 = null;
Iterator iterator = world.players.iterator();
while (iterator.hasNext()) {
EntityHuman entityhuman2 = (EntityHuman) iterator.next();
if (entityhuman2.isSleeping()) {
ChunkCoordinates chunkcoordinates = entityhuman2.F;
if (chunkcoordinates.x == i && chunkcoordinates.y == j && chunkcoordinates.z == k) {
entityhuman1 = entityhuman2;
}
}
}
if (entityhuman1 != null) {
entityhuman.a("tile.bed.occupied");
return true;
}
a(world, i, j, k, false);
}
EnumBedResult enumbedresult = entityhuman.a(i, j, k);
if (enumbedresult == EnumBedResult.OK) {
a(world, i, j, k, true);
return true;
} else {
if (enumbedresult == EnumBedResult.NOT_POSSIBLE_NOW) {
entityhuman.a("tile.bed.noSleep");
} else if (enumbedresult == EnumBedResult.NOT_SAFE) {
entityhuman.a("tile.bed.notSafe");
}
return true;
}
}
}
}
public int a(int i, int j) {
if (i == 0) {
return Block.WOOD.textureId;
} else {
int k = b(j);
int l = Direction.h[k][i];
return d(j) ? (l == 2 ? this.textureId + 2 + 16 : (l != 5 && l != 4 ? this.textureId + 1 : this.textureId + 1 + 16)) : (l == 3 ? this.textureId - 1 + 16 : (l != 5 && l != 4 ? this.textureId : this.textureId + 16));
}
}
public int c() {
return 14;
}
public boolean b() {
return false;
}
public boolean a() {
return false;
}
public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) {
this.t();
}
public void doPhysics(World world, int i, int j, int k, int l) {
int i1 = world.getData(i, j, k);
int j1 = b(i1);
if (d(i1)) {
if (world.getTypeId(i - a[j1][0], j, k - a[j1][1]) != this.id) {
world.setTypeId(i, j, k, 0);
}
} else if (world.getTypeId(i + a[j1][0], j, k + a[j1][1]) != this.id) {
world.setTypeId(i, j, k, 0);
/* CraftBukkit - Move this to on break instead of on physics
if (!world.isStatic) {
this.b(world, i, j, k, i1, 0);
}
// */
}
}
public int getDropType(int i, Random random, int j) {
return /* d(i) ? 0 CraftBukkit : */ Item.BED.id;
}
private void t() {
this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.5625F, 1.0F);
}
public static boolean d(int i) {
return (i & 8) != 0;
}
public static boolean e(int i) {
return (i & 4) != 0;
}
public static void a(World world, int i, int j, int k, boolean flag) {
int l = world.getData(i, j, k);
if (flag) {
l |= 4;
} else {
l &= -5;
}
world.setData(i, j, k, l);
}
public static ChunkCoordinates f(World world, int i, int j, int k, int l) {
int i1 = world.getData(i, j, k);
int j1 = BlockDirectional.b(i1);
for (int k1 = 0; k1 <= 1; ++k1) {
int l1 = i - a[j1][0] * k1 - 1;
int i2 = k - a[j1][1] * k1 - 1;
int j2 = l1 + 2;
int k2 = i2 + 2;
for (int l2 = l1; l2 <= j2; ++l2) {
for (int i3 = i2; i3 <= k2; ++i3) {
if (world.e(l2, j - 1, i3) && world.isEmpty(l2, j, i3) && world.isEmpty(l2, j + 1, i3)) {
if (l <= 0) {
return new ChunkCoordinates(l2, j, i3);
}
--l;
}
}
}
}
return null;
}
public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) {
//if (!d(l)) { // CraftBukkit
super.dropNaturally(world, i, j, k, l, f, 0);
// } // CraftBukkit
}
public int g() {
return 1;
}
}

Datei anzeigen

@ -96,7 +96,6 @@ public class BlockCrops extends BlockFlower {
for (int k1 = 0; k1 < j1; ++k1) {
if (world.random.nextInt(15) <= l) {
/* CraftBukkit start - Identical logic to superclass method; defer to that method
float f1 = 0.7F;
float f2 = world.random.nextFloat() * f1 + (1.0F - f1) * 0.5F;
float f3 = world.random.nextFloat() * f1 + (1.0F - f1) * 0.5F;
@ -105,8 +104,6 @@ public class BlockCrops extends BlockFlower {
entityitem.pickupDelay = 10;
world.addEntity(entityitem);
// */
this.a(world, i, j, k, new ItemStack(Item.SEEDS));
}
}
}

Datei anzeigen

@ -1,49 +0,0 @@
package net.minecraft.server;
import java.util.Random;
public class BlockDeadBush extends BlockFlower {
protected BlockDeadBush(int i, int j) {
super(i, j, Material.REPLACEABLE_PLANT);
float f = 0.4F;
this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.8F, 0.5F + f);
}
protected boolean d(int i) {
return i == Block.SAND.id;
}
public int a(int i, int j) {
return this.textureId;
}
public int getDropType(int i, Random random, int j) {
return -1;
}
public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
if (!world.isStatic && entityhuman.U() != null && entityhuman.U().id == Item.SHEARS.id) {
entityhuman.a(StatisticList.C[this.id], 1);
/* CraftBukkit start - moved this line into calculateDrops
this.a(world, i, j, k, new ItemStack(Block.DEAD_BUSH, 1, l));
*/
this.doActualDrop(world, i, j, k);
// CraftBukkit end
} else {
super.a(world, entityhuman, i, j, k, l);
}
}
// CraftBukkit start - Calculate drops
public java.util.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) {
this.a(world, i, j, k, new ItemStack(Block.DEAD_BUSH, 1, l));
} else {
return super.calculateDrops(world, entityhuman, i, j, k, l);
}
return this.dropList;
}
// CraftBukkit end
}

Datei anzeigen

@ -157,7 +157,7 @@ public class BlockDoor extends Block {
if (world.getTypeId(i, j + 1, k) != this.id) {
world.setTypeId(i, j, k, 0);
//flag = true; // CraftBukkit
flag = true;
}
if (!world.e(i, j - 1, k)) {
@ -172,6 +172,7 @@ public class BlockDoor extends Block {
if (!world.isStatic) {
this.b(world, i, j, k, i1, 0);
}
// CraftBukkit start
} else if (l > 0 && Block.byId[l].isPowerSource()) {
org.bukkit.World bworld = world.getWorld();
org.bukkit.block.Block block = bworld.getBlockAt(i, j, k);
@ -194,7 +195,7 @@ public class BlockDoor extends Block {
}
public int getDropType(int i, Random random, int j) {
return /* (i & 8) != 0 ? 0 CraftBukkit : */ (this.material == Material.ORE ? Item.IRON_DOOR.id : Item.WOOD_DOOR.id);
return (i & 8) != 0 ? 0 : (this.material == Material.ORE ? Item.IRON_DOOR.id : Item.WOOD_DOOR.id);
}
public MovingObjectPosition a(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) {

Datei anzeigen

@ -161,27 +161,12 @@ public class BlockLeaves extends BlockTransparant {
public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
if (!world.isStatic && entityhuman.U() != null && entityhuman.U().id == Item.SHEARS.id) {
entityhuman.a(StatisticList.C[this.id], 1);
/* CraftBukkit start - moved this line into calculateDrops
this.a(world, i, j, k, new ItemStack(Block.LEAVES.id, 1, l & 3));
*/
this.doActualDrop(world, i, j, k);
// CraftBukkit end
} else {
super.a(world, entityhuman, i, j, k, l);
}
}
// CraftBukkit start - Calculate drops
public java.util.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) {
this.a(world, i, j, k, new ItemStack(Block.LEAVES.id, 1, l & 3));
} else {
return super.calculateDrops(world, entityhuman, i, j, k, l);
}
return this.dropList;
}
// CraftBukkit end
protected int getDropData(int i) {
return i & 3;
}

Datei anzeigen

@ -1,49 +0,0 @@
package net.minecraft.server;
import java.util.Random;
public class BlockLongGrass extends BlockFlower {
protected BlockLongGrass(int i, int j) {
super(i, j, Material.REPLACEABLE_PLANT);
float f = 0.4F;
this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.8F, 0.5F + f);
}
public int a(int i, int j) {
return j == 1 ? this.textureId : (j == 2 ? this.textureId + 16 + 1 : (j == 0 ? this.textureId + 16 : this.textureId));
}
public int getDropType(int i, Random random, int j) {
return random.nextInt(8) == 0 ? Item.SEEDS.id : -1;
}
public int getDropCount(int i, Random random) {
return 1 + random.nextInt(i * 2 + 1);
}
public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
if (!world.isStatic && entityhuman.U() != null && entityhuman.U().id == Item.SHEARS.id) {
entityhuman.a(StatisticList.C[this.id], 1);
/* CraftBukkit start - moved this line into calculateDrops
this.a(world, i, j, k, new ItemStack(Block.LONG_GRASS, 1, l));
*/
this.doActualDrop(world, i, j, k);
// CraftBukkit end
} else {
super.a(world, entityhuman, i, j, k, l);
}
}
// CraftBukkit start - Calculate drops
public java.util.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) {
this.a(world, i, j, k, new ItemStack(Block.LONG_GRASS, 1, l));
} else {
return super.calculateDrops(world, entityhuman, i, j, k, l);
}
return this.dropList;
}
// CraftBukkit end
}

Datei anzeigen

@ -13,28 +13,9 @@ public class BlockPistonExtension extends Block {
this.c(0.5F);
}
// CraftBukkit start - Support getDrops() in BlockBreakEvent
public java.util.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 this.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) {
this.dropList.add(new ItemStack(Block.byId[j1], 1));
}
return this.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) & 0x7;
int l = world.getData(i, j, k);
if (l > 5 || l < 0) return; // CraftBukkit - fixed a piston AIOOBE issue.
int i1 = Facing.OPPOSITE_FACING[b(l)];
@ -46,7 +27,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); // CraftBukkit - drop moved into drop list
Block.byId[j1].b(world, i, j, k, l, 0);
world.setTypeId(i, j, k, 0);
}
}

Datei anzeigen

@ -46,7 +46,7 @@ public class BlockSnow extends Block {
if (!this.canPlace(world, i, j, k)) {
this.b(world, i, j, k, world.getData(i, j, k), 0);
world.setRawTypeId(i, j, k, 0); // CraftBukkit
world.notify(i, j, k); // CraftBukkit - Notfiy clients of the reversion
world.notify(i, j, k); // CraftBukkit - Notify clients of the reversion
return false;
} else {
return true;
@ -54,31 +54,19 @@ 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);
*/
this.doActualDrop(world, i, j, k);
// CraftBukkit end
world.setTypeId(i, j, k, 0);
entityhuman.a(StatisticList.C[this.id], 1);
}
// CraftBukkit start - Calculate drops
public java.util.ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
this.a(world, i, j, k, new ItemStack(Item.SNOW_BALL.id, 1, 0));
return this.dropList;
}
// CraftBukkit end
public int getDropType(int i, Random random, int j) {
return Item.SNOW_BALL.id;
}

Datei anzeigen

@ -158,7 +158,6 @@ public class BlockStem extends BlockFlower {
for (int j1 = 0; j1 < 3; ++j1) {
if (world.random.nextInt(15) <= l) {
/* CraftBukkit - Identical logic to superclass method; defer there
float f1 = 0.7F;
float f2 = world.random.nextFloat() * f1 + (1.0F - f1) * 0.5F;
float f3 = world.random.nextFloat() * f1 + (1.0F - f1) * 0.5F;
@ -167,8 +166,6 @@ public class BlockStem extends BlockFlower {
entityitem.pickupDelay = 10;
world.addEntity(entityitem);
// */
this.a(world, i, j, k, new ItemStack(item));
}
}
}

Datei anzeigen

@ -43,9 +43,7 @@ public class BlockTNT extends Block {
public void postBreak(World world, int i, int j, int k, int l) {
if (!world.isStatic) {
if ((l & 1) == 0) {
/* CraftBukkit - Move this earlier so the block break event can see it
this.a(world, i, j, k, new ItemStack(Block.TNT.id, 1, 0));
*/
} else {
EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F));
@ -55,15 +53,6 @@ public class BlockTNT extends Block {
}
}
// CraftBukkit start - Calculate drops
public java.util.ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
if ((l & 1) == 0) {
this.a(world, i, j, k, new ItemStack(Block.TNT.id, 1, 0));
}
return this.dropList;
}
// CraftBukkit end
public void attack(World world, int i, int j, int k, EntityHuman entityhuman) {
if (entityhuman.U() != null && entityhuman.U().id == Item.FLINT_AND_STEEL.id) {
world.setRawData(i, j, k, 1);

Datei anzeigen

@ -1,309 +0,0 @@
package net.minecraft.server;
import java.util.Random;
public class BlockVine extends Block {
public BlockVine(int i) {
super(i, 143, Material.REPLACEABLE_PLANT);
this.a(true);
}
public void f() {
this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
public int c() {
return 20;
}
public boolean a() {
return false;
}
public boolean b() {
return false;
}
public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) {
int l = iblockaccess.getData(i, j, k);
float f = 1.0F;
float f1 = 1.0F;
float f2 = 1.0F;
float f3 = 0.0F;
float f4 = 0.0F;
float f5 = 0.0F;
boolean flag = l > 0;
if ((l & 2) != 0) {
f3 = Math.max(f3, 0.0625F);
f = 0.0F;
f1 = 0.0F;
f4 = 1.0F;
f2 = 0.0F;
f5 = 1.0F;
flag = true;
}
if ((l & 8) != 0) {
f = Math.min(f, 0.9375F);
f3 = 1.0F;
f1 = 0.0F;
f4 = 1.0F;
f2 = 0.0F;
f5 = 1.0F;
flag = true;
}
if ((l & 4) != 0) {
f5 = Math.max(f5, 0.0625F);
f2 = 0.0F;
f = 0.0F;
f3 = 1.0F;
f1 = 0.0F;
f4 = 1.0F;
flag = true;
}
if ((l & 1) != 0) {
f2 = Math.min(f2, 0.9375F);
f5 = 1.0F;
f = 0.0F;
f3 = 1.0F;
f1 = 0.0F;
f4 = 1.0F;
flag = true;
}
if (!flag && this.d(iblockaccess.getTypeId(i, j + 1, k))) {
f1 = Math.min(f1, 0.9375F);
f4 = 1.0F;
f = 0.0F;
f3 = 1.0F;
f2 = 0.0F;
f5 = 1.0F;
}
this.a(f, f1, f2, f3, f4, f5);
}
public AxisAlignedBB e(World world, int i, int j, int k) {
return null;
}
public boolean canPlace(World world, int i, int j, int k, int l) {
switch (l) {
case 1:
return this.d(world.getTypeId(i, j + 1, k));
case 2:
return this.d(world.getTypeId(i, j, k + 1));
case 3:
return this.d(world.getTypeId(i, j, k - 1));
case 4:
return this.d(world.getTypeId(i + 1, j, k));
case 5:
return this.d(world.getTypeId(i - 1, j, k));
default:
return false;
}
}
private boolean d(int i) {
if (i == 0) {
return false;
} else {
Block block = Block.byId[i];
return block.b() && block.material.isSolid();
}
}
private boolean g(World world, int i, int j, int k) {
int l = world.getData(i, j, k);
int i1 = l;
if (l > 0) {
for (int j1 = 0; j1 <= 3; ++j1) {
int k1 = 1 << j1;
if ((l & k1) != 0 && !this.d(world.getTypeId(i + Direction.a[j1], j, k + Direction.b[j1])) && (world.getTypeId(i, j + 1, k) != this.id || (world.getData(i, j + 1, k) & k1) == 0)) {
i1 &= ~k1;
}
}
}
if (i1 == 0 && !this.d(world.getTypeId(i, j + 1, k))) {
return false;
} else {
if (i1 != l) {
world.setData(i, j, k, i1);
}
return true;
}
}
public void doPhysics(World world, int i, int j, int k, int l) {
if (!world.isStatic && !this.g(world, i, j, k)) {
this.b(world, i, j, k, world.getData(i, j, k), 0);
world.setTypeId(i, j, k, 0);
}
}
public void a(World world, int i, int j, int k, Random random) {
if (!world.isStatic && world.random.nextInt(4) == 0) {
byte b0 = 4;
int l = 5;
boolean flag = false;
int i1;
int j1;
int k1;
label138:
for (i1 = i - b0; i1 <= i + b0; ++i1) {
for (j1 = k - b0; j1 <= k + b0; ++j1) {
for (k1 = j - 1; k1 <= j + 1; ++k1) {
if (world.getTypeId(i1, k1, j1) == this.id) {
--l;
if (l <= 0) {
flag = true;
break label138;
}
}
}
}
}
i1 = world.getData(i, j, k);
j1 = world.random.nextInt(6);
k1 = Direction.d[j1];
int l1;
int i2;
if (j1 == 1 && j < 255 && world.isEmpty(i, j + 1, k)) {
if (flag) {
return;
}
l1 = world.random.nextInt(16) & i1;
if (l1 > 0) {
for (i2 = 0; i2 <= 3; ++i2) {
if (!this.d(world.getTypeId(i + Direction.a[i2], j + 1, k + Direction.b[i2]))) {
l1 &= ~(1 << i2);
}
}
if (l1 > 0) {
world.setTypeIdAndData(i, j + 1, k, this.id, l1);
}
}
} else {
int j2;
if (j1 >= 2 && j1 <= 5 && (i1 & 1 << k1) == 0) {
if (flag) {
return;
}
l1 = world.getTypeId(i + Direction.a[k1], j, k + Direction.b[k1]);
if (l1 != 0 && Block.byId[l1] != null) {
if (Block.byId[l1].material.j() && Block.byId[l1].b()) {
world.setData(i, j, k, i1 | 1 << k1);
}
} else {
i2 = k1 + 1 & 3;
j2 = k1 + 3 & 3;
if ((i1 & 1 << i2) != 0 && this.d(world.getTypeId(i + Direction.a[k1] + Direction.a[i2], j, k + Direction.b[k1] + Direction.b[i2]))) {
world.setTypeIdAndData(i + Direction.a[k1], j, k + Direction.b[k1], this.id, 1 << i2);
} else if ((i1 & 1 << j2) != 0 && this.d(world.getTypeId(i + Direction.a[k1] + Direction.a[j2], j, k + Direction.b[k1] + Direction.b[j2]))) {
world.setTypeIdAndData(i + Direction.a[k1], j, k + Direction.b[k1], this.id, 1 << j2);
} else if ((i1 & 1 << i2) != 0 && world.isEmpty(i + Direction.a[k1] + Direction.a[i2], j, k + Direction.b[k1] + Direction.b[i2]) && this.d(world.getTypeId(i + Direction.a[i2], j, k + Direction.b[i2]))) {
world.setTypeIdAndData(i + Direction.a[k1] + Direction.a[i2], j, k + Direction.b[k1] + Direction.b[i2], this.id, 1 << (k1 + 2 & 3));
} else if ((i1 & 1 << j2) != 0 && world.isEmpty(i + Direction.a[k1] + Direction.a[j2], j, k + Direction.b[k1] + Direction.b[j2]) && this.d(world.getTypeId(i + Direction.a[j2], j, k + Direction.b[j2]))) {
world.setTypeIdAndData(i + Direction.a[k1] + Direction.a[j2], j, k + Direction.b[k1] + Direction.b[j2], this.id, 1 << (k1 + 2 & 3));
} else if (this.d(world.getTypeId(i + Direction.a[k1], j + 1, k + Direction.b[k1]))) {
world.setTypeIdAndData(i + Direction.a[k1], j, k + Direction.b[k1], this.id, 0);
}
}
} else if (j > 1) {
l1 = world.getTypeId(i, j - 1, k);
if (l1 == 0) {
i2 = world.random.nextInt(16) & i1;
if (i2 > 0) {
world.setTypeIdAndData(i, j - 1, k, this.id, i2);
}
} else if (l1 == this.id) {
i2 = world.random.nextInt(16) & i1;
j2 = world.getData(i, j - 1, k);
if (j2 != (j2 | i2)) {
world.setData(i, j - 1, k, j2 | i2);
}
}
}
}
}
}
public void postPlace(World world, int i, int j, int k, int l) {
byte b0 = 0;
switch (l) {
case 2:
b0 = 1;
break;
case 3:
b0 = 4;
break;
case 4:
b0 = 8;
break;
case 5:
b0 = 2;
}
if (b0 != 0) {
world.setData(i, j, k, b0);
}
}
public int getDropType(int i, Random random, int j) {
return 0;
}
public int a(Random random) {
return 0;
}
public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
if (!world.isStatic && entityhuman.U() != null && entityhuman.U().id == Item.SHEARS.id) {
entityhuman.a(StatisticList.C[this.id], 1);
/* CraftBukkit start - moved this line into calculateDrops
this.a(world, i, j, k, new ItemStack(Block.VINE, 1, 0));
*/
this.doActualDrop(world, i, j, k);
// CraftBukkit end
} else {
super.a(world, entityhuman, i, j, k, l);
}
}
// CraftBukkit start - Calculate drops
public java.util.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) {
this.a(world, i, j, k, new ItemStack(Block.VINE, 1, 0));
} else {
return super.calculateDrops(world, entityhuman, i, j, k, l);
}
return this.dropList;
}
// CraftBukkit end
}

Datei anzeigen

@ -4,7 +4,6 @@ import java.util.List;
import java.util.Random;
// CraftBukkit start
import java.util.ArrayList;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.block.BlockFace;
@ -18,7 +17,6 @@ import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
import org.bukkit.event.vehicle.VehicleEnterEvent;
import org.bukkit.event.vehicle.VehicleExitEvent;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -1360,18 +1358,12 @@ public abstract class Entity {
final PluginManager pluginManager = Bukkit.getPluginManager();
if (thisBukkitEntity instanceof Painting) {
List<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>();
PaintingBreakByEntityEvent event = new PaintingBreakByEntityEvent((Painting) thisBukkitEntity, stormBukkitEntity, drops);
PaintingBreakByEntityEvent event = new PaintingBreakByEntityEvent((Painting) thisBukkitEntity, stormBukkitEntity);
pluginManager.callEvent(event);
if (event.isCancelled()) {
return;
}
// Something might've been added to the list of drops, so drop them
for (org.bukkit.inventory.ItemStack stack : drops) {
this.a(CraftItemStack.createNMSItemStack(stack), 0.0f);
}
}
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(stormBukkitEntity, thisBukkitEntity, EntityDamageEvent.DamageCause.LIGHTNING, 5);

Datei anzeigen

@ -1,11 +1,9 @@
package net.minecraft.server;
import java.util.ArrayList;
import java.util.List;
// CraftBukkit start
import org.bukkit.Location;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.entity.Vehicle;
import org.bukkit.event.vehicle.VehicleCreateEvent;
import org.bukkit.event.vehicle.VehicleDamageEvent;
@ -113,19 +111,7 @@ public class EntityBoat extends Entity {
this.aW();
if (this.getDamage() > 40) {
// CraftBukkit start
List<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>();
int j;
for (j = 0; j < 3; ++j) {
drops.add(new CraftItemStack(Block.WOOD.id, 1));
}
for (j = 0; j < 2; ++j) {
drops.add(new CraftItemStack(Item.STICK.id,1));
}
VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker, drops);
VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker);
this.world.getServer().getPluginManager().callEvent(destroyEvent);
if (destroyEvent.isCancelled()) {
@ -138,7 +124,6 @@ public class EntityBoat extends Entity {
this.passenger.mount(this);
}
/* CraftBukkit - This logic has been moved up before the event firing
int j;
for (j = 0; j < 3; ++j) {
@ -148,14 +133,8 @@ public class EntityBoat extends Entity {
for (j = 0; j < 2; ++j) {
this.a(Item.STICK.id, 1, 0.0F);
}
// */
this.die();
// CraftBukkit start
for (org.bukkit.inventory.ItemStack stack : drops) {
this.a(CraftItemStack.createNMSItemStack(stack), 0.0f);
}
// CraftBukkit end
}
return true;
@ -323,38 +302,24 @@ public class EntityBoat extends Entity {
if (this.positionChanged && d3 > 0.2D) {
if (!this.world.isStatic) {
// CraftBukkit start
List<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>();
/* CraftBukkit end
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, null);
this.world.getServer().getPluginManager().callEvent(destroyEvent);
if (!destroyEvent.isCancelled()) {
// CraftBukkit end
this.die();
// CraftBukkit - deferred to after the event */
int k;
for (k = 0; k < 3; ++k) {
/* CraftBukkit - add to drop list instead of immediately dropping
this.a(Block.WOOD.id, 1, 0.0F);
// */
drops.add(new CraftItemStack(Block.WOOD.id, 1));
}
for (k = 0; k < 2; ++k) {
/* CraftBukkit - add to drop list instead of immediately dropping
this.a(Item.STICK.id, 1, 0.0F);
// */
drops.add(new CraftItemStack(Item.STICK.id,1));
}
// CraftBukkit start
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, null, drops);
this.world.getServer().getPluginManager().callEvent(destroyEvent);
if (!destroyEvent.isCancelled()) {
this.die();
for (org.bukkit.inventory.ItemStack stack : drops) {
this.a(CraftItemStack.createNMSItemStack(stack), 0.0f);
}
}
// CraftBukkit end
} // CraftBukkit
}
} else {
this.motX *= 0.9900000095367432D;

Datei anzeigen

@ -1,9 +1,9 @@
package net.minecraft.server;
import java.util.List;
// CraftBukkit start
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.entity.HumanEntity;
@ -18,7 +18,6 @@ import org.bukkit.event.vehicle.VehicleUpdateEvent;
import org.bukkit.util.Vector;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.craftbukkit.entity.CraftHumanEntity;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
// CraftBukkit end
public class EntityMinecart extends Entity implements IInventory {
@ -148,35 +147,21 @@ public class EntityMinecart extends Entity implements IInventory {
this.aW();
this.setDamage(this.getDamage() + i * 10);
if (this.getDamage() > 40) {
// CraftBukkit start
List<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>();
drops.add(new CraftItemStack(Item.MINECART.id,1));
if (this.type == 1) {
drops.add(new CraftItemStack(Block.CHEST.id,1));
} else if (this.type == 2) {
drops.add(new org.bukkit.inventory.ItemStack(Block.FURNACE.id,1));
if (this.passenger != null) {
this.passenger.mount(this);
}
VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, passenger, drops);
// CraftBukkit start
VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, passenger);
this.world.getServer().getPluginManager().callEvent(destroyEvent);
if (destroyEvent.isCancelled()) {
this.setDamage(40); // Maximize damage so this doesn't get triggered again right away
return true;
}
// CraftBukkit end
if (this.passenger != null) {
this.passenger.mount(this);
}
this.die();
// CraftBukkit start - Drop items from the event
for(org.bukkit.inventory.ItemStack stack : drops) {
this.a(CraftItemStack.createNMSItemStack(stack), 0.0f);
}
// CraftBukkit end
// this.a(Item.MINECART.id, 1, 0.0F); // CraftBukkit - handled by main drop loop
this.a(Item.MINECART.id, 1, 0.0F);
if (this.type == 1) {
EntityMinecart entityminecart = this;
@ -208,9 +193,9 @@ public class EntityMinecart extends Entity implements IInventory {
}
}
// this.a(Block.CHEST.id, 1, 0.0F); // CraftBukkit - handled by main drop loop
this.a(Block.CHEST.id, 1, 0.0F);
} else if (this.type == 2) {
// this.a(Block.FURNACE.id, 1, 0.0F); // CraftBukkit - handled by main drop loop
this.a(Block.FURNACE.id, 1, 0.0F);
}
}

Datei anzeigen

@ -1,12 +1,5 @@
package net.minecraft.server;
// CraftBukkit start
import java.util.ArrayList;
import java.util.List;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
// CraftBukkit end
public class EntityMushroomCow extends EntityCow {
public EntityMushroomCow(World world) {
@ -23,11 +16,7 @@ public class EntityMushroomCow extends EntityCow {
return true;
} else if (itemstack != null && itemstack.id == Item.SHEARS.id && this.getAge() >= 0) {
// CraftBukkit start
List<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>();
for (int i = 0; i < 5; ++i) {
drops.add(new CraftItemStack(Block.RED_MUSHROOM.id, 1));
}
org.bukkit.event.player.PlayerShearEntityEvent event = new org.bukkit.event.player.PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity(), drops);
org.bukkit.event.player.PlayerShearEntityEvent event = new org.bukkit.event.player.PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
this.world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
@ -45,15 +34,9 @@ public class EntityMushroomCow extends EntityCow {
entitycow.V = this.V;
this.world.addEntity(entitycow);
/* CraftBukkit start - This logic moved up to before the event is fired ...
for (int i = 0; i < 5; ++i) {
this.world.addEntity(new EntityItem(this.world, this.locX, this.locY + (double) this.length, this.locZ, new ItemStack(Block.RED_MUSHROOM)));
}
// ... and replaced by this logic */
for (org.bukkit.inventory.ItemStack stack : drops) {
this.world.addEntity(new EntityItem(this.world, this.locX, this.locY + this.length, this.locZ, CraftItemStack.createNMSItemStack(stack)));
}
// CraftBukkit end
}
return true;

Datei anzeigen

@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.List;
// CraftBukkit start
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.entity.Painting;
import org.bukkit.event.painting.PaintingBreakByEntityEvent;
import org.bukkit.event.painting.PaintingBreakEvent.RemoveCause;
@ -126,8 +125,6 @@ public class EntityPainting extends Entity {
this.f = 0;
if (!this.dead && !this.survives()) {
// CraftBukkit start
List<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>();
drops.add(new CraftItemStack(Item.PAINTING.id, 1));
Material material = this.world.getMaterial((int) this.locX, (int) this.locY, (int) this.locZ);
RemoveCause cause;
if (material.equals(Material.WATER)) {
@ -138,7 +135,7 @@ public class EntityPainting extends Entity {
} else {
cause = RemoveCause.PHYSICS;
}
PaintingBreakEvent event = new PaintingBreakEvent((Painting) this.getBukkitEntity(), cause, drops);
PaintingBreakEvent event = new PaintingBreakEvent((Painting) this.getBukkitEntity(), cause);
this.world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled() || dead) {
@ -147,12 +144,7 @@ public class EntityPainting extends Entity {
// CraftBukkit end
this.die();
// CraftBukkit start - replace following line with the loop
//this.world.addEntity(new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.PAINTING)));
for (org.bukkit.inventory.ItemStack stack : drops) {
this.world.addEntity(new EntityItem(this.world, this.locX, this.locY, this.locZ, CraftItemStack.createNMSItemStack(stack)));
}
// CraftBukkit end
this.world.addEntity(new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.PAINTING)));
}
}
}
@ -222,14 +214,12 @@ public class EntityPainting extends Entity {
public boolean damageEntity(DamageSource damagesource, int i) {
if (!this.dead && !this.world.isStatic) {
// CraftBukkit start
List<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>();
drops.add(new CraftItemStack(Item.PAINTING.id, 1));
PaintingBreakEvent event = null;
if (damagesource.getEntity() != null) {
event = new PaintingBreakByEntityEvent((Painting) this.getBukkitEntity(), damagesource.getEntity().getBukkitEntity(), drops);
event = new PaintingBreakByEntityEvent((Painting) this.getBukkitEntity(), damagesource.getEntity() == null ? null : damagesource.getEntity().getBukkitEntity());
} else {
if (damagesource == DamageSource.FIRE) {
event = new PaintingBreakEvent((Painting) this.getBukkitEntity(), RemoveCause.FIRE, drops);
event = new PaintingBreakEvent((Painting) this.getBukkitEntity(), RemoveCause.FIRE);
}
// TODO: Could put other stuff here?
}
@ -246,12 +236,7 @@ public class EntityPainting extends Entity {
this.die();
this.aW();
// CraftBukkit start - replace following line with the loop
//this.world.addEntity(new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.PAINTING)));
for (org.bukkit.inventory.ItemStack stack : drops) {
this.world.addEntity(new EntityItem(this.world, this.locX, this.locY, this.locZ, CraftItemStack.createNMSItemStack(stack)));
}
// CraftBukkit end
this.world.addEntity(new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.PAINTING)));
}
return true;
@ -300,7 +285,7 @@ public class EntityPainting extends Entity {
public void b_(double d0, double d1, double d2) {
/* CraftBukkit start - not needed for paintings
if (!this.world.isStatic && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) {
if (!this.world.isStatic && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) {
this.die();
this.world.addEntity(new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.PAINTING)));
}

Datei anzeigen

@ -3,12 +3,8 @@ package net.minecraft.server;
import java.util.Random;
// CraftBukkit start
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.craftbukkit.event.CraftEventFactory;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.entity.Sheep;
// CraftBukkit end
@ -84,12 +80,7 @@ public class EntitySheep extends EntityAnimal {
if (itemstack != null && itemstack.id == Item.SHEARS.id && !this.isSheared() && !this.isBaby()) {
if (!this.world.isStatic) {
// CraftBukkit start
int i = 1 + this.random.nextInt(3);
List<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>();
for (int j = 0; j < i; ++j) {
drops.add(new CraftItemStack(Block.WOOL.id, 1, (short) this.getColor()));
}
org.bukkit.event.player.PlayerShearEntityEvent event = new org.bukkit.event.player.PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity(), drops);
org.bukkit.event.player.PlayerShearEntityEvent event = new org.bukkit.event.player.PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
this.world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
@ -98,15 +89,10 @@ public class EntitySheep extends EntityAnimal {
// CraftBukkit end
this.setSheared(true);
/* CraftBukkit start - Moved this line to before the event is fired
int i = 1 + this.random.nextInt(3);
// And this logic is changed to use the drop list from the event
for (int j = 0; j < i; ++j) {
EntityItem entityitem = this.a(new ItemStack(Block.WOOL.id, 1, this.getColor()), 1.0F);
// */
for (org.bukkit.inventory.ItemStack stack : drops) {
EntityItem entityitem = this.a(CraftItemStack.createNMSItemStack(stack), 1.0f);
// CraftBukkit end
entityitem.motY += (double) (this.random.nextFloat() * 0.05F);
entityitem.motX += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
entityitem.motZ += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);

Datei anzeigen

@ -243,11 +243,10 @@ public class Explosion {
this.world.a("smoke", d0, d1, d2, d3, d4, d5);
}
// CraftBukkit start - stop explosions from putting out fire
// CraftBukkit - stop explosions from putting out fire
if (i1 > 0 && i1 != Block.FIRE.id) {
// CraftBukkit
Block.byId[i1].dropNaturally(this.world, j, k, l, this.world.getData(j, k, l), event.getYield(), 0);
Block.byId[i1].doActualDrop(this.world, j, k, l);
// CraftBukkit end
this.world.setTypeId(j, k, l, 0);
Block.byId[i1].wasExploded(this.world, j, k, l);
}

Datei anzeigen

@ -1,6 +1,7 @@
package net.minecraft.server;
// CraftBukkit start
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.craftbukkit.event.CraftEventFactory;
import org.bukkit.event.Event;
@ -202,24 +203,37 @@ public class ItemInWorldManager {
}
public boolean breakBlock(int i, int j, int k) {
int l = this.world.getTypeId(i, j, k);
int i1 = this.world.getData(i, j, k);
// CraftBukkit start
if (player instanceof EntityPlayer) {
if(CraftEventFactory.callBlockBreakEvent(this.world, i, j, k, l, i1, this.isCreative(), this.player)) {
if (this.player instanceof EntityPlayer) {
org.bukkit.block.Block block = this.world.getWorld().getBlockAt(i, j, k);
// Tell client the block is gone immediately then process events
if (world.getTileEntity(i, j, k) == null) {
Packet53BlockChange packet = new Packet53BlockChange(i, j, k, this.world);
packet.material = 0;
packet.data = 0;
((EntityPlayer) this.player).netServerHandler.sendPacket(packet);
}
BlockBreakEvent event = new BlockBreakEvent(block, (org.bukkit.entity.Player) this.player.getBukkitEntity());
this.world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
// Let the client know the block still exists
((EntityPlayer) this.player).netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, this.world));
return false;
}
}
// CraftBukkit end
int l = this.world.getTypeId(i, j, k);
int i1 = this.world.getData(i, j, k);
this.world.a(this.player, 2001, i, j, k, l + (this.world.getData(i, j, k) << 12));
boolean flag = this.b(i, j, k);
if (this.isCreative()) {
// CraftBukkit start - honour additions to drop list
Block.byId[l].doActualDrop(this.world, i, j, k);
// CraftBukkit end
((EntityPlayer) this.player).netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, this.world));
} else {
ItemStack itemstack = this.player.U();

Datei anzeigen

@ -1056,7 +1056,6 @@ public class CraftWorld implements World {
int blockZ = block.getZ();
// following code is lifted from Explosion.a(boolean), and modified
net.minecraft.server.Block.byId[blockId].dropNaturally(this.world, blockX, blockY, blockZ, block.getData(), yield, 0);
net.minecraft.server.Block.byId[blockId].doActualDrop(this.world, blockX, blockY, blockZ);
block.setType(org.bukkit.Material.AIR);
// not sure what this does, seems to have something to do with the 'base' material of a block.
// For example, WOODEN_STAIRS does something with WOOD in this method

Datei anzeigen

@ -18,7 +18,6 @@ import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.PistonMoveReaction;
import org.bukkit.craftbukkit.CraftChunk;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;
@ -348,7 +347,7 @@ public class CraftBlock implements Block {
setTypeId(Material.AIR.getId());
if (block != null) {
block.b(chunk.getHandle().world, x, y, z, data, 0);
block.dropNaturally(chunk.getHandle().world, x, y, z, data, 1.0F, 0);
return true;
}
return false;

Datei anzeigen

@ -20,7 +20,6 @@ import net.minecraft.server.InventoryCrafting;
import net.minecraft.server.Item;
import net.minecraft.server.ItemStack;
import net.minecraft.server.Packet101CloseWindow;
import net.minecraft.server.Packet53BlockChange;
import net.minecraft.server.World;
import net.minecraft.server.WorldServer;
@ -511,49 +510,4 @@ public class CraftEventFactory {
Bukkit.getPluginManager().callEvent(event);
return event;
}
private static final List<org.bukkit.inventory.ItemStack> drops = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
public static boolean callBlockBreakEvent(World world, int x, int y, int z, int id, int data, boolean creative, EntityHuman player) {
net.minecraft.server.Block blockType = net.minecraft.server.Block.byId[id];
if (blockType == null) { // Illegal block ID
return true;
}
// Tell client the block is gone immediately then process events
if (world.getTileEntity(x, y, z) == null) {
Packet53BlockChange packet = new Packet53BlockChange(x, y, z, world);
packet.material = 0;
packet.data = 0;
((EntityPlayer) player).netServerHandler.sendPacket(packet);
}
Block block = world.getWorld().getBlockAt(x, y, z);
List<ItemStack> toDrop = blockType.calculateDrops(world, player, x, y, z, data);
drops.clear();
if (!creative && player.b(blockType)) {
for (ItemStack stack : toDrop) {
drops.add(new CraftItemStack(stack));
}
}
BlockBreakEvent event = new BlockBreakEvent(block, (org.bukkit.entity.Player) player.getBukkitEntity(), drops);
world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
toDrop.clear();
// Let the client know the block still exists
((EntityPlayer) player).netServerHandler.sendPacket(new Packet53BlockChange(x, y, z, world));
return true;
}
toDrop.clear();
for (org.bukkit.inventory.ItemStack stack : drops) {
toDrop.add(CraftItemStack.createNMSItemStack(stack));
}
return false; // Event not cancelled
}
}