Want a better Minecraft server? Read about SpigotMC here!
Separate names with a comma.
Discussion in 'Spigot Plugin Development' started by kadesa, Nov 13, 2017.
That's, like, way overkill, if you mean actual blocks.
Either way you run into the same issue
Why? You could follow the same technique MC uses for water/lava combined with that it uses for crops.
Lets say we have two new block types "RADIATED_AIR" and "FLOWING_RADIATED_AIR" when the world is generated all AIR blocks are replaced with "RADIATED_AIR".
When a block is broken which is is connected to a "RADIATED_AIR" block the block is changed to "FLOWING_RADIATED_AIR".
Every N ticks a block within each loaded chunk is selected at random and if it's "FLOWING_RADIATED_AIR" the block is changed to "RADIATED_AIR" and all the blocks which are connected to it are checked and if they are "AIR" then they are updated to "FLOWING_RADIATED_AIR".
The "AIR" blocks are created by scrubbers which clean the air within a radius of their position (i.e. change them from "FLOWING_RADIATED_AIR" or "FLOWING_RADIATED_AIR" to "AIR". If this is done within an enclosed space then the scrubber could be removed and the "AIR" blocks would remain "AIR" if not then the surrounding "RADIATED_AIR" blocks would replace the "AIR" blocks over time.
That's a good idea - see us programmers get paid to overthink everything
Just do it with a location chunk map -- no need to add real IDs.
Why not get the player location and get the highest y block and check if the player location is greater, if it is than do damage or whatever
Because that's not accurate for radiation. That would be more like, acid rain or something.
Sure, I wasn't meaning to outline an implementation just the algorithm, that's why I used the quotes .
A while back I looked into creating an infrastructure plugin to provide custom tile entities and multi block structures. You can save yourself some pain by hooking into chunk load/unload events and create objects and add metadata to blocks then. It would be an alternative to having to select a random block in the chunk and tick it, rather add metadata to the blocks on chunk load (based on a chunk map as you said) and on block break you could check if you need to update in air block. If you maintained a list of "FLOWING_RADIATED_AIR" per chunk then rather then random selection you could update each block in the list to "RADIATED_AIR", check for connected "AIR" blocks, modify those and add them to the list. Do that each tick and you'll quickly fill in the area. Watch for chunk boundaries though!
If you know the type of building is going to be a box, you can use this algorithm/idea.
1. Get the block above player (simple method for this available in bukkit API). If none, return here.
2. Iterate all blocks around this block starting from origin in a circle like approach until you find air.
3. Start iterating down with y until you find air. If there is air, stop here and confirm room is not closed.
4. If you finish where a block is at the same y as the player or you find ablock adjacent to the block, you can end here confirming room is closed.
This doesn't work for rooms that are not boxes. Or rooms where a hole in the floor is a problem. This could also not work effectively with multi story buildings. But, if you continue to iterate with the walls like approach you can check a multi story box for leaks aswell.
You could also raycast from the side of the player to find the walls and iterate through those blocks aswell to find a hole, there are many solutions to effectively doing this without brute forcing and checking every block surrounding a player, good luck.
Also, instead of doing this to each player every few ticks, do it at the loading of a chunk and when a block is placed or removed.