Skip to content

Block Picker

CaliberMC edited this page Jan 14, 2024 · 5 revisions

Block Picker Mod Compat

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!

  1. Add the following line to your repositories section in your build.gradle file:
repositories {
    maven {
        url = "https://api.modrinth.com/maven"
    }
}
  1. 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")
}
  1. 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()));
        }
    }
}

Block Picker Data Pack

Follow these simple steps to create a data pack for use with the Buildify Block Picker.

  1. Create a new folder for your data pack.
  2. Create your new file called pack.mcmeta.
  3. 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
    }
}
  1. Create another folder labeled 'data' inside of your main folder.
  2. Create another folder inside of 'data' labeled 'example datapack' to match whatever you put in your description.
  3. Create another folder inside of 'example datapack' labeled 'blockpicker' !DO NOT CHANGE THIS FOLDER NAME!
  4. 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"
  ]
}
  1. Zip the entire folder structure you have created and label it the same name as your datapack folder.
  2. Place the zip file in your datapacks folder.
Clone this wiki locally