diff options
author | Nathan Adams <dinnerbone@dinnerbone.com> | 2011-11-21 22:56:17 +0000 |
---|---|---|
committer | Nathan Adams <dinnerbone@dinnerbone.com> | 2011-11-21 22:56:17 +0000 |
commit | a3399c64314766bcdd420a1e179fde5b93198906 (patch) | |
tree | 170312cfdc1e5a6e0f7cf3a1bb51e9e5b340542a /src | |
parent | a83fc1d6a2510af0a4ce20b4f3adc0f7f1355bb4 (diff) | |
download | craftbukkit-a3399c64314766bcdd420a1e179fde5b93198906.tar craftbukkit-a3399c64314766bcdd420a1e179fde5b93198906.tar.gz craftbukkit-a3399c64314766bcdd420a1e179fde5b93198906.tar.lz craftbukkit-a3399c64314766bcdd420a1e179fde5b93198906.tar.xz craftbukkit-a3399c64314766bcdd420a1e179fde5b93198906.zip |
Fixed crash on right clicking dragon eggs
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/net/minecraft/server/BlockDragonEgg.java | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/src/main/java/net/minecraft/server/BlockDragonEgg.java b/src/main/java/net/minecraft/server/BlockDragonEgg.java new file mode 100644 index 00000000..400a7117 --- /dev/null +++ b/src/main/java/net/minecraft/server/BlockDragonEgg.java @@ -0,0 +1,106 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockDragonEgg extends Block { + + public BlockDragonEgg(int i, int j) { + super(i, j, Material.DRAGON_EGG); + } + + public void a(World world, int i, int j, int k) { + world.c(i, j, k, this.id, this.d()); + } + + public void doPhysics(World world, int i, int j, int k, int l) { + world.c(i, j, k, this.id, this.d()); + } + + public void a(World world, int i, int j, int k, Random random) { + this.g(world, i, j, k); + } + + private void g(World world, int i, int j, int k) { + if (BlockSand.g(world, i, j - 1, k) && j >= 0) { + byte b0 = 32; + + if (!BlockSand.instaFall && world.a(i - b0, j - b0, k - b0, i + b0, j + b0, k + b0)) { + // CraftBukkit - added data + EntityFallingSand entityfallingsand = new EntityFallingSand(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), this.id, world.getData(i, j, k)); + + world.addEntity(entityfallingsand); + } else { + world.setTypeId(i, j, k, 0); + + while (BlockSand.g(world, i, j - 1, k) && j > 0) { + --j; + } + + if (j > 0) { + world.setTypeId(i, j, k, this.id); + } + } + } + } + + public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) { + this.h(world, i, j, k); + return true; + } + + public void b(World world, int i, int j, int k, EntityHuman entityhuman) { + this.h(world, i, j, k); + } + + private void h(World world, int i, int j, int k) { + if (world.getTypeId(i, j, k) == this.id) { + if (!world.isStatic) { + for (int l = 0; l < 1000; ++l) { + int i1 = i + world.random.nextInt(16) - world.random.nextInt(16); + int j1 = j + world.random.nextInt(8) - world.random.nextInt(8); + int k1 = k + world.random.nextInt(16) - world.random.nextInt(16); + + if (world.getTypeId(i1, j1, k1) == 0) { + world.setTypeIdAndData(i1, j1, k1, this.id, world.getData(i, j, k)); + world.setTypeId(i, j, k, 0); + short short1 = 128; + + for (int l1 = 0; l1 < short1; ++l1) { + double d0 = world.random.nextDouble(); + float f = (world.random.nextFloat() - 0.5F) * 0.2F; + float f1 = (world.random.nextFloat() - 0.5F) * 0.2F; + float f2 = (world.random.nextFloat() - 0.5F) * 0.2F; + double d1 = (double) i1 + (double) (i - i1) * d0 + (world.random.nextDouble() - 0.5D) * 1.0D + 0.5D; + double d2 = (double) j1 + (double) (j - j1) * d0 + world.random.nextDouble() * 1.0D - 0.5D; + double d3 = (double) k1 + (double) (k - k1) * d0 + (world.random.nextDouble() - 0.5D) * 1.0D + 0.5D; + + world.a("portal", d1, d2, d3, (double) f, (double) f1, (double) f2); + } + + return; + } + } + } + } + } + + public int d() { + return 3; + } + + public boolean canPlace(World world, int i, int j, int k) { + return super.canPlace(world, i, j, k); + } + + public boolean a() { + return false; + } + + public boolean b() { + return false; + } + + public int c() { + return 27; + } +} |