Modding/Assets
Modding | Data Mods | Documentation | Fabric Mods | Quilt Mods |
Asset or Data mods are the preferred way to modify the game, by overwriting behavior through JSON files. New blocks, models, textures, shaders and behaviors can be added in this method.
Basics of a Data Modding
To create a Data Mod, go to your Cosmic Reach data location
- On Linux, this is
/home/username/.local/share/cosmic-reach
- On Windows, this is
%LocalAppData%\cosmic-reach
- On Mac, this is
/Users/username/Library/cosmic-reach
Create a new folder with the name mods
, then inside of the mods folder, create a new folder named assets
.
Then inside of the assets
folder, create the following new directories/folders, blocks
, models
, sounds
, textures
, block_events
, and recipes
. From here on, you'll be able to create new data mods for Cosmic Reach
View Folder Tree |
mods
└── assets ├── block_events ├── blocks ├── models │ └── blocks ├── recipes │ ├── crafting │ └── furnace ├── sounds └── textures └── blocks |
JSON Files
A JSON file is a file with any name that ends in .json
, for example, "block_test.json" is a valid JSON file.
If you are unfamiliar with JSON, it is recommended that you visit these resources:
Creating a Basic Block
Block JSON
To create a new block, go to the blocks
folder you just created and create a new JSON file. You can call it whatever you want, but for this example, we'll call it block_myblock.json
Open the JSON file in a text editor of your choice. Below is an example of how to add a basic block to the game.
Replace "modid" with your username or the name of your mod, and "myblock" with the name of your block.
Block Model JSON
Next, you will need to create a model for our block. Go to your models folder you created earlier and create a new folder inside of it called blocks
Then create a new JSON file, give it the same name you gave it in the modelName
section of your block JSON file.
For example, I'm going to call the example model_myblock.json
and input the following:
View JSON File |
{ "parent": "cube", "textures": { "all": { "fileName": "myblock.png" } } } |
Block Texture
Finally, you need to create a texture. The fileName
key inside of your model JSON file will determine where the game looks for your block texture, so make sure that it is set to the name you are going to give to your texture.
Go to the textures folder you created earlier and make a new folder inside of it called blocks
and then inside of that folder, create a new texture for your block. It must be 16 x 16 pixels.
If you've followed the steps correctly, you should now have your basic block in the game!
Making your block emit light
Making your block glow is as easy as adding a few keys to your block JSON file. The following code will make your block glow yellow.
View JSON File |
{ "stringId": "modid:myblock", "blockStates": { "myblock": { "modelName": "model_myblock", "lightLevelRed": 15, "lightLevelGreen": 15, "lightLevelBlue": 0 } } } |
The accepted keys for this are lightLevelRed
, lightLevelBlue
and lightLevelGreen
.
You will have to use RGB values to get the desired colour you want. How large your values are will determine how far the light reaches.
Making your block transparent
Using an image editor of your choice, if you set the opacity or alpha value of your image to a low number, you can create a transparent effect.
Simply doing so, however, causes a strange effect to occur, where you can see the sky through your blocks.
this is caused because the game doesn't know that the block is transparent, so it treats it like a normal block.
To fix this, simply go into your block JSON file and create a new key, setting "isTransparent":true
and "isOpaque":false
View JSON File |
{ "stringId": "modid:myblock", "blockStates": { "myblock": { "modelName": "model_myblock", "isTransparent": true, "isOpaque": false, "lightLevelRed": 15, "lightLevelGreen": 15, "lightLevelBlue": 0 } } } |
Generating Slabs
Making slabs for your block is extremely easy! Just add in a new "generateSlabs":true
key to your block JSON file!
View JSON File |
{ "stringId": "modid:myblock", "blockStates": { "myblock": { "modelName": "model_myblock", "isTransparent": true, "generateSlabs":true, "isOpaque": false, "lightLevelRed": 15, "lightLevelGreen": 15, "lightLevelBlue": 0 } } } |
Block states
You may have noticed that inside of our block JSON file, there is a key called "blockStates"
Using this key, you can add states to your block. Allowing you to change specific properties and extend the customizability of the block
Here is an example that creates a different state to the block. It includes a new model file and a new texture.
View JSON File |
{ "stringId": "modid:myblock", "blockStates": { "myblock": { "modelName": "model_myblock", "isTransparent": true, "isOpaque": false, "lightLevelRed": 15, "lightLevelGreen": 15, "lightLevelBlue": 0 }, "myblock2": { "modelName": "model_myblock2", "isTransparent": false, "isOpaque": true, "lightLevelRed": 15, "lightLevelGreen": 0, "lightLevelBlue": 0 } } } |
Block Events
Using the key, "blockEventsId"
, we can add block events to the block.
Using pre-existing block events
Inside of the Cosmic Reach JAR file, there is a folder that contains a collection of JSON files, like block_events_c4.json
for example.
You can use this make our block perform the pre-existing block event, block_events_c4.json
, Which will make your block explode.
View JSON File |
{ "stringId": "modid:myblock", "blockStates": { "myblock2": { "modelName": "model_myblock2", "blockEventsId": "base:block_events_c4", "isTransparent": false, "generateSlabs": true, "isOpaque": true, "lightLevelRed": 15, "lightLevelGreen": 0, "lightLevelBlue": 0 }, } } |
Adding custom block events
To create custom block events, go to your assets
folder and create a new folder called block_events
Inside of that folder, create a new JSON file. For the purpose of demonstration, I'm going to call this one block_event_myevent.json
To demonstrate the power of custom block events, this is a block that spreads love and joy across the world.
It also has custom place noises and break noises.
View JSON File |
{ "parent":"base:block_events_default", "stringId":"modid:block_event_myevent", "triggers": { "onInteract": [ { "actionId": "base:replace_block_state", "parameters": { "xOff": 0, "yOff": 1, "zOff": 0, "blockStateId": "self" } }, { "actionId": "base:replace_block_state", "parameters": { "xOff": 1, "yOff": 0, "zOff": 0, "blockStateId": "self" } }, { "actionId": "base:replace_block_state", "parameters": { "xOff": 0, "yOff": 0, "zOff": 1, "blockStateId": "self" } }, { "actionId": "base:replace_block_state", "parameters": { "xOff": 0, "yOff": -1, "zOff": 0, "blockStateId": "self" } }, { "actionId": "base:replace_block_state", "parameters": { "xOff": -1, "yOff": 0, "zOff": 0, "blockStateId": "self" } }, { "actionId": "base:replace_block_state", "parameters": { "xOff": 0, "yOff": 0, "zOff": -1, "blockStateId": "self" } } ], "onBreak": [ { "actionId": "base:replace_block_state", "parameters": { "xOff": 0, "yOff": 0, "zOff": 0, "blockStateId": "base:air[default]" } }, { "actionId": "base:play_sound_2d", "parameters": { "sound": "aww.ogg", "volume": 1, "pitch": 1, "pan": 0 } } ], "onPlace": [ { "actionId": "base:replace_block_state", "parameters": { "xOff": 0, "yOff": 0, "zOff": 0, "blockStateId": "self" } }, { "actionId": "base:play_sound_2d", "parameters": { "sound": "spring.ogg", "volume": 1, "pitch": 1, "pan": 0 } } ] } } |
Once you've finished editing your block event JSON file, go back to your block JSON file and register the block event, like this:
View JSON File |
{ "stringId": "modid:myblock", "blockStates": { "myblock": { "modelName": "model_myblock", "isTransparent": true, "isOpaque": false, "generateSlabs": true, "lightLevelRed": 15, "lightLevelGreen": 15, "lightLevelBlue": 0 }, "myblock2": { "modelName": "model_myblock2", "blockEventsId": "base:block_events_c4", "isTransparent": false, "generateSlabs": true, "isOpaque": true, "lightLevelRed": 15, "lightLevelGreen": 0, "lightLevelBlue": 0 }, "myblock3": { "modelName": "model_myblock3", "blockEventsId": "modid:block_event_myevent", "isTransparent": false, "generateSlabs": true, "isOpaque": true, "lightLevelRed": 0, "lightLevelGreen": 0, "lightLevelBlue": 15 } } } |
Congrats! You've finished your first basic data mod!
Documentation
Full documentation can be found on Modding/Documentation