Paper/src/main/java/net/minecraft/server/ItemHoe.java

47 Zeilen
1.8 KiB
Java

package net.minecraft.server;
public class ItemHoe extends Item {
2012-07-29 09:33:13 +02:00
protected EnumToolMaterial a;
2013-11-04 14:07:38 +01:00
public ItemHoe(EnumToolMaterial enumtoolmaterial) {
2012-07-29 09:33:13 +02:00
this.a = enumtoolmaterial;
2011-01-29 22:50:29 +01:00
this.maxStackSize = 1;
this.setMaxDurability(enumtoolmaterial.a());
2012-07-29 09:33:13 +02:00
this.a(CreativeModeTab.i);
}
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) {
final int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit
if (!entityhuman.a(i, j, k, l, itemstack)) {
2011-01-29 22:50:29 +01:00
return false;
} else {
2013-11-04 14:07:38 +01:00
Block block = world.getType(i, j, k);
2013-11-04 14:07:38 +01:00
if (l != 0 && world.getType(i, j + 1, k).getMaterial() == Material.AIR && (block == Blocks.GRASS || block == Blocks.DIRT)) {
Block block1 = Blocks.SOIL;
2013-11-04 14:07:38 +01:00
world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), block1.stepSound.getStepSound(), (block1.stepSound.getVolume1() + 1.0F) / 2.0F, block1.stepSound.getVolume2() * 0.8F);
2011-09-15 02:23:52 +02:00
if (world.isStatic) {
return true;
} else {
// CraftBukkit start - Hoes - blockface -1 for 'SELF'
2013-11-04 14:07:38 +01:00
// world.setTypeUpdate(i, j, k, block1);
if (!ItemBlock.processBlockPlace(world, entityhuman, null, i, j, k, block1, 0, clickedX, clickedY, clickedZ)) {
2011-09-15 02:23:52 +02:00
return false;
}
// CraftBukkit end
itemstack.damage(1, entityhuman);
return true;
}
2013-07-01 13:03:00 +02:00
} else {
return false;
}
}
}
2012-07-29 09:33:13 +02:00
2013-11-04 14:07:38 +01:00
public String i() {
2012-07-29 09:33:13 +02:00
return this.a.toString();
}
}