summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvilSeph <evilseph@unaligned.org>2011-07-02 19:17:43 -0400
committerEvilSeph <evilseph@unaligned.org>2011-07-02 20:46:25 -0400
commit22097a9962cb53ddf837e8b9861029cc825509b0 (patch)
tree96fd813f7ad2c4ccf6f4f98d04f35877958f4d81
parent7cd03e65d11bf5dd79f9d56b89f7de220238205e (diff)
downloadcraftbukkit-22097a9962cb53ddf837e8b9861029cc825509b0.tar
craftbukkit-22097a9962cb53ddf837e8b9861029cc825509b0.tar.gz
craftbukkit-22097a9962cb53ddf837e8b9861029cc825509b0.tar.lz
craftbukkit-22097a9962cb53ddf837e8b9861029cc825509b0.tar.xz
craftbukkit-22097a9962cb53ddf837e8b9861029cc825509b0.zip
Fixed NPE in BlockFurnace.
-rw-r--r--src/main/java/net/minecraft/server/BlockFurnace.java145
1 files changed, 145 insertions, 0 deletions
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..e5cae3d2
--- /dev/null
+++ b/src/main/java/net/minecraft/server/BlockFurnace.java
@@ -0,0 +1,145 @@
+package net.minecraft.server;
+
+import java.util.Random;
+
+public class BlockFurnace extends BlockContainer {
+
+ private Random a = new Random();
+ private final boolean b;
+ private static boolean c = false;
+
+ protected BlockFurnace(int i, boolean flag) {
+ super(i, Material.STONE);
+ this.b = flag;
+ this.textureId = 45;
+ }
+
+ public int a(int i, Random random) {
+ return Block.FURNACE.id;
+ }
+
+ public void c(World world, int i, int j, int k) {
+ super.c(world, i, j, k);
+ this.g(world, i, j, k);
+ }
+
+ private void g(World world, int i, int j, int k) {
+ if (!world.isStatic) {
+ int l = world.getTypeId(i, j, k - 1);
+ int i1 = world.getTypeId(i, j, k + 1);
+ int j1 = world.getTypeId(i - 1, j, k);
+ int k1 = world.getTypeId(i + 1, j, k);
+ byte b0 = 3;
+
+ if (Block.o[l] && !Block.o[i1]) {
+ b0 = 3;
+ }
+
+ if (Block.o[i1] && !Block.o[l]) {
+ b0 = 2;
+ }
+
+ if (Block.o[j1] && !Block.o[k1]) {
+ b0 = 5;
+ }
+
+ if (Block.o[k1] && !Block.o[j1]) {
+ b0 = 4;
+ }
+
+ world.setData(i, j, k, b0);
+ }
+ }
+
+ public int a(int i) {
+ return i == 1 ? this.textureId + 17 : (i == 0 ? this.textureId + 17 : (i == 3 ? this.textureId - 1 : this.textureId));
+ }
+
+ public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {
+ if (world.isStatic) {
+ return true;
+ } else {
+ TileEntityFurnace tileentityfurnace = (TileEntityFurnace) world.getTileEntity(i, j, k);
+
+ entityhuman.a(tileentityfurnace);
+ return true;
+ }
+ }
+
+ public static void a(boolean flag, World world, int i, int j, int k) {
+ int l = world.getData(i, j, k);
+ TileEntity tileentity = world.getTileEntity(i, j, k);
+ if (tileentity == null) return; // CraftBukkit
+
+ c = true;
+ if (flag) {
+ world.setTypeId(i, j, k, Block.BURNING_FURNACE.id);
+ } else {
+ world.setTypeId(i, j, k, Block.FURNACE.id);
+ }
+
+ c = false;
+ world.setData(i, j, k, l);
+ tileentity.j();
+ world.setTileEntity(i, j, k, tileentity);
+ }
+
+ protected TileEntity a_() {
+ return new TileEntityFurnace();
+ }
+
+ public void postPlace(World world, int i, int j, int k, EntityLiving entityliving) {
+ int l = MathHelper.floor((double) (entityliving.yaw * 4.0F / 360.0F) + 0.5D) & 3;
+
+ if (l == 0) {
+ world.setData(i, j, k, 2);
+ }
+
+ if (l == 1) {
+ world.setData(i, j, k, 5);
+ }
+
+ if (l == 2) {
+ world.setData(i, j, k, 3);
+ }
+
+ if (l == 3) {
+ world.setData(i, j, k, 4);
+ }
+ }
+
+ public void remove(World world, int i, int j, int k) {
+ if (!c) {
+ TileEntityFurnace tileentityfurnace = (TileEntityFurnace) world.getTileEntity(i, j, k);
+
+ for (int l = 0; l < tileentityfurnace.getSize(); ++l) {
+ ItemStack itemstack = tileentityfurnace.getItem(l);
+
+ if (itemstack != null) {
+ float f = this.a.nextFloat() * 0.8F + 0.1F;
+ float f1 = this.a.nextFloat() * 0.8F + 0.1F;
+ float f2 = this.a.nextFloat() * 0.8F + 0.1F;
+
+ while (itemstack.count > 0) {
+ int i1 = this.a.nextInt(21) + 10;
+
+ if (i1 > itemstack.count) {
+ i1 = itemstack.count;
+ }
+
+ itemstack.count -= i1;
+ EntityItem entityitem = new EntityItem(world, (double) ((float) i + f), (double) ((float) j + f1), (double) ((float) k + f2), new ItemStack(itemstack.id, i1, itemstack.getData()));
+ float f3 = 0.05F;
+
+ entityitem.motX = (double) ((float) this.a.nextGaussian() * f3);
+ entityitem.motY = (double) ((float) this.a.nextGaussian() * f3 + 0.2F);
+ entityitem.motZ = (double) ((float) this.a.nextGaussian() * f3);
+ world.addEntity(entityitem);
+ }
+ }
+ }
+ }
+
+ super.remove(world, i, j, k);
+ }
+}