1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
package net.minecraft.server;
// CraftBukkit start
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Type;
import org.bukkit.event.player.PlayerItemEvent;
// CraftBukkit end
public class ItemBoat extends Item {
public ItemBoat(int i) {
super(i);
this.maxStackSize = 1;
}
public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) {
float f = 1.0F;
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 = 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;
} 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);
PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
craftServer.getPluginManager().callEvent(event);
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))));
}
--itemstack.count;
}
return itemstack;
}
}
}
|