Started by
clocked_artifact
on
Topic category: Help with Minecraft modding (Java Edition)
God knows how long I've been trying to get this bit of code to work, What I'm trying to do is make a fishing net block. As far as i know, i cant add items to the fishing loot table sothats why im making it. What i want it to do is every second it chooses a number between 0-1, and if it chooses 1, an item from its loot table gets put in the fishing net blocks inventory. As of now the only thing in its loot table is just fish.
idk what happened to the image link i cant see it either so here it is https://imgur.com/a/9WDUN69
I don't know if I can explain it properly in English. But. The generated random number will never equal to 1 because on the right side there is a open interval (1). So the generated random number is: 0 <= number < 1.
Also I think you will have problem with the infinity loop you made. It means if the procedure is trigerred, do infinity times putting a fish in the net. This repeat block gives sense only when you want to do the task x times when procedure is trigerred.
it took me a while to get it But I removed the repeat block and just stuck the blocks of code from inside it and just stuck that as the do function. And I changed the equal sign to a less than or equal sign. I've actually got results! I placed the block in water and when i opened it i got a fish! right now it's only limited to one slot and only one fish but i know what i need to do and my code looks like this now. Thank you for your help!
https://imgur.com/a/dxS7Pyb
You're welcome.
I just have one more remark:
Now the fish is "caught" in the net in 100% cases. The "random number" block generates not just 0 and 1 but also decimal numbers between them (0,456; 0,567; etc.). Because you set the number less or equal than 1 and these are all generated numbers. So if you want to make some probability (30%; 20%; etc.) you have to set the number smaller than 1.
For example if you want to do it with 50% chance it would be: if random number is smaller than 0,5 then do...
I think this tutorial will explain it better than me. :D
https://www.youtube.com/watch?v=SBtTsNYiHzw
thank you :D