Posted July 14, 20232 yr Hi! If I want to know what block is for example at position (10, 64, 100), it is very easy to get that block as long as this position is in the players view distance (which means the chunk where the block is located is loaded). But how can I get a block from a location where the player has been previously but what is out of the player's view distance at the moment. Since the chunk is not loaded I get always the same result (Block{void_air}) even if there is grass block. How can I fix this issue and is it even possible to fix it? Thanks.
July 16, 20232 yr well you can load a chunk, but i feel you shouldn't. i don't know what you are doing but the game is structured so that parts of the world where no player has been for a while are "frozen", kinda. machines from good-quality mods stop working when in unloaded parts of the world. plants from good-quality mods stop growing. all those modders could have forced part of the world to stay loaded (at a price paid by the player). but they didn't. they didn't say "i don't care how the game is intended to run and that players expect all mods to behave uniformly, because my block is just that important!". when mods keep chunks loaded it's often because the young modder was too lazy to make their block just unavailable at the moment.
July 17, 20232 yr Author Yeah nothing that I already don't know. In my case it's not so simple as just a block. I'm trying to implement a map editor/system into my mod like JourneyMap's fullscreen map with some extras. The problem is that when I try to map all regions of the world, it only maps what's in the player's view distance and everything else will be blank/transparent images, because the level.getBlockState(pos) in unloaded chunks always returns Block{minecraft:void_air}. So at the moment I'm trying to read the block data from the world region files (.mca). But I have no idea how to decode the 64-bit integers into actual understandable hints to the chunk section palette...
July 17, 20232 yr I imagine most mods (or vanilla with the map item) keep a cached image or structure of the visible blocks and update it when the chunk is loaded/saved.
July 17, 20232 yr make a handler for ChunkDataEvent.Load event. get pixel colors for your map and add to your data structure. do not worry about that chunk getting unloaded 5 minutes later. you will have to update map later if player builds a big fort, but that can be done in EnteringSection event.
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.