2011-06-30 19:51:42 +02:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
|
|
|
|
|
|
|
|
public class BlockTrapdoor extends Block {
|
|
|
|
|
|
|
|
protected BlockTrapdoor(int i, Material material) {
|
|
|
|
super(i, material);
|
|
|
|
float f = 0.5F;
|
|
|
|
float f1 = 1.0F;
|
|
|
|
|
|
|
|
this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a(CreativeModeTab.d);
|
2011-06-30 19:51:42 +02:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public boolean c() {
|
2011-06-30 19:51:42 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public boolean b() {
|
2011-06-30 19:51:42 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public boolean b(IBlockAccess iblockaccess, int i, int j, int k) {
|
|
|
|
return !f(iblockaccess.getData(i, j, k));
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public int d() {
|
2011-11-20 09:01:14 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public AxisAlignedBB b(World world, int i, int j, int k) {
|
2011-11-30 00:17:43 +01:00
|
|
|
this.updateShape(world, i, j, k);
|
2013-03-13 23:33:27 +01:00
|
|
|
return super.b(world, i, j, k);
|
2011-06-30 19:51:42 +02:00
|
|
|
}
|
|
|
|
|
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));
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void g() {
|
2011-11-20 09:01:14 +01:00
|
|
|
float f = 0.1875F;
|
|
|
|
|
|
|
|
this.a(0.0F, 0.5F - f / 2.0F, 0.0F, 1.0F, 0.5F + f / 2.0F, 1.0F);
|
2011-06-30 19:51:42 +02:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void d(int i) {
|
2011-06-30 19:51:42 +02:00
|
|
|
float f = 0.1875F;
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if ((i & 8) != 0) {
|
|
|
|
this.a(0.0F, 1.0F - f, 0.0F, 1.0F, 1.0F, 1.0F);
|
|
|
|
} else {
|
|
|
|
this.a(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F);
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (f(i)) {
|
2011-06-30 19:51:42 +02:00
|
|
|
if ((i & 3) == 0) {
|
|
|
|
this.a(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((i & 3) == 1) {
|
|
|
|
this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((i & 3) == 2) {
|
|
|
|
this.a(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((i & 3) == 3) {
|
|
|
|
this.a(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public void attack(World world, int i, int j, int k, EntityHuman entityhuman) {}
|
2011-06-30 19:51:42 +02:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman, int l, float f, float f1, float f2) {
|
2011-06-30 19:51:42 +02:00
|
|
|
if (this.material == Material.ORE) {
|
|
|
|
return true;
|
|
|
|
} else {
|
2012-07-29 09:33:13 +02:00
|
|
|
int i1 = world.getData(i, j, k);
|
2011-06-30 19:51:42 +02:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
world.setData(i, j, k, i1 ^ 4, 2);
|
2011-06-30 19:51:42 +02:00
|
|
|
world.a(entityhuman, 1003, i, j, k, 0);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
public void setOpen(World world, int i, int j, int k, boolean flag) {
|
2011-06-30 19:51:42 +02:00
|
|
|
int l = world.getData(i, j, k);
|
|
|
|
boolean flag1 = (l & 4) > 0;
|
|
|
|
|
|
|
|
if (flag1 != flag) {
|
2013-03-13 23:33:27 +01:00
|
|
|
world.setData(i, j, k, l ^ 4, 2);
|
2011-06-30 19:51:42 +02:00
|
|
|
world.a((EntityHuman) null, 1003, i, j, k, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void doPhysics(World world, int i, int j, int k, int l) {
|
|
|
|
if (!world.isStatic) {
|
|
|
|
int i1 = world.getData(i, j, k);
|
|
|
|
int j1 = i;
|
|
|
|
int k1 = k;
|
|
|
|
|
|
|
|
if ((i1 & 3) == 0) {
|
|
|
|
k1 = k + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((i1 & 3) == 1) {
|
|
|
|
--k1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((i1 & 3) == 2) {
|
|
|
|
j1 = i + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((i1 & 3) == 3) {
|
|
|
|
--j1;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (!g(world.getTypeId(j1, j, k1))) {
|
|
|
|
world.setAir(i, j, k);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.c(world, i, j, k, i1, 0);
|
2011-06-30 19:51:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CraftBukkit start
|
2012-01-12 23:10:13 +01:00
|
|
|
if (l == 0 || l > 0 && Block.byId[l] != null && Block.byId[l].isPowerSource()) {
|
2011-06-30 19:51:42 +02:00
|
|
|
org.bukkit.World bworld = world.getWorld();
|
|
|
|
org.bukkit.block.Block block = bworld.getBlockAt(i, j, k);
|
|
|
|
|
|
|
|
int power = block.getBlockPower();
|
|
|
|
int oldPower = (world.getData(i, j, k) & 4) > 0 ? 15 : 0;
|
|
|
|
|
2011-11-23 01:08:56 +01:00
|
|
|
if (oldPower == 0 ^ power == 0 || (Block.byId[l] != null && Block.byId[l].isPowerSource())) {
|
2011-06-30 19:51:42 +02:00
|
|
|
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, oldPower, power);
|
|
|
|
world.getServer().getPluginManager().callEvent(eventRedstone);
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
this.setOpen(world, i, j, k, eventRedstone.getNewCurrent() > 0);
|
2011-06-30 19:51:42 +02:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public MovingObjectPosition a(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) {
|
2011-11-30 00:17:43 +01:00
|
|
|
this.updateShape(world, i, j, k);
|
2011-06-30 19:51:42 +02:00
|
|
|
return super.a(world, i, j, k, vec3d, vec3d1);
|
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
public int getPlacedData(World world, int i, int j, int k, int l, float f, float f1, float f2, int i1) {
|
|
|
|
int j1 = 0;
|
2011-06-30 19:51:42 +02:00
|
|
|
|
|
|
|
if (l == 2) {
|
2012-11-06 13:05:28 +01:00
|
|
|
j1 = 0;
|
2011-06-30 19:51:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (l == 3) {
|
2012-11-06 13:05:28 +01:00
|
|
|
j1 = 1;
|
2011-06-30 19:51:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (l == 4) {
|
2012-11-06 13:05:28 +01:00
|
|
|
j1 = 2;
|
2011-06-30 19:51:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (l == 5) {
|
2012-11-06 13:05:28 +01:00
|
|
|
j1 = 3;
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (l != 1 && l != 0 && f1 > 0.5F) {
|
2012-11-06 13:05:28 +01:00
|
|
|
j1 |= 8;
|
2011-06-30 19:51:42 +02:00
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
return j1;
|
2011-06-30 19:51:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean canPlace(World world, int i, int j, int k, int l) {
|
|
|
|
if (l == 0) {
|
|
|
|
return false;
|
|
|
|
} else if (l == 1) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
if (l == 2) {
|
|
|
|
++k;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l == 3) {
|
|
|
|
--k;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l == 4) {
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l == 5) {
|
|
|
|
--i;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
return g(world.getTypeId(i, j, k));
|
2011-06-30 19:51:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public static boolean f(int i) {
|
2011-06-30 19:51:42 +02:00
|
|
|
return (i & 4) != 0;
|
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
private static boolean g(int i) {
|
2011-11-20 09:01:14 +01:00
|
|
|
if (i <= 0) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
Block block = Block.byId[i];
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
return block != null && block.material.k() && block.b() || block == Block.GLOWSTONE || block instanceof BlockStepAbstract || block instanceof BlockStairs;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
}
|
2011-06-30 19:51:42 +02:00
|
|
|
}
|