TransWikia.com

How could I check if a player is exposed to rain?

Arqade Asked by Bruno Rodrigues on April 18, 2021

I was looking for a way to check if a player is exposed (no roof or anything) for a project and ended up thinking of one, but I failed to create it.

I found out that spreadplayer will tp the armorstand to the highest block on the xz cords and used Pos[1](y cord) with store to store the Y value.Then, i’d subtract the armorstand score to mine, so if it’s +, then it’s above, and bellow is .Then, to prevente lag, it would take sometime to refresh and repeat the process.
But I found bug and can’t find a way to fix it. The problem I stumbled upon was that if the armorstand is bellow,it would get a score value and die as expected, but after 3 times of killing itself, it would emit a positive signal (even though the score displayed as always ) and trigger as if it were above me.

World download: World Download
A little messed up but here is the chart: Print

Since I’m looking foward to use it in Multiplayer, creating a unique armorstand to each player simultaneosly is pretty hard.
I found out that spreadplayer will tp the armorstand to the highest block on the xz cords and used Pos[1](y cord) with store to store the Y value.Then, i’d subtract the armorstand score to mine, so if it’s +, then it’s above, and bellow is -.Then, to prevente lag, it would take sometime to refresh and repeat the process.

2 Answers

The simpliest solution:

/execute as [selector] at @s if blocks ~ ~1 ~ ~ 255 ~ x y z all run scoreboard players set @s [name] 1
/execute as [selector] at @s unless blocks ~ ~1 ~ ~ 255 ~ x y z all run scoreboard players set @s [name] 0

Where [name] stands for the scoreboard name of your choice, [selector] is the player or entity you are looking to test for and x y z is a coordinate of the world where it should be all air(only the block of that coordinate and all above). 1 means he is exposed and 0 means he is in cover.

Correct answer by Bruno Rodrigues on April 18, 2021

When you want to detect this on a multiplayer server, I would create a plugin, whichs checks, if it's raining (by getting the weather of the world of the player) and if the weather is actually affecting the biome at the players location (e.g. there is no rain in the desert). If this all is given and the block below the player is also the highest block at the players location, then the player is 'affected' of the rain.

Answered by Marvin Klar on April 18, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP