Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 65 lines 2.6 kB view raw
1package net.minecraft.server; 2 3// CraftBukkit start 4 5import org.bukkit.craftbukkit.event.CraftEventFactory; 6import org.bukkit.event.block.Action; 7import org.bukkit.event.player.PlayerInteractEvent; 8// CraftBukkit end 9 10public class ItemBoat extends Item { 11 12 public ItemBoat(int i) { 13 super(i); 14 this.maxStackSize = 1; 15 } 16 17 public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) { 18 float f = 1.0F; 19 float f1 = entityhuman.lastPitch + (entityhuman.pitch - entityhuman.lastPitch) * f; 20 float f2 = entityhuman.lastYaw + (entityhuman.yaw - entityhuman.lastYaw) * f; 21 double d0 = entityhuman.lastX + (entityhuman.locX - entityhuman.lastX) * (double) f; 22 double d1 = entityhuman.lastY + (entityhuman.locY - entityhuman.lastY) * (double) f + 1.62D - (double) entityhuman.height; 23 double d2 = entityhuman.lastZ + (entityhuman.locZ - entityhuman.lastZ) * (double) f; 24 Vec3D vec3d = Vec3D.create(d0, d1, d2); 25 float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F); 26 float f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F); 27 float f5 = -MathHelper.cos(-f1 * 0.017453292F); 28 float f6 = MathHelper.sin(-f1 * 0.017453292F); 29 float f7 = f4 * f5; 30 float f8 = f3 * f5; 31 double d3 = 5.0D; 32 Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); 33 MovingObjectPosition movingobjectposition = world.rayTrace(vec3d, vec3d1, true); 34 35 if (movingobjectposition == null) { 36 return itemstack; 37 } else { 38 if (movingobjectposition.type == EnumMovingObjectType.TILE) { 39 int i = movingobjectposition.b; 40 int j = movingobjectposition.c; 41 int k = movingobjectposition.d; 42 43 if (!world.isStatic) { 44 // CraftBukkit start - Boat placement 45 PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityhuman, Action.RIGHT_CLICK_BLOCK, i, j, k, movingobjectposition.face, itemstack); 46 47 if (event.isCancelled()) { 48 return itemstack; 49 } 50 // CraftBukkit end 51 52 if (world.getTypeId(i, j, k) == Block.SNOW.id) { 53 --j; 54 } 55 56 world.addEntity(new EntityBoat(world, (double) ((float) i + 0.5F), (double) ((float) j + 1.0F), (double) ((float) k + 0.5F))); 57 } 58 59 --itemstack.count; 60 } 61 62 return itemstack; 63 } 64 } 65}