Skip to content

Modifying Materials

Sometimes you don't want to create new materials. You just want to modify some properties of an existing material. Similar to creating materials you use an event. But for modifying materials you use the PostMaterialEvent.

groovy
mods.gregtech.lateMaterialEvent {
    // modify materials here
}

See the Retrieving Existing Materials section for information on retrieving existing materials.

The material registry can do more than just get materials.

Setting basic properties

Formula

groovy
setFormula(String formula)
setFormula(String formula, boolean withFormatting)

Sets the internal formula and thus tooltip of this Material.

  • formula - the string to set the formula to
  • withFormatting - whether to apply number formatting (subscripts, etc) to the formula and tooltip (Default: false)

Flags

groovy
addFlags(String... names)

Adds additional flags to this Material.

  • names - a string array of flags to add

Color

groovy
setMaterialRGB(int materialRGB)

Sets the color of this Material.

  • materialRGB - the int color to set. Accepts the raw int value or values in the 0x format.

Icon set

groovy
setIconSet(String iconSet)

Sets the icon set of this Material.

Example

groovy
import gregtech.api.GregTechAPI.PostMaterialEvent

event_manager.listen { PostMaterialEvent event ->
    def gold = material('gold')
    def name = gold.toString() // "gold"
    def color = gold.getMaterialRGB() // 0xFFE650
    gold.setFormula("(Au)2Au", true) // set formula
    def formula = gold.getChemicalFormula() // "(Au)2Au"
    gold.addFlags("generate_long_rod", "generate_gear") // add gold long rod, add gold gear
}
groovy

Fluid, Gas, Plasma

groovy
addLiquid()
addLiquid(FluidBuilder)
addGas()
addGas(FluidBuilder)
addPlasma()
addPlasma(FluidBuilder)

Adds a liquid, gas or plasma to a material. Check out fluid builder for the fluid builder parameter. You can use the fluidBuilder() method in late material event too.

Deprecation

Do not use the addFluid(String) and addFluid(String, boolean) methods. They are deprecated and might get removed in a future update.

Other methods:

groovy
// getter
isGaseous() // boolean // returns true if the material has a gas

Dust

groovy
addDust()
addDust(int harvestLevel)
addDust(int harvestLevel, int burnTime)

Adds or modifies a DustProperty to this Material, which generates a Dust, Small Dust, and Tiny Dust. Is automatically applied by IngotProperty and GemProperty.

  • harvestLevel - The Harvest Level of the Material's block when mining it. If the Material also has a ToolProperty, this value will also be used to determine the tool's Mining Level.
  • burnTime - The Burn Time (in ticks) of this Material as a Furnace Fuel. If not specified, the material * cannot* be used as a furnace fuel.

Other methods:

groovy
// setter
setHarvestLevel(int harvestLevel)
setBurnTime(int burnTime)
// getter
harvestLevel() // int
burnTime() // int

Ingot

groovy
addIngot()

Adds an IngotProperty to this Material, which generates an Ingot. It automatically adds a DustProperty. This is INCOMPATIBLE with GemProperty.

To modify harvest level or burn time, you should look into adding/modifying dust property.

Gem

groovy
addGem()

Adds a GemProperty to this Material, which generates all types of GregTech Gems. It automatically adds a DustProperty. This is INCOMPATIBLE with IngotProperty.

To modify harvest level or burn time, you should look into adding/modifying dust property.

Ore

groovy
addOre()
addOre(boolean emissive)
addOre(int oreMultiplier, int byproductMultiplier)
addOre(int oreMultiplier, int byproductMultiplier, boolean emissive)

Adds Ore Blocks, Crushed, Crushed Purified, Crushed Centrifuged, Impure Dust, and Purified Dust for this Material.

  • oreMultiplier - Crushed Ore output amount multiplier for Ore -> Crushed Ore Maceration. Default: 1 (no multiplier).
  • byproductMultiplier - Byproduct output amount multiplier for Crushed Ore processing of any kind. Default: 1 (no multiplier).
  • emissive - Should ore block use emissive texturing (see below image). Default: false.

Wood

groovy
addWood()

Adds wood property to the material.

Polymer

There is currently no helper to add the polymer property.

Blast

groovy
addBlastProperty(int temp)
addBlastProperty(int temp, String gasTier)
addBlastProperty(int temp, String gasTier, int eutOverride)
addBlastProperty(int temp, String gasTier, int eutOverride, int durationOverride)
addBlastProperty(int temp, String gasTier, int eutOverride, int durationOverride, int vacuumEUtOverride, int vacuumDurationOverride)

Sets or modifies the Blast Furnace Temperature of this Material. If below 1000 Kelvin, Primitive Blast Furnace recipes will be also added. If above 1750 Kelvin, a Hot Ingot and its appropriate Vacuum Freezer recipe will be also added. If a Material with this Property has a Fluid, its temperature will be set to this if it is currently using the default Fluid temperature.

  • temp - Blast Furnace Temperature in Kelvin required to heat up the material. Just like in real life, this value * cannot* be less than 0.
  • gasTier - The tier of gas used to smelt in the Electric Blast Furnace. Available options are: "LOW", "MID", "HIGH", "HIGHER", "HIGHEST.
  • eutOverride - Sets the EU/t of autogenerated Electric Blast Furnace recipes to the specified value.
  • durationOverride - Sets the base duration in ticks of autogenerated Electric Blast Furnace recipes to the specified value.
  • vacuumEUtOverride - Sets the EU/t of autogenerated Vacuum Freezer recipes to the specified value.
  • vacuumDurationOverride - Sets the base duration in ticks of autogenerated Vacuum Freezer recipes to the specified value.

Other methods:

groovy
// setter
setBlastTemp(int blastTemp)
// getter
blastTemp() // int

Tools

groovy
addTools(float harvestSpeed, float attackDamage, float attackSpeed, int durability)
addTools(float harvestSpeed, float attackDamage, float attackSpeed, int durability, int harvestLevel)
addTools(float harvestSpeed, float attackDamage, float attackSpeed, int durability, int harvestLevel, int enchantability)
addTools(float harvestSpeed, float attackDamage, float attackSpeed, int durability, int harvestLevel, int enchantability, int durabilityMultiplier)
addTools(ToolProperty toolProperty)
addTools(ToolProperty.Builder toolPropertyBuilder)

Set or modifies the stats for tools which are made from this Material.

See Tool Builder on how to use the tool builder. The toolBuilder() method is also available in the late material event.

Other methods:

groovy
// sets / modifies properties
setToolStats(float speed, float attackDamage, int durability)
setToolStats(float speed, float attackDamage, int durability, boolean shouldIgnoreCraftingTools)
setToolStats(float speed, float attackDamage, int durability, int enchantability)
setToolStats(float speed, float attackDamage, int durability, int enchantability, int harvestLevel)
setToolStats(float speed, float attackDamage, int durability, int enchantability, boolean shouldIgnoreCraftingTools)
setToolStats(float speed, float attackDamage, int durability, int enchantability, int harvestLevel, boolean shouldIgnoreCraftingTools)
addToolEnchantment(Enchantment enchantment, int level)
addScaledToolEnchantment(Enchantment enchantment, int level, double levelGrowth)
// returns properties
toolSpeed() // float
attackDamage() // float
toolDurability() // int
toolHarvestLevel() // int
toolEnchantability() // int

Item Pipe

groovy
addItemPipes(int priority, float stacksPerSec)

Adds or modifies item pipes of this Material. Requires IngotProperty to be set.

  • priority - Sets the priority for the pipe. Items will take the path with the lowest priority. This value is used for the Normal Pipe. The Small Pipe has this value multiplied by 1.5, and the Large Pipe has this value multiplied by 0.75.
  • stacksPerSec - Sets the maximum transfer rate in stacks of 64 items per second. This value is used for the Normal Pipe. Small Pipes have this value multiplied by 0.5. Large Pipes have this value multiplied by 2.

Fluid Pipe

groovy
fluidPipeProperties(int maxTemp, int throughput, boolean gasProof)
fluidPipeProperties(int maxTemp, int throughput, boolean gasProof, boolean acidProof, boolean cryoProof, boolean plasmaProof)

Adds or modifies Fluid Pipes of this Material. Requires IngotProperty to be set.

  • maxTemp - Sets the maximum allowed fluid temperature in the pipe. Pipes burn/vanish when fluid is too hot.
  • throughput - Sets the maximum flowrate through the pipes. This value multiplied by 20 is the maximum rate for the Tiny Pipe. Each subsequent pipe is further multiplied by 2 over the previous.
  • gasProof - If true, the pipe is able to transfer fluids with the Gas state. Else, they will vaporize.
  • acidProof - If true, the pipe is able to transfer fluids with the Acidic attribute. Else, they will destroy the pipe.
  • cryoProof - If true, the pipe is able to transfer fluids with a temperature below 120. Else, they will vaporize.
  • plasmaProof - If true, the pipe is able to transfer fluids with the Plasma state, regardless of the fluid pipe's maximum temperature. Else, they will destroy the pipe.

Wires & Cables

groovy
addCables(long voltage, int amperage, int loss)
addCables(long voltage, int amperage, int loss, boolean isSuperCon)
addCables(long voltage, int amperage, int loss, boolean isSuperCon, int criticalTemperature)

Adds or modifies cables and wires of this Material. Requires IngotProperty to be set. addWires is an alternative method name. It does the same thing.

  • voltage - The voltage amount a 1x wire/cable can transfer.
  • amperage - The amperage amount a 1x wire/cable can handle.
  • loss - The loss per block a 1x wire will have. Cables have this value divided by 2, but will never be lossless unless set to 0.
  • isSuperCon - Whether this is a superconductor. This will prevent cables from generating, and have a loss of 0.
  • criticalTemperature - The temperature of the superconductive phase transition. Cable needs to be a super conductor. (Effect unclear)

Contributors

Changelog

© 2024 CleanroomMC. All Rights Reserved.