diff options
Diffstat (limited to 'src/main/java/net/minecraft')
-rw-r--r-- | src/main/java/net/minecraft/server/BlockButton.java | 258 | ||||
-rw-r--r-- | src/main/java/net/minecraft/server/BlockChest.java | 169 | ||||
-rw-r--r-- | src/main/java/net/minecraft/server/BlockDoor.java | 194 | ||||
-rw-r--r-- | src/main/java/net/minecraft/server/BlockFurnace.java | 121 | ||||
-rw-r--r-- | src/main/java/net/minecraft/server/BlockJukeBox.java | 64 | ||||
-rw-r--r-- | src/main/java/net/minecraft/server/BlockLever.java | 231 | ||||
-rw-r--r-- | src/main/java/net/minecraft/server/BlockPressurePlate.java | 171 | ||||
-rw-r--r-- | src/main/java/net/minecraft/server/BlockWorkbench.java | 48 |
8 files changed, 1256 insertions, 0 deletions
diff --git a/src/main/java/net/minecraft/server/BlockButton.java b/src/main/java/net/minecraft/server/BlockButton.java new file mode 100644 index 00000000..cc4462d6 --- /dev/null +++ b/src/main/java/net/minecraft/server/BlockButton.java @@ -0,0 +1,258 @@ +package net.minecraft.server; + + +import java.util.Random; + +import org.bukkit.craftbukkit.CraftBlock; +import org.bukkit.craftbukkit.CraftPlayer; +import org.bukkit.event.Event.Type; +import org.bukkit.event.block.BlockInteractEvent; + + +public class BlockButton extends Block { + + protected BlockButton(int i, int j) { + super(i, j, Material.n); + a(true); + } + + public AxisAlignedBB d(World world, int i, int j, int k) { + return null; + } + + public int b() { + return 20; + } + + public boolean a() { + return false; + } + + public boolean a(World world, int i, int j, int k) { + if (world.d(i - 1, j, k)) { + return true; + } + if (world.d(i + 1, j, k)) { + return true; + } + if (world.d(i, j, k - 1)) { + return true; + } + return world.d(i, j, k + 1); + } + + public void c(World world, int i, int j, int k, int l) { + int i1 = world.b(i, j, k); + int j1 = i1 & 8; + + i1 &= 7; + if (l == 2 && world.d(i, j, k + 1)) { + i1 = 4; + } + if (l == 3 && world.d(i, j, k - 1)) { + i1 = 3; + } + if (l == 4 && world.d(i + 1, j, k)) { + i1 = 2; + } + if (l == 5 && world.d(i - 1, j, k)) { + i1 = 1; + } + world.b(i, j, k, i1 + j1); + } + + public void e(World world, int i, int j, int k) { + if (world.d(i - 1, j, k)) { + world.b(i, j, k, 1); + } else if (world.d(i + 1, j, k)) { + world.b(i, j, k, 2); + } else if (world.d(i, j, k - 1)) { + world.b(i, j, k, 3); + } else if (world.d(i, j, k + 1)) { + world.b(i, j, k, 4); + } + g(world, i, j, k); + } + + public void b(World world, int i, int j, int k, int l) { + if (g(world, i, j, k)) { + int i1 = world.b(i, j, k) & 7; + boolean flag = false; + + if (!world.d(i - 1, j, k) && i1 == 1) { + flag = true; + } + if (!world.d(i + 1, j, k) && i1 == 2) { + flag = true; + } + if (!world.d(i, j, k - 1) && i1 == 3) { + flag = true; + } + if (!world.d(i, j, k + 1) && i1 == 4) { + flag = true; + } + if (flag) { + a_(world, i, j, k, world.b(i, j, k)); + world.d(i, j, k, 0); + } + } + } + + private boolean g(World world, int i, int j, int k) { + if (!a(world, i, j, k)) { + a_(world, i, j, k, world.b(i, j, k)); + world.d(i, j, k, 0); + return false; + } else { + return true; + } + } + + public void a(IBlockAccess iblockaccess, int i, int j, int k) { + int l = iblockaccess.b(i, j, k); + int i1 = l & 7; + boolean flag = (l & 8) > 0; + float f = 0.375F; + float f1 = 0.625F; + float f2 = 0.1875F; + float f3 = 0.125F; + + if (flag) { + f3 = 0.0625F; + } + if (i1 == 1) { + a(0.0F, f, 0.5F - f2, f3, f1, 0.5F + f2); + } else if (i1 == 2) { + a(1.0F - f3, f, 0.5F - f2, 1.0F, f1, 0.5F + f2); + } else if (i1 == 3) { + a(0.5F - f2, f, 0.0F, 0.5F + f2, f1, f3); + } else if (i1 == 4) { + a(0.5F - f2, f, 1.0F - f3, 0.5F + f2, f1, 1.0F); + } + } + + public void b(World world, int i, int j, int k, EntityPlayer entityplayer) { + a(world, i, j, k, entityplayer); + } + + public boolean a(World world, int i, int j, int k, EntityPlayer entityplayer) { + // Craftbukkit start - Interact Button + CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); + CraftPlayer player = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer); + BlockInteractEvent bie = new BlockInteractEvent(Type.BLOCK_INTERACT, block, player); + + ((WorldServer) world).getServer().getPluginManager().callEvent(bie); + + if (bie.isCancelled()) return true; + + if (world.z) { + return true; + } + int l = world.b(i, j, k); + int i1 = l & 7; + int j1 = 8 - (l & 8); + + if (j1 == 0) { + return true; + } + world.b(i, j, k, i1 + j1); + world.b(i, j, k, i, j, k); + world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.6F); + world.g(i, j, k, bh); + if (i1 == 1) { + world.g(i - 1, j, k, bh); + } else if (i1 == 2) { + world.g(i + 1, j, k, bh); + } else if (i1 == 3) { + world.g(i, j, k - 1, bh); + } else if (i1 == 4) { + world.g(i, j, k + 1, bh); + } else { + world.g(i, j - 1, k, bh); + } + world.h(i, j, k, bh); + return true; + } + + public void b(World world, int i, int j, int k) { + int l = world.b(i, j, k); + + if ((l & 8) > 0) { + world.g(i, j, k, bh); + int i1 = l & 7; + + if (i1 == 1) { + world.g(i - 1, j, k, bh); + } else if (i1 == 2) { + world.g(i + 1, j, k, bh); + } else if (i1 == 3) { + world.g(i, j, k - 1, bh); + } else if (i1 == 4) { + world.g(i, j, k + 1, bh); + } else { + world.g(i, j - 1, k, bh); + } + } + super.b(world, i, j, k); + } + + public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) { + return (iblockaccess.b(i, j, k) & 8) > 0; + } + + public boolean d(World world, int i, int j, int k, int l) { + int i1 = world.b(i, j, k); + + if ((i1 & 8) == 0) { + return false; + } + int j1 = i1 & 7; + + if (j1 == 5 && l == 1) { + return true; + } + if (j1 == 4 && l == 2) { + return true; + } + if (j1 == 3 && l == 3) { + return true; + } + if (j1 == 2 && l == 4) { + return true; + } + return j1 == 1 && l == 5; + } + + public boolean c() { + return true; + } + + public void a(World world, int i, int j, int k, Random random) { + if (world.z) { + return; + } + int l = world.b(i, j, k); + + if ((l & 8) == 0) { + return; + } + world.b(i, j, k, l & 7); + world.g(i, j, k, bh); + int i1 = l & 7; + + if (i1 == 1) { + world.g(i - 1, j, k, bh); + } else if (i1 == 2) { + world.g(i + 1, j, k, bh); + } else if (i1 == 3) { + world.g(i, j, k - 1, bh); + } else if (i1 == 4) { + world.g(i, j, k + 1, bh); + } else { + world.g(i, j - 1, k, bh); + } + world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.5F); + world.b(i, j, k, i, j, k); + } +} + diff --git a/src/main/java/net/minecraft/server/BlockChest.java b/src/main/java/net/minecraft/server/BlockChest.java new file mode 100644 index 00000000..90e41e33 --- /dev/null +++ b/src/main/java/net/minecraft/server/BlockChest.java @@ -0,0 +1,169 @@ +package net.minecraft.server; + + +import java.util.Random; + +import org.bukkit.craftbukkit.CraftBlock; +import org.bukkit.craftbukkit.CraftPlayer; +import org.bukkit.event.Event.Type; +import org.bukkit.event.block.BlockInteractEvent; + + +public class BlockChest extends BlockContainer { + + private Random a; + + protected BlockChest(int i) { + super(i, Material.c); + a = new Random(); + bg = 26; + } + + public int a(int i) { + if (i == 1) { + return bg - 1; + } + if (i == 0) { + return bg - 1; + } + if (i == 3) { + return bg + 1; + } else { + return bg; + } + } + + public boolean a(World world, int i, int j, int k) { + int l = 0; + + if (world.a(i - 1, j, k) == bh) { + l++; + } + if (world.a(i + 1, j, k) == bh) { + l++; + } + if (world.a(i, j, k - 1) == bh) { + l++; + } + if (world.a(i, j, k + 1) == bh) { + l++; + } + if (l > 1) { + return false; + } + if (g(world, i - 1, j, k)) { + return false; + } + if (g(world, i + 1, j, k)) { + return false; + } + if (g(world, i, j, k - 1)) { + return false; + } + return !g(world, i, j, k + 1); + } + + private boolean g(World world, int i, int j, int k) { + if (world.a(i, j, k) != bh) { + return false; + } + if (world.a(i - 1, j, k) == bh) { + return true; + } + if (world.a(i + 1, j, k) == bh) { + return true; + } + if (world.a(i, j, k - 1) == bh) { + return true; + } + return world.a(i, j, k + 1) == bh; + } + + public void b(World world, int i, int j, int k) { + TileEntityChest tileentitychest = (TileEntityChest) world.l(i, j, k); + + label0: + for (int l = 0; l < tileentitychest.a(); l++) { + ItemStack itemstack = tileentitychest.a(l); + + if (itemstack == null) { + continue; + } + float f = a.nextFloat() * 0.8F + 0.1F; + float f1 = a.nextFloat() * 0.8F + 0.1F; + float f2 = a.nextFloat() * 0.8F + 0.1F; + + do { + if (itemstack.a <= 0) { + continue label0; + } + int i1 = a.nextInt(21) + 10; + + if (i1 > itemstack.a) { + i1 = itemstack.a; + } + itemstack.a -= i1; + EntityItem entityitem = new EntityItem(world, (float) i + f, (float) j + f1, (float) k + f2, new ItemStack(itemstack.c, i1, itemstack.d)); + float f3 = 0.05F; + + entityitem.s = (float) a.nextGaussian() * f3; + entityitem.t = (float) a.nextGaussian() * f3 + 0.2F; + entityitem.u = (float) a.nextGaussian() * f3; + world.a(entityitem); + } while (true); + } + + super.b(world, i, j, k); + } + + public boolean a(World world, int i, int j, int k, EntityPlayer entityplayer) { + Object obj = (TileEntityChest) world.l(i, j, k); + + if (world.d(i, j + 1, k)) { + return true; + } + if (world.a(i - 1, j, k) == bh && world.d(i - 1, j + 1, k)) { + return true; + } + if (world.a(i + 1, j, k) == bh && world.d(i + 1, j + 1, k)) { + return true; + } + if (world.a(i, j, k - 1) == bh && world.d(i, j + 1, k - 1)) { + return true; + } + if (world.a(i, j, k + 1) == bh && world.d(i, j + 1, k + 1)) { + return true; + } + if (world.a(i - 1, j, k) == bh) { + obj = new InventoryLargeChest("Large chest", (TileEntityChest) world.l(i - 1, j, k), ((IInventory) (obj))); + } + if (world.a(i + 1, j, k) == bh) { + obj = new InventoryLargeChest("Large chest", ((IInventory) (obj)), (TileEntityChest) world.l(i + 1, j, k)); + } + if (world.a(i, j, k - 1) == bh) { + obj = new InventoryLargeChest("Large chest", (TileEntityChest) world.l(i, j, k - 1), ((IInventory) (obj))); + } + if (world.a(i, j, k + 1) == bh) { + obj = new InventoryLargeChest("Large chest", ((IInventory) (obj)), (TileEntityChest) world.l(i, j, k + 1)); + } + if (world.z) { + return true; + } else { + // Craftbukkit start - Interact Chest + CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); + CraftPlayer player = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer); + BlockInteractEvent bie = new BlockInteractEvent(Type.BLOCK_INTERACT, block, player); + + ((WorldServer) world).getServer().getPluginManager().callEvent(bie); + + if (!bie.isCancelled()) entityplayer.a(((IInventory) (obj))); + + return true; + } + } + + protected TileEntity a_() { + return new TileEntityChest(); + } +} + diff --git a/src/main/java/net/minecraft/server/BlockDoor.java b/src/main/java/net/minecraft/server/BlockDoor.java new file mode 100644 index 00000000..08fba33b --- /dev/null +++ b/src/main/java/net/minecraft/server/BlockDoor.java @@ -0,0 +1,194 @@ +package net.minecraft.server; + + +import java.util.Random; + +import org.bukkit.craftbukkit.CraftBlock; +import org.bukkit.craftbukkit.CraftPlayer; +import org.bukkit.event.Event.Type; +import org.bukkit.event.block.BlockInteractEvent; + + +public class BlockDoor extends Block { + + protected BlockDoor(int i, Material material) { + super(i, material); + bg = 97; + if (material == Material.e) { + bg++; + } + float f = 0.5F; + float f1 = 1.0F; + + a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f); + } + + public boolean a() { + return false; + } + + public AxisAlignedBB d(World world, int i, int j, int k) { + a(world, i, j, k); + return super.d(world, i, j, k); + } + + public void a(IBlockAccess iblockaccess, int i, int j, int k) { + b(d(iblockaccess.b(i, j, k))); + } + + public void b(int i) { + float f = 0.1875F; + + a(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F); + if (i == 0) { + a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); + } + if (i == 1) { + a(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + if (i == 2) { + a(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); + } + if (i == 3) { + a(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); + } + } + + public void b(World world, int i, int j, int k, EntityPlayer entityplayer) { + a(world, i, j, k, entityplayer); + } + + public boolean a(World world, int i, int j, int k, EntityPlayer entityplayer) { + if (bs == Material.e) { + return true; + } + int l = world.b(i, j, k); + + if ((l & 8) != 0) { + if (world.a(i, j - 1, k) == bh) { + a(world, i, j - 1, k, entityplayer); + } + return true; + } + + // Craftbukkit start - Interact Door + CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); + CraftPlayer player = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer); + BlockInteractEvent bie = new BlockInteractEvent(Type.BLOCK_INTERACT, block, player); + + ((WorldServer) world).getServer().getPluginManager().callEvent(bie); + + // Craftbukkit the client updates the doors before the server does it's thing. + // Forcibly send correct data. + if (bie.isCancelled()) { + ((EntityPlayerMP) entityplayer).a.b(new Packet53BlockChange(i, j, k, (WorldServer) world)); + ((EntityPlayerMP) entityplayer).a.b(new Packet53BlockChange(i, j + 1, k, (WorldServer) world)); + return true; + } + + if (world.a(i, j + 1, k) == bh) { + world.b(i, j + 1, k, (l ^ 4) + 8); + } + world.b(i, j, k, l ^ 4); + world.b(i, j - 1, k, i, j, k); + if (Math.random() < 0.5D) { + world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_open", 1.0F, world.l.nextFloat() * 0.1F + 0.9F); + } else { + world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_close", 1.0F, world.l.nextFloat() * 0.1F + 0.9F); + } + return true; + } + + public void a(World world, int i, int j, int k, boolean flag) { + int l = world.b(i, j, k); + + if ((l & 8) != 0) { + if (world.a(i, j - 1, k) == bh) { + a(world, i, j - 1, k, flag); + } + return; + } + boolean flag1 = (world.b(i, j, k) & 4) > 0; + + if (flag1 == flag) { + return; + } + if (world.a(i, j + 1, k) == bh) { + world.b(i, j + 1, k, (l ^ 4) + 8); + } + world.b(i, j, k, l ^ 4); + world.b(i, j - 1, k, i, j, k); + if (Math.random() < 0.5D) { + world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_open", 1.0F, world.l.nextFloat() * 0.1F + 0.9F); + } else { + world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_close", 1.0F, world.l.nextFloat() * 0.1F + 0.9F); + } + } + + public void b(World world, int i, int j, int k, int l) { + int i1 = world.b(i, j, k); + + if ((i1 & 8) != 0) { + if (world.a(i, j - 1, k) != bh) { + world.d(i, j, k, 0); + } + if (l > 0 && Block.m[l].c()) { + b(world, i, j - 1, k, l); + } + } else { + boolean flag = false; + + if (world.a(i, j + 1, k) != bh) { + world.d(i, j, k, 0); + flag = true; + } + if (!world.d(i, j - 1, k)) { + world.d(i, j, k, 0); + flag = true; + if (world.a(i, j + 1, k) == bh) { + world.d(i, j + 1, k, 0); + } + } + if (flag) { + a_(world, i, j, k, i1); + } else if (l > 0 && Block.m[l].c()) { + boolean flag1 = world.o(i, j, k) || world.o(i, j + 1, k); + + a(world, i, j, k, flag1); + } + } + } + + public int a(int i, Random random) { + if ((i & 8) != 0) { + return 0; + } + if (bs == Material.e) { + return Item.az.aW; + } else { + return Item.at.aW; + } + } + + public MovingObjectPosition a(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) { + a(((IBlockAccess) (world)), i, j, k); + return super.a(world, i, j, k, vec3d, vec3d1); + } + + public int d(int i) { + if ((i & 4) == 0) { + return i - 1 & 3; + } else { + return i & 3; + } + } + + public boolean a(World world, int i, int j, int k) { + if (j >= 127) { + return false; + } else { + return world.d(i, j - 1, k) && super.a(world, i, j, k) && super.a(world, i, j + 1, k); + } + } +} + diff --git a/src/main/java/net/minecraft/server/BlockFurnace.java b/src/main/java/net/minecraft/server/BlockFurnace.java new file mode 100644 index 00000000..64df942c --- /dev/null +++ b/src/main/java/net/minecraft/server/BlockFurnace.java @@ -0,0 +1,121 @@ +package net.minecraft.server; + + +import java.util.Random; + +import org.bukkit.craftbukkit.CraftBlock; +import org.bukkit.craftbukkit.CraftPlayer; +import org.bukkit.event.Event.Type; +import org.bukkit.event.block.BlockInteractEvent; + + +public class BlockFurnace extends BlockContainer { + + private final boolean a; + + protected BlockFurnace(int i, boolean flag) { + super(i, Material.d); + a = flag; + bg = 45; + } + + public int a(int i, Random random) { + return Block.aB.bh; + } + + public void e(World world, int i, int j, int k) { + super.e(world, i, j, k); + g(world, i, j, k); + } + + private void g(World world, int i, int j, int k) { + int l = world.a(i, j, k - 1); + int i1 = world.a(i, j, k + 1); + int j1 = world.a(i - 1, j, k); + int k1 = world.a(i + 1, j, k); + byte byte0 = 3; + + if (Block.o[l] && !Block.o[i1]) { + byte0 = 3; + } + if (Block.o[i1] && !Block.o[l]) { + byte0 = 2; + } + if (Block.o[j1] && !Block.o[k1]) { + byte0 = 5; + } + if (Block.o[k1] && !Block.o[j1]) { + byte0 = 4; + } + world.b(i, j, k, byte0); + } + + public int a(int i) { + if (i == 1) { + return Block.t.bh; + } + if (i == 0) { + return Block.t.bh; + } + if (i == 3) { + return bg - 1; + } else { + return bg; + } + } + + public boolean a(World world, int i, int j, int k, EntityPlayer entityplayer) { + if (world.z) { + return true; + } else { + // Craftbukkit start - Interact Furnace + CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); + CraftPlayer player = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer); + BlockInteractEvent bie = new BlockInteractEvent(Type.BLOCK_INTERACT, block, player); + + ((WorldServer) world).getServer().getPluginManager().callEvent(bie); + + if (bie.isCancelled()) return true; + + TileEntityFurnace tileentityfurnace = (TileEntityFurnace) world.l(i, j, k); + + entityplayer.a(tileentityfurnace); + return true; + } + } + + public static void a(boolean flag, World world, int i, int j, int k) { + int l = world.b(i, j, k); + TileEntity tileentity = world.l(i, j, k); + + if (flag) { + world.d(i, j, k, Block.aC.bh); + } else { + world.d(i, j, k, Block.aB.bh); + } + world.b(i, j, k, l); + world.a(i, j, k, tileentity); + } + + protected TileEntity a_() { + return new TileEntityFurnace(); + } + + public void a(World world, int i, int j, int k, EntityLiving entityliving) { + int l = MathHelper.b((double) ((entityliving.v * 4F) / 360F) + 0.5D) & 3; + + if (l == 0) { + world.b(i, j, k, 2); + } + if (l == 1) { + world.b(i, j, k, 5); + } + if (l == 2) { + world.b(i, j, k, 3); + } + if (l == 3) { + world.b(i, j, k, 4); + } + } +} + diff --git a/src/main/java/net/minecraft/server/BlockJukeBox.java b/src/main/java/net/minecraft/server/BlockJukeBox.java new file mode 100644 index 00000000..8c7e61ad --- /dev/null +++ b/src/main/java/net/minecraft/server/BlockJukeBox.java @@ -0,0 +1,64 @@ +package net.minecraft.server; + + +import org.bukkit.craftbukkit.CraftBlock; +import org.bukkit.craftbukkit.CraftPlayer; +import org.bukkit.event.Event.Type; +import org.bukkit.event.block.BlockInteractEvent; + + +public class BlockJukeBox extends Block { + + protected BlockJukeBox(int i, int j) { + super(i, j, Material.c); + } + + public int a(int i) { + return bg + (i != 1 ? 0 : 1); + } + + public boolean a(World world, int i, int j, int k, EntityPlayer entityplayer) { + int l = world.b(i, j, k); + + if (l > 0) { + // Craftbukkit start - Interact Jukebox + CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); + CraftPlayer player = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer); + BlockInteractEvent bie = new BlockInteractEvent(Type.BLOCK_INTERACT, block, player); + + ((WorldServer) world).getServer().getPluginManager().callEvent(bie); + + if (bie.isCancelled()) return true; + + f(world, i, j, k, l); + return true; + } else { + return false; + } + } + + public void f(World world, int i, int j, int k, int l) { + world.a((String) null, i, j, k); + world.b(i, j, k, 0); + int i1 = (Item.aU.aW + l) - 1; + float f1 = 0.7F; + double d = (double) (world.l.nextFloat() * f1) + (double) (1.0F - f1) * 0.5D; + double d1 = (double) (world.l.nextFloat() * f1) + (double) (1.0F - f1) * 0.20000000000000001D + 0.59999999999999998D; + double d2 = (double) (world.l.nextFloat() * f1) + (double) (1.0F - f1) * 0.5D; + EntityItem entityitem = new EntityItem(world, (double) i + d, (double) j + d1, (double) k + d2, new ItemStack(i1)); + + entityitem.c = 10; + world.a(entityitem); + } + + public void a(World world, int i, int j, int k, int l, float f1) { + if (world.z) { + return; + } + if (l > 0) { + f(world, i, j, k, l); + } + super.a(world, i, j, k, l, f1); + } +} + diff --git a/src/main/java/net/minecraft/server/BlockLever.java b/src/main/java/net/minecraft/server/BlockLever.java new file mode 100644 index 00000000..b8204e16 --- /dev/null +++ b/src/main/java/net/minecraft/server/BlockLever.java @@ -0,0 +1,231 @@ +package net.minecraft.server; + +import org.bukkit.craftbukkit.CraftBlock; +import org.bukkit.craftbukkit.CraftPlayer; +import org.bukkit.event.Event.Type; +import org.bukkit.event.block.BlockInteractEvent; + + +public class BlockLever extends Block { + + protected BlockLever(int i, int j) { + super(i, j, Material.n); + } + + public AxisAlignedBB d(World world, int i, int j, int k) { + return null; + } + + public boolean a() { + return false; + } + + public boolean a(World world, int i, int j, int k) { + if (world.d(i - 1, j, k)) { + return true; + } + if (world.d(i + 1, j, k)) { + return true; + } + if (world.d(i, j, k - 1)) { + return true; + } + if (world.d(i, j, k + 1)) { + return true; + } + return world.d(i, j - 1, k); + } + + public void c(World world, int i, int j, int k, int l) { + int i1 = world.b(i, j, k); + int j1 = i1 & 8; + + i1 &= 7; + if (l == 1 && world.d(i, j - 1, k)) { + i1 = 5 + world.l.nextInt(2); + } + if (l == 2 && world.d(i, j, k + 1)) { + i1 = 4; + } + if (l == 3 && world.d(i, j, k - 1)) { + i1 = 3; + } + if (l == 4 && world.d(i + 1, j, k)) { + i1 = 2; + } + if (l == 5 && world.d(i - 1, j, k)) { + i1 = 1; + } + world.b(i, j, k, i1 + j1); + } + + public void e(World world, int i, int j, int k) { + if (world.d(i - 1, j, k)) { + world.b(i, j, k, 1); + } else if (world.d(i + 1, j, k)) { + world.b(i, j, k, 2); + } else if (world.d(i, j, k - 1)) { + world.b(i, j, k, 3); + } else if (world.d(i, j, k + 1)) { + world.b(i, j, k, 4); + } else if (world.d(i, j - 1, k)) { + world.b(i, j, k, 5 + world.l.nextInt(2)); + } + g(world, i, j, k); + } + + public void b(World world, int i, int j, int k, int l) { + if (g(world, i, j, k)) { + int i1 = world.b(i, j, k) & 7; + boolean flag = false; + + if (!world.d(i - 1, j, k) && i1 == 1) { + flag = true; + } + if (!world.d(i + 1, j, k) && i1 == 2) { + flag = true; + } + if (!world.d(i, j, k - 1) && i1 == 3) { + flag = true; + } + if (!world.d(i, j, k + 1) && i1 == 4) { + flag = true; + } + if (!world.d(i, j - 1, k) && i1 == 5) { + flag = true; + } + if (flag) { + a_(world, i, j, k, world.b(i, j, k)); + world.d(i, j, k, 0); + } + } + } + + private boolean g(World world, int i, int j, int k) { + if (!a(world, i, j, k)) { + a_(world, i, j, k, world.b(i, j, k)); + world.d(i, j, k, 0); + return false; + } else { + return true; + } + } + + public void a(IBlockAccess iblockaccess, int i, int j, int k) { + int l = iblockaccess.b(i, j, k) & 7; + float f = 0.1875F; + + if (l == 1) { + a(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f); + } else if (l == 2) { + a(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f); + } else if (l == 3) { + a(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F); + } else if (l == 4) { + a(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F); + } else { + float f1 = 0.25F; + + a(0.5F - f1, 0.0F, 0.5F - f1, 0.5F + f1, 0.6F, 0.5F + f1); + } + } + + public void b(World world, int i, int j, int k, EntityPlayer entityplayer) { + a(world, i, j, k, entityplayer); + } + + public boolean a(World world, int i, int j, int k, EntityPlayer entityplayer) { + if (world.z) { + return true; + } + + // Craftbukkit start - Interact Lever + CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); + CraftPlayer player = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer); + BlockInteractEvent bie = new BlockInteractEvent(Type.BLOCK_INTERACT, block, player); + + ((WorldServer) world).getServer().getPluginManager().callEvent(bie); + + // Craftbukkit the client updates the doors before the server does it's thing. + // Forcibly send correct data. + if (bie.isCancelled()) { + ((EntityPlayerMP) entityplayer).a.b(new Packet53BlockChange(i, j, k, (WorldServer) world)); + return true; + } + + int l = world.b(i, j, k); + int i1 = l & 7; + int j1 = 8 - (l & 8); + + world.b(i, j, k, i1 + j1); + world.b(i, j, k, i, j, k); + world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, j1 <= 0 ? 0.5F : 0.6F); + world.g(i, j, k, bh); + if (i1 == 1) { + world.g(i - 1, j, k, bh); + } else if (i1 == 2) { + world.g(i + 1, j, k, bh); + } else if (i1 == 3) { + world.g(i, j, k - 1, bh); + } else if (i1 == 4) { + world.g(i, j, k + 1, bh); + } else { + world.g(i, j - 1, k, bh); + } + return true; + } + + public void b(World world, int i, int j, int k) { + int l = world.b(i, j, k); + + if ((l & 8) > 0) { + world.g(i, j, k, bh); + int i1 = l & 7; + + if (i1 == 1) { + world.g(i - 1, j, k, bh); + } else if (i1 == 2) { + world.g(i + 1, j, k, bh); + } else if (i1 == 3) { + world.g(i, j, k - 1, bh); + } else if (i1 == 4) { + world.g(i, j, k + 1, bh); + } else { + world.g(i, j - 1, k, bh); + } + } + super.b(world, i, j, k); + } + + public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) { + return (iblockaccess.b(i, j, k) & 8) > 0; + } + + public boolean d(World world, int i, int j, int k, int l) { + int i1 = world.b(i, j, k); + + if ((i1 & 8) == 0) { + return false; + } + int j1 = i1 & 7; + + if (j1 == 5 && l == 1) { + return true; + } + if (j1 == 4 && l == 2) { + return true; + } + if (j1 == 3 && l == 3) { + return true; + } + if (j1 == 2 && l == 4) { + return true; + } + return j1 == 1 && l == 5; + } + + public boolean c() { + return true; + } +} + diff --git a/src/main/java/net/minecraft/server/BlockPressurePlate.java b/src/main/java/net/minecraft/server/BlockPressurePlate.java new file mode 100644 index 00000000..4745f678 --- /dev/null +++ b/src/main/java/net/minecraft/server/BlockPressurePlate.java @@ -0,0 +1,171 @@ +package net.minecraft.server; + + +import java.util.List; +import java.util.Random; + +import org.bukkit.craftbukkit.CraftBlock; +import org.bukkit.craftbukkit.CraftLivingEntity; +import org.bukkit.craftbukkit.CraftPlayer; +import org.bukkit.event.Event.Type; +import org.bukkit.event.block.BlockInteractEvent; + + +public class BlockPressurePlate extends Block { + + private EnumMobType a; + + protected BlockPressurePlate(int i, int j, EnumMobType enummobtype) { + super(i, j, Material.d); + a = enummobtype; + a(true); + float f = 0.0625F; + + a(f, 0.0F, f, 1.0F - f, 0.03125F, 1.0F - f); + } + + public int b() { + return 20; + } + + public AxisAlignedBB d(World world, int i, int j, int k) { + return null; + } + + public boolean a() { + return false; + } + + public boolean a(World world, int i, int j, int k) { + return world.d(i, j - 1, k); + } + + public void e(World world, int i, int j, int k) {} + + public void b(World world, int i, int j, int k, int l) { + boolean flag = false; + + if (!world.d(i, j - 1, k)) { + flag = true; + } + if (flag) { + a_(world, i, j, k, world.b(i, j, k)); + world.d(i, j, k, 0); + } + } + + public void a(World world, int i, int j, int k, Random random) { + if (world.z) { + return; + } + if (world.b(i, j, k) == 0) { + return; + } else { + g(world, i, j, k); + return; + } + } + + public void a(World world, int i, int j, int k, Entity entity) { + if (world.z) { + return; + } + if (world.b(i, j, k) == 1) { + return; + } else { + if (entity instanceof EntityLiving) { + // Craftbukkit start - Interact Pressure Plate + CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); + CraftLivingEntity craftEntity = null; + if (entity instanceof EntityPlayerMP) { + craftEntity = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entity); + } else { + craftEntity = new CraftLivingEntity(((WorldServer) world).getServer(), (EntityLiving) entity); + } + BlockInteractEvent bie = new BlockInteractEvent(Type.BLOCK_INTERACT, block, craftEntity); + + ((WorldServer) world).getServer().getPluginManager().callEvent(bie); + + if (bie.isCancelled()) return; + } + + g(world, i, j, k); + return; + } + } + + private void g(World world, int i, int j, int k) { + boolean flag = world.b(i, j, k) == 1; + boolean flag1 = false; + float f = 0.125F; + List list = null; + + if (a == EnumMobType.a) { + list = world.b(null, AxisAlignedBB.b((float) i + f, j, (float) k + f, (float) (i + 1) - f, (double) j + 0.25D, (float) (k + 1) - f)); + } + if (a == EnumMobType.b) { + list = world.a(net.minecraft.server.EntityLiving.class, AxisAlignedBB.b((float) i + f, j, (float) k + f, (float) (i + 1) - f, (double) j + 0.25D, (float) (k + 1) - f)); + } + if (a == EnumMobType.c) { + list = world.a(net.minecraft.server.EntityPlayer.class, AxisAlignedBB.b((float) i + f, j, (float) k + f, (float) (i + 1) - f, (double) j + 0.25D, (float) (k + 1) - f)); + } + if (list.size() > 0) { + flag1 = true; + } + if (flag1 && !flag) { + world.b(i, j, k, 1); + world.g(i, j, k, bh); + world.g(i, j - 1, k, bh); + world.b(i, j, k, i, j, k); + world.a((double) i + 0.5D, (double) j + 0.10000000000000001D, (double) k + 0.5D, "random.click", 0.3F, 0.6F); + } + if (!flag1 && flag) { + world.b(i, j, k, 0); + world.g(i, j, k, bh); + world.g(i, j - 1, k, bh); + world.b(i, j, k, i, j, k); + world.a((double) i + 0.5D, (double) j + 0.10000000000000001D, (double) k + 0.5D, "random.click", 0.3F, 0.5F); + } + if (flag1) { + world.h(i, j, k, bh); + } + } + + public void b(World world, int i, int j, int k) { + int l = world.b(i, j, k); + + if (l > 0) { + world.g(i, j, k, bh); + world.g(i, j - 1, k, bh); + } + super.b(world, i, j, k); + } + + public void a(IBlockAccess iblockaccess, int i, int j, int k) { + boolean flag = iblockaccess.b(i, j, k) == 1; + float f = 0.0625F; + + if (flag) { + a(f, 0.0F, f, 1.0F - f, 0.03125F, 1.0F - f); + } else { + a(f, 0.0F, f, 1.0F - f, 0.0625F, 1.0F - f); + } + } + + public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) { + return iblockaccess.b(i, j, k) > 0; + } + + public boolean d(World world, int i, int j, int k, int l) { + if (world.b(i, j, k) == 0) { + return false; + } else { + return l == 1; + } + } + + public boolean c() { + return true; + } +} + diff --git a/src/main/java/net/minecraft/server/BlockWorkbench.java b/src/main/java/net/minecraft/server/BlockWorkbench.java new file mode 100644 index 00000000..08977d50 --- /dev/null +++ b/src/main/java/net/minecraft/server/BlockWorkbench.java @@ -0,0 +1,48 @@ +package net.minecraft.server; + +import org.bukkit.craftbukkit.CraftBlock; +import org.bukkit.craftbukkit.CraftPlayer; +import org.bukkit.event.Event.Type; +import org.bukkit.event.block.BlockInteractEvent; + + +public class BlockWorkbench extends Block { + + protected BlockWorkbench(int i) { + super(i, Material.c); + bg = 59; + } + + public int a(int i) { + if (i == 1) { + return bg - 16; + } + if (i == 0) { + return Block.x.a(0); + } + if (i == 2 || i == 4) { + return bg + 1; + } else { + return bg; + } + } + + public boolean a(World world, int i, int j, int k, EntityPlayer entityplayer) { + if (world.z) { + return true; + } else { + // Craftbukkit start - Interact Workbench + CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); + CraftPlayer player = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer); + BlockInteractEvent bie = new BlockInteractEvent(Type.BLOCK_INTERACT, block, player); + + ((WorldServer) world).getServer().getPluginManager().callEvent(bie); + + if (bie.isCancelled()) return true; + + entityplayer.a(i, j, k); + return true; + } + } +} + |