Probability issues - spawn one structure OR another

Started by funsihd on

Topic category: Help with modding (Java Edition)

Last seen on 08:37, 22. Oct 2023
Joined Feb 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Probability issues - spawn one structure OR another
Wed, 10/18/2023 - 14:16 (edited)

Hello MCreator Community,

I'm having problems with setting up a random spawn system. It should spawn either one structure or another or none at all, but in my case it spawns either one structure or all at once. To put this into context, I am using the technique from our community member ChewyBullets by putting a procedure on entity tick update to spawn certain structures next to each other. I will put a picture down of the procedure I made. 

I hope someone can help me fix it so it works how it should be

https://imgur.com/Bv076YD

 

Edited by funsihd on Wed, 10/18/2023 - 14:16
Last seen on 16:12, 15. Oct 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This should, (technically),…
Wed, 10/18/2023 - 22:28

This should, (technically), work. (It'd help if you were clearer on what the problem was...?) However, the way you've arranged this is really confusing. There are many easier ways to do probability, and with your else if statements, there's a small chance none of the checks pass, and you wind up with no structure at all. 

If you want to do a random percentage chance, you could use the 'do with 70% chance' procedure template. You really only need one check, (whether not a random 0-1 number is less than a decimal value), and you need to keep in mind that nesting percentage checks like this changes the probability of each consecutive check. A better option is to create a local number variable that chooses a random number, (say, between 1 and 100, if you still want percentages), then for each structure check if the number variable is within a certain range. This way you could do something like what you're trying, without having to do a lot of weird math to figure out the probabilities.

Last seen on 08:37, 22. Oct 2023
Joined Feb 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@Mindthemoods Thanks for the…
Thu, 10/19/2023 - 09:44

@Mindthemoods

Thanks for the reply. It should spawn a structure in the middle and then random structures around it. The problem I had was that these possibilties came up all at once instead of coming up randomly by themselves. 

Needless to say, It's the same concept of having random item drops but with structures. Imagine having a block that you can destroy and it would drop either coal, diamond or gold. But if you break it the first time, it drops coal. The second time you would break it, it drops coal, diamond and gold. The third time you break it, it drops coal and gold. Each and everytime it wouldn't drop either coal or diamond or gold, it would drop them all at once.  It is hard to describe. 

Anyway, I adjusted the procedure like you told me. But it still would not work. Did I do it correctly?

https://imgur.com/CrnrbFt