2011-01-08 12:18:05 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2012-07-22 08:18:00 +02:00
|
|
|
import org.bukkit.craftbukkit.block.CraftBlockState; // CraftBukkit
|
2011-01-08 12:18:05 +01:00
|
|
|
|
|
|
|
public class ItemHoe extends Item {
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected EnumToolMaterial a;
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
public ItemHoe(int i, EnumToolMaterial enumtoolmaterial) {
|
2011-01-08 12:18:05 +01:00
|
|
|
super(i);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a = enumtoolmaterial;
|
2011-01-29 22:50:29 +01:00
|
|
|
this.maxStackSize = 1;
|
2012-01-14 21:03:48 +01:00
|
|
|
this.setMaxDurability(enumtoolmaterial.a());
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a(CreativeModeTab.i);
|
2011-01-08 12:18:05 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) {
|
|
|
|
if (!entityhuman.e(i, j, k)) {
|
2011-01-29 22:50:29 +01:00
|
|
|
return false;
|
|
|
|
} else {
|
2011-09-15 02:23:52 +02:00
|
|
|
int i1 = world.getTypeId(i, j, k);
|
|
|
|
int j1 = world.getTypeId(i, j + 1, k);
|
2011-01-08 12:18:05 +01:00
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
if ((l == 0 || j1 != 0 || i1 != Block.GRASS.id) && i1 != Block.DIRT.id) {
|
|
|
|
return false;
|
2011-01-29 22:50:29 +01:00
|
|
|
} else {
|
2011-09-15 02:23:52 +02:00
|
|
|
Block block = Block.SOIL;
|
2011-01-08 12:18:05 +01:00
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
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);
|
|
|
|
if (world.isStatic) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
world.setTypeId(i, j, k, block.id);
|
2011-05-14 16:29:42 +02:00
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
// CraftBukkit start - Hoes - blockface -1 for 'SELF'
|
2012-07-22 08:18:00 +02:00
|
|
|
org.bukkit.event.block.BlockPlaceEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, i, j, k);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
if (event.isCancelled() || !event.canBuild()) {
|
|
|
|
event.getBlockPlaced().setTypeId(blockState.getTypeId());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
itemstack.damage(1, entityhuman);
|
|
|
|
return true;
|
|
|
|
}
|
2011-01-08 12:18:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-07-29 09:33:13 +02:00
|
|
|
|
|
|
|
public String f() {
|
|
|
|
return this.a.toString();
|
|
|
|
}
|
2011-01-08 12:18:05 +01:00
|
|
|
}
|