|
7 | 7 | import net.earthcomputer.clientcommands.network.NetUtils; |
8 | 8 | import net.minecraft.block.Block; |
9 | 9 | import net.minecraft.block.BlockCommandBlock; |
| 10 | +import net.minecraft.block.BlockDirt; |
10 | 11 | import net.minecraft.block.BlockStructure; |
11 | 12 | import net.minecraft.block.material.Material; |
12 | 13 | import net.minecraft.block.state.IBlockState; |
@@ -93,8 +94,23 @@ public static void registerEvents() { |
93 | 94 | } |
94 | 95 | } |
95 | 96 | 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) { |
98 | 114 | if (postToolDamaged(e.getEntityPlayer(), stack, 1)) { |
99 | 115 | e.setCanceled(true); |
100 | 116 | packetsToBlock.add(CPacketPlayerTryUseItemOnBlock.class); |
|
0 commit comments