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 ItemRedstone extends Item {
11
12 public ItemRedstone(int i) {
13 super(i);
14 }
15
16 public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) {
17 int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit
18
19 if (world.getTypeId(i, j, k) != Block.SNOW.id) {
20 if (l == 0) {
21 --j;
22 }
23
24 if (l == 1) {
25 ++j;
26 }
27
28 if (l == 2) {
29 --k;
30 }
31
32 if (l == 3) {
33 ++k;
34 }
35
36 if (l == 4) {
37 --i;
38 }
39
40 if (l == 5) {
41 ++i;
42 }
43
44 if (!world.isEmpty(i, j, k)) {
45 return false;
46 }
47 }
48
49 if (Block.REDSTONE_WIRE.canPlace(world, i, j, k)) {
50 CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit
51
52 world.setRawTypeId(i, j, k, Block.REDSTONE_WIRE.id); // CraftBukkit - We update after the event
53
54 // CraftBukkit start - redstone
55 BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, Block.REDSTONE_WIRE);
56
57 if (event.isCancelled() || !event.canBuild()) {
58 event.getBlockPlaced().setTypeIdAndData(blockState.getTypeId(), blockState.getRawData(), false);
59 return false;
60 }
61
62 world.update(i, j, k, Block.REDSTONE_WIRE.id); // Must take place after BlockPlaceEvent, we need to update all other blocks.
63 // CraftBukkit end
64
65 --itemstack.count; // CraftBukkit - ORDER MATTERS
66 }
67
68 return true;
69 }
70}