Posted June 27, 20169 yr 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.
June 27, 20169 yr If you are setting the block to air on the server, all clients should automatically be notified. Sounds like you are setting the block on one client instead. Show your code. http://i.imgur.com/NdrFdld.png[/img]
June 27, 20169 yr Author 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);
June 27, 20169 yr This should be called on server. Idk if you even should touch notify stuff. 1.7.10 is no longer supported by forge, you are on your own.
June 27, 20169 yr Author I assume you mean the markAndNotifyBlock method as the notifiyNeighborsOfStateChange seems necessary so that adjacent blocks will properly update when the one gets removed.
June 27, 20169 yr If you only want to set block to air - you only need to call exacly that method and ONLY on server. Other methods are not what you may think. 1.7.10 is no longer supported by forge, you are on your own.
June 27, 20169 yr Author Calling it only on the server and removing all mark methods still only updates on the one client and only causes block updates if in multiplayer.
June 27, 20169 yr Author https://gist.github.com/Selim042/10a8d1796ceed7bc21e73a50a2d6a6b9#file-blockshifter-java-L88-L90
June 27, 20169 yr Author Am I being dumb, am I using isRemote backwards or what is wrong, I still am not seeing it.
June 27, 20169 yr 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.
June 27, 20169 yr Author Ok. Yea, thought of that after, fixing. Still in progress, on the list of things to do. I realized that after uploading, fixed now.
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.