Jump to content

[1.12.2] Executing a void method after few ticks in a event


Recommended Posts

Posted

Hello. I am here because I want to know how to execute a void method after few ticks. What do I mean? Here is an example: In a subscribe event(for example BlockRightClick event) when you actually right click the block after the number of ticks you want it will do a void method/action for example spawn particles. Thank you for reading. I hope I was clear enough.

Posted

Set a counter field to the amount of ticks you want to wait in your triggering event, decrement the counter in a tick event, once it reaches zero do your action. You may or may not need to store the context you need(block position, triggering player, etc) in fields too.

 

You could also store the time(in ticks) at which you want the code to execute and instead of decrementing the counter compare the current time against the stored one.

Posted

Thank you void for your amazing reply. I just have a question. How its called the "tick event" you are talking about?

Also does the tick field needs to be int or a double?

Posted
5 minutes ago, devdude said:

How its called the "tick event" you are talking about?

Use one of the subclasses of TickEvent. The one you use depends on your circumstances and your mod.

 

7 minutes ago, devdude said:

Also does the tick field needs to be int or a double?

It can be whatever you need it to be. In most cases it would be an int. If you are going with the second approach it would be a long

Posted

Hello, it`s been a while, and now i am again here, i was really busy. I coded some events but i cant figure out how to connect them. For example I wanna make a method like this:

 

this.tick(123) { //123 are ticks

        //Do my things here after 123 ticks in the RightClickBlock event

}

 

Is a thing like this possible? If yes how can i do it?

 

Thank you for reading.

Posted

Well, I know that, I dont actually know how to start the tickevent when rightclicking the block. Even making a boolean "started" it cant work because if the player right click on more blocks at one only 1 boolean cant work

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

    • Those are just warnings, probably because those libraries do not contain actual mods, just helper classes or something, hence the missing mods.toml files. You should be fine just ignoring them.
    • [28Jan2025 17:04:56.714] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\{COMPUTER_USERNAME}\AppData\Roaming\ModrinthApp\meta\libraries\net\minecraftforge\fmlcore\1.19.2-43.3.5\fmlcore-1.19.2-43.3.5.jar is missing mods.toml file [28Jan2025 17:04:56.727] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\{COMPUTER_USERNAME}\AppData\Roaming\ModrinthApp\meta\libraries\net\minecraftforge\javafmllanguage\1.19.2-43.3.5\javafmllanguage-1.19.2-43.3.5.jar is missing mods.toml file [28Jan2025 17:04:56.739] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\{COMPUTER_USERNAME}\AppData\Roaming\ModrinthApp\meta\libraries\net\minecraftforge\lowcodelanguage\1.19.2-43.3.5\lowcodelanguage-1.19.2-43.3.5.jar is missing mods.toml file [28Jan2025 17:04:56.751] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\{COMPUTER_USERNAME}\AppData\Roaming\ModrinthApp\meta\libraries\net\minecraftforge\mclanguage\1.19.2-43.3.5\mclanguage-1.19.2-43.3.5.jar is missing mods.toml file
    • thank you! removing imeediatelyfast made it work
    • Whether you are a fan of Hypixel Bedwars, SkyWars and PvP gamemodes, you would enjoy this server! We have a very fun and unique style of PvP that a lot of our players really enjoy and we want to bring this server to more players like you! Introducing Minezone, home of SUPER CRAFT BLOCKS. Here is what we have to offer: SUPER CRAFT BLOCKS: This has 3 different gamemodes you can play, Classic, Duels and Frenzy. Each mode offers over 60 kits to choose from, along with a total of over 60 maps, allowing for various different playstyles on each map. There are also random powerups that spawn on the map which can include Health Pots, Bazookas, Nukes, Extra Lives and way way more! There is also double jump in this gamemode as well, which makes PvP a lot more fun & unique. You only need a minimum of 2 players to start any mode! Classic: Choose a kit, 5 lives for each player, fight it out and claim the #1 spot! Look out for lightning as they can spawn powerups to really give you an advantage in the game! Duels: Fight against another random player or one of your friends and see who is the best! Frenzy: Your kit is randomly selected for you, each life you will have a different kit. All the other stuff from Classic/Duels apply to this mode as well like powerups.   SERVER IP: If this server has caught your interest in any way, please consider joining and you will NOT regret it! Bring some of your friends online for an even better experience and join in on the fun at: IP: minezone.club Hope to see you online!   SERVER TRAILER: https://www.youtube.com/watch?v=0phpMgu1mH0
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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