Skip to content

Commit 55685f2

Browse files
committed
Fix ghost block mining fix
1 parent d5492d6 commit 55685f2

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
import net.minecraft.entity.player.EntityPlayer;
1414
import net.minecraft.init.Enchantments;
1515
import net.minecraft.inventory.ClickType;
16-
import net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock;
16+
import net.minecraft.network.play.client.CPacketPlayerDigging;
1717
import net.minecraft.util.EnumFacing;
18-
import net.minecraft.util.EnumHand;
1918
import net.minecraft.util.math.BlockPos;
2019

2120
public class TempRulesImpl {
@@ -79,23 +78,23 @@ private static void initGhostBlockFix() {
7978
// Test conditions for instant-mining
8079
PlayerControllerMP controller = Minecraft.getMinecraft().playerController;
8180
IBlockState state = e.getWorld().getBlockState(e.getPos());
82-
boolean slowMine = state.getMaterial() != Material.AIR
81+
boolean canInstaMine = state.getMaterial() != Material.AIR
8382
&& state.getPlayerRelativeBlockHardness(e.getEntityPlayer(), e.getWorld(), e.getPos()) >= 1;
84-
if (controller.isNotCreative() && !slowMine) {
83+
if (controller.isNotCreative() && canInstaMine) {
8584
blocksToUpdate.add(e.getPos());
8685
}
8786
}
8887
});
8988
EventManager.addPlayerTickListener(e -> {
9089
if (!blocksToUpdate.isEmpty()) {
9190
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));
9594
}
9695
blocksToUpdate.clear();
9796
}
9897
});
9998
}
100-
99+
101100
}

0 commit comments

Comments
 (0)