Jump to content

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


Recommended Posts

Posted
11 hours ago, Ice2670 said:

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

Yes you do

  • Like 1

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

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

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)

  • 3 weeks later...
Posted (edited)
On 3/2/2019 at 7:16 PM, Cadiboo said:

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

that is a really BAD definition for professional computer programmer.

 

On 3/2/2019 at 7:16 PM, 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. 

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.

Spoiler

Logs (Most issues require logs to diagnose):

Spoiler

Please post logs using one of the following sites (Thank you Lumber Wizard for the list):

https://gist.github.com/100MB Requires member (Free)

https://pastebin.com/: 512KB as guest, 10MB as Pro ($$$)

https://hastebin.com/: 400KB

Do NOT use sites like Mediafire, Dropbox, OneDrive, Google Drive, or a site that has a countdown before offering downloads.

 

What to provide:

...for Crashes and Runtime issues:

Minecraft 1.14.4 and newer:

Post debug.log

Older versions:

Please update...

 

...for Installer Issues:

Post your installer log, found in the same place you ran the installer

This log will be called either installer.log or named the same as the installer but with .log on the end

Note for Windows users:

Windows hides file extensions by default so the installer may appear without the .jar extension then when the .log is added the log will appear with the .jar extension

 

Where to get it:

Mojang Launcher: When using the Mojang launcher debug.log is found in .minecraft\logs.

 

Curse/Overwolf: If you are using the Curse Launcher, their configurations break Forge's log settings, fortunately there is an easier workaround than I originally thought, this works even with Curse's installation of the Minecraft launcher as long as it is not launched THROUGH Twitch:

Spoiler
  1. Make sure you have the correct version of Forge installed (some packs are heavily dependent on one specific build of Forge)
  2. Make a launcher profile targeting this version of Forge.
  3. Set the launcher profile's GameDir property to the pack's instance folder (not the instances folder, the folder that has the pack's name on it).
  4. Now launch the pack through that profile and follow the "Mojang Launcher" instructions above.

Video:

Spoiler

 

 

 

or alternately, 

 

Fallback ("No logs are generated"):

If you don't see logs generated in the usual place, provide the launcher_log.txt from .minecraft

 

Server Not Starting:

Spoiler

If your server does not start or a command window appears and immediately goes away, run the jar manually and provide the output.

 

Reporting Illegal/Inappropriate Adfocus Ads:

Spoiler

Get a screenshot of the URL bar or copy/paste the whole URL into a thread on the General Discussion board with a description of the Ad.

Lex will need the Ad ID contained in that URL to report it to Adfocus' support team.

 

Posting your mod as a GitHub Repo:

Spoiler

When you have an issue with your mod the most helpful thing you can do when asking for help is to provide your code to those helping you. The most convenient way to do this is via GitHub or another source control hub.

When setting up a GitHub Repo it might seem easy to just upload everything, however this method has the potential for mistakes that could lead to trouble later on, it is recommended to use a Git client or to get comfortable with the Git command line. The following instructions will use the Git Command Line and as such they assume you already have it installed and that you have created a repository.

 

  1. Open a command prompt (CMD, Powershell, Terminal, etc).
  2. Navigate to the folder you extracted Forge’s MDK to (the one that had all the licenses in).
  3. Run the following commands:
    1. git init
    2. git remote add origin [Your Repository's URL]
      • In the case of GitHub it should look like: https://GitHub.com/[Your Username]/[Repo Name].git
    3. git fetch
    4. git checkout --track origin/master
    5. git stage *
    6. git commit -m "[Your commit message]"
    7. git push
  4. Navigate to GitHub and you should now see most of the files.
    • note that it is intentional that some are not synced with GitHub and this is done with the (hidden) .gitignore file that Forge’s MDK has provided (hence the strictness on which folder git init is run from)
  5. Now you can share your GitHub link with those who you are asking for help.

[Workaround line, please ignore]

 

Posted (edited)
3 hours ago, Ice2670 said:

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

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.

 

3 hours ago, Ice2670 said:

my opinion that behavior is extremely RUDE

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:

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
On 3/3/2019 at 1:16 AM, Cadiboo said:

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

 

4 hours ago, Ice2670 said:

that is a really BAD definition for professional computer programmer.

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)
3 hours ago, 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.

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
3 hours ago, DavidM said:

 

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

 

 

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

Posted
On 2/27/2019 at 5:44 AM, diesieben07 said:

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

Saying that means you are a dumbass too!

Posted
2 hours ago, 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?

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

Posted (edited)
2 hours ago, 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?

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

Edited by Ice2670
Posted
6 hours ago, 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.

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)
38 minutes ago, Ice2670 said:

google is not as good as you thought

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:

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 minute ago, 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.

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)
7 minutes ago, Ice2670 said:

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

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

 

7 minutes ago, Ice2670 said:

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

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

 

21 minutes ago, 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

I answered this in my first reply.

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
10 minutes ago, 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.

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)
8 minutes ago, 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 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
9 minutes ago, DavidM said:

 

I answered this in my first reply.

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
13 minutes ago, 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.

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)
20 minutes ago, 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.

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)
30 minutes ago, Ice2670 said:

you view learning through examples as copy/paste

That's straw man.

The "example" was more like:

On 2/27/2019 at 7:02 PM, diesieben07 said:

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

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

 

30 minutes ago, Ice2670 said:

you assume others know what you know

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

Edited by DavidM
  • Like 1

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.

 

 

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.