gnembon / fabric-carpet

Fabric Carpet
MIT License
1.71k stars 273 forks source link

[Scarpet] Tracking scheduled ticks and random chunk ticks #1580

Open Guimoute opened 1 year ago

Guimoute commented 1 year ago

Hello, I think it would be interesting to have new events to track random/block/fluid ticks in Scarpet:

For context, those came to mind because I wanted to extend the behavior of renewableBlackstone and renewableDeepslate from Carpet and add a system to create easily any lava + water + <block1> = <block2> recipes. It is not doable with __on_tick(). Such a script would be based on the __on_fluid_tick event only, but I still suggested the two other events because they fall into the same "world action" event category.

James103 commented 1 year ago

I would make the events take a single block argument which is the block being ticked. This allows the usage of block-based functions directly on the block passed in instead of having to do block(x, y, z) on the three coordinate arguments.

Furthermore, the event should allow cancelling vanilla behavior by returning 'cancel'. This can be used for example to stop water/lava flowing or to simulate a fractional value for the randomTickSpeed gamerule.

Guimoute commented 1 year ago

@James103 Very good points. We can add more examples of use cases:

Fluid ticks:

Random ticks: