Started by
Among
on
Topic category: Help with Minecraft modding (Java Edition)
I'm making a creeper that will teleport when hit and with a 5% chance spawn another creeper when hit. I already have the way the creeper explodes and the procedure for it to teleport, but when I try it it teleports into a void or into a mountain (which suffocates it and it dies) and I don't know how to fix it. Someone knows? (I would also like to know how I do what I said about spawning another creeper with a 5% chance when hit)
So I'm assuming that the block you're using for teleporting the creeper is the "Set location of "{Event/Target Entity} to x: {x} y: {y} z: {z}" In my mind, I see two options that you can take.
A) Add the "Random integer between min: {1} and max: {10}" block into the x and z slots of the first block I mentioned. Then you can just safely choose a range that isn't too far. Granted it doesn't solve the issue directly if you're in a cave which brings me to the next option.
B) Under the "World Data" tab, there's a "Is air at x: {x} y: {y} z: {z}" block. I would use that to check the random range that the creeper can teleport to for air, then if air is there, let it teleport, otherwise no. The only downside is that of you are in a two block space (hypothetically) with no air gaps for a range. Then the creeper wouldn't teleport but this scenario is unlikely unless a player built a containment for the creeper that was big enough to surpass the specified range of the random integer block.
I meant random number block, not integer.