2011-04-04 06:48:40 +02:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.util.Random;
|
2011-04-20 19:05:14 +02:00
|
|
|
|
2012-07-22 08:18:00 +02:00
|
|
|
import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit
|
2011-04-04 06:48:40 +02:00
|
|
|
|
|
|
|
public class BlockSoil extends Block {
|
|
|
|
|
|
|
|
protected BlockSoil(int i) {
|
|
|
|
super(i, Material.EARTH);
|
|
|
|
this.textureId = 87;
|
2012-07-29 09:33:13 +02:00
|
|
|
this.b(true);
|
2011-04-04 06:48:40 +02:00
|
|
|
this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.9375F, 1.0F);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.h(255);
|
2011-04-04 06:48:40 +02:00
|
|
|
}
|
|
|
|
|
2011-06-30 00:02:25 +02:00
|
|
|
public AxisAlignedBB e(World world, int i, int j, int k) {
|
2012-07-29 09:33:13 +02:00
|
|
|
return AxisAlignedBB.a().a((double) (i + 0), (double) (j + 0), (double) (k + 0), (double) (i + 1), (double) (j + 1), (double) (k + 1));
|
2011-04-04 06:48:40 +02:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public boolean c() {
|
2011-04-04 06:48:40 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public boolean b() {
|
2011-05-26 14:48:22 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-04-04 06:48:40 +02:00
|
|
|
public int a(int i, int j) {
|
|
|
|
return i == 1 && j > 0 ? this.textureId - 1 : (i == 1 ? this.textureId : 2);
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void b(World world, int i, int j, int k, Random random) {
|
2012-11-06 13:05:28 +01:00
|
|
|
if (!this.n(world, i, j, k) && !world.D(i, j + 1, k)) {
|
2011-11-20 09:01:14 +01:00
|
|
|
int l = world.getData(i, j, k);
|
|
|
|
|
|
|
|
if (l > 0) {
|
|
|
|
world.setData(i, j, k, l - 1);
|
2012-07-29 09:33:13 +02:00
|
|
|
} else if (!this.l(world, i, j, k)) {
|
2011-11-20 09:01:14 +01:00
|
|
|
world.setTypeId(i, j, k, Block.DIRT.id);
|
2011-04-04 06:48:40 +02:00
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
} else {
|
|
|
|
world.setData(i, j, k, 7);
|
2011-04-04 06:48:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
public void a(World world, int i, int j, int k, Entity entity, float f) {
|
2012-07-29 09:33:13 +02:00
|
|
|
if (!world.isStatic && world.random.nextFloat() < f - 0.5F) {
|
|
|
|
// CraftBukkit start - interact soil
|
2011-06-27 00:25:01 +02:00
|
|
|
org.bukkit.event.Cancellable cancellable;
|
2011-04-20 19:05:14 +02:00
|
|
|
if (entity instanceof EntityHuman) {
|
2012-07-22 08:18:00 +02:00
|
|
|
cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, i, j, k, -1, null);
|
2011-04-20 19:05:14 +02:00
|
|
|
} else {
|
2011-06-27 00:25:01 +02:00
|
|
|
cancellable = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(i, j, k));
|
|
|
|
world.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable);
|
2011-04-20 19:05:14 +02:00
|
|
|
}
|
2011-05-14 16:29:42 +02:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (cancellable.isCancelled()) {
|
|
|
|
return;
|
2011-04-04 06:48:40 +02:00
|
|
|
}
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit end
|
2011-04-20 19:05:14 +02:00
|
|
|
|
|
|
|
world.setTypeId(i, j, k, Block.DIRT.id);
|
2011-04-04 06:48:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
private boolean l(World world, int i, int j, int k) {
|
2011-04-04 06:48:40 +02:00
|
|
|
byte b0 = 0;
|
|
|
|
|
|
|
|
for (int l = i - b0; l <= i + b0; ++l) {
|
|
|
|
for (int i1 = k - b0; i1 <= k + b0; ++i1) {
|
2011-09-15 02:23:52 +02:00
|
|
|
int j1 = world.getTypeId(l, j + 1, i1);
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
if (j1 == Block.CROPS.id || j1 == Block.MELON_STEM.id || j1 == Block.PUMPKIN_STEM.id || j1 == Block.POTATOES.id || j1 == Block.CARROTS.id) {
|
2011-04-04 06:48:40 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
private boolean n(World world, int i, int j, int k) {
|
2011-04-04 06:48:40 +02:00
|
|
|
for (int l = i - 4; l <= i + 4; ++l) {
|
|
|
|
for (int i1 = j; i1 <= j + 1; ++i1) {
|
|
|
|
for (int j1 = k - 4; j1 <= k + 4; ++j1) {
|
|
|
|
if (world.getMaterial(l, i1, j1) == Material.WATER) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void doPhysics(World world, int i, int j, int k, int l) {
|
|
|
|
super.doPhysics(world, i, j, k, l);
|
2011-04-04 06:48:40 +02:00
|
|
|
Material material = world.getMaterial(i, j + 1, k);
|
|
|
|
|
|
|
|
if (material.isBuildable()) {
|
2011-04-20 19:05:14 +02:00
|
|
|
world.setTypeId(i, j, k, Block.DIRT.id);
|
2011-04-04 06:48:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
public int getDropType(int i, Random random, int j) {
|
|
|
|
return Block.DIRT.getDropType(0, random, j);
|
2011-04-04 06:48:40 +02:00
|
|
|
}
|
|
|
|
}
|