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
10import uk.betacraft.uberbukkit.UberbukkitConfig;
11
12public class ItemHoe extends Item {
13
14 public ItemHoe(int i, EnumToolMaterial enumtoolmaterial) {
15 super(i);
16 this.maxStackSize = 1;
17 this.d(enumtoolmaterial.a());
18 }
19
20 public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) {
21 int i1 = world.getTypeId(i, j, k);
22 int j1 = world.getTypeId(i, j + 1, k);
23
24 if ((l == 0 || j1 != 0 || i1 != Block.GRASS.id) && i1 != Block.DIRT.id) {
25 return false;
26 } else {
27 Block block = Block.SOIL;
28
29 world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), block.stepSound.getName(), (block.stepSound.getVolume1() + 1.0F) / 2.0F, block.stepSound.getVolume2() * 0.8F);
30 if (world.isStatic) {
31 return true;
32 } else {
33 CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit
34
35 world.setTypeId(i, j, k, block.id);
36
37 // CraftBukkit start - Hoes - blockface -1 for 'SELF'
38 BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, i, j, k, block);
39
40 if (event.isCancelled() || !event.canBuild()) {
41 event.getBlockPlaced().setTypeId(blockState.getTypeId());
42 return false;
43 }
44 // CraftBukkit end
45
46 itemstack.damage(1, entityhuman);
47
48 // uberbukkit
49 if (UberbukkitConfig.getInstance().getBoolean("mechanics.tile_grass_drop_seeds", false)) {
50 if (world.random.nextInt(8) == 0 && i1 == Block.GRASS.id) {
51 byte b0 = 1;
52
53 for (j1 = 0; j1 < b0; ++j1) {
54 float f = 0.7F;
55 float f1 = world.random.nextFloat() * f + (1.0F - f) * 0.5F;
56 float f2 = 1.2F;
57 float f3 = world.random.nextFloat() * f + (1.0F - f) * 0.5F;
58 EntityItem entityitem = new EntityItem(world, (double) ((float) i + f1), (double) ((float) j + f2), (double) ((float) k + f3), new ItemStack(Item.SEEDS));
59
60 entityitem.pickupDelay = 10;
61 world.addEntity(entityitem);
62 }
63 }
64 }
65 return true;
66 }
67 }
68 }
69}