Block registry.


Creating a registry. 0.4>



In order to register blocks you will have to create a registry. To do this, you must use the following code within the init() function:

                    
//This is the init() inside your main class.
public static void init() {
    //Here we create the registry so we can use it later.
    BlockRegistry.CreateRegistry(MOD_ID);
}
                    
                

Register a block. 0.4>



Registering a block is a bit more complicated. As usual, you'll need to have all the texture files and JSONs already created and placed in their respective locations. To register a block, you'll have to create its properties, its sounds (if needed, otherwise you can copy/use existing sounds in the game), and finally, the block along with its item.
                    
//This is another separate class from the initial one. I recommend you do this for organization.
public class BlocksRegister {
    //Here we create the block.
    public static final RestBlock block = BlockRegistry.CreateBlock(MOD_ID, "BLOCK_ID", blockProperties, TestTabs.tab);

    /*
        Parameters:
            - MOD_ID = Your mod id as string.
            - "BLOCK_ID" = Your block's id as string.
            - blockProperties = The properties. You can use (LINK.CustomBlockProperties) to create block properties.
            - TestTabs.tab = Creative tab/null.
    */

    //You can create a method/function like this to call it from the main class.
    public static void register() {
        //This registers all of your blocks into minecraft.
        BlockRegistry.Register(Testing.MOD_ID);
    }
}
                    
                
                    
//This is another separate class from the initial one. I recommend you do this for organization.
public class BlocksRegister {
    //Here we create the block.
    public static final Object block = BlockRegistry.CreateBlock(MOD_ID, "BLOCK_ID", blockProperties, TestTabs.tab);

    /*
        Parameters:
            - MOD_ID = Your mod id as string.
            - "BLOCK_ID" = Your block's id as string.
            - blockProperties = The properties. You can use (LINK.CustomBlockProperties) to create block properties.
            - TestTabs.tab = Creative tab/null.
    */

    //You can create a method/function like this to call it from the main class.
    public static void register() {
        //This registers all of your blocks into minecraft.
        BlockRegistry.Register(Testing.MOD_ID);
    }
}