diff options
author | EvilSeph <evilseph@gmail.com> | 2011-07-24 17:17:11 -0400 |
---|---|---|
committer | EvilSeph <evilseph@gmail.com> | 2011-07-27 13:04:34 -0400 |
commit | 4fdc2255283957e8723ea15e66a50b1a05ee4319 (patch) | |
tree | 199f5eb4241821c34c99f88e28554faa64e80cb0 /src/main | |
parent | f4a789b48a65171796d6a572253e02ff1538a591 (diff) | |
download | craftbukkit-4fdc2255283957e8723ea15e66a50b1a05ee4319.tar craftbukkit-4fdc2255283957e8723ea15e66a50b1a05ee4319.tar.gz craftbukkit-4fdc2255283957e8723ea15e66a50b1a05ee4319.tar.lz craftbukkit-4fdc2255283957e8723ea15e66a50b1a05ee4319.tar.xz craftbukkit-4fdc2255283957e8723ea15e66a50b1a05ee4319.zip |
Fixed crash caused by Jukeboxes under certain circumstances.
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/net/minecraft/server/BlockJukeBox.java | 70 |
1 files changed, 70 insertions, 0 deletions
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..67f857a4 --- /dev/null +++ b/src/main/java/net/minecraft/server/BlockJukeBox.java @@ -0,0 +1,70 @@ +package net.minecraft.server; + +public class BlockJukeBox extends BlockContainer { + + protected BlockJukeBox(int i, int j) { + super(i, j, Material.WOOD); + } + + public int a(int i) { + return this.textureId + (i == 1 ? 1 : 0); + } + + public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) { + if (world.getData(i, j, k) == 0) { + return false; + } else { + this.b_(world, i, j, k); + return true; + } + } + + public void f(World world, int i, int j, int k, int l) { + if (!world.isStatic) { + TileEntityRecordPlayer tileentityrecordplayer = (TileEntityRecordPlayer) world.getTileEntity(i, j, k); + + tileentityrecordplayer.a = l; + tileentityrecordplayer.update(); + world.setData(i, j, k, 1); + } + } + + public void b_(World world, int i, int j, int k) { + if (!world.isStatic) { + TileEntityRecordPlayer tileentityrecordplayer = (TileEntityRecordPlayer) world.getTileEntity(i, j, k); + if (tileentityrecordplayer == null) return; // CraftBukkit + int l = tileentityrecordplayer.a; + + if (l != 0) { + world.e(1005, i, j, k, 0); + world.a((String) null, i, j, k); + tileentityrecordplayer.a = 0; + tileentityrecordplayer.update(); + world.setData(i, j, k, 0); + float f = 0.7F; + double d0 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D; + double d1 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.2D + 0.6D; + double d2 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D; + EntityItem entityitem = new EntityItem(world, (double) i + d0, (double) j + d1, (double) k + d2, new ItemStack(l, 1, 0)); + + entityitem.pickupDelay = 10; + world.addEntity(entityitem); + } + } + } + + public void remove(World world, int i, int j, int k) { + this.b_(world, i, j, k); + super.remove(world, i, j, k); + } + + public void dropNaturally(World world, int i, int j, int k, int l, float f) { + if (!world.isStatic) { + super.dropNaturally(world, i, j, k, l, f); + } + } + + protected TileEntity a_() { + return new TileEntityRecordPlayer(); + } +} |