Skip to content

Commit

Permalink
Add support for smithing table recipes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkhax committed Jul 21, 2020
1 parent 999212c commit c49f5ad
Showing 1 changed file with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.blamejared.crafttweaker.impl.managers;

import org.openzen.zencode.java.ZenCodeGlobals;
import org.openzen.zencode.java.ZenCodeType;

import com.blamejared.crafttweaker.CraftTweaker;
import com.blamejared.crafttweaker.api.CraftTweakerAPI;
import com.blamejared.crafttweaker.api.annotations.ZenRegister;
import com.blamejared.crafttweaker.api.item.IIngredient;
import com.blamejared.crafttweaker.api.item.IItemStack;
import com.blamejared.crafttweaker.api.managers.IRecipeManager;
import com.blamejared.crafttweaker.impl.actions.recipes.ActionAddRecipe;
import com.blamejared.crafttweaker_annotations.annotations.Document;

import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.item.crafting.SmithingRecipe;
import net.minecraft.util.ResourceLocation;

/**
* @docParam this smithing
*/
@ZenRegister
@ZenCodeType.Name("crafttweaker.api.SmithingManager")
@Document("vanilla/api/managers/SmithingManager")
public class CTSmithingManager implements IRecipeManager {

@ZenCodeGlobals.Global("smithing")
public static final CTSmithingManager INSTANCE = new CTSmithingManager();

/**
* Adds a recipe to the smithing table.
*
* @param recipeName Name of the recipe.
* @param result The item created by the recipe.
* @param base The initial ingredient for the recipe.
* @param addition The item added to the base item.
*
* @docParam recipeName "recipe_name"
* @docParam result <item:minecraft:golden_apple>
* @docParam base <item:minecraft:apple>
* @docParam addition <tag:forge:ingots/gold>
*/
@ZenCodeType.Method
public void addRecipe(String recipeName, IItemStack result, IIngredient base, IIngredient addition) {
recipeName = validateRecipeName(recipeName);
final SmithingRecipe smithing = new SmithingRecipe(new ResourceLocation(CraftTweaker.MODID, recipeName), base.asVanillaIngredient(), addition.asVanillaIngredient(), result.getInternal());
CraftTweakerAPI.apply(new ActionAddRecipe(this, smithing, ""));
}

@Override
public IRecipeType<?> getRecipeType() {
return IRecipeType.SMITHING;
}
}

0 comments on commit c49f5ad

Please sign in to comment.