Content mentioned in this page is outdated
FileGenerator is a class for mass generating model files, specifically Platform Screen Doors and Automatic Platform Gates for the Minecraft Transit Railway Mod.
This file is located under
common/src/main/java/FileGenerator.java, and is no longer used after the migration to be rendered with tile entity
Before MTR is migrated to Architectury, it uses Fabric Rendering API to render the APG & PSD.
This however does not work well with Sodium and requires the Indium mod to be installed.
To fix the compatibility issues, these blocks has to be converted to regular Minecraft blockstates.
With the opening state split to 32 parts, we're looking at over 100 files, this could take an enormous amount of time to do each state manually.
As such, a class is made to automatically convert the file name and shift the model.
As of MTR 3.1.0-unofficial-5, PSD/APG are now rendered dynamically with Tile Entity.
While this file still exists in the source code, it should no longer be used for generating PSD/APG block model for newer versions of MTR.
Note: This version is slightly modified from the original class, of the fact that it's no longer hard coded to
How this works
This is a command line program, and you will need Java 17 to run it.
Let's take a look at the following example:
java -jar FileGenerator.java "top_left_%i" "33"
java -jar FileGenerator.java is telling java to run FileGenerator.jar, nothing special.
"top_left_%i" is referring to the exported file name, and
%i represents the integer it's looping through.
The end result is bunch of files named:
And so on.
"33" is referring to the number of states it exports. (So 0-32, as 0 itself is also a state)
Note: You must name your file
input.json on the same directory, so the program can find it.
Where the magic happens
After executing the above command, a
generated folder will appear on where you run the jar, these are your outputed files.
But it only exports the files named accordingly, how does this shift the model?
It also replaces the content inside the file with a placeholder.
With a basic understanding of json and Minecraft's model, we can find the coordinates of each model.
To make it automatically shift from 0 to 16 pixels, we need to replace the Z axis with:
This simply means the incrementation would be 0.5.
top_left_0.json would be 0
top_left_1.json would be 0.5
top_left_2.json would be 1, and so on...
But what if it doesn't start with 0?
You can also increment a base number, for example:
%0.5+16% would make the code start at 16.0, then 16.5, 17.0, 17.5 and so on...
The increment can also be negative. For the door to open the other side, you can switch from