Modding/Assets

From Cosmic Reach Wiki
Jump to navigation Jump to search
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

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

Example Mod Filepath01.png

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.

Example Mod Filepath02.png

For example, I'm going to call the example model_myblock.json and input the following:

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.

Example Mod Filepath03.png

If you've followed the steps correctly, you should now have your basic block in the game!

Example Mod Outcome.png

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.

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.

Example Mod Light.png

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.
Example Mod Transparency.png

To fix this, simply go into your block JSON file and create a new key, setting "isTransparent":true and "isOpaque":false

Example Mod Transparency Fixed.png

Generating Slabs

Making slabs for your block is extremely easy! Just add in a new "generateSlabs":true key to your block JSON file!

Example Mod Slabs.png

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.

Example Mod Blockstates.png

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.

Example Mod Blockevent.gif

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

Example Mod Filepath04.png

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.

Once you've finished editing your block event JSON file, go back to your block JSON file and register the block event, like this:


Example Mod Custom Blockevent.gif


Congrats! You've finished your first basic data mod!

Documentation

Full documentation can be found on Modding/Documentation