Topic category: Help with Minecraft modding (Java Edition)
I have issues figuring out how to detect if is raining above a block, what I need to a certain event to happen. I tried as conditions a combo of the procedure blocks to verify if the block can see the sky and to check if is there's rain or storm in the world. It works almost as I want but the trouble starts when the block is under a transparent block as glass, triggering the event even indoors.
I guess that what I really need it's some kind of custom code to verify raining at this block specifically instead of using the "can see sky" procedure block.
I'm sort of a rookie with coding. I found something about "World.isRainingAt", but I have no idea about how to make it work.
Beforehand, thanks for your help.
EDIT:
The block must do the thing ONLY when rain is falling directly at the block. Using the "can see sky" procedure block also triggers the effect when this block is under transparent blocks.
So your request sounds like to me the "if-do" procedure could be the right answer for this. In every case the requirement of is
"if "is raining in the provided world" or "is thundering in the provided world"" this is mandatory to trigger whatever you want that the Block should do.
This should be detected indoors as well, because both properties are in the level.dat of the minecraft world. So I assume it gets the rain or thunder value from there. If I am right, you don't need the Block see the sky tag at all neither outdoors nor indoors, if a block is placed on that rain sensor.
I am also not wondering that you have issues if you placed e.g. a glassblock over your rain detecting block. It can't see the sky, because a block is over the sensor, which blocks the rain. Although glass does not decrease the lightlevel (or decrease with minor effects on stained glass but i don't know.) But you can see the sky through glass, the daylight sensor detects the daylight but the Block it self can't detect the rain, while glass is placed over it. The block needs to see the sky? So no other blocks may placed over that block, which should see the sky.
Well actually what I really need is that the block detects if rain is falling directly over it, not if raining in the world. If I put a glass block at any height above the block, there is no rain particles, but it still detect as if there was nothing above... The same happens with any other transparent block.
In other words, the block can see the sky through any transparent blocks. There is no issues with opaque blocks. I tested it many times. Still happens.
The block "attracts" lightning if raining directly above it. I must stop if is below a transparent block at any height.
Endermen don't receive damage by rain if they are below any transparent block. Also farmland hydrates if it's raining directly above the farmland block but cannot do it if there's glass over it at any height blocking the rain. I need to figure out that condition exactly.
To do this I can't help. I don't know how I can do this and I'm really sorry for this and I am sorry as well the rain/thundering if statement are not sufficient what you want to have. I wish for you, someone else can help you out.
Do something like this:
if (is raining in the world):
if (can Block at x y z see the sun):
executable code
~Lanee
Sorry Lamyr, but it's what I'm doing already, and the sky can be seen thru transparent blocks.
use a raycast y to the Hight limit and check for all blocks except fluids as your other check
MinerMiner, how am I going to do that? It seems that only works for entities, not blocks...