Skip to content

Creating a block

Olafcio1 edited this page Sep 18, 2026 · 8 revisions

This guide assumes you've already created and setup an Avoid project.
This guide uses meta-programming. Another way may either not be implemented or you may need to figure it out on your own.


§ Making a block with the Avoid Framework


  1. Create a java class;
    You can pick any location within your project source code directory.

  2. Paste the following code:

    package com.example.avoidtmpl;
    
    import pl.olafcio.avoid.mods.annotation_processor.AutoBlock;
    import pl.olafcio.avoid.mods.annotation_processor.AutoBlockItem;
    import pl.olafcio.avoid.mods.annotation_processor.AutoID;
    import pl.olafcio.avoid.net.block.Block;
    import pl.olafcio.avoid.net.block.properties.*;
    import pl.olafcio.avoid.net.block.values.MapColor;
    import pl.olafcio.avoid.net.block.values.NoteBlockInstrument;
    
    @AutoBlock
    @AutoBlockItem
    @AutoID
    
    @_strength(0.8F)
    @_ignitedByLava
    @_instrument(NoteBlockInstrument.BANJO)
    
    public class AlphaDirtBlock extends Block {
        @Override
        public MapColor getMapColor() {
            return MapColor.COLOR_BLACK;
        }
    }

    Of course you need to replace the class name and package.

  3. Customize it as you wish;
    I would say the API is quite easy once it clicks, as all block properties are done with these little underscore (_)-prefixed annotations.
    You can change the block's map color, tick methods (and maybe more at the time you're reading this) in the class contents itself [by overriding inherited Block methods].

  4. Add assets;
    In your project src/main/resources, create the folder assets/{yourModID}.
    In that folder, create the following structure:

    ↳ blockstates
     ↳ {yourBlockID}.json
    ↳ models
     ↳ block
      ↳ {yourBlockID}.json
    ↳ textures
     ↳ block
      ↳ {yourBlockID}.png

    (Replace {yourModID} with your mod ID, e.g. testmod.
     Replace {yourBlockID} with your block name ID-ified, e.g. black_button.)

    Now:

    • in the blockstates/{yourBlockID}.json file, paste the following content:

      {
        "variants": {
          "": {
            "model": "{yourModID}:block/{yourBlockID}"
          }
        }
      }

      There are ways to change block models based on their properties.
      However, I don't think Avoid supports them - wouldn't recommend trying for now.


    • in the models/block/{yourBlockID}.json file, paste the following content:

      {
        "parent": "minecraft:block/cube_all",
        "textures": {
          "texture": "{yourModID}:block/{yourBlockID}"
        }
      }

      There are ways to customize this, e.g. to make a button.
      Take a look at Minecraft's assets (inside the Minecraft JAR) - they can be a good reference.


    • as the textures/block/{yourBlockID}.json file, paste your block texture.

  5. Add item assets;
    If you want your block to have an item auto-generated, you're almost there.
    Here's what it requires:


Avoid Framework


    🏚️ 1. Home
    📽️ 2. Creating your mod
    🌄 3. Adding assets to your mod
    🧊 4. Creating a block
    💧 5. Creating a fluid
    ✏️ 6. Creating an item
    🎯 7. Creating an entity selector
    🤖 8. Creating a command
    ⌨️ 9. Creating a keybind
    🐺 10. Creating an entity
    🌫️ 11. Creating a fog
    🔩 12. Creating an item component
    🔮 13. Creating an effect
    📚 14. Language support & adding libraries

Clone this wiki locally