Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
1package net.minecraft.server;
2
3// CraftBukkit start
4
5import org.bukkit.craftbukkit.block.CraftBlockState;
6import org.bukkit.craftbukkit.event.CraftEventFactory;
7import org.bukkit.event.block.BlockPlaceEvent;
8// CraftBukkit end
9
10public class ItemSign extends Item {
11
12 public ItemSign(int i) {
13 super(i);
14 this.maxStackSize = 1;
15 }
16
17 public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) {
18 if (l == 0) {
19 return false;
20 } else if (!world.getMaterial(i, j, k).isBuildable()) {
21 return false;
22 } else {
23 int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit
24
25 if (l == 1) {
26 ++j;
27 }
28
29 if (l == 2) {
30 --k;
31 }
32
33 if (l == 3) {
34 ++k;
35 }
36
37 if (l == 4) {
38 --i;
39 }
40
41 if (l == 5) {
42 ++i;
43 }
44
45 if (!Block.SIGN_POST.canPlace(world, i, j, k) || j >= 128 || j < 0) {
46 return false;
47 } else {
48 CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit
49
50 if (l == 1) {
51 world.setTypeIdAndData(i, j, k, Block.SIGN_POST.id, MathHelper.floor((double) ((entityhuman.yaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15);
52 } else {
53 world.setTypeIdAndData(i, j, k, Block.WALL_SIGN.id, l);
54 }
55
56 // CraftBukkit start - sign
57 BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, l == 1 ? Block.SIGN_POST : Block.WALL_SIGN);
58
59 if (event.isCancelled() || !event.canBuild()) {
60 event.getBlockPlaced().setTypeIdAndData(blockState.getTypeId(), blockState.getRawData(), false);
61 return false;
62 }
63 // CraftBukkit end
64
65 --itemstack.count;
66 TileEntitySign tileentitysign = (TileEntitySign) world.getTileEntity(i, j, k);
67
68 if (tileentitysign != null) {
69 entityhuman.a(tileentitysign);
70 }
71
72 return true;
73 }
74 }
75 }
76}