Jump to content

Run Code the First Time the Mod is Run


ComputerCraze

Recommended Posts

I am trying to make a simple mod where there is fifty "dummy blocks" that you can assign textures to through a texture pack, perfect for a mapmaking scenario. However, I need the json files to be created when the mod is first run. I don't want to write all of the files manually (cut down on file size) so I want to create all of them by code, probably during the preInit cycle, before the actual blocks are initiated. Is there a way to run a specific section of code only when it is the first time running the mod?

 

Thanks in advance,

ComputerCraze

Link to comment
Share on other sites

Sure: save a boolean value to your Config file. When you read the config, check if that value is false - if it is, generate the files, set the value to true, and save your config.

 

Next time, the value will be read in as true and the files will not generate; in the future, you can always edit your config file and change the value back to false to re-generate the JSON files.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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