Tut Posted May 13, 2021 Share Posted May 13, 2021 (edited) Hi, I have an AABB that I want to set all of the blocks in to a different block. final Stream<BlockPos> blocksBetweenPlayerLookingAndDowsingEffect = BlockPos.betweenClosedStream( WorldHelper.getAABBInDirectionWithOffset( itemUseContext.getClickedPos(), itemUseContext.getClickedFace(), 0, 1, 1 ) ); blocksBetweenPlayerLookingAndDowsingEffect.forEach( blockPos -> { world.setBlockAndUpdate(blockPos, Blocks.CYAN_WOOL.defaultBlockState()); }); I think there were different names for both of betweenClosedStream and setBlockAndUpdate in the MCP mappings. So it's been hard to find exactly the fix I'm looking for. The problem I'm facing now is that when I call setBlockAndUpdate, only the first clicked on block updates. The rest don't update until I restart the world. I assume this has something to do with being used in a stream, or the flag that's used on setBlock? I'm not entirely sure. Thanks! Edited May 13, 2021 by Tut Fix formatting Quote Link to comment Share on other sites More sharing options...
Draco18s Posted May 13, 2021 Share Posted May 13, 2021 7 hours ago, Tut said: or the flag that's used on setBlock? Probably this. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
Tut Posted May 13, 2021 Author Share Posted May 13, 2021 40 minutes ago, Draco18s said: Probably this. setBlockAndUpdate uses flag 3, but I've tried 1, 2, and 4 with no success. Is there any documentation on what these flags do? I found this thread but since I'm using the mojang mappings I don't think I have the same javadocs. Quote Link to comment Share on other sites More sharing options...
Luis_ST Posted May 13, 2021 Share Posted May 13, 2021 1 hour ago, Tut said: setBlockAndUpdate uses flag 3, but I've tried 1, 2, and 4 with no success. Is there any documentation on what these flags do? I found this thread but since I'm using the mojang mappings I don't think I have the same javadocs. Constants.BlockFlags, in this class all BlockFlags are listed with an explanation Quote Link to comment Share on other sites More sharing options...
Tut Posted May 13, 2021 Author Share Posted May 13, 2021 12 minutes ago, Luis_ST said: Constants.BlockFlags, in this class all BlockFlags are listed with an explanation Thank you for letting me know! Unfortunately still having issues. I'm not sure why this code isn't working.. blocksBetweenPlayerLookingAndDowsingEffect.forEach( blockPos -> { world.setBlock(blockPos, Blocks.CYAN_WOOL.defaultBlockState(), ( Constants.BlockFlags.DEFAULT_AND_RERENDER ) ); }); Here's an example of the behavior I'm experiencing.. https://files.catbox.moe/z4ov1m.m4v Quote Link to comment Share on other sites More sharing options...
Draco18s Posted May 13, 2021 Share Posted May 13, 2021 (edited) Yes we know what it looks like. The client and server have desync'd. We need more of your code. Edited May 13, 2021 by Draco18s Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
Tut Posted May 13, 2021 Author Share Posted May 13, 2021 Just now, Draco18s said: Yes we know what it looks like. We need more of your code. Here's the whole class. public class ShungiteDowsingRod extends Item implements IForgeItem { public ShungiteDowsingRod(Properties properties) { super(properties); } @Override public ActionResultType useOn(ItemUseContext itemUseContext) { final World world = itemUseContext.getLevel(); if (!world.isClientSide()) { final Stream<BlockPos> blocksBetweenPlayerLookingAndDowsingEffect = BlockPos.betweenClosedStream( WorldHelper.getAABBInDirectionWithOffset( itemUseContext.getClickedPos(), itemUseContext.getClickedFace(), 0, 1, 1 ) ); blocksBetweenPlayerLookingAndDowsingEffect.forEach( blockPos -> { world.setBlock(blockPos, Blocks.CYAN_WOOL.defaultBlockState(), ( Constants.BlockFlags.DEFAULT_AND_RERENDER ) ); }); } return super.useOn(itemUseContext); } } Quote Link to comment Share on other sites More sharing options...
Tut Posted May 13, 2021 Author Share Posted May 13, 2021 I see the issue. But I'm not sure why being on the server means the client isn't being updated, if the setBlock event should update the client? Quote Link to comment Share on other sites More sharing options...
Luis_ST Posted May 13, 2021 Share Posted May 13, 2021 (edited) 3 minutes ago, Tut said: if (!world.isClientSide()) { you should remove this because you are checking here if you are on the server (not on client) and the video shows that the server receives the changes but the client doesn't Edited May 13, 2021 by Luis_ST Quote Link to comment Share on other sites More sharing options...
Draco18s Posted May 13, 2021 Share Posted May 13, 2021 2 minutes ago, Tut said: I see the issue. But I'm not sure why being on the server means the client isn't being updated, if the setBlock event should update the client? Because the server is not the client. They are different threads (and in the case of multiplayer, may be on different machines!) I'm not sure why the usual block state change isn't being propagated as normal, but I would do as Luis says and just remove the side check. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
Tut Posted May 13, 2021 Author Share Posted May 13, 2021 I guess I was just confused as to how things were getting handled when something is updated on the server. Not sure how I didn't see it before, thanks all. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.