2011-01-03 10:41:43 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start
|
2011-01-15 22:21:05 +01:00
|
|
|
import org.bukkit.entity.LivingEntity;
|
2011-01-15 22:40:18 +01:00
|
|
|
import org.bukkit.craftbukkit.block.CraftBlock;
|
2011-01-15 22:23:28 +01:00
|
|
|
import org.bukkit.craftbukkit.entity.CraftEntity;
|
|
|
|
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
|
|
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
2011-01-12 06:48:19 +01:00
|
|
|
import org.bukkit.craftbukkit.CraftServer;
|
2011-01-15 21:26:05 +01:00
|
|
|
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
|
|
|
import org.bukkit.event.entity.EntityDamageEvent;
|
2011-01-18 08:29:41 +01:00
|
|
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2011-01-03 10:41:43 +01:00
|
|
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
public class BlockCactus extends Block {
|
|
|
|
|
|
|
|
protected BlockCactus(int i, int j) {
|
|
|
|
super(i, j, Material.u);
|
|
|
|
a(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(World world, int i, int j, int k, Random random) {
|
|
|
|
if (world.e(i, j + 1, k)) {
|
|
|
|
int l;
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
for (l = 1; world.a(i, j - l, k) == bi; l++) {
|
2011-01-03 10:41:43 +01:00
|
|
|
;
|
|
|
|
}
|
|
|
|
if (l < 3) {
|
|
|
|
int i1 = world.b(i, j, k);
|
|
|
|
|
|
|
|
if (i1 == 15) {
|
2011-01-14 14:31:10 +01:00
|
|
|
world.e(i, j + 1, k, bi);
|
|
|
|
world.c(i, j, k, 0);
|
2011-01-03 10:41:43 +01:00
|
|
|
} else {
|
2011-01-14 14:31:10 +01:00
|
|
|
world.c(i, j, k, i1 + 1);
|
2011-01-03 10:41:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public AxisAlignedBB d(World world, int i, int j, int k) {
|
|
|
|
float f1 = 0.0625F;
|
|
|
|
|
|
|
|
return AxisAlignedBB.b((float) i + f1, j, (float) k + f1, (float) (i + 1) - f1, (float) (j + 1) - f1, (float) (k + 1) - f1);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int a(int i) {
|
|
|
|
if (i == 1) {
|
2011-01-14 14:31:10 +01:00
|
|
|
return bh - 1;
|
2011-01-03 10:41:43 +01:00
|
|
|
}
|
|
|
|
if (i == 0) {
|
2011-01-14 14:31:10 +01:00
|
|
|
return bh + 1;
|
2011-01-03 10:41:43 +01:00
|
|
|
} else {
|
2011-01-14 14:31:10 +01:00
|
|
|
return bh;
|
2011-01-03 10:41:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a(World world, int i, int j, int k) {
|
|
|
|
if (!super.a(world, i, j, k)) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return f(world, i, j, k);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b(World world, int i, int j, int k, int l) {
|
|
|
|
if (!f(world, i, j, k)) {
|
|
|
|
a_(world, i, j, k, world.b(i, j, k));
|
2011-01-14 14:31:10 +01:00
|
|
|
world.e(i, j, k, 0);
|
2011-01-03 10:41:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean f(World world, int i, int j, int k) {
|
|
|
|
if (world.c(i - 1, j, k).a()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (world.c(i + 1, j, k).a()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (world.c(i, j, k - 1).a()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (world.c(i, j, k + 1).a()) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
int l = world.a(i, j - 1, k);
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
return l == Block.aV.bi || l == Block.E.bi;
|
2011-01-03 10:41:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(World world, int i, int j, int k, Entity entity) {
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start - ENTITY_DAMAGEBY_BLOCK event
|
|
|
|
|
2011-01-12 06:48:19 +01:00
|
|
|
if(entity instanceof EntityLiving) {
|
|
|
|
CraftServer server = ((WorldServer) world).getServer();
|
2011-01-18 08:29:41 +01:00
|
|
|
org.bukkit.block.Block damager = ((WorldServer) world).getWorld().getBlockAt(i, j, k);
|
|
|
|
org.bukkit.entity.Entity damagee = entity.getBukkitEntity();
|
|
|
|
DamageCause damageType = EntityDamageEvent.DamageCause.CONTACT;
|
|
|
|
int damageDone = 1;
|
|
|
|
|
|
|
|
EntityDamageByBlockEvent edbbe = new EntityDamageByBlockEvent(damager, damagee, damageType, damageDone);
|
2011-01-12 06:48:19 +01:00
|
|
|
server.getPluginManager().callEvent(edbbe);
|
2011-01-11 09:25:13 +01:00
|
|
|
|
2011-01-12 06:48:19 +01:00
|
|
|
if (!edbbe.isCancelled()){
|
|
|
|
entity.a(((Entity) (null)), edbbe.getDamage());
|
|
|
|
}
|
|
|
|
return;
|
2011-01-18 08:29:41 +01:00
|
|
|
} else {
|
|
|
|
entity.a(((Entity) (null)), 1);
|
2011-01-03 10:41:43 +01:00
|
|
|
}
|
2011-01-18 08:29:41 +01:00
|
|
|
// CraftBukkit end
|
2011-01-03 10:41:43 +01:00
|
|
|
}
|
|
|
|
}
|