2011-09-26 09:07:06 +02:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
public class BlockSand extends Block {
|
|
|
|
|
|
|
|
public static boolean instaFall = false;
|
|
|
|
|
|
|
|
public BlockSand(int i, int j) {
|
|
|
|
super(i, j, Material.SAND);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a(CreativeModeTab.b);
|
2011-09-26 09:07:06 +02:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public BlockSand(int i, int j, Material material) {
|
|
|
|
super(i, j, material);
|
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
public void onPlace(World world, int i, int j, int k) {
|
2012-10-25 05:53:23 +02:00
|
|
|
world.a(i, j, k, this.id, this.r_());
|
2011-09-26 09:07:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void doPhysics(World world, int i, int j, int k, int l) {
|
2012-10-25 05:53:23 +02:00
|
|
|
world.a(i, j, k, this.id, this.r_());
|
2011-09-26 09:07:06 +02:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void b(World world, int i, int j, int k, Random random) {
|
|
|
|
if (!world.isStatic) {
|
|
|
|
this.l(world, i, j, k);
|
|
|
|
}
|
2011-09-26 09:07:06 +02:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
private void l(World world, int i, int j, int k) {
|
2012-01-14 21:03:48 +01:00
|
|
|
if (canFall(world, i, j - 1, k) && j >= 0) {
|
2011-09-26 09:07:06 +02:00
|
|
|
byte b0 = 32;
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (!instaFall && world.d(i - b0, j - b0, k - b0, i + b0, j + b0, k + b0)) {
|
2011-11-20 09:01:14 +01:00
|
|
|
if (!world.isStatic) {
|
2011-11-30 00:17:43 +01:00
|
|
|
EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), this.id, world.getData(i, j, k));
|
2011-09-26 09:07:06 +02:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
this.a(entityfallingblock);
|
2011-11-30 00:17:43 +01:00
|
|
|
world.addEntity(entityfallingblock);
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
2011-09-26 09:07:06 +02:00
|
|
|
} else {
|
|
|
|
world.setTypeId(i, j, k, 0);
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
while (canFall(world, i, j - 1, k) && j > 0) {
|
2011-09-26 09:07:06 +02:00
|
|
|
--j;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (j > 0) {
|
|
|
|
world.setTypeId(i, j, k, this.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
protected void a(EntityFallingBlock entityfallingblock) {}
|
|
|
|
|
|
|
|
public int r_() {
|
2012-11-06 13:05:28 +01:00
|
|
|
return 5;
|
2011-09-26 09:07:06 +02:00
|
|
|
}
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
public static boolean canFall(World world, int i, int j, int k) {
|
2011-09-26 09:07:06 +02:00
|
|
|
int l = world.getTypeId(i, j, k);
|
|
|
|
|
|
|
|
if (l == 0) {
|
|
|
|
return true;
|
|
|
|
} else if (l == Block.FIRE.id) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
Material material = Block.byId[l].material;
|
|
|
|
|
|
|
|
return material == Material.WATER ? true : material == Material.LAVA;
|
|
|
|
}
|
|
|
|
}
|
2012-10-25 05:53:23 +02:00
|
|
|
|
|
|
|
public void a_(World world, int i, int j, int k, int l) {}
|
2011-09-26 09:07:06 +02:00
|
|
|
}
|