Voxel Eras Modding Tutorial - How to make a simple item
voxel_eras, mod, tutorial ·This tutorial assumes you already set up your mod. If you didn’t, look at this tutorial here.
Creating a new file
Making an item in Voxel Eras is even easier than making a block. We are going to start by creating a new file items.rhai
inside the scripts
folder and add the define
function :
fn define(mod_info) {
// Mod content here!
}
Don’t forget to call the script in your entrypoint entry.rhai
:
fn setup(mod_info) {
import "mod_folder_name/scripts/path/to/block_name" as block_name;
import "mod_folder_name/scripts/path/to/items" as items;
block_name::define(mod_info);
items::define(mod_info);
}
NOTE : This isn’t actually mandatory. You can just register your items in the setup
function of the entrypoint directly or wherever you want (as long as the place where you define your item is called in setup
). It’s just for good coding practices to only group elements that share common stuff. Look at the base mods to see what I mean.
Adding an ItemBuilder
Like for many elements in Voxel Eras Modding API, you register them by making a builder, this time an ItemBuilder
:
fn define(mod_info) {
mod_info.add(
ItemBuilder(
"ItemName:ModName",
"Item Name",
"Description",
"IconId:ModName"
)
);
}
And that’s it, your item is now registered.
Additional Stuff
ItemBuilder
also has a bunch of other functions to call to be able to add a bit more functionality, three (3) to be exact :
pipette
-> set the item builder’s pipette given a construct identifier (example:ItemBuilder(...).pipette("BlockName:ModName")
).stacking_to
-> set the maximum stack size for this item (example:ItemBuilder(...).stacking_to(32)
).with_burn
-> makes the item be useable as fuel (example:ItemBuilder(...).with_burn(1800)
).
fn define(mod_info) {
mod_info.add(
ItemBuilder(
"ItemName:ModName",
"Item Name",
"Description",
"IconId:ModName"
)
.pipette("Stone:VoxelEras")
.stacking_to(32)
.with_burn(1800)
);
}
In this example, the item will select the stone construct when pipette, can only stack to 32 items and will burn for 1800 ticks if used as fuel.
Conclusion
Now that you now that you can add new items to the game, you can add custom recipes to be able to craft them or used them as ingredients for said recipes or constructs (COMING SOON).