-
-
Notifications
You must be signed in to change notification settings - Fork 1
Block Picker
CaliberMC edited this page Jan 14, 2024
·
5 revisions
Buildify uses Minecraft's BlockFamilies to easily create the Block Picker lists for each block type. For an example of how to implement your own BlockFamilies, check out the Caliber-Mod repository to see how we did it there. This is going to be the easier option for Mods with a large number of blocks that need to be added. If you only have a few blocks to add or would like to add blocks from any other mods for your own use, or use in a mod pack check out the Data Pack option below.
To integrate Block Picker into your mod follow these easy steps!
- Add the following line to your repositories section in your build.gradle file:
repositories {
maven {
url = "https://api.modrinth.com/maven"
}
}
- Add the following line to your dependencies section in your build.gradle file:
dependencies {
implementation fg.deobf("maven.modrinth:buildify:0.1.3-1.18.2")
}
- Create a class for working with the Buildify API.
package com.calibermc.caliber.util.compat;
import com.calibermc.buildify.util.BlockPickerStatesJson;
import com.calibermc.caliber.data.ModBlockFamilies;
import com.calibermc.caliber.data.ModBlockFamily;
import java.util.ArrayList;
public class BuildifyBlockPicker {
public static void init() {
for (ModBlockFamily modBlockFamily : ModBlockFamilies.getAllFamilies().toList()) {
BlockPickerStatesJson.registerBlockFamily(modBlockFamily.getBaseBlock(), () ->
new ArrayList<>(modBlockFamily.getVariants().entrySet().stream()
.filter(p -> !p.getKey().equals(ModBlockFamily.Variant.WALL_SIGN))
.map(p -> p.getValue().asItem().getDefaultInstance()).toList()));
}
}
}
Follow these simple steps to create a data pack for use with the Buildify Block Picker.
- Create a new folder for your data pack.
- Create your new file called pack.mcmeta.
- Edit pack.mcmeta to match the following format. You may change the description to whatever you'd like it to be.
{
"pack": {
"description": "example datapack",
"pack_format": 8
}
}
- Create another folder labeled 'data' inside of your main folder.
- Create another folder inside of 'data' labeled 'example datapack' to match whatever you put in your description.
- Create another folder inside of 'example datapack' labeled 'blockpicker' !DO NOT CHANGE THIS FOLDER NAME!
- Create your custom Block Picker JSON files in the following format (the name of the file is not important, but I recommend labeling it the same name as your main block ie. tnt.json):
{
"main_block": "minecraft:tnt",
"blocks": [
"minecraft:apple",
"minecraft:stick",
"minecraft:carrot"
]
}
- Zip the entire folder structure you have created and label it the same name as your datapack folder.
- Place the zip file in your datapacks folder.