Started by
Gun Man
on
Topic category: Help with MCreator software
How do I check for if a player is in a generated structure? I want to do this because i want to run certain procedures if a player is in a structure.
Vanilla Example: If a player enters a Stronghold, they get the advancement "Eye Spy"
Modded Example: If a player enters a pre-generated cabin, a music track plays.
You could make a custom entity (that does not have health, despawn, or move) that spawns in the center of the structure. In its tick update, make it check for player in radius, and if true, make it do what you want then despawn (only despawn it if you want something to happen only the first time you enter).
If you wanted something to happen to the player, not just a sound play, you may need to have the entity tick only despawn itself, not do anything else, and run a global player tick that tests for the entity then does what you want (besides despawning the entity).
Alternatively, make an invisible block in the doorways that triggers what you want, though this is not optimal.
A proper solution is planned on the tracker too :)
How would I get the entity to check for the player in a radius?
There is a procedure for it, though I'm afraid I can't remember which section it is in.
Can you find out what procedure it is? I am looking for a way to detect this and if you are right, that would help a lot. Thank you.
I came up with a solution. I use it often in my random structures. Make invisible entity. With this method you have to set the entity tick high when placing in your structures. Lower it back to normal before testing your structure. Use this method with caution. I will make a small tutorial that is more in depth. I made a flea entity. This method is very flexible and easy to understand.
This procedure will fire off a sound when the player is 5 blocks away and de-spawn 1 tick later. I added random chance for flexibility. You can use this method to fire off anything you want. Command block, spawn entity etc.
https://i.ibb.co/xq2nd1b/2021-05-17-17-41-2.png
Chewy