Su5eD / GregTech-Experimental

A fully-featured port of GregTech 3 for modern minecraft versions
GNU Lesser General Public License v3.0
21 stars 8 forks source link

CraftTweaker Support #42

Closed Su5eD closed 2 years ago

Su5eD commented 2 years ago

The Issue

The current recipe system relies on copying recipe config files from the mod jar to the config directory, so that they can be modified by users. Dynamic recipes, which are generated depending on present mods, are also saved and modifiable.
However, this approach introduces severe migration issues:

  1. Adding/removing mods will not regenerate dynamic recipes
  2. Removing mods may invalidate some existing dynamic recipes, resulting in a crash
  3. Updated base GTE recipes are not copied to the config dir, and end up being ignored These problems may appear very frustrating to users and make the pack making experience less friendly.

The Solution

We remove the current file copy system as well as caching dynamic recipes. Instead, base recipes will be loaded from the mod jar and dynamic recipes will always be generated at runtime. Rather than modifying the files directly, pack makers will be able to tweak GTE's recipes via CraftTweaker.
Modders can keep using the programmatic interface which can be aquired by calling IGregTechAPI#getRecipeFactory for recipes and IGregTechAPI#getFuelFactory for fuels respectively.

CraftTweaker support documentation

Recipes

Each recipe support class contains methods for adding and removing recipes, including variants with optional parameters. A lot of parameter types are resused so I'll briefly explain the common ones to avoid duplicate docs:

Removing recipes

I mean, you can only remove things once they're registered, right?

While adding recipes doesn't require any additional configuration, removing them needs to be handled separately.
It's very important you use the gregtechmod loader for removing recipes. This loader only loads the script after GTE finished registering all of its recipes in post-init. You can apply it to your script by using the loader preprocessor:

#loader gregtechmod

Invididual machine Zen methods

### Alloy Smelter #### Zen Class `mods.gregtechmod.AlloySmelter` #### Methods ```java void addRecipe(IIngredient[] inputs, IItemStack output, int duration, @Optional double energyCost, @Optional boolean universal) ``` ```java void removeRecipe(IItemStack[] inputs) ``` ### Assembler #### Zen Class `mods.gregtechmod.Assembler` #### Methods ```java void addRecipe(IIngredient[] inputs, IItemStack output, int duration, @Optional double energyCost) ``` ```java void removeRecipe(IItemStack[] inputs) ``` ### Bending Machine #### Zen Class `mods.gregtechmod.Bender` #### Methods ```java void addRecipe(IIngredient input, IItemStack output, int duration, double energyCost) ``` ```java void removeRecipe(IItemStack input) ``` ### Automatic Canning Machine #### Zen Class `mods.gregtechmod.Canner` #### Methods ```java void addRecipe(IIngredient[] inputs, IItemStack[] outputs, int duration, double energyCost) ``` ```java void removeRecipe(IItemStack[] inputs) ``` ### Chemical Reactor #### Zen Class `mods.gregtechmod.ChemicalReactor` #### Methods ```java void addRecipe(IIngredient[] inputs, IItemStack outputs, int duration) ``` ```java void removeRecipe(IItemStack[] inputs) ``` ### Distillation Tower #### Zen Class `mods.gregtechmod.DistillationTower` #### Methods Parameter `int cells`: The amount of cells required for processing the recipe. ```java void addRecipe(IIngredient input, IItemStack[] outputs, int cells, int duration) ``` ```java void removeRecipe(ILiquidStack input) ``` ```java void removeRecipe(ILiquidStack input, int cells) ``` ```java void removeRecipe(IItemStack input) ``` ```java void removeRecipe(IItemStack input, int cells) ``` ### Fusion Reactor #### Zen Class `mods.gregtechmod.FusionReactor` #### Methods Parameter `double startEnergy`: The amount of EU required to start the reactor. Subsequent processing of the same recipe does not require it. ```java void addRecipe(IIngredient[] inputs, ILiquidStack output, int duration, double energyCost, double startEnergy) ``` ```java void addRecipe(IIngredient[] inputs, IItemStack output, int duration, double energyCost, double startEnergy) ``` ```java void removeRecipe(ILiquidStack[] inputs) ``` ```java void removeRecipe(ILiquidStack[] inputs) ``` ### Implosion Compressor #### Zen Class `mods.gregtechmod.ImplosionCompressor` #### Methods Parameter `int tnt`: The amount of Industrial TNT required to process the recipe. ```java void addRecipe(IIngredient input, int tnt, IItemStack[] outputs) ``` ```java void removeRecipe(IItemStack input, int tnt) ``` ### Industrial Blast Furnace #### Zen Class `mods.gregtechmod.IndustrialBlastFurnace` #### Methods Parameter `int heat`: The required amount of Blast Furnace heat capacity to process the recipe. ```java void addRecipe(IIngredient[] inputs, IItemStack[] outputs, int duration, int heat, @Optional boolean universal) ``` ```java void addRecipe(IIngredient[] inputs, IItemStack[] outputs, int duration, double energyCost, int heat, @Optional boolean universal) ``` ```java void removeRecipe(IItemStack[] inputs) ``` ### Industrial Centrifuge #### Zen Class `mods.gregtechmod.IndustrialCentrifuge` #### Methods Parameter `int cells`: The amount of cells required to process the recipe. ```java void addRecipe(IIngredient input, IItemStack[] outputs, int cells, int duration, @Optional CTCellType cellType) ``` ```java void removeRecipe(ILiquidStack input) ``` ```java void removeRecipe(ILiquidStack input, int cells) ``` ```java void removeRecipe(IItemStack input) ``` ```java void removeRecipe(IItemStack input, int cells) ``` ### Industrial Electrolyzer #### Zen Class `mods.gregtechmod.IndustrialElectrolyzer` #### Methods Parameter `int cells`: The amount of cells required to process the recipe. ```java void addRecipe(IIngredient input, IItemStack[] outputs, int cells, int duration, @Optional(valueDouble = 128) double energyCost) ``` ```java void removeRecipe(ILiquidStack input) ``` ```java void removeRecipe(ILiquidStack input, int cells) ``` ```java void removeRecipe(IItemStack input) ``` ```java void removeRecipe(IItemStack input, int cells) ``` ### Industrial Grinder #### Zen Class `mods.gregtechmod.IndustrialGrinder` #### Methods ```java void addRecipe(IIngredient input, ILiquidStack fluid, IItemStack[] output) ``` ```java void removeRecipe(IItemStack input, ILiquidStack fluid) ``` ### Industrial Sawmill #### Zen Class `mods.gregtechmod.IndustrialSawmill` #### Methods Parameter `int water`: Buckets of water required to process the recipe. ```java void addRecipe(IIngredient input, IItemStack[] outputs, @Optional int water, @Optional boolean universal) ``` ```java void removeRecipe(IItemStack input, ILiquidStack fluid) ``` ### Lathe #### Zen Class `mods.gregtechmod.Lathe` #### Methods ```java void addRecipe(IIngredient input, IItemStack[] outputs, int duration, @Optional(valueDouble = RecipeLathe.DEFAULT_ENERGY_COST) double energyCost) ``` ```java void removeRecipe(IItemStack input) ``` ### Printer #### Zen Class `mods.gregtechmod.Printer` #### Methods ```java void addRecipe(IIngredient[] inputs, IItemStack output, int duration, @Optional double energyCost) ``` ```java void addRecipe(IIngredient[] inputs, @Nullable IIngredient copy, IItemStack output, int duration, @Optional double energyCost) ``` ```java void removeRecipe(IItemStack[] inputs) ``` ### Vacuum Freezer #### Zen Class `mods.gregtechmod.VacuumFreezer` #### Methods ```java void addRecipe(IIngredient input, IItemStack output, int duration, double energyCost) ``` ```java void removeRecipe(IItemStack input) ``` ### Wiremill #### Zen Class `mods.gregtechmod.Wiremill` #### Methods ```java void addRecipe(IIngredient input, IItemStack output, int duration, double energyCost) ``` ```java void removeRecipe(IItemStack input) ```

Fuels

Same rules apply as for adding/removing recipes.

Methods

Parameters:

void addFuel(IIngredient input, double energy, @Optional IItemStack output)
void removeFuel(ILiquidStack fluid)
void removeFuel(IItemStack stack)

Invididual fuel Zen class identifiers and usages

### Dense Liquid `mods.gregtechmod.fuel.DenseLiquid` Used in the Semifluid generator. ### Diesel `mods.gregtechmod.fuel.Diesel` Used in the Diesel generator. ### Gas `mods.gregtechmod.fuel.Gas` Used in Gas turbines. ### Magic `mods.gregtechmod.fuel.Magic` Used in the Magic Energy Converter. ### Plasma `mods.gregtechmod.fuel.Plasma` Used in the Plasma Generator. ### Steam `mods.gregtechmod.fuel.Steam` Used in the Large Steam Turbine, as well as the Steam Engine upgrade.

OreDict

mods.gregtechmod.OreDict

Utility methods for modifying the OreDictHandler, which is used to generate dynamic recipes.

Invididual oredict Zen methods

### Ore Aliases Alias an oredict entry name. ```java void addOreAlias(String ore, String alias) ``` ```java removeOreAlias(String ore) ``` ### Valuable Ores Modify values in IC2's `OreValues` class, which are then used in the Miner and ore Scanner. ```java void addValuableOre(String ore, int value) ``` ```java void removeValuableOre(String ore) ``` ### Ignored names Exclude an oredict entry from `OreDictHandler`. ```java void addIgnoredName(String ore) ``` ```java void removeIgnoredName(String ore) ```

Zen Utilities

Fluid Cell Bracket Handler

GTE adds a custom bracket handler that returns a fluid cell IItemStack for the current IC2 profile. You can use it by calling <fluid_cell:fluid_name>, where fluid_name is the name of the desired fluid.

Custom damage setter

Items that implement ICustomDamageItem (electric items, reactor coolant cells etc.) have a separate way of handling item damage and traditional methods such as setItemDamage don't have any effect on them. Instead, you need to call interface specific methods. For this purpose, GTE extends IItemStack with 2 new functions:

  1. IItemStack anyCustomDamage(IItemStack stack): Sets the stack's custom damage to the wildcard value
  2. IItemStack withCustomDamage(IItemStack stack, int damage): Sets the stack's custom damage to the specified value

Examples!

Because we love examples.

You can find examples for most ZS methods here.