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

50 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;
2011-01-14 14:31:10 +01:00
public ItemHoe(int i, EnumToolMaterial enumtoolmaterial) {
super(i);
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 {
2011-09-15 02:23:52 +02:00
int i1 = world.getTypeId(i, j, k);
int j1 = world.getTypeId(i, j + 1, k);
2013-07-01 13:03:00 +02:00
if (l != 0 && j1 == 0 && (i1 == Block.GRASS.id || i1 == Block.DIRT.id)) {
2011-09-15 02:23:52 +02:00
Block block = Block.SOIL;
2012-11-06 13:05:28 +01:00
world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), block.stepSound.getStepSound(), (block.stepSound.getVolume1() + 1.0F) / 2.0F, block.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-03-13 23:33:27 +01:00
// world.setTypeIdUpdate(i, j, k, block.id);
if (!ItemBlock.processBlockPlace(world, entityhuman, null, i, j, k, block.id, 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
public String g() {
2012-07-29 09:33:13 +02:00
return this.a.toString();
}
}