Jump to content

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


Recommended Posts

Posted
  On 3/2/2019 at 1:13 AM, Ice2670 said:

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

Expand  

Yes you do

  • Like 1

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

You 100% need to know basic programming principles, such as counters, classes, abstraction, etc. to be able to do anything higher level than a pretty basic mod. There's a reason that nearly every Modding tutorial recommends learning java first, otherwise you're just going to be copy and pasting code that you don't understand. This can lead to extremely inefficient code and code that just flat out is unnecessary and useless.

Posted (edited)

Yes you do. Writing a computer program in a computer programming language by definition makes you a computer programmer. Modifying another application - making a "mod" - is a pretty advanced thing for a computer programmer to do. Forge, FML etc. take care of 99.9% of this, including the ASM, loading your mod and deobfuscating MC. Therefore what you are making isn't really a "mod" at all, its more of an add-on. There are other "mods" out there that allow you to write your add-on in another computer programming language. For example these "mods" allow you to write your "mod" in Skript, JavaScript, Scala, Kotlin or even whatever Scratch-based language MCreator uses. However, doing this is inherently writing "code" to make a computer do something, which makes you a computer programmer.

In future if you want help on this forum I would recommend being more polite. It may be hard for beginners who haven't done the appropriate pre-requisite background stuff (learning how to write code in the language you've decided to make your mod in, learning the basics of setting up gradle from the command line - or using the command line at all, learning the basics of git etc.), however beginners should have done their research and learned how to do these things.
Learning by example is great, and it's how I've learned 95% of everything programming related, but the key part of it is learning, not just copy pasting code. This is why posting ready-made code snippets is discouraged on these forums.

The question you asked was pretty simple and you got a quick answer. After that, you could have googled what a "counter" is in programming and how to make one that increments. The basic idea of it (in this scenario) is to have a variable (an instance field in this case) that you increment (pre-increment would be perfect for a tiny performance gain in this case) every "tick" (in your onUpdate method in your TileEntity in this case) and, if the value is the desired one, reset the variable and execute your logic that should only happen every several ticks.

Edited by Cadiboo
Fixed spelling mistake
  • Like 3

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)

  • 3 weeks later...
Posted (edited)
  On 3/3/2019 at 12:16 AM, Cadiboo said:

Writing a computer program in a computer programming language by definition makes you a computer programmer. 

Expand  

that is a really BAD definition for professional computer programmer.

 

  On 3/3/2019 at 12:16 AM, Cadiboo said:

The question you asked was pretty simple and you got a quick answer. After that, you could have googled what a "counter" is in programming and how to make one that increments. 

Expand  

i tried google "counter" in programming and it gives me program counter which is NOT what i need. It is an answer that you think is easy to find yet it's not. I need a very simple example just to understand what a counter means, it is definitely NOT a hard thing for you guys to do. Even if you don't, i won't blame you for that cause it is not you obligation to tell me what i asked. But, when someone give me an example which is just enough for me to understand what a counter is, it is your problem to ask him/her to delete that, and in my opinion that behavior is extremely RUDE! So, in that sense you are already in no position to have my respect.

Edited by Ice2670
Posted

Oh for Pete's sake....

in your class you want a variable that will count up with each tick of your desired type.

When this variable reaches n (n being defined by the statement "I want my logic to run every nth tick") run your logic and reset this number to zero.

 

If you cannot construct what you want from this description, I don't know how you expect to be able to make mods.

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

  Reveal hidden contents

 

Posted (edited)
  On 3/20/2019 at 3:09 AM, Ice2670 said:

i tried google "counter" in programming and it gives me program counter which is NOT what i need

Expand  

Google cannot read your mind and serve you with the perfect working code on a silver plate.

Learn from the results on google and construct your own code.

 

The concept of a counter is very straightforward; google should be more than enough to learn from.

 

  On 3/20/2019 at 3:09 AM, Ice2670 said:

my opinion that behavior is extremely RUDE

Expand  

Rudeness is what you get for wanting to copy/paste working code without learning and failing to follow simple instructions.

Edited by DavidM

Some tips:

  Reveal hidden contents

 

Posted
  On 3/3/2019 at 12:16 AM, Cadiboo said:

Writing a computer program in a computer programming language by definition makes you a computer programmer.

Expand  

 

  On 3/20/2019 at 3:09 AM, Ice2670 said:

that is a really BAD definition for professional computer programmer.

Expand  
1

First of all, he didn't even say "professional". Second, if that definition is so bad, what is a better one then?
Also, modding in Minecraft absolutely requires you to know programming, even with the MASSIVE help of forge. After all, you were asking for help with programming in Minecraft modding, weren't you?

Posted (edited)
  On 3/20/2019 at 5:56 AM, DavidM said:

Google cannot read your mind and serve you with the perfect working code on a silver plate.

Learn from the results on google and construct your own code.

 

The concept of a counter is very straightforward; google should be more than enough to learn from.

 

Rudeness is what you get for wanting to copy/paste working code without learning and failing to follow simple instructions.

Expand  

and rudeness is what you get for imposing your idea and way of learning to others. And by the way, i DID NOT copy anyone's working code cause the example is not gonna work for my code if i copy! i actually already get what a counter is before he post the example! it just because you act like an asshole so i replied ok?! I really don't like you kind of people and don't need your help, so please, add me to your ignore least. you mother fucker!

Edited by Ice2670
  • Like 1
Posted
  On 3/20/2019 at 5:56 AM, DavidM said:

 

The concept of a counter is very straightforward; google should be more than enough to learn from.

 

 

Expand  

google is not as good as you thought, and FUCK YOU AGAIN! 

Posted
  On 3/20/2019 at 7:29 AM, SizzleBae said:

 

First of all, he didn't even say "professional". Second, if that definition is so bad, what is a better one then?
Also, modding in Minecraft absolutely requires you to know programming, even with the MASSIVE help of forge. After all, you were asking for help with programming in Minecraft modding, weren't you?

Expand  

it's my problem for missing the word "professional" in my original description. 

Posted (edited)
  On 3/20/2019 at 7:29 AM, SizzleBae said:

 

First of all, he didn't even say "professional". Second, if that definition is so bad, what is a better one then?
Also, modding in Minecraft absolutely requires you to know programming, even with the MASSIVE help of forge. After all, you were asking for help with programming in Minecraft modding, weren't you?

Expand  

the thing is someone thinks that asking for an example is equivalent to wanting copy/paste, which is absolutely WRONG!  

Edited by Ice2670
Posted
  On 3/20/2019 at 3:28 AM, DaemonUmbra said:

Oh for Pete's sake....

in your class you want a variable that will count up with each tick of your desired type.

When this variable reaches n (n being defined by the statement "I want my logic to run every nth tick") run your logic and reset this number to zero.

 

If you cannot construct what you want from this description, I don't know how you expect to be able to make mods.

Expand  

the problem is not about that simple logic, i ask for help because that is the logic i want to achieve. It is rather because I don't know whether the "counter" means a built in method for the update() or is it just a number you create in your class. Even if it is just a number you create, how do i know if java has some "none sense" rules for a counter? You never know how the creater of java thinks! 

Posted (edited)
  On 3/20/2019 at 9:22 AM, Ice2670 said:

google is not as good as you thought

Expand  

In fact, your problem can be solved easily with google.

The first result on google for searching up “counter in java”: https://stackoverflow.com/questions/43900032/how-the-counter-works-very-basic-java

 

You might want to learn to search on google effectively, as searching problems on google comes in handy when programming.

Edited by DavidM

Some tips:

  Reveal hidden contents

 

Posted
  On 3/20/2019 at 9:59 AM, DavidM said:

The first result on google for searching up “counter in java”: https://stackoverflow.com/questions/43900032/how-the-counter-works-very-basic-java

 

You might want to learn to search on google effectively, as searching problems on google comes in handy when programming.

Expand  

you know, in that example, it is not in the update() method of forge, so how do i know that way of making a counter would work the same on update()? what if the update() method has some unknown reason causing that logic to fail? I did not invent the update() method

Posted (edited)
  On 3/20/2019 at 10:09 AM, Ice2670 said:

in that example, it is not in the update() method of forge

Expand  

... I didn't tell you to copy that code; I said you should read the post and understand the concept behind it.

 

  On 3/20/2019 at 10:09 AM, Ice2670 said:

what if the update() method has some unknown reason causing that logic to fail

Expand  

Forge, like all other api, follows the fundamentals of java and programming.

 

  On 3/20/2019 at 9:55 AM, Ice2670 said:

It is rather because I don't know whether the "counter" means a built in method for the update() or is it just a number you create in your class

Expand  

I answered this in my first reply.

Edited by DavidM

Some tips:

  Reveal hidden contents

 

Posted
  On 3/20/2019 at 9:59 AM, DavidM said:

The first result on google for searching up “counter in java”: https://stackoverflow.com/questions/43900032/how-the-counter-works-very-basic-java

 

You might want to learn to search on google effectively, as searching problems on google comes in handy when programming.

Expand  

Most important point for having an example for a problem that you think simple is that I could know whether I get your meaning correctly! Cause you might don't know which part really got me confused and I might get your words incorrectly. A simple example could solve all those confusions.  

Posted (edited)
  On 3/20/2019 at 10:15 AM, DavidM said:

... I didn't tell you to copy that code; I said you should read the post and understand the concept behind it.

 

Forge, like all other api, follows the fundamentals of java and programming.

Expand  

i understand the concept long before i start to ask here, the thing i really don't know is update(), i don't know if it has some "no sense" properties cause i did not write forge codes

Edited by Ice2670
Posted
  On 3/20/2019 at 10:15 AM, DavidM said:

 

I answered this in my first reply.

Expand  

you said "Make a counter", not "Make a instance variable", and as i said, i don't know whether this "counter" refers to a built in method or an instance variable.

Posted
  On 3/20/2019 at 10:15 AM, DavidM said:

... I didn't tell you to copy that code; I said you should read the post and understand the concept behind it.

 

Forge, like all other api, follows the fundamentals of java and programming.

 

I answered this in my first reply.

Expand  

your problem is, you assume others know what you know, but for most of the time it is NOT the case. And also, you view learning through examples as copy/paste, which is even worse than assuming other people's knowledge and background. 

Posted (edited)
  On 3/20/2019 at 10:15 AM, DavidM said:

... I didn't tell you to copy that code; I said you should read the post and understand the concept behind it.

 

Forge, like all other api, follows the fundamentals of java and programming.

 

I answered this in my first reply.

Expand  

you put toooooooooooooooo much attention on avoiding copy/paste, which blinds you from understanding other people. That's why insulting you is the right thing to do 

Edited by Ice2670
Posted (edited)
  On 3/20/2019 at 10:31 AM, Ice2670 said:

you view learning through examples as copy/paste

Expand  

That's straw man.

The "example" was more like:

  On 2/27/2019 at 11:02 AM, diesieben07 said:

You did not post an example. You posted "do this".

Expand  

You are mistaking "example" with "do this".

 

  On 3/20/2019 at 10:31 AM, Ice2670 said:

you assume others know what you know

Expand  

I assumed that you know basic java and programming concepts, as the forum rules stated.

Edited by DavidM
  • Like 1

Some tips:

  Reveal hidden contents

 

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.