2011-06-17 20:48:20 +02:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
public class BlockSnow extends Block {
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected BlockSnow(int i) {
|
|
|
|
super(i, Material.SNOW_LAYER);
|
2011-06-17 20:48:20 +02:00
|
|
|
this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.b(true);
|
|
|
|
this.a(CreativeModeTab.c);
|
2013-03-13 23:33:27 +01:00
|
|
|
this.d(0);
|
2011-06-17 20:48:20 +02:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public AxisAlignedBB b(World world, int i, int j, int k) {
|
2011-06-17 20:48:20 +02:00
|
|
|
int l = world.getData(i, j, k) & 7;
|
2013-03-13 23:33:27 +01:00
|
|
|
float f = 0.125F;
|
2011-06-17 20:48:20 +02:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
return AxisAlignedBB.a().a((double) i + this.minX, (double) j + this.minY, (double) k + this.minZ, (double) i + this.maxX, (double) ((float) j + (float) l * f), (double) k + this.maxZ);
|
2011-06-17 20:48:20 +02:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public boolean c() {
|
2011-06-17 20:48:20 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public boolean b() {
|
2011-06-17 20:48:20 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void g() {
|
|
|
|
this.d(0);
|
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.d(iblockaccess.getData(i, j, k));
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void d(int i) {
|
|
|
|
int j = i & 7;
|
|
|
|
float f = (float) (2 * (1 + j)) / 16.0F;
|
2011-06-17 20:48:20 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
return l == 0 ? false : (l == this.id && (world.getData(i, j - 1, k) & 7) == 7 ? true : (l != Block.LEAVES.id && !Block.byId[l].c() ? false : world.getMaterial(i, j - 1, k).isSolid()));
|
2011-06-17 20:48:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void doPhysics(World world, int i, int j, int k, int l) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.m(world, i, j, k);
|
2011-06-17 20:48:20 +02:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
private boolean m(World world, int i, int j, int k) {
|
2011-06-17 20:48:20 +02:00
|
|
|
if (!this.canPlace(world, i, j, k)) {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.c(world, i, j, k, world.getData(i, j, k), 0);
|
2013-03-13 23:33:27 +01:00
|
|
|
world.setAir(i, j, k);
|
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) {
|
|
|
|
int i1 = Item.SNOW_BALL.id;
|
2013-03-13 23:33:27 +01:00
|
|
|
int j1 = l & 7;
|
2012-10-25 05:53:23 +02:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
this.b(world, i, j, k, new ItemStack(i1, j1 + 1, 0));
|
|
|
|
world.setAir(i, j, k);
|
2011-06-17 20:48:20 +02:00
|
|
|
entityhuman.a(StatisticList.C[this.id], 1);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void a(World world, int i, int j, int k, Random random) {
|
2012-07-29 09:33:13 +02:00
|
|
|
if (world.b(EnumSkyBlock.BLOCK, i, j, k) > 11) {
|
2011-06-17 20:48:20 +02:00
|
|
|
// CraftBukkit start
|
2012-07-22 08:18:00 +02:00
|
|
|
if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(i, j, k), 0).isCancelled()) {
|
2011-06-17 20:48:20 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
this.c(world, i, j, k, world.getData(i, j, k), 0);
|
2013-03-13 23:33:27 +01:00
|
|
|
world.setAir(i, j, k);
|
2011-06-17 20:48:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|