SpongeAPI icon indicating copy to clipboard operation
SpongeAPI copied to clipboard

Add event for creating scheduled updates

Open Meegooo opened this issue 9 years ago • 7 comments
trafficstars

I'm talking about World#scheduleUpdate. This event will allow plugins to change delay of liquid/fire spreading, blocks falling, buttons, pressure plates, redstone torches, tripwires, rail detectors. Or even stop them from ticking at all (for something like one-time use buttons or static liquids)

Meegooo avatar Jun 27 '16 10:06 Meegooo

We already have this, https://jd.spongepowered.org/4.1.0/org/spongepowered/api/event/block/TickBlockEvent.html

me4502 avatar Jun 27 '16 11:06 me4502

Ticks arn't necessarily scheduled block updates. I believe Meegooo was asked to create this issue by someone.

ryantheleach avatar Jun 27 '16 11:06 ryantheleach

And I was told on IRC that TickBlockEvent fires for random ticks (growth and stuff), not scheduled ones.

Meegooo avatar Jun 27 '16 11:06 Meegooo

There used to be a sub event for scheduled, it appears to be gone

me4502 avatar Jun 27 '16 12:06 me4502

Isn't this just ScheduledBlockUpdate? https://github.com/SpongePowered/SpongeAPI/blob/44b5f5ecc6bf3751ef81b1ff6321fbe3f08099fc/src/main/java/org/spongepowered/api/world/extent/Extent.java#L333-L395

simon816 avatar Jun 27 '16 13:06 simon816

@simon816 This is for an event to listen, rather than create - from what I can tell

me4502 avatar Jun 27 '16 15:06 me4502

You can't really use those methods the way event could be used.

I mean, in case of stopping water from spreading (although you can just cancel ChangeBlockEvent.Place for flowing water) you could do something like this: Listen for ChangeBlockEvent.Place for water and after 1 tick change scheduled updates at that location (and around it). But that is quite hacky and might not work for scheduled updates with 1 tick delay. (scheduled updates are created after ChangeBlockEvent is fired, right?)

PS. I just realized. ScheduledBlockUpdate doesn't have information about future block inside it. So you can't really tell what will happen after that update occurs. Looks like it just ticks whatever is located at Location. World#scheduleUpdate, from what I can tell, is used to place/change blocks

Meegooo avatar Jun 27 '16 15:06 Meegooo