Started by
mangamaniacs2064
on
Topic category: Help with MCreator software
okay heres is what i tried...
set nbt number tag "catchfish" of block at x y z random0,1 x 6 if it has tile entity
if nbt number tag "catchfish" of block at x: x y z if it has tile entity = 2 or nbt number tag "catchfish" of block at x: x y z if it has tile entity = 6
do send to chat to all players:"fish catched!!!"
can you show me why it doesnt work.
random[0,1] is not an integer (whole) number. It's a float/decimal number. Checking whether such a number is equal to something is very bad practice.
Your procedure does work and generates a number between 0 and 6. However here are some of the possible outcomes:
5,245642 - 3,723453 - 52,64223 - 6
You can see why there's such a minute chance of catchfish ever being equal to 2 or 6. When working with floating point numbers, try something like:
which would give you a 20% chance at catching the fish. If you do want whole numbers, make sure to use ROUND to round the number. (Rounding up/down is also good practice when working with chance, as simply using round causes the 0 and highest number to only have half of the chance of appearing compared to any other number in between)
it worked out thanks!!!