Posted May 27, 20187 yr I'm pretty new to modding but have a pretty good understanding of Java. The big question I have is if there is a relatively easy way to check if an area in world is either empty. I have an item that builds a structure. At the moment anywhere a block is placed it replaces whatever was there. I would like it to only run the block placement code if the region for the final structure is either completely empty or only contains blocks that are replaceable (I.e grass, snow, etc.). Is this possible or do I need to check before every block placement? Edited May 29, 20187 yr by GenghisKahn1992 Question Answered
May 28, 20187 yr You have to check for every block placement. You can check for == Blocks.AIR (and other blocks you consider replaceable. (Note that in 1.13 upcoming I think they are adding some different types of air like "cave air" to help with generation and spawning.). The alternative is to take over the chunk generator and replace it with one where, if you're going to build the structure, doesn't put anything else in the way in the first place. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
May 28, 20187 yr Author Ok. I was afraid of that. I'll needed to find a better way of storing the block locations of the structure then.
May 28, 20187 yr 40 minutes ago, GenghisKahn1992 said: Ok. I was afraid of that. I'll needed to find a better way of storing the block locations of the structure then. Why? are you seeing a performance problem? Almost everything related to handling the blocks in the world is already pretty optimized so not sure how you would optimize it further. What is different about what you're trying to do versus something like a stronghold? Edited May 28, 20187 yr by jabelar Check out my tutorials here: http://jabelarminecraft.blogspot.com/
May 28, 20187 yr Author Oh, sorry for the confusion. It's not a world gen structure. It's an item that builds structures on use using items in the players inventory. So instead of listing every block location and then testing block.isReplaceable(world, pos) I'll need to find a good way to store relative positioning of the structure so that I can loop through the positions with only a single isReplaceable test that gets called each loop. (And hopefully have the looping generic enough so that I can have the single item usable for multiple structures)
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.