Jump to content

Can I make Tickable tileentities update some functionality every several ticks?


Recommended Posts

Posted

My tileentity implements ITickable to make it tickable, but I want my codes in update() to update every 5 ticks. Is there a way I can achieve that? 

Posted

Make a counter that increments every tick. If the counter hits 5, reset it to 0 and do whatever you want.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Posted
2 hours ago, DavidM said:

Make a counter that increments every tick. If the counter hits 5, reset it to 0 and do whatever you want.

thank you for replying! are there 3 kinds of counters for ServerTickEvent, WorldTcikEvent and PlayerTickEvent? 

 Mind show me an example or just direct me to a thread with examples?

Posted

Those are irrelevant. Add the counter in your ITickable#update. My previous post explained how to implement this.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Posted
3 hours ago, Ice2670 said:

thank you for replying! are there 3 kinds of counters for ServerTickEvent, WorldTcikEvent and PlayerTickEvent? 

 Mind show me an example or just direct me to a thread with examples?

By counter, I believe DavidM is suggesting you use a type such as an Integer which is incremented by 1(int++) within update().

You would then have the if statement check the value of this Integer and if it reaches 5, set it back to 0.

Posted (edited)
19 minutes ago, TheMCJavaFre4k said:

Integer

probably an int, not an Integer

20 minutes ago, TheMCJavaFre4k said:

1(int++)

This is also the perfect place for a pre-increment with ++counter;

Edited by Cadiboo

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted (edited)
41 minutes ago, Krevik said:

in your tile entity class


private int ticker=0;

in your tick() method


tick(){
ticker++;
  if(ticker>=5){
  ticker=0;
  //do your thing here
  }
}

 

1. Use the correct syntax highlight when posting code.

2. Post code with correct Java syntax or specify that it is pseudocode.

3. Don't just post solutions like that. Others can copy/paste without learning.

Edited by DavidM

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Posted (edited)
2 hours ago, DavidM said:

1. Use the correct syntax highlight when posting code.

2. Post code with correct Java syntax or specify that it is pseudocode.

3. Don't just post solutions like that. Others can copy/paste without learning.

Others already explained it enough. He asked for example. And this your post is not connected with his problem.

Edited by Krevik
Posted
13 minutes ago, diesieben07 said:

Yes. Which usually means "I don't want to learn, just give me the code".

Learning without examples? Huh it can cause mass of misunderstandings ?

Posted (edited)
3 hours ago, Krevik said:

He asked for example.

1. Even if he did, you should not directly post the code that he is supposed to write.

2. Your example is bad both style-wise and performance-wise. This will set a poor example for others.

Edited by DavidM

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Posted
12 minutes ago, DavidM said:

1. Even if he did, you should not directly post the code that he is supposed to write.

2. Your example is bad, both style-wise and performance-wise. This will set a poor example for others.

Okay I will delete my bad example then.

Posted

They don’t exactly “let” you learn. They force you to learn ?

  • Haha 2

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted (edited)
On 2/27/2019 at 3:09 AM, DavidM said:

1. Use the correct syntax highlight when posting code.

2. Post code with correct Java syntax or specify that it is pseudocode.

3. Don't just post solutions like that. Others can copy/paste without learning.

What you say is ridiculous. I'll need to understand what you are saying so that i can learn, but most of the time it is really hard to understand what you say with out an example. For example, what i don't understand is "counter", it is a term that others may don't understand. you should say an int++ in update() can be a counter, or show me that update{int++ } is a counter. other wise HOW I'm I suppose to learn??

Edited by Ice2670
Posted
On 2/27/2019 at 5:35 AM, Krevik said:

Others already explained it enough. He asked for example. And this your post is not connected with his problem.

keep your example there, what DavidM says really don't make sense! People can LEARN WITH examples!

Posted
On 2/27/2019 at 8:39 AM, DavidM said:

1. Even if he did, you should not directly post the code that he is supposed to write.

2. Your example is bad both style-wise and performance-wise. This will set a poor example for others.

yeah, maybe the example is not that good, then you should tell others what is a good example!!! If you are a teacher then you are a BAD teacher with BAD teaching principle!!

Posted (edited)
4 hours ago, Ice2670 said:

other wise HOW I'm I suppose to learn??

1. If you need an example in order to understand "increment every tick and check if it reaches 5", then you should probably learn basic programming before trying to make a mod. It is a basic programming concept.

2. He is not giving you an example, but rather giving you a copy to copy/paste from, which is discouraged on this forum.

Edited by DavidM
Deleted unproductive comments

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Posted
1 hour ago, DavidM said:

1. If you need an example in order to understand "increment every tick and check if it reaches 5", then you should probably learn basic programming before trying to make a mod. It is a basic programming concept.

2. He is not giving you an example, but rather giving you a copy to copy/paste from, which is discouraged on this forum.

 

3. I'm not a teacher, but my principle is that people should learn instead of posting functioning code for others to copy.

 

4. a) add space to style code. b) use I++ inside the if loop to prevent multiple unnecessary references.

not everyone here is a professional computer programmer and you don't need to be a computer programmer to make a mod!! 

Posted
1 hour ago, DavidM said:

 

 

3. I'm not a teacher, but my principle is that people should learn instead of posting functioning code for others to copy.

 

 

I don't care how your principle work! different people got different learning principle, if you don't have the ability to understand that you are just simply toooooooooooo selfish! not to mention that you are imposing your principle on others!

Posted
1 hour ago, DavidM said:

 

2. He is not giving you an example, but rather giving you a copy to copy/paste from, which is discouraged on this forum.

 

 

the problem is you didn't even give me a proper example in your standard! and the code he gave me is definitely not gonna work on my mod if i just copy/paste it 

Posted (edited)
1 hour ago, Ice2670 said:

you don't need to be a computer programmer to make a mod

You need to know programming though.

Edited by DavidM

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Posted (edited)
8 minutes ago, DavidM said:

You need to know programming though.

You should probably, you know, learn programming like a good boy and stop telling others to give you copy/paste-able code.

Also, you focus too much on complaining instead of trying to solve your problem, so welcome to my ignore list ;).

my problem is already solved you dumbass! it's you being a selfish dumbass first so i replied. Since you are not being helpful i don't need your future help either, you are also on my ignore list 

Edited by Ice2670
Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Please see https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/ for information on how to post your log correctly.
    • Hello!  The detailed description of how you got to where you are is certainly valuable.  But, at the end of the day (well, any time of the day actually), it is going to be the actual logs that going to provide the necessary details to hopefully solve your startup issue. Part of me wonders if you have installed a client-only mod on a dedicated server.  But I may very well be wrong, and it will be the logs that will tell that story.
    • Hello there! I didn't quite know where to go regarding this, but ended up deciding to post it here. I have been running a forge server with around 200 mods for me and some friends to play on casually, but have recently started to get an issue when booting the server. This all started after I decided to add some new mods to the server. Like usual, I add a mod, test run the server for any issues, and if all is well, I'll add a next one and so on until I have added all that I wanted to. After doing so, in all test runs, it all seemed to work just fine. However, the next day, after trying to boot the server, I kept getting an error regarding java.lang.NullPointerException, towards one of the mods I had recently added. So far so good, I removed the mod that was causing the issue, started up the server again, and here in when things took a turn for the worse. I received another java.lang.NullPointerException null error that wouldn't allow me to boot the server, but this time with a mod that wasn't part of the new ones I had recently added. I found this weird, but nonetheless, I removed it thinking it might be causing some conflicts with some of the new ones. Afterwards, booting the server again proved to be impossible, as it gave me another java.lang.NullPointerException null error with the 3rd mod I had ever installed on the server! This mod was there since the start, it added some biomes and had been just fine so far. This turn of events made me remove all the newer mods I had recently added in hopes to fix this whole ordeal, but alas, to no avail. Same error, with that same biome mod that had been there since day one. Reluctantly, I removed the biome mod, booted the server, and voila! The server was running, although without a major mod that had always been there to begin with. As I do not wish to part ways with this mod, specially since it had been working so far without any issues, I tried to bring everything back to how it was before I added those new mods, but kept on getting the same java.lang.NullPointerException null error for the biome mod. Even adding the newer mods won't cause me this error, with exception of the one that started it all, which I find quite odd since the mods I had been using without any issues are now giving me the same error the newer one that started it all gave me. Now, I have checked that everything is up to date regarding the mods, forge (forge-1.20.1-47.3.12) and java. The modpack runs perfectly fine when I start Minecraft itself, and play singleplayer, or even when I open a LAN world, everything works. Everything aside from the server. From what I could gather, this java.lang.NullPointerException null error would point to a missing value of sorts, for an item perhaps, within the mod that is causing the error, but aside from removing the whole mod, I lack the knowledge on how to fix this. With this in mind, if anyone would be so kind as to shine some light into this situation, with a way to fix all this blunder, I would be most grateful!
    • If you want a mana GUI, call Minecraft.getInstance().setScreen(new ManaScreen()); somewhere display your GUI. I would recommend creating a keybind and listening to key events, and if your key bind is pressed down, running that code.
    • You are creating an entire new screen, or GUI. What you probably want is an Overlay.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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