Custom ores that glow in the dark? How about some new decorative blocks? Or maybe you just enjoy torturing your players with excessive numbers of intermediate crafting steps?
Adding new blocks and items to the game with ContentTweaker.
ContentTweaker docs can be found
here.
ContentTweaker is a member of the CraftTweaker 'mod family' and reads the Zenscript (.zs) files located in .minecraft/scripts/[filename/folder].
ContentTweaker can read nested folders/files, so it'll be worthwhile keeping everything organised- such as separate folders for blocks, items, and recipes.
You can also have multiple
blocks/
items defined in a single file- its useful to keep like items/blocks together.
In addition ContentTweaker also makes use of the resources folder for localization (display names) and textures;
.minecraft/resources/contentweaker/(blockstates, lang, models, sounds, textures)
Remember you'll need to restart the game for any changes to take effect.
Adding new blocks
Blocks are added using Zenscript (.zs) files, which go into the .minecraft/scripts folder.
Always start your script with #loader contenttweaker, and import the ContentTweaker functions;
Code:
#loader contenttweaker
import mods.contenttweaker.VanillaFactory;
import mods.contenttweaker.Block;
Remember scripts for adding blocks/items can't be used for adding/changing recipes.
Defining the new block:
Code:
var BlockName = VanillaFactory.createBlock("internalname", <blockmaterial:rock>);
BlockName is just a name (named variable) that the script uses to assign the block's properties. The list of block materials can be
found here.
"internalname" is the internal name (string) that the game uses to identify the block. ContentTweaker also uses this as the default for defining the block's textures.
All blocks/items added by ContentTweaker can be referenced by contenttweaker:internalname when using CraftTweaker scripts.
Both BlockName and internalname must be unique values, and internalname must be in lowercase. (Capitalisation being a good method to differentiate the two).
blockmaterial is the material type (rock/dirt ect) the block is made of.
Defining the block's properties:
The blocks hardness (mining speed), blast resistance, tool type ect are all define under 'properties'.
Note some properties are required, while others are optional.
Code:
#loader contenttweaker
import mods.contenttweaker.VanillaFactory;
import mods.contenttweaker.Block;
var Dolomite = VanillaFactory.createBlock("dolomite", <blockmaterial:rock>);
Dolomite.setBlockHardness(4.0);
Dolomite.setBlockResistance(15.0);
Dolomite.setToolClass("pickaxe");
Dolomite.setToolLevel(2);
Dolomite.setBlockSoundType(<soundtype:stone>);
Dolomite.setSlipperiness(0.6);
Dolomite.register();
The last line for each block will always be to register that block. You can
define multiple blocks in a single script if you want. (
useful for similar block- such as ore varients, or different designs of chiselled stone)
ToolLevel is the mining level. Vanilla default is 0-3, but you can use any integer- so setting it to 7 will only allow level 7 (or higher!) tools to successfully mine the block.
Slipperiness has some ...interesting side effects. 0.6 is normal for most blocks, other values are worth experimenting with.
Adding the textures
Everything texture related goes in .minecraft/resources/contenttweaker
Texture related scripts use the .JSON (NOT the Zenscript).
So you've got the block defined. Time to boot up the game and see what happens right?
Well it looks pretty hideous as it doesn't have a texture yet, but if everything worked ok ContentTweaker should of automagically created some scripts to help us out;
First go to .minecraft/resources/contentweaker/blockstates
You'll find a list of .JSON files for every block, named after their internal names. This defines where the textures images are found.
Code:
{
"forge_marker": 1,
"defaults": {
"textures": {
"texture": "contenttweaker:blocks/dolomite",
"particle": "contenttweaker:blocks/dolomite"
},
"model": "base:storage",
"uvlock": true,
"transform": "forge:default-block"
},
"variants": {
"normal": [{}],
"inventory": [{}]
}
}
By default textures are given the blocks internal name, and go into .minecraft/resources/contenttweaker/textures/blocks/internalname
Changing the filepath defined in the blockstate .JSON will allow you to use a different texture name, and/or sort textures into sub-folders.
By default a block is given the same texture on each side. If you want
different sided textures you can do this. Make sure you texture files (.PNG) match the file path defined in the .JSON
Giving it a name
Finally giving the block a proper display name. Go to .minecraft/resources/contenttweaker/lang.
Open up the en_us.lang file and add the following;
Code:
tile.contenttweaker.dolomite.name=Dolomite
All the blocks and items are named in this .lang file- so it'll be wise to keep them in
alphabetical order (by internal name) otherwise you'll end up with a mess.
Adding new items
Items are added using Zenscript (.zs) files, which go into the .minecraft/scripts folder.
Adding a new item is similar to adding a new block; items are defined like so:
Remember scripts for adding blocks/items can't be used for adding/changing recipes.
Code:
#loader contenttweaker
import mods.contenttweaker.VanillaFactory;
import mods.contenttweaker.Item;
import mods.contenttweaker.IItemRightClick;
import mods.contenttweaker.Commands;
var CoilLV = VanillaFactory.createItem("coillv");
CoilLV.register();
The last line for each item will always be to register that item, but since you dont have to define any properties most items simply require two lines. You can define
multiple items in a script like this.
Giving items a texture.
Everything texture related goes in .minecraft/resources/contenttweaker
Texture related scripts use the .JSON (NOT the Zenscript).
Like with blocks, ContentTweaker will automatically generate the texture scripts when you load the game;
Go to .minecraft/resources/contenttweaker/models/items and you'll find a list of .JSON files for every item, named after their internal names. This .JSON defines where the textures images are found.
Code:
{
"parent": "item/generated",
"textures": {
"layer0": "contenttweaker:items/coillv"
}
}
As with blocks, the texture path defaults to the item's internal name, and you can change this to anything you like.
Your texture files (.PNG images) go into .minecraft/resources/contenttweaker/textures/items.
Naming your item
Finally giving the item a proper display name. Go to .minecraft/resources/contenttweaker/lang.
Open up the en_us.lang file and add the following;
Code:
item.contenttweaker.coillv.name=Low Voltage Coil
All the blocks and items are defined in this .lang file- so it'll be wise to keep them in
alphabetical order (by internal name) otherwise you'll end up with a mess.
Adding new blocks/items with the Gregtech Material Builder.
The Gregtech material builder is a CraftTweaker tool designed to automatically create sets of blocks, items, and tools with recipes included in the mix. If you're playing/building a pack with Gregtech then this tool will be very useful.
Requires
Gregtech: Community Edition
Material Builder docs can be
found here.
Scripts for the material builder go .minecraft/scripts, and use the Zenscript (.zs) format.
All Material Builder scripts start with #loader gregtech (so the script loads first), and calling up the Gregtech packages.
Remember scripts for adding blocks/items can't be used for adding/changing recipes.
Code:
#loader gregtech
import mods.gregtech.material.MaterialRegistry;
import mods.gregtech.recipe.RecipeMap;
Each Gregtech material is assigned a numerical ID (from 000-999); much like the old block-IDs from early Minecraft versions this is limited one ID per material, and 000-500 are reserved for stock Gregtech Materials.
This ID is used to generate the internal names for the items added by the material builder.
Adding a new material
First thing to do is define the material- like so
Code:
val ingotTest= MaterialRegistry.createIngotMaterial(602, "test", 0xFF4C00, "dull", 4, null, 3.5, 128, 1800);
- val ingotTest is the name (string) assigned to this material, you'll use it in your script to specify additional properties/items/blocks
- MaterialRegistry.createIngotMaterial tells Gregtech what material type this is (dust, ingot, gemstone, or fluid). This will automatically generate a few items depending on whats selected. (an ingotMaterial will have an ingot [Duh!], dust, small dust, tiny dust, and liquid form generated by default).
- 602 is the material ID. This is unique to this material. Used for generating items.
- "test" is the internal name. This is unique to this material. Used for generating ore dictionary tags and the internal names of blocks.
- 0xFF4C00 is the base colour of the material, as a 6 figure RGB hexadecimal number.
- "dull" is the iconset used. (decided what the item textures looks like)
- 4 is the mining level (of this material's ores/blocks/tools)
- null is for an optional array of materials. (See adding a chemical formula).
- 3.5 is the mining speed of the tools
- 128 is tool durability. Set to 0 to skip generating tools.
- 1800 optional value for blast furnace temperature. Less then 1000 is smeltable in the primitative blast furnace. Greater than 1700 generates a 'hot ingot' and a vacuum freezer recipe.
Naming the material
Materials need be given a display name in a .lang file, otherwise you'll end up with something horrible like
material.test Ingot appearing as the ingot item name.
Go to .minecraft/resources/gregtech/lang and create a file called en_us.lang
Materials can be named like this;
This'll automatically names all of the generated components from that material type.
Adding more components/blocks/recipes ect...
You can specify additional items/blocks/recipes (such as plates, gears, ores) to be generated out of each material type- this is called adding 'flags'.
Code:
ingotTest.addFlags("GENERATE_PLATE", "GENERATE_ROD", "GENERATE_ORE");
Some of these generate a single item (plate and rod) while others (ore) generate a number (ore blocks for most stone types, crushed, washed, pure/impure dusts ect) and all the processing recipes to match.
The docs have a full list of flags
Creating Wires and Fluid Pipes.
The material can also be made into functional wires (
for Gtech Eu) and fluid pipes;
Code:
ingotTest.setCableProperties(512, 1, 1);
Cable properties are Max Voltage (Eu), Max Current (Amps), Energy Loss (Eu/Amp/Block)
(Max current is for a single core cable; multicore cables take 2x/4x/8x/16x this value).
(Energy loss is for insulated cables; uninsulated wires automatically have a 2x/3x loss).
Code:
ingotTest.setFluidPipeProperties(2000, 5000, true);
Pipe properties are Throughput (mB/t), Max Temperature (
°K), Gas Proof (true/false)
(Throughput is for a tiny pipe. Small/Medium/Large pipes have 2x/4x/8x this throughput).
Adding Enchantments.
If you add an enchantment to a material, any tool/weapon crafted from this material will have them automatically applied;
Code:
ingotTest.addToolEnchantment(<enchantment:minecraft:smite> * 4);
ingotTest.addToolEnchantment(<enchantment:minecraft:fortune> * 3);
So tools/weapons made out of
test will always have Smite IV and Fortune III.
Adding Chemical Formula
Gregtech can generate a chemical formula for a given material, and display it as a tooltip under the material item name. This is made with an array of existing material types in material generator;
This will also generate an electrolzyer recipe to produce the component materials from your new one.
(
If you do NOT want a chemical formula, leave this array as null).
Code:
val ingotsignalum = MaterialRegistry.createIngotMaterial(612, "signalum", 0xF6872E, "shiny", 1, [<material:copper>*3, <material:silver>*1, <material:redstone>*9], 3.5, 0, 4500);
Any previously added material can be used- including your own; however keep in mind;
- You cannot add new elements to the builder. (you'll have to make your own Gtech add-on mod if you want them)
- You can nest as many chemical formulae as you wish. (I tried to find the upper limit and got the tooltip to cover half the screen!)
- If a component material lacks a chemical formula/element, the new chemical formula tooltip will have a blank space in it (electrolyzer recipes will still work as normal).
- Electrolyzer recipes default to 120Eu/t, unless Tungsten is a component material- then its defaults to a higher value.
Modifying an existing material
Need to add components to an existing material?
(note- you can only add features to an existing material, you can't remove stock features)
Code:
var copper = <material:copper>;
copper.addFlags(["GENERATE_RING"]);
var titanium = <material:titanium>;
titanium.addFlags(["GENERATE_ORE"]);
So this generates Copper rings, and a full set of ores for Titanium. (
and have every hardcore Gregtech player baying for my blood)
You can rename an existing material too; go the the lang file in .minecraft/resources/gregtech/lang and add;
Code:
material.titanium=Fancy Purple Metal
Which will rename all the Titanium components to 'Fancy Purple Metal'
(
This example isn't something you'll see in the pack)
Hints and tips
For the
ingotMaterial tools; the tool heads are crafted out of plates and rods. You'll need to generate these items too.