BlockCategories Tutorial

This tutorial teaches you how to add a block to one of the categories of blocks displayed in the G-menu on the left hand side and also explains how to add your own such category to the game. The relevant reference page for this tutorial is https://semref.atlassian.net/wiki/spaces/reference/pages/28999700.


I. Adding to an existing BlockCategory

Navigate to your game’s installation directory and into the Data-subfolder. There you will find the file named BlockCategories.sbc. Copy it into your mod’s Data-folder.

Open the file in Visual Studio Code. Within the element CategoryClasses you’ll see individual Category-entries defined. Search for the category you want to add your block(s) to either by looking at their Name or the individual block entries. Once you’ve found the Category you want, delete all other categories from the file.

Blocks are generally added to at least one vanilla category, which is the LargeBlocks or SmallBlocks category, depending on the block’s grid size.

Next, you remove all existing blocks under ItemIds from the category and replace them with entries for your own blocks. An entry consists of a block’s TypeId and SubtypeId, separated by a / slash.

Note that these entries are additive, which means that you will not have to include all entries in the vanilla BlockCategory if you’d like to add your own.

For this example, I’m going to use my conveyor mod. As you can see below, I added the relevant blocks both to the Large Blocks and the Conveyor-categories. If my blocks were also available for small grid, I would be adding them to that category here too.

<?xml version="1.0"  encoding="utf-8"?> <Definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">   <CategoryClasses>     <Category xsi:type="MyObjectBuilder_GuiBlockCategoryDefinition">       <Id>         <TypeId>GuiBlockCategoryDefinition</TypeId>         <SubtypeId/>       </Id>       <DisplayName>DisplayName_Category_LargeBlocks</DisplayName>       <Name>LargeBlocks</Name>       <ItemIds>         <string>Conveyor/AQD_LG_ConveyorJunctionTubes</string>         <string>Conveyor/AQD_LG_ConveyorX</string>         <string>ConveyorConnector/AQD_LG_ConveyorStraight5x1</string>         <string>ConveyorConnector/AQD_LG_ConveyorStraightArmored</string>         <string>ConveyorConnector/AQD_LG_ConveyorCornerArmored</string>         <string>Conveyor/AQD_LG_ConveyorTArmored</string>         <string>Conveyor/AQD_LG_ConveyorXArmored</string>         <string>CargoContainer/AQD_LG_ConveyorAccess</string>         <string>CargoContainer/AQD_LG_ConveyorVent</string>       </ItemIds>     </Category>     <Category xsi:type="MyObjectBuilder_GuiBlockCategoryDefinition">       <Id>         <TypeId>GuiBlockCategoryDefinition</TypeId>         <SubtypeId/>       </Id>       <DisplayName>DisplayName_Category_ConveyorBlocks</DisplayName>       <Name>Conveyors</Name>       <ItemIds>         <string>Conveyor/AQD_LG_ConveyorJunctionTubes</string>         <string>Conveyor/AQD_LG_ConveyorX</string>         <string>ConveyorConnector/AQD_LG_ConveyorStraight5x1</string>         <string>ConveyorConnector/AQD_LG_ConveyorStraightArmored</string>         <string>ConveyorConnector/AQD_LG_ConveyorCornerArmored</string>         <string>Conveyor/AQD_LG_ConveyorTArmored</string>         <string>Conveyor/AQD_LG_ConveyorXArmored</string>         <string>CargoContainer/AQD_LG_ConveyorAccess</string>       </ItemIds>     </Category>   </CategoryClasses> </Definitions>

Start up the game and add your mod to a savegame. Then load it and check your G-menu and the category you altered. The block(s) should now show up:


II. Creating a new BlockCategory

In some cases, you might want to create your own category instead of extending an existing one. To do that, navigate to your game’s installation directory and into the Data-subfolder. There you will find the file named BlockCategories.sbc. Copy it into your mod’s Data-folder.


Troubleshooting

My block does not show up in the category I added it to

My weapon / tool cannot be placed as such onto the hotbar

 

Learnings

 

Prerequisites

 

Overview

 

Related