|
13 | 13 | import net.minecraft.entity.player.EntityPlayer; |
14 | 14 | import net.minecraft.init.Enchantments; |
15 | 15 | import net.minecraft.inventory.ClickType; |
16 | | -import net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock; |
| 16 | +import net.minecraft.network.play.client.CPacketPlayerDigging; |
17 | 17 | import net.minecraft.util.EnumFacing; |
18 | | -import net.minecraft.util.EnumHand; |
19 | 18 | import net.minecraft.util.math.BlockPos; |
20 | 19 |
|
21 | 20 | public class TempRulesImpl { |
@@ -79,23 +78,23 @@ private static void initGhostBlockFix() { |
79 | 78 | // Test conditions for instant-mining |
80 | 79 | PlayerControllerMP controller = Minecraft.getMinecraft().playerController; |
81 | 80 | IBlockState state = e.getWorld().getBlockState(e.getPos()); |
82 | | - boolean slowMine = state.getMaterial() != Material.AIR |
| 81 | + boolean canInstaMine = state.getMaterial() != Material.AIR |
83 | 82 | && state.getPlayerRelativeBlockHardness(e.getEntityPlayer(), e.getWorld(), e.getPos()) >= 1; |
84 | | - if (controller.isNotCreative() && !slowMine) { |
| 83 | + if (controller.isNotCreative() && canInstaMine) { |
85 | 84 | blocksToUpdate.add(e.getPos()); |
86 | 85 | } |
87 | 86 | } |
88 | 87 | }); |
89 | 88 | EventManager.addPlayerTickListener(e -> { |
90 | 89 | if (!blocksToUpdate.isEmpty()) { |
91 | 90 | for (BlockPos pos : blocksToUpdate) { |
92 | | - // Update block by right clicking |
93 | | - Minecraft.getMinecraft().getConnection().sendPacket( |
94 | | - new CPacketPlayerTryUseItemOnBlock(pos, EnumFacing.DOWN, EnumHand.MAIN_HAND, 0, 0, 0)); |
| 91 | + // Cause the server to re-send the block |
| 92 | + Minecraft.getMinecraft().getConnection().sendPacket(new CPacketPlayerDigging( |
| 93 | + CPacketPlayerDigging.Action.ABORT_DESTROY_BLOCK, pos, EnumFacing.DOWN)); |
95 | 94 | } |
96 | 95 | blocksToUpdate.clear(); |
97 | 96 | } |
98 | 97 | }); |
99 | 98 | } |
100 | | - |
| 99 | + |
101 | 100 | } |
0 commit comments