From df69047324abc54f5d5b8d069bb69b1061b20cce Mon Sep 17 00:00:00 2001 From: Erik Broes Date: Sat, 29 Jan 2011 22:50:29 +0100 Subject: Port to new mc-dev format. --- src/main/java/net/minecraft/server/ItemBoat.java | 82 ++++++++++++------------ 1 file changed, 42 insertions(+), 40 deletions(-) (limited to 'src/main/java/net/minecraft/server/ItemBoat.java') diff --git a/src/main/java/net/minecraft/server/ItemBoat.java b/src/main/java/net/minecraft/server/ItemBoat.java index ade7bf24..6b3b4358 100644 --- a/src/main/java/net/minecraft/server/ItemBoat.java +++ b/src/main/java/net/minecraft/server/ItemBoat.java @@ -15,59 +15,61 @@ public class ItemBoat extends Item { public ItemBoat(int i) { super(i); - bb = 1; + this.maxStackSize = 1; } - public ItemStack a(ItemStack itemstack, World world, EntityPlayer entityplayer) { + public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) { float f = 1.0F; - float f1 = entityplayer.y + (entityplayer.w - entityplayer.y) * f; - float f2 = entityplayer.x + (entityplayer.v - entityplayer.x) * f; - double d = entityplayer.m + (entityplayer.p - entityplayer.m) * (double) f; - double d1 = (entityplayer.n + (entityplayer.q - entityplayer.n) * (double) f + 1.6200000000000001D) - (double) entityplayer.H; - double d2 = entityplayer.o + (entityplayer.r - entityplayer.o) * (double) f; - Vec3D vec3d = Vec3D.b(d, d1, d2); - float f3 = MathHelper.b(-f2 * 0.01745329F - 3.141593F); - float f4 = MathHelper.a(-f2 * 0.01745329F - 3.141593F); - float f5 = -MathHelper.b(-f1 * 0.01745329F); - float f6 = MathHelper.a(-f1 * 0.01745329F); + float f1 = entityhuman.lastPitch + (entityhuman.pitch - entityhuman.lastPitch) * f; + float f2 = entityhuman.lastYaw + (entityhuman.yaw - entityhuman.lastYaw) * f; + double d0 = entityhuman.lastX + (entityhuman.locX - entityhuman.lastX) * (double) f; + double d1 = entityhuman.lastY + (entityhuman.locY - entityhuman.lastY) * (double) f + 1.62D - (double) entityhuman.height; + double d2 = entityhuman.lastZ + (entityhuman.locZ - entityhuman.lastZ) * (double) f; + Vec3D vec3d = Vec3D.b(d0, d1, d2); + float f3 = MathHelper.b(-f2 * 0.017453292F - 3.1415927F); + float f4 = MathHelper.a(-f2 * 0.017453292F - 3.1415927F); + float f5 = -MathHelper.b(-f1 * 0.017453292F); + float f6 = MathHelper.a(-f1 * 0.017453292F); float f7 = f4 * f5; - float f8 = f6; - float f9 = f3 * f5; - double d3 = 5D; - Vec3D vec3d1 = vec3d.c((double) f7 * d3, (double) f8 * d3, (double) f9 * d3); + float f8 = f3 * f5; + double d3 = 5.0D; + Vec3D vec3d1 = vec3d.c((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); MovingObjectPosition movingobjectposition = world.a(vec3d, vec3d1, true); if (movingobjectposition == null) { return itemstack; - } - if (movingobjectposition.a == EnumMovingObjectType.a) { - int i = movingobjectposition.b; - int j = movingobjectposition.c; - int k = movingobjectposition.d; + } else { + if (movingobjectposition.a == EnumMovingObjectType.TILE) { + int i = movingobjectposition.b; + int j = movingobjectposition.c; + int k = movingobjectposition.d; + + if (!world.isStatic) { + // CraftBukkit start - Boat placement + CraftWorld craftWorld = ((WorldServer) world).getWorld(); + CraftServer craftServer = ((WorldServer) world).getServer(); + + Type eventType = Type.PLAYER_ITEM; + Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity(); + org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack); + org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k); + BlockFace blockFace = CraftBlock.notchToBlockFace(movingobjectposition.e); - if (!world.z) { - // CraftBukkit start - Boat placement - CraftWorld craftWorld = ((WorldServer) world).getWorld(); - CraftServer craftServer = ((WorldServer) world).getServer(); - - Type eventType = Type.PLAYER_ITEM; - Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity(); - org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack); - org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k); - BlockFace blockFace = CraftBlock.notchToBlockFace(movingobjectposition.e); - - PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace); - craftServer.getPluginManager().callEvent(pie); + PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace); + craftServer.getPluginManager().callEvent(event); - if (pie.isCancelled()) { - return itemstack; + if (event.isCancelled()) { + return itemstack; + } + // CraftBukkit end + + world.a((Entity) (new EntityBoat(world, (double) ((float) i + 0.5F), (double) ((float) j + 1.5F), (double) ((float) k + 0.5F)))); } - // CraftBukkit end - world.a(((Entity) (new EntityBoat(world, (float) i + 0.5F, (float) j + 1.5F, (float) k + 0.5F)))); + --itemstack.count; } - itemstack.a--; + + return itemstack; } - return itemstack; } } -- cgit v1.2.3