Sherd Checklist

This is the checklist I use when I want to add a new sherd. Sherds are items that can be used to create decorated pots. Each sherd adds a different pattern to the side of the pot, allowing for some unique combinations and creations.

Checklist


  1. Create the Item
  2. Register the Decorated Pot Pattern
  3. Create the Decorated Pot Pattern Texture
  4. Link the Pattern to the Item
  5. Create the Recipe Tag

Create the Item


The pottery sherd item just uses the base Item class in Minecraft. All sherds are placed under Ingredients in the Creative Tab Menu, so you can also add it there for consistency. Other than that, you can follow the Item Checklist for details on how to add the new item.

The steps that follow are what will allow you to use the item to create decorated pots.

Register the Decorated Pot Pattern


We need to register the pattern itself and to do this, we need a new registry. A simple registry for decorated pot patterns may look like the following.

/**
 * Registers pottery patterns.
 */
public class DecoratedPotPatternsRegistry {

    // An instance of a deferred registry we use to register items.
    private final DeferredRegister<String> deferredRegister;

    // The butterfly pot pattern.
    private RegistryObject<String> butterflyPotPattern;

    /**
     * Construction
     * @param modEventBus The event bus to register with.
     */
    public DecoratedPotPatternsRegistry(IEventBus modEventBus) {
        this.deferredRegister = DeferredRegister.create(Registries.DECORATED_POT_PATTERNS, ButterfliesMod.MOD_ID);
        this.deferredRegister.register(modEventBus);
    }

    /**
     * Register the items.
     */
    public void initialise() {
        butterflyPotPattern = deferredRegister.register("butterfly_pottery_pattern", () -> "butterfly_pottery_pattern");
    }

    /**
     * Accessor for butterfly pot pattern.
     * @return The butterfly pot pattern.
     */
    public RegistryObject<String> getButterflyPotPattern() {
        return butterflyPotPattern;
    }
}

Note that this DeferredRegister uses a registry from the Registries class rather than ForgeRegistries as in other classes.

Create the Decorated Pot Pattern Texture


Patterns will need a texture, which you can add in the following location:

\resources\assets\<MOD_ID>\textures\entity\decorated_pot\<PATTERN_ID>.png

Link the Pattern to the Item


This only registers the pattern, however. We also need to link this pattern to the item we created. We need to set this up in response to an FMLCommonSetupEvent:

    /**
     * Common setup event.
     * @param event The event class.
     */
    private void commonSetup(FMLCommonSetupEvent event) {

        // Butterfly Sherd Pattern.
        Map<Item, ResourceKey<String>> itemToPotTextureMap = Maps.newHashMap(DecoratedPotPatterns.ITEM_TO_POT_TEXTURE);
        itemToPotTextureMap.put(itemRegistry.getButterflyPotterySherd().get(),
                                decoratedPotPatternsRegistry.getButterflyPotPattern().getKey());
        DecoratedPotPatterns.ITEM_TO_POT_TEXTURE = itemToPotTextureMap;
    }

Create an Access Modifier

There is one problem here, however. ITEM_TO_POT_TEXTURE is marked private and final. We need to use an access transformer to change its access level. To start, we add, or uncomment, a line from build.gradle.

    // This property enables access transformers for use in development.
    // They will be applied to the Minecraft artifact.
    // The access transformer file can be anywhere in the project.
    // However, it must be at "META-INF/accesstransformer.cfg" in the final mod jar to be loaded by Forge.
    // This default location is a best practice to automatically put the file in the right place in the final jar.
    // See https://docs.minecraftforge.net/en/latest/advanced/accesstransformers/ for more information.
    accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')

Now we need to add our accesstransformer.cfg file, and add a line to allow us access to this property.

public-f net.minecraft.world.level.block.entity.DecoratedPotPatterns f_271367_ # ITEM_TO_POT_TEXTURE

The strange numbers preceded by f_ are known as SRG names, and are needed so the mod knows where in the compiled code these methods will be. To get them in IntelliJ, you can right-click on the property you want to modify and choose Get SRG Name. This will show you the SRG name, and you can use it in this config file. They may need to be updated for different versions of your mod.

Create the Recipe Tag


The item is now linked to the new pattern, but it cannot be used in crafting recipes. We need to add it to Minecraft’s pottery sherds tags, so we have to create a new file, \resources\data\minecraft\tags\items\decorated_pot_sherds.json:

{
  "values": [
    "butterflies:butterfly_pottery_sherd"
  ]
}