diff options
author | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-02-01 22:01:37 +0000 |
---|---|---|
committer | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-02-01 22:01:37 +0000 |
commit | 661f209b7edf7de7d55d2fdafcfb42a1677fa4a9 (patch) | |
tree | e703736e3c8f94b787187dbc2173fd4066bce01f /src | |
parent | f8cdbe1d825479f1aa9008f17b578f474723f114 (diff) | |
download | craftbukkit-661f209b7edf7de7d55d2fdafcfb42a1677fa4a9.tar craftbukkit-661f209b7edf7de7d55d2fdafcfb42a1677fa4a9.tar.gz craftbukkit-661f209b7edf7de7d55d2fdafcfb42a1677fa4a9.tar.lz craftbukkit-661f209b7edf7de7d55d2fdafcfb42a1677fa4a9.tar.xz craftbukkit-661f209b7edf7de7d55d2fdafcfb42a1677fa4a9.zip |
Fixed dispenser
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/net/minecraft/server/BlockDispenser.java | 168 |
1 files changed, 84 insertions, 84 deletions
diff --git a/src/main/java/net/minecraft/server/BlockDispenser.java b/src/main/java/net/minecraft/server/BlockDispenser.java index 66d0b141..7a0231f7 100644 --- a/src/main/java/net/minecraft/server/BlockDispenser.java +++ b/src/main/java/net/minecraft/server/BlockDispenser.java @@ -1,7 +1,6 @@ package net.minecraft.server; import java.util.Random; - import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.block.CraftBlock; @@ -12,8 +11,8 @@ import org.bukkit.event.block.BlockInteractEvent; public class BlockDispenser extends BlockContainer { protected BlockDispenser(int i) { - super(i, Material.d); - bh = 45; + super(i, Material.STONE); + this.textureId = 45; } public int b() { @@ -21,52 +20,46 @@ public class BlockDispenser extends BlockContainer { } public int a(int i, Random random) { - return Block.P.bi; + return Block.DISPENSER.id; } public void e(World world, int i, int j, int k) { super.e(world, i, j, k); - g(world, i, j, k); + this.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; + 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]) { - byte0 = 3; + b0 = 3; } + if (Block.o[i1] && !Block.o[l]) { - byte0 = 2; + b0 = 2; } + if (Block.o[j1] && !Block.o[k1]) { - byte0 = 5; + b0 = 5; } + if (Block.o[k1] && !Block.o[j1]) { - byte0 = 4; + b0 = 4; } - world.c(i, j, k, ((int) (byte0))); + + world.c(i, j, k, b0); } public int a(int i) { - if (i == 1) { - return bh + 17; - } - if (i == 0) { - return bh + 17; - } - if (i == 3) { - return bh + 1; - } else { - return bh; - } + return i == 1 ? this.textureId + 17 : (i == 0 ? this.textureId + 17 : (i == 3 ? this.textureId + 1 : this.textureId)); } - public boolean a(World world, int i, int j, int k, EntityPlayer entityplayer) { - if (world.z) { + public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) { + if (world.isStatic) { return true; } else { // CraftBukkit start - Interact Dispenser @@ -74,8 +67,8 @@ public class BlockDispenser extends BlockContainer { CraftServer server = ((WorldServer) world).getServer(); Type eventType = Type.BLOCK_INTERACT; CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k); - LivingEntity who = (entityplayer == null)?null:(LivingEntity)entityplayer.getBukkitEntity(); - + LivingEntity who = (entityhuman == null)?null:(LivingEntity)entityhuman.getBukkitEntity(); + BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who); server.getPluginManager().callEvent(bie); @@ -83,116 +76,123 @@ public class BlockDispenser extends BlockContainer { return true; } // CraftBukkit end - - TileEntityDispenser tileentitydispenser = (TileEntityDispenser) world.m(i, j, k); + + TileEntityDispenser tileentitydispenser = (TileEntityDispenser) world.getTileEntity(i, j, k); - entityplayer.a(tileentitydispenser); + entityhuman.a(tileentitydispenser); return true; } } private void b(World world, int i, int j, int k, Random random) { - int l = world.b(i, j, k); + int l = world.getData(i, j, k); float f = 0.0F; float f1 = 0.0F; if (l == 3) { f1 = 1.0F; } else if (l == 2) { - f1 = -1F; + f1 = -1.0F; } else if (l == 5) { f = 1.0F; } else { - f = -1F; + f = -1.0F; } - TileEntityDispenser tileentitydispenser = (TileEntityDispenser) world.m(i, j, k); + + TileEntityDispenser tileentitydispenser = (TileEntityDispenser) world.getTileEntity(i, j, k); ItemStack itemstack = tileentitydispenser.e(); - double d = (double) i + (double) f * 0.5D + 0.5D; + double d0 = (double) i + (double) f * 0.5D + 0.5D; double d1 = (double) j + 0.5D; double d2 = (double) k + (double) f1 * 0.5D + 0.5D; if (itemstack == null) { - world.a(i, j, k, "random.click", 1.0F, 1.2F); + world.a((double) i, (double) j, (double) k, "random.click", 1.0F, 1.2F); } else { - if (itemstack.c == Item.j.ba) { - EntityArrow entityarrow = new EntityArrow(world, d, d1, d2); - - entityarrow.a(f, 0.10000000149011612D, f1, 1.1F, 6F); - world.a(((Entity) (entityarrow))); - world.a(i, j, k, "random.bow", 1.0F, 1.2F); - } else if (itemstack.c == Item.aN.ba) { - EntityEgg entityegg = new EntityEgg(world, d, d1, d2); - - entityegg.a(f, 0.10000000149011612D, f1, 1.1F, 6F); - world.a(((Entity) (entityegg))); - world.a(i, j, k, "random.bow", 1.0F, 1.2F); - } else if (itemstack.c == Item.aB.ba) { - EntitySnowball entitysnowball = new EntitySnowball(world, d, d1, d2); - - entitysnowball.a(f, 0.10000000149011612D, f1, 1.1F, 6F); - world.a(((Entity) (entitysnowball))); - world.a(i, j, k, "random.bow", 1.0F, 1.2F); + double d3; + + if (itemstack.id == Item.ARROW.id) { + EntityArrow entityarrow = new EntityArrow(world, d0, d1, d2); + + entityarrow.a((double) f, 0.10000000149011612D, (double) f1, 1.1F, 6.0F); + world.a((Entity) entityarrow); + world.a((double) i, (double) j, (double) k, "random.bow", 1.0F, 1.2F); + } else if (itemstack.id == Item.EGG.id) { + EntityEgg entityegg = new EntityEgg(world, d0, d1, d2); + + entityegg.a((double) f, 0.10000000149011612D, (double) f1, 1.1F, 6.0F); + world.a((Entity) entityegg); + world.a((double) i, (double) j, (double) k, "random.bow", 1.0F, 1.2F); + } else if (itemstack.id == Item.SNOW_BALL.id) { + EntitySnowball entitysnowball = new EntitySnowball(world, d0, d1, d2); + + entitysnowball.a((double) f, 0.10000000149011612D, (double) f1, 1.1F, 6.0F); + world.a((Entity) entitysnowball); + world.a((double) i, (double) j, (double) k, "random.bow", 1.0F, 1.2F); } else { - EntityItem entityitem = new EntityItem(world, d, d1 - 0.29999999999999999D, d2, itemstack); - double d3 = random.nextDouble() * 0.10000000000000001D + 0.20000000000000001D; - - entityitem.s = (double) f * d3; - entityitem.t = 0.20000000298023224D; - entityitem.u = (double) f1 * d3; - entityitem.s += random.nextGaussian() * 0.0074999998323619366D * 6D; - entityitem.t += random.nextGaussian() * 0.0074999998323619366D * 6D; - entityitem.u += random.nextGaussian() * 0.0074999998323619366D * 6D; - world.a(((Entity) (entityitem))); - world.a(i, j, k, "random.click", 1.0F, 1.0F); + EntityItem entityitem = new EntityItem(world, d0, d1 - 0.3D, d2, itemstack); + + d3 = random.nextDouble() * 0.1D + 0.2D; + entityitem.motX = (double) f * d3; + entityitem.motY = 0.20000000298023224D; + entityitem.motZ = (double) f1 * d3; + entityitem.motX += random.nextGaussian() * 0.007499999832361937D * 6.0D; + entityitem.motY += random.nextGaussian() * 0.007499999832361937D * 6.0D; + entityitem.motZ += random.nextGaussian() * 0.007499999832361937D * 6.0D; + world.a((Entity) entityitem); + world.a((double) i, (double) j, (double) k, "random.click", 1.0F, 1.0F); } - for (int i1 = 0; i1 < 10; i1++) { - double d4 = random.nextDouble() * 0.20000000000000001D + 0.01D; - double d5 = d + (double) f * 0.01D + (random.nextDouble() - 0.5D) * (double) f1 * 0.5D; - double d6 = d1 + (random.nextDouble() - 0.5D) * 0.5D; - double d7 = d2 + (double) f1 * 0.01D + (random.nextDouble() - 0.5D) * (double) f * 0.5D; - double d8 = (double) f * d4 + random.nextGaussian() * 0.01D; - double d9 = -0.029999999999999999D + random.nextGaussian() * 0.01D; - double d10 = (double) f1 * d4 + random.nextGaussian() * 0.01D; - - world.a("smoke", d5, d6, d7, d8, d9, d10); + + for (int i1 = 0; i1 < 10; ++i1) { + d3 = random.nextDouble() * 0.2D + 0.01D; + double d4 = d0 + (double) f * 0.01D + (random.nextDouble() - 0.5D) * (double) f1 * 0.5D; + double d5 = d1 + (random.nextDouble() - 0.5D) * 0.5D; + double d6 = d2 + (double) f1 * 0.01D + (random.nextDouble() - 0.5D) * (double) f * 0.5D; + double d7 = (double) f * d3 + random.nextGaussian() * 0.01D; + double d8 = -0.03D + random.nextGaussian() * 0.01D; + double d9 = (double) f1 * d3 + random.nextGaussian() * 0.01D; + + world.a("smoke", d4, d5, d6, d7, d8, d9); } } } public void b(World world, int i, int j, int k, int l) { - if (l > 0 && Block.m[l].c()) { + if (l > 0 && Block.byId[l].c()) { boolean flag = world.p(i, j, k) || world.p(i, j + 1, k); if (flag) { - world.i(i, j, k, bi); + world.i(i, j, k, this.id); } } } public void a(World world, int i, int j, int k, Random random) { if (world.p(i, j, k) || world.p(i, j + 1, k)) { - b(world, i, j, k, random); + this.b(world, i, j, k, random); } } protected TileEntity a_() { - return ((TileEntity) (new TileEntityDispenser())); + return new TileEntityDispenser(); } 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; + int l = MathHelper.b((double) (entityliving.yaw * 4.0F / 360.0F) + 0.5D) & 3; if (l == 0) { world.c(i, j, k, 2); } + if (l == 1) { world.c(i, j, k, 5); } + if (l == 2) { world.c(i, j, k, 3); } + if (l == 3) { world.c(i, j, k, 4); } } -} +}
\ No newline at end of file |