Well the title kind of says it all. Would any of you be interested in/is there already a plugin that can do this? I don't want to start making it only to have a perfectly good competitor/no users!
ive thought about this in the past, but the biggest problem here is, how would you determine what is a hole?
well looking at this plugins src I think i can cancel the normal weather when is generated and fake my own weather in a place where i can define a cuboid. i then just set up a repeating task to check each block for holes by checking the blocks up 1 and on all 4 sides. if there all blocks then its a hole although it may be a bit resource heavy and time consuming it SHOULD work i just dont know if i wanna try it!
so you mean like single block holes. otherwise i was going to say you could end up with a massive amount of massive lakes everywhere lol
thats true, or you could determine the largest area that could be filled, like if the area is larger than 10 blocks it wont fill. the next issue i see here though then is that every time its going to rain its going to do a massive block calculation, making it lag even more than it normally does when it rains... at least i assume it would. idk edit: then again that could cause issues for open caves.
I agree with kalez. The only effective way to check if there is a 'hole' is search below a certain y value, and if it is in view of the sky, fill it with water. However this would cause all sorts of problems, mainly huge server resources. On an average sized map, you would be talking about 1000s of block changes instantly as soon as it started raining. This would almost surely crash any server and probably do irreversible damage to the map. (Have you ever tried world-editing something over 10k blocks...)
well i was going to try it but yeah if u wanna give it a go no prob it looks like u'll need to import the craftbukkit.jar, and when theres a normal storm cancel it and generate your own in an area where you can make a cuboid and check for holes via an async task. If you can think of a better idea i'd LOVE to hear it
1. Only check loaded chunks. 2. Use chunk.getHighestBlockAt(x, y); 3. Don't use async tasks, they will fire ConcurrentModificationExceptions and other weird things.
so youre not calculating pointless air i would assume edit: it would also have to be by certain block types. you proly dont want water in a tree
Cause at lower blocks it's not raining? //EDIT: Block possibleHole = chunk.getHighestBlockAt(x, z).getRelative(BlockFace.UP); then do your hole check...
wait so you can check if a block is being rained on??? that would be great if i could just look at the top block and check if its being rained on... the hole code will be simple just getRelative(BlockFace.UP, 1) then check if all for sides on that block aren't air. If its not just set the data to 8 (or maybe 9 so it wont flow?). That would be easy to do in a loop if i could just get a cuboid of the blocks being rained on. The problem is i would have to put some form of delayed task otherwise it would just look like water is glitching into the holes. You could even store the location in a hashMap or arraylist and change them back to air after the rain is over. The problem is just getting that cuboid.... EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Something like this (untested): Code:java if(!world.hasStorm()) return;for(Chunk chunk: world.getLoadedChunks()){ int sx = chunk.getX() * 16; int sz = chunk.getZ() * 16; for(int x = sx; x < sx + 16; sx++) { for(int z = sz; z < sz + 16; sz++) { Block b = chunk.getHighestBlockAt(x, y).getRelative(BlockFace.UP); if(b == null) continue; Biome bio = b.getBiome(); if(bio == Biome.DESERT || bio == Biome.FROZEN_OCEAN || ...) continue; if(b.getRelative(BlockFace.NORTH).getType() == Material.AIR || b.getRelative(BlockFace.WEST).getType() == Material.AIR || b.getRelative(BlockFace.SOUTH).getType() == Material.AIR || b.getRelative(BlockFace.EAST).getType() == Material.AIR) continue; b.setBlockIdAndData(Material.WATER.getID(), 9); } }} ?
yeah but when theres a storm it doesnt rain on EVERY loaded chunk does it? if it does on all but deserts and snow areas then this plugin just got a WHOLE lot eaiser
I don't think it does. On the server i play on me and my friend would be in two different areas and it would rain in one location and not the other
well what i heard is that the server tells the client "TIME TO RAIN!" and then the client chooses how do handle it. Thats why i started to look at the src for this.
Yes, but server and client have to be synced (damaging Enderman, for example) for it to work. So both sides set the rain based on biomes. It's per-world rain. Just trust me. That's pretty advanced stuff (faking packages) and has nothing to do with the notch rain.
Code: package me.advsnoob.rainHole; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.Chunk; import org.bukkit.block.Biome; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.event.weather.WeatherChangeEvent; import org.bukkit.event.weather.WeatherListener; public class WorldWeatherListener extends WeatherListener{ public void hasStorm(WeatherChangeEvent event){ World world = event.getWorld(); if(!world.hasStorm()) return; for(Chunk chunk: world.getLoadedChunks()) { int sx = chunk.getX() * 16; int sz = chunk.getZ() * 16; for(int x = sx; x < sx + 16; sx++) { for(int z = sz; z < sz + 16; sz++) { Block b = chunk.getWorld().getHighestBlockAt(x, z).getRelative(BlockFace.UP); if(b == null) continue; Biome bio = b.getBiome(); if(bio == Biome.DESERT || bio == Biome.FROZEN_OCEAN) continue; if(b.getRelative(BlockFace.NORTH).getType() == Material.AIR || b.getRelative(BlockFace.WEST).getType() == Material.AIR || b.getRelative(BlockFace.SOUTH).getType() == Material.AIR || b.getRelative(BlockFace.EAST).getType() == Material.AIR) continue; b.setType(Material.WATER); } } } } } Slightly Modified code from V10lator Doesn't seem to want to work. Any advice you guys? I do know java just haven't really worked in bukkit before
@hammale: No, cause you want the air block above the highest (non air) block. //EDIT: @AdvsNoob: Your code will never be executed. Use bukkits scheduler for it, not a listener!
Bleh, i remember reading this. It confused the H*** out of me XD. Can anyone further explain? All i know for bukkit is how to use listeners :/ I have no clue about this stuff so i don't know what to change or not to change Pretty bad huh?