How to make multiple random timers on one block.

Started by Dragma2005 on

Topic category: Help with modding (Java Edition)

Last seen on 00:59, 1. Dec 2023
Joined Feb 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to make multiple random timers on one block.

I am having trouble because I want to make a block that does something after x-y amount of seconds, for example, if it was 12-16 seconds, it could happen after 12,13,14,15, or 16 seconds (or maybe in-between full seconds?), and does something else after, for example, 15-22 seconds. I have not been able to find a way to do this and I would really appreciate help.

Last seen on 20:25, 8. May 2020
Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You need to enable inventory…
Thu, 09/26/2019 - 13:57

You need to enable inventory for the block and set slots to 0. Now you'll be able to create NBT tags for the block.

Go to the "On tick update' for that block and create the procedure:

if Get NBT number tag "CounterOne" < 20*16 (this makes it a 16 seconds timer as it ticks with 20 per second)

do (whatever you want it to do)

do Set NBT number tag "CounterOne" to 0

else 

do Set NBT number tag "CounterOne" to Get NBT number tag "CounterOne" + 1



if Get NBT number tag "CounterTwo" < 20*22 (22 seconds)

do (whatever you want it to do)

do Set NBT number tag "CounterTwo" to 0

else 

do Set NBT number tag "CounterTwo" to Get NBT number tag "CounterTwo" + 1

You can replace the 22 or the 16 and create a random number for it too if you want. Which you can set in On Block Added. I don't know what exactly it is that you're trying to do, but if you only want the numbers to be randomly initialised:

On Block Added:

Set NBT number tag "RandomTimeOne" to Random[0,1] * 4 + 6 rounded (To get a number between 6 and 10)

Set NBT number tag "RandomTimeTwo" to (Another random number

 

Last seen on 00:59, 1. Dec 2023
Joined Feb 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Can someone tell me why this…
Thu, 09/26/2019 - 19:19

Can someone tell me why this doesn't work? It should place the selected block below it after 5-11 seconds.

 

A picture of my procedure.

Last seen on 20:25, 8. May 2020
Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The picture doesn't load for…
Fri, 09/27/2019 - 08:53

The picture doesn't load for me.

Last seen on 00:59, 1. Dec 2023
Joined Feb 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I think you just have to…
Fri, 09/27/2019 - 11:45

I think you just have to right click the little icon and click "open image in new tab".

Last seen on 20:25, 8. May 2020
Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Did you enable inventory on…
Sat, 09/28/2019 - 01:31

Did you enable inventory on this block? Otherwise you can't use an NBT tag on the block; "If it has tile entity". Set inventory slots to 0.

Last seen on 00:59, 1. Dec 2023
Joined Feb 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yes, I did.
Sat, 09/28/2019 - 13:45

Yes, I did.