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:

  Reveal hidden contents

 

Posted
  On 2/27/2019 at 1:19 AM, DavidM said:

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

Expand  

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:

  Reveal hidden contents

 

Posted
  On 2/27/2019 at 3:27 AM, 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?

Expand  

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)
  On 2/27/2019 at 7:12 AM, TheMCJavaFre4k said:

Integer

Expand  

probably an int, not an Integer

  On 2/27/2019 at 7:12 AM, TheMCJavaFre4k said:

1(int++)

Expand  

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

Edited by Cadiboo

About Me

  Reveal hidden contents

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 7:38 AM, 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
  }
}

 

Expand  

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:

  Reveal hidden contents

 

Posted (edited)
  On 2/27/2019 at 8: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.

Expand  

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

Edited by Krevik
Posted (edited)
  On 2/27/2019 at 10:35 AM, Krevik said:

He asked for example.

Expand  

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:

  Reveal hidden contents

 

Posted
  On 2/27/2019 at 1:39 PM, 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.

Expand  

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

  Reveal hidden contents

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 8: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.

Expand  

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 10:35 AM, Krevik said:

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

Expand  

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

Posted
  On 2/27/2019 at 1:39 PM, 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.

Expand  

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)
  On 3/1/2019 at 10:50 PM, Ice2670 said:

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

Expand  

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:

  Reveal hidden contents

 

Posted
  On 3/1/2019 at 11:34 PM, 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.

Expand  

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

Posted
  On 3/1/2019 at 11:34 PM, 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.

 

 

Expand  

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
  On 3/1/2019 at 11:34 PM, 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.

 

 

Expand  

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)
  On 3/2/2019 at 1:13 AM, Ice2670 said:

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

Expand  

You need to know programming though.

Edited by DavidM

Some tips:

  Reveal hidden contents

 

Posted (edited)
  On 3/2/2019 at 1:26 AM, 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 ;).

Expand  

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.