Skip to content

Commit 281b3b1

Browse files
committed
Fix hoes
1 parent dc549f4 commit 281b3b1

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/main/java/net/earthcomputer/clientcommands/ToolDamageManager.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import net.earthcomputer.clientcommands.network.NetUtils;
88
import net.minecraft.block.Block;
99
import net.minecraft.block.BlockCommandBlock;
10+
import net.minecraft.block.BlockDirt;
1011
import net.minecraft.block.BlockStructure;
1112
import net.minecraft.block.material.Material;
1213
import net.minecraft.block.state.IBlockState;
@@ -93,8 +94,23 @@ public static void registerEvents() {
9394
}
9495
}
9596
if (e.getEntityPlayer().canPlayerEdit(e.getPos().offset(e.getFace()), e.getFace(), stack)) {
96-
if (item instanceof ItemHoe || item == Items.FLINT_AND_STEEL) {
97-
// tilling the ground or setting it on fire
97+
if (item instanceof ItemHoe) {
98+
boolean usedHoe = false;
99+
if (state.getBlock() == Blocks.GRASS || state.getBlock() == Blocks.GRASS_PATH) {
100+
usedHoe = true;
101+
} else if (state.getBlock() == Blocks.DIRT) {
102+
BlockDirt.DirtType variant = state.getValue(BlockDirt.VARIANT);
103+
usedHoe = variant == BlockDirt.DirtType.DIRT || variant == BlockDirt.DirtType.COARSE_DIRT;
104+
}
105+
if (usedHoe) {
106+
if (postToolDamaged(e.getEntityPlayer(), stack, 1)) {
107+
e.setCanceled(true);
108+
packetsToBlock.add(CPacketPlayerTryUseItemOnBlock.class);
109+
}
110+
}
111+
return;
112+
}
113+
else if (item == Items.FLINT_AND_STEEL) {
98114
if (postToolDamaged(e.getEntityPlayer(), stack, 1)) {
99115
e.setCanceled(true);
100116
packetsToBlock.add(CPacketPlayerTryUseItemOnBlock.class);

0 commit comments

Comments
 (0)