Started by
BecauseiiThan
on
Topic category: Troubleshooting, bugs, and solutions
I'm making a horror mod currently and I'm almost done making it but there is just one problem that I don't know how to fix. The problem is that the spawn block isn't spawning my entity I'll send images of the spawning tab and the procedure to spawn it in.
The entity is only meant to spawn on grass and to spawn a maximum of 50 blocks away from the player.
Since I am a beginner please provide an image if possible.
Okay I may know what's going on, Open a Superflat world and see if your entity spawns (Make sure its the default grass one) tell me if it spawns there.
Sorry for the late reply. My copy for the mod was making me unable to test for some reason so when I went to delete it when I deleted it MCreator froze but I thought it just didn't delete so I tried to delete it again but it ended up deleting both. I was able to recover the workspace but sadly everything was corrupted. Its going to take me a while to remake it but can you explain what you think was not working with it so when I remake it I can fix it.
I'm sorry to here that.
I believe the issue is in your code. it starts by picking a random value for the X and Z which should be all good. your main issue is the grass detection, it checks for a grass block at (Y - 1) or one block under the player. but at the X and Z its spawning at. The issue is Minecraft worlds are hardly ever flat enough for that. Take this example image
https://imgur.com/a/hTsWgLs
It shows minecraft on a 2d slice, the yellow is the player and the red is your entity or at least the position its attempting to spawn at, as you see the block directly below the spawn position is air not grass but that is the players Y - 1. You would need to check for a grass block with any Y position on the X and Z generated and put it on top of that. Also the global "TheStatueAmount" Is not set back to 0 after a failed spawn attempt so it cant try again (Probably why it wasn't attempting over and over till it did manage to find a grass block on the same level as you) here is some code that should work
https://imgur.com/a/uIu0EcB
Just make sure you set it to spawn your entity and not a pig. Good Luck
Thank you so much for the help I've been trying to fix this for hour now I actually tried something like this so I didn't think this was the problem. Since I still remember most of the code I should be able to remake it faster than I made it. Also instead of repeating it 50 times should I use a while block to repeat it instead so it repeats until TheStatueAmount = 1?
Not quite, if you use an until block and there is no grass in that X-Z column of the world it would move down forever. (Note that the code is set tp check 25 blocks above and 25 blocks below the player, you can set TestY to any number and set the repeat to 2X that for a smaller or bigger height margin)
Ok thanks but I don't really understand the Y cords thing like wouldn't Test Y = 25 spawn it at Y 25.
You know what, your right Test Y should be set to Y + 25 not just 25, so it checks 25 blocks above the player, it removes 1 from test Y each check until it finds a grass block (Or fails) so where it says Set Test Y to 25 Change to set Test Y to Y+25, my bad.
Ok thank you so much for all the help. When I remake the mod I will add the code.
Also would spliting the code between different procedures cause less lag since the on tick procedure is running less. Basically what I mean is I could split the code between two procedures and call the second one in the first kinda like this...
https://imgur.com/a/kXTUsdm
Yes you could do that for less lag, should work all the same just split it where the line is in the picture and it should work.
Ok thank you so much for all the help. Im going to give you credit in the mods description for all the help. The mod is going to be a horror mod called Find Me.
No worries! your welcome to ask if anything else doesn't work.
I have another problem the entity spawns in but after it spawns in it's meant to call a procedure called TheStatueIsHiding but it's not and if that's not called then you can't win or lose.
https://imgur.com/a/kh1LETD
The first and the third one are for spawning and the second on is TheStatueIsHiding
Okay, try calling TheStatueIsHiding after the loop instead of in it, Call it if SpawnSuccessful = True
https://imgur.com/a/agdBBPH
(Do not remove the SpawnSuccessful = False part just add call TheStatueIsHiding if SpawnSuccessful = True
under it)
If it still doesn't work, please say how it should work, What counts as winning? or how do you find the statue? (I assume that's the goal) Its hard to tell what's wrong without knowing what its supposed to do