Started by
UAPvP
on
Topic category: Help with Minecraft modding (Java Edition)
So, I need to always check if player is below y0 and there is my custom block in the world.
But every time I use While to check that, my mc just crashes.
My code:
https://imgur.com/kj6psTi
My mod idea:
Custom block, when clicked starts checking if player is falling in void below y0 and is there a custom block, and teleports player above the block if so.
You may want to watch some tutorials to get a better idea of how procedures work. (I recommend NorthWestTrees Gaming), but I can offer some basic pointers:
'While' loops can VERY easily crash the game, especially if you're not super familiar with how they work. You're right in that a while loop will check something constantly until its condition is no longer true. But if you use a while loop and either don't give it an end condition, or give it an end condition that can't be met, then you have a problem.
Essentially, procedures are supposed to run instantly, in a single game tick unless you tell them otherwise. A while loop would be used for something like moving the player until they're outside a certain area, running through a series of blocks to check for something, that sort of thing. But if the while loop never stops, the game can't move on to the next tick until it's finished, which usually causes a crash. For your block, you want something that will trigger every tick, not something that will keep running through a single tick until it reaches a stopping point.