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



×
×
  • Create New...

Important Information

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