2011-06-17 20:48:20 +02:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2012-03-05 20:21:43 +01:00
|
|
|
import java.util.ArrayList; // CraftBukkit
|
2011-06-17 20:48:20 +02:00
|
|
|
import java.util.Random;
|
2011-08-29 17:09:13 +02:00
|
|
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
2011-06-17 20:48:20 +02:00
|
|
|
|
|
|
|
public class BlockSnow extends Block {
|
|
|
|
|
|
|
|
protected BlockSnow(int i, int j) {
|
|
|
|
super(i, j, Material.SNOW_LAYER);
|
|
|
|
this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
|
|
|
|
this.a(true);
|
|
|
|
}
|
|
|
|
|
2011-06-30 00:02:25 +02:00
|
|
|
public AxisAlignedBB e(World world, int i, int j, int k) {
|
2011-06-17 20:48:20 +02:00
|
|
|
int l = world.getData(i, j, k) & 7;
|
|
|
|
|
|
|
|
return l >= 3 ? AxisAlignedBB.b((double) i + this.minX, (double) j + this.minY, (double) k + this.minZ, (double) i + this.maxX, (double) ((float) j + 0.5F), (double) k + this.maxZ) : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean b() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) {
|
2011-06-17 20:48:20 +02:00
|
|
|
int l = iblockaccess.getData(i, j, k) & 7;
|
|
|
|
float f = (float) (2 * (1 + l)) / 16.0F;
|
|
|
|
|
|
|
|
this.a(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean canPlace(World world, int i, int j, int k) {
|
|
|
|
int l = world.getTypeId(i, j - 1, k);
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
return l != 0 && (l == Block.LEAVES.id || Block.byId[l].a()) ? world.getMaterial(i, j - 1, k).isSolid() : false;
|
2011-06-17 20:48:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void doPhysics(World world, int i, int j, int k, int l) {
|
|
|
|
this.g(world, i, j, k);
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean g(World world, int i, int j, int k) {
|
|
|
|
if (!this.canPlace(world, i, j, k)) {
|
2011-11-20 09:01:14 +01:00
|
|
|
this.b(world, i, j, k, world.getData(i, j, k), 0);
|
2012-01-17 13:37:14 +01:00
|
|
|
world.setRawTypeId(i, j, k, 0); // CraftBukkit
|
|
|
|
world.notify(i, j, k); // CraftBukkit - Notfiy clients of the reversion
|
2011-06-17 20:48:20 +02:00
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
|
2012-03-05 20:21:43 +01:00
|
|
|
/* CraftBukkit start - This logic is exactly the same as in the superclass method, so defer it there
|
2011-06-17 20:48:20 +02:00
|
|
|
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));
|
2012-03-05 20:21:43 +01:00
|
|
|
// This is done so that getDrops() in the BlockBreakEvent works properly.
|
2011-06-17 20:48:20 +02:00
|
|
|
|
|
|
|
entityitem.pickupDelay = 10;
|
|
|
|
world.addEntity(entityitem);
|
2012-03-23 12:08:54 +01:00
|
|
|
*/
|
|
|
|
this.doActualDrop(world, i, j, k);
|
2012-03-05 20:21:43 +01:00
|
|
|
// CraftBukkit end
|
2011-06-17 20:48:20 +02:00
|
|
|
world.setTypeId(i, j, k, 0);
|
|
|
|
entityhuman.a(StatisticList.C[this.id], 1);
|
|
|
|
}
|
|
|
|
|
2012-03-05 20:21:43 +01:00
|
|
|
// CraftBukkit start - Calculate drops
|
|
|
|
public 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, 1));
|
2012-03-23 12:08:54 +01:00
|
|
|
return this.dropList;
|
2012-03-05 20:21:43 +01:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
public int getDropType(int i, Random random, int j) {
|
2011-06-17 20:48:20 +02:00
|
|
|
return Item.SNOW_BALL.id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int a(Random random) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(World world, int i, int j, int k, Random random) {
|
|
|
|
if (world.a(EnumSkyBlock.BLOCK, i, j, k) > 11) {
|
|
|
|
// CraftBukkit start
|
2011-08-29 17:09:13 +02:00
|
|
|
if (CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(i, j, k), 0).isCancelled()) {
|
2011-06-17 20:48:20 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
this.b(world, i, j, k, world.getData(i, j, k), 0);
|
2011-06-17 20:48:20 +02:00
|
|
|
world.setTypeId(i, j, k, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|