Jump to content

Forge's equivalent of bukkit's Delayed Events


Scribblon

Recommended Posts

Hey Everybody,

 

The following is background, if you would like to go direct to the question, just skip it.

 

>Background<

Old Bukkit plugin-dev here trying out new more advanced and exiting modding waters. I suddenly had the itch to revamp an old plugin after some long nights messing with mystcraft: riftcraf. Now the plugin was not initially mine, nor did it became mine after the original author abandoned it. But I contributed to it a while back.

 

When you are a fan of pvp and get to the point where everyone has a following book from mystcraft, escaping is quite easy. Riftcraft tries to combat that by making teleporting not impossible, but delayed.

In context: After long study you are starting to figure out how Enderman and mobs use The Ether to get around. However, unlike an enderman you need to stabilize (focus) a rift before you can step through it. Until it is stabilized you are not allowed to move or you will lose your focus. On top of that, each jump requires 'rift-energy'.

On the other end you may facilitate a rift by placing down a rift-stone, these help 'stabilize' the rift and make them require less energy to form.

In reverse you may place down a disruption stone to prevent others of rifting in, handy to keep unwanted guests out your base. Even stealing the rift energy when they attempt to open a rift inside its range.

>/Background<

 

In bukkit you could register an event on a delay, EventManager.register(Eventable/Runnable, delay). Now, I searched high and low for a Forge equivalent,  through the wiki and through the forums. It is highly likely that I might be overlooking something or looking at the wrong packages for all that matter. But what I have seen so far of the EventBus and the event packages left me wondering if this functionality I seek is available?

"I guess as this is pretty much WIP, I can just 'borrow' the sounds from that game without problem. They are just 'placeholders' anyway." -Me, while extracting the Tear sounds of Bioshock Infinite.

Link to comment
Share on other sites

I appreciate the response. I hope you can help me a bit to understand the following inner workings of forge.

 

In bukkit you had this option (register delayed events) because you are not allowed to sleep a thread as everything is synchronized, thus sleeping would stop the whole server. Now I assumed this is also the case in forge as multiple mods can modify the same event in the same manner (set canceled, modify world/player). Or am I wrong and is forge a-synchronous?

 

(Now, I am aware that a-synchronous runables could be registered in bukkit, but these were not allowed to mutate anything inside the world and were only to be used to get info out of the world or do tasks outside the tick-clock like update your mysql database with the latest information.)

 

Now I have done some further research on this and I am afraid I have to code my own event manager which have to catch every tick and compare it to my own queue. Although this would probably leave me with more flexibility, it will also increase the load for a mod with such a simple premise: pvp friendly teleportation.

 

 

"I guess as this is pretty much WIP, I can just 'borrow' the sounds from that game without problem. They are just 'placeholders' anyway." -Me, while extracting the Tear sounds of Bioshock Infinite.

Link to comment
Share on other sites

Thank you for the nudge in the right direction.

 

I was too focused on the term 'events' that I experienced some tunnel vision towards the subject. For future reference:

The ITickHandler brought me to the IScheduledTickHandler, which is actually pretty much what I searched for.

Both require a TickType defining on what kind of tick you want your mod to trigger upon.

In the end these handlers need to be registered in the TickRegistry.

"I guess as this is pretty much WIP, I can just 'borrow' the sounds from that game without problem. They are just 'placeholders' anyway." -Me, while extracting the Tear sounds of Bioshock Infinite.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • before I updated my pack I made for paintings++ mod, i noticed and saw that only modded paintings and vanilla ones move one block each time I re-enter my world! is there something wrong? what the hell is even going on? why is there a ghost living in my house?! the modded paintings even phase through blocks which is super weird!! help! here is my painting mod list: Paintings++ Dark paintings Macaw's paintings Joy of painting Immersive paintings My custom paintings++ resource pack
    • Error: java.lang.NullPointerException: Cannot invoke "me.codexadrian.tempad.TempadClientConfig.renderBlur()" because the return value of "me.codexadrian.tempad.TempadClient.getClientConfig()" is null I keep having this error while trying to launch a modpack through the forge modloader, any suggestions? https://docs.google.com/document/d/1CRKUoSiu2e_mDvDTVYpIA5wqD3w-BsCycxBu1_vQ4OA/edit?usp=sharing Crash Report ^^^^
    • I'm trying to start a server with the latest installer, but running the run.bat file doesn't generate new files. It shows the following in the cmd prompt.
    • One of my players is suddenly unable to join a locally hosted MC Eternal server. We have been playing on this server for about 2-3 weeks now. I have tried erasing his player files and his reputation file, and now it just coughs up this and kicks him out: [User Authenticator #5/INFO] [minecraft/NetHandlerLoginServer]: UUID of player EthosTheGod is 7692d8db-02c3-424f-a4ab-0e4e259b106b [20:25:36] [User Authenticator #4/INFO] [minecraft/NetHandlerLoginServer]: UUID of player EthosTheGod is 7692d8db-02c3-424f-a4ab-0e4e259b106b [20:29:35] [Server thread/WARN] [minecraft/MinecraftServer]: Can't keep up! Did the system time change, or is the server overloaded? Running 575849ms behind, skipping 11516 tick(s) [20:29:35] [Server thread/INFO] [minecraft/NetHandlerLoginServer]: com.mojang.authlib.GameProfile@4a6c63f1[id=7692d8db-02c3-424f-a4ab-0e4e259b106b,name=EthosTheGod,properties={textures=[com.mojang.authlib.properties.Property@241ea89e]},legacy=false] (/IP.ADDRESS) lost connection: Disconnected [20:29:35] [Server thread/INFO] [minecraft/NetHandlerLoginServer]: com.mojang.authlib.GameProfile@6ab6c661[id=7692d8db-02c3-424f-a4ab-0e4e259b106b,name=EthosTheGod,properties={textures=[com.mojang.authlib.properties.Property@7f19aae3]},legacy=false] (/IP.ADDRESS) lost connection: Disconnected It just says "connection timed out" on his end. Any ideas?
    • I'm trying to migrate my mod from 1.20 to 1.21. Some packages in the forge api were changed so my mod did have some classes not working. I've changed everything i needed but still is getting me the following error error: cannot access Registry DeferredRegister.create(ForgeRegistries.BLOCKS, FarmMod.MOD_ID); ^ class file for net.minecraft.core.Registry not found The piece of code that is wrong is   public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, FarmMod.MOD_ID); And here are my imports   import com.lucas.farmmod.FarmMod; import com.lucas.farmmod.block.custom.BaseIrrigatorBlock; import com.lucas.farmmod.item.ModItems; import com.lucas.farmmod.item.custom.BaseIrrigatorBlockItem; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; The class DeferredRegister is throwing the error in the print below     I've tried running rebuilding my project in every way possible, tried refreshing my dependencies but nothing works. What can i do?
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.