Add option to enable/disable block ticking based on redstone power

Published by hawkster97 on Mon, 08/12/2019 - 16:45
Upvotes: 1
Issue description

In 1.9.1, I think it would be a great feature to see the option to only perform ticks on a block when powered with redstone. This would allow for lots of new creations and ideas centered around redstone power, such as block sound loops when powered by redstone or a block that requires redstone to perform actions.

 

I brought up the concept in this forum post: https://mcreator.net/comment/88815

Basically, here's the steps

1. [Block Unlocked] Create procedure that plays desired sound

2. [Block Unlocked] Set tick rate of block to length of sound

3. [Block Unlocked] Set block onTick procedure to created sound procedure from step 1

4. [Block Unlocked] Set block redstone on procedure to created sound procedure from step 1

4. LOCK BLOCK AND GO TO BLOCK CODE

5. [Block Locked] Move schedule block update/tick call from onBlockAdded to Redstone on function.

5. [Block Locked] In onTick function in block code, add check for if block still has redstone power. Inside that, add another call to schedule block update/tick.

 

In generic form, its mostly a matter of not calling schedule block update unless powered by redstone. in the redstoneOn function, a call will be made to schedule block update, and then in on tick function, whatever action is performed, and if the block still has redstone power, call schedule block update.

 

 

Issue comments

Nice idea! I think it would be the best fit to implement this as a part of our new planned mod element condition, so I merged the idea here: https://mcreator.net/tracker/issue/49202

For now, you can add this condition in the update tick procedure itself to achieve a relatively similar effect.



Donate to MCreator

By donating to developers you can speed up development, as with more resources, we can dedicate more time to MCreator. It is a free project made by developers working on it in their free time.