Jump to content

Force Block Update on Client


Selim_042

Recommended Posts

As part of my mod, I am using world.setBlockToAir, but it is not updating that the block is no longer there on the client.  I run the server and connect two clients, one that initiates the method on which it works fine, but the other client still sees the block as there.  I can still stand on it until the server kicks the client for "flying".

 

I have already tried world.markAndNotifyBlock but I am guessing it isn't doing what I thought it would.

Link to comment
Share on other sites

It should be setting it both on the client and server.

world.setBlockToAir(pos);
world.notifyNeighborsOfStateChange(pos, null);
world.markAndNotifyBlock(pos, world.getChunkFromBlockCoords(pos), world.getBlockState(pos), world.getBlockState(pos), 0);
world.playSound(player, pos, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F);

Link to comment
Share on other sites

TileEntity should (almost?) never be removed on demand. Leave that to internals.

 

Basically - wrap every damn thing in !world.isRemote. From start to end.

2nd - TAKE CARE OF YOUR RETURN! You can't just place null there.

 

Also:

Block selectedBlock = world.getBlockState(pos).getBlock();
                if (!selectedBlock.equals(Blocks.BEDROCK)) {
IBlockState block = world.getBlockState(pos);

Really?

1.7.10 is no longer supported by forge, you are on your own.

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.

Guest
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.

Announcements



×
×
  • Create New...

Important Information

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