Jump to content

[1.11] Client-side block break event


Recommended Posts

Hello all.


I'm trying to find a way to tell if the player broke a block client-side - any block at all.


I've tried using BlockEvents.BreakEvent but that appears to be server-side only... (isRemote only returns false, never true)


It's for rendering stuff, so I really don't want to send packets every time the player breaks a block... has anyone got any ideas?

Link to comment
Share on other sites

Thanks, I got it working now:

public void playEvent(EntityPlayer player, int code, BlockPos pos, int blockId) {
	EntityPlayerSP realPlayer = Minecraft.getMinecraft().thePlayer; 
	if (code == 2001 && player == null && realPlayer != null
			&& realPlayer.getDistanceSq(pos) < 46
			&& realPlayer.rayTrace(4.5, 0).getBlockPos().equals(pos)
			&& realPlayer.isSwingInProgress) { // 50 == 5 blocks (max. 4)
		this.blockBroken = true;


Edited by 315Lukas
Code improvements
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.