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);
}
//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);
}
}