Chessboard
A step-by-step tutorial on how to use INJ to create Minecraft function which will generate a chessboard. This is the most detailed tutorial.
Note: From a beginner's perspective, I will include detailed explanations in the form of collapsible text throughout this tutorial. If you prefer not to see these detailed explanations, feel free to skip them.
There is an example datapack for this tutorial provided. You can download it here.
Install INJ
If you haven't installed INJ yet, you can install it by following the instructions on: installation.
Create a New Datapack
Here I create a new folder: saves > (world name) > datapacks > chessboard
. This step is the same as when you are creating a vanilla datapack. So, create a pack.mcmeta
file inside chessboard
folder. The content of pack.mcmeta
is the same as when you are creating a vanilla datapack. We will do nothing on pack.mcmeta
.
Create Src Folder
In vanilla datapacks, there should be a data
folder, where all the functions, tags, and other files are stored. However, here, we will create a folder with a name other than data
, because we will later use INJ to compile INJ code and generate a data
folder. The structure of the src
folder is the same as how the data
folder should be in vanilla datapacks. In this tutorial, we will only create a functions
folder inside it because we don't need other parts like tags
, advancements
, loot
, etc. You can also create othere folders if you want. Now we've got file structure like this:
Create a gen.inj
File
We will later write INJ code in this file. Now we've got file structure like this:
Write INJ Code
Use any source code editor you like. Open gen.inj
file and write the following INJ code:
Compile INJ Code
In the chessboard
folder, open a terminal and run the following command to compile INJ code:
After running the command, you will see a data
folder was created in the chessboard
folder.
Your file structure should look like this:
There are generated codes in the data
folder. Now it's time to see the effect in Minecraft.
Open the World and Test
Open the world where you've created the datapack. Run the command function chess:gen
. You will see a 10x10 chessboard is generated instantly.