Skip to content

Creating lux pack

Zeith edited this page Sep 26, 2021 · 6 revisions

To get started, in /.minecraft/luxpacks/ create a folder for your future lux pack. Let it be PACK

Step 1

In PACK, create a new file pack.json, and put the following code inside it:

{
	"api": 2,
	"name": "Awesome Lux Pack!",
	"authors": [ "CoolDude" ],
	"description": "Awesome pack!",
	"dependencies": [ "forge@[14.23.5.2847,)", "minecraft" ]
}

Fill out what you need. The api property describes the API this pack was made for. This wiki shows the latest API version in action. (API v2)

Step 2

The next step is optional, but adds 100% coolness to your pack: the icon! in your PACK, put icon.png, an image with 1:1 ratio, 128x128 in size.

Step 3 (optional)

After that, create blocks.json and entities.json (both are optional, you may create just one of them) in PACK's folder. Both jsons follow the deprecated standarts, that can be found here: blocks / entities.

Step 4 (optional) [since v2]

Alternatively, if the block you want to add support for is a Tile Entity, you might need to approach this a bit differently. For that, in PACK's folder, create main.js, and create a main function. (You have to know basic JavaScript code to proceed)

Inside the main function, you'll be adding support for Tile Entities from mods.

A good example of this is ProjectRed lamps. (we'll be using them for this example)

First off, point on the block that has a tile entity, and run /lux picktile. You will get the tile type, and some information about it is going to be dumped to the console.

Then, using the tile type (path to tile class), inside the main function add a new call: addTileScript("mrtjp.projectred.illumination.TileLamp", "scripts/lamp.js");

Where the first string is a tile type, and the second one is the full path (within the PACK to the script that is going to handle this tile entity)

After that, create the respective js file specified by the second parameter. In our example, the file must be located at PACK/scripts/lamp.js.

The script must contain function light(world, pos, tile, rawTile), the third and fourth parameter is the instance of tile entity that is going to be handled. The difference between tile and rawTile is usually non-existent, but some tiles like Minecraft's may have obfuscation, which is solved by wrapping a tile and creating identically-named fields for easy access. If you see "WRAP FOR USE IN JS" in the tile entity export, then you are going to deal with the wrapper on the third argument. If you do not care about the wrapper, use the fourth one.

To create a new light source, call Light.builder().pos(pos).color(0xFFFFFF, false).radius(15).build(). The chain may be modified as you wish, but must contain pos, color, and radius calls to the builder.

To add light source, call add(<Light>)

All other logic within the light function is up to you! You should be able to do pretty much any checks for any variable inside the tile entity (all fields and methods can be looked up in the dump done by running /lux pickstate)

Step 5

After you're done with setting up lights, it's time to share your work! To do that, simply select all files within PACK's folder, and ZIP them. The resulting zip should contain all files in its root. If that's true, then you can put that zip file in your /.minecraft/luxpacks/ and enable in-game!

Small note: you can also enable the pack as a folder, there is no need to zip if you want to test. Also, if you want to see changes appear without having to re-enable the lux pack, simply run /lux reload in chat. All lux packs are going to reload.