-
Notifications
You must be signed in to change notification settings - Fork 160
How to add a new drawer style
This is how to add a new drawer type made from wooden planks provided by some other mod. The drawer type will be added to the StorageDrawers-Misc
drawer pack, which is suitable for mods that only add one or two planks. For mods adding lots of planks, a dedicated pack should be created, but the process is mostly the same. The two main tasks are to declare the new drawer types and their crafting components, and to create the textures and add the names for the new drawer blocks.
Before declaring the new drawer type, you need three pieces of info from the mod providing the planks. These can be found using an NEI item dump and the numeric IDs from NEI's tooltips:
- Internal name of the Forge mod
- Internal name and meta value for the plank item
- Internal name and meta value for the slab item made from those planks. (If the mod does not provide a slab item, you will have to either create the item yourself, or alter or omit the recipe for the half-width "compact" drawers.)
Drawer types are declared as a new meta value of the drawer blocks. The creation of the six different drawer blocks (five drawers and trim) is mostly handled by DataResolver.java
, so all you have to do is inform it of the plank and slab items and add them to its data arrays.
ModRecipes
has two arrays that declare which blocks to look for:
Block[] planks = new Block[] {
GameRegistry.findBlock("ExtrabiomesXL", "planks"),
GameRegistry.findBlock("Highlands", "hl_woodPlanks"),
GameRegistry.findBlock("Thaumcraft", "blockWoodenDevice" ), // 6, 7
GameRegistry.findBlock("witchery", "witchwood"),
GameRegistry.findBlock("ImmersiveEngineering", "treatedWood"),
GameRegistry.findBlock("Botania", "livingwood"),
GameRegistry.findBlock("Botania", "dreamwood")
};
Block[][] slabs = new Block[][] {
new Block[] { GameRegistry.findBlock("ExtrabiomesXL", "woodslab" ), GameRegistry.findBlock("ExtrabiomesXL", "woodslab2" ) },
new Block[] { GameRegistry.findBlock("Highlands", "hl_woodSlab"), null },
new Block[] { GameRegistry.findBlock("Thaumcraft", "blockCosmeticSlabWood" ), null },
new Block[] { GameRegistry.findBlock("witchery", "witchwoodslab"), null },
new Block[] { GameRegistry.findBlock("ImmersiveEngineering", "woodenDecoration"), null }, // 2
new Block[] { GameRegistry.findBlock("Botania", "livingwood1Slab"), null },
new Block[] { GameRegistry.findBlock("Botania", "dreamwood1Slab"), null }
};
The parameters to findBlock
are the Forge mod's internal name and the item's internal name.
Take the internal name of the plank item and add an item to the planks
array of ModRecipes.java
. Do the same for the slab item and the slabs
array. Note that the slabs array is an array of pairs - don't worry about this, just add the slab as a {GameRegistry.findBlock([...]), null}
pair. The plank and slab should be at the same position in these arrays - remember the index, you're about to use it in DataResolver.java
.
(If the mod doesn't provide a slab item, just add new Block[] {null, null}
to slabs
- compact drawers will not be created.)
DataResolver
has four arrays that define the drawer types:
public static String[][] textureBank = new String[][] {
new String[] { "ebxl_redwood", "ebxl_fir", "ebxl_acacia", "ebxl_cypress", "ebxl_japanesemaple", "ebxl_rainboweucalyptus", "ebxl_autumn", "ebxl_baldcypress", "ebxl_sakura" },
new String[] { "hl_yellow", "hl_white", "hl_red", "hl_grey",
"tc_greatwood", "tc_silverwood",
"witchery_rowan", "witchery_alder", "witchery_hawthorn",
"immeng_treated",
"botania_livingwood", "botania_dreamwood" }
};
public static int[][] modBankMap = new int[][] {
new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new int[] { 1, 1, 1, 1, 2, 2, 3, 3, 3, 4, 5, 6 }
};
public static int[][] modMetaMap = new int[][] {
new int [] { 0, 1, 2, 3, 4, 5, 6, 7, 8 },
new int [] { 0, 1, 2, 3, 6, 7, 0, 1, 2, 0, 1, 1 }
};
public static int[][] modSlabMetaMap = new int[][] {
new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 },
new int[] { 0, 1, 2, 3, 0, 1, 0, 1, 2, 2, 0, 0 }
};
The mod declares two "banks" of drawers, which means it adds two sets of drawer types. The first and second elements of these arrays correspond to the banks, so all of the first elements should be the same length as each other, and likewise for the second elements. To add a new drawer style, you only need to add your data to one of these two "banks".
textureBank
is the texture names used by StorageDrawers to refer to this block's name and textures. Create a suitable name and add it to one of the banks. Remember the name, since you'll use it again when creating textures.
modBankMap
is the indexes into the planks
and slabs
array. Add the index you remembered from ModRecipes
to the end of one of the banks - be sure to add it to the same bank (first or second) as you added the texture name to. This adds a new meta value for that drawer bank.
modMetaMap
is the meta values of the plank blocks from the mod that provides them. For example, if you are adding drawers made from awesomeMod:blockAwesomePlanks:2
, then you would add 2
to the array - also make sure you add it to the same bank as the previous two values.
modSlabMetaMap
is the meta values of the slab blocks from that mod. To add compact drawers made from awesomeMod:blockAwesomeWoodSlab:2
, add 2
to the array. Again, make sure you add it to the same bank as before.
That's all for the data values. On to the textures.
StorageDrawers includes a helpful tool for overlaying the standard details (handles, edges, etc) over a wood texture. This tool is in tools/TextureBuilder
and requires Visual C# or mono-dev to build. Building in Visual C# is as simple as opening the project and clicking "Run/Debug".
Before using TextureBuilder, you should prepare your wood panel and trim textures. The wood panel should have similar colors to the original plank texture, but as a single sheet of wood, without any edges between planks. Extract the plank texture from the original mod and play with it until you are satisfied. The trim texture should be a darker version of the plank texture. Doing a "Hue/Saturation/Lightness" adjustment is usually enough once you have the panel texture.
Examples, from Immersive Engineering's Treated Wood:
Original Planks | Wood Panel | Trim |
---|---|---|
Now that you have created your texture, you can use the TextureBuilder app to create the final textures. Remember the texture name you added to textureBank
earlier? You'll need to type it into the text field above "Export". Click "Base" and choose the panel texture, then click "Trim" and choose the trim texture. The app will show you a preview of the new textures. Type the texture name into the text field and click "Export" to generate the textures.
The textures will be exported to the same folder as TextureBuilder.exe
, so you will have to move them to the assets folder, packs\Misc\resources\assets\storagedrawersmisc\textures\blocks
. If you're feeling especially artistic, you can modify the exported textures even further.
The last step is to define the localized (or human-readable) names for the new drawer blocks. If you don't do this, the items in game will have unfriendly names like tile.storagedrawersmisc.blahblah
. Open the file packs/Misc/resources/assets/storagedrawersmisc/lang/en_US.lang
and add a new line for each of the six block types, using the same texture name you used earlier and a fitting human-readable name. For example:
tile.storagedrawersmisc.halfDrawers4.immeng_treated.name=Compact Treated Wood Drawers 2x2
That's it! You're done. All that's left is to build the pack and try it out in Minecraft. gradle build
should rebuild the pack - if this works, you'll find it in packs/Misc/build/libs
, ready to be copied into your mods
folder.