SpongePowered / SpongeAPI

A Minecraft plugin API
http://www.spongepowered.org/
MIT License
1.14k stars 342 forks source link

Add event for creating scheduled updates #1286

Open Meegooo opened 8 years ago

Meegooo commented 8 years ago

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)

me4502 commented 8 years ago

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

ryantheleach commented 8 years ago

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

Meegooo commented 8 years ago

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

me4502 commented 8 years ago

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

simon816 commented 8 years ago

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

me4502 commented 8 years ago

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

Meegooo commented 8 years ago

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