Skip to content

Commit

Permalink
Merge pull request #115 from 3TUSK/master
Browse files Browse the repository at this point in the history
Add basic support for TerraFirmaCraft
  • Loading branch information
Yulife committed Apr 19, 2015
2 parents f7c0dea + 504f150 commit c757841
Show file tree
Hide file tree
Showing 10 changed files with 484 additions and 0 deletions.
Binary file added libs/[1.7.10]TerraFirmaCraft-deobf-0.79.17.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions src/main/java/modtweaker2/ModTweaker2.java
Expand Up @@ -16,6 +16,7 @@
import modtweaker2.mods.pneumaticcraft.PneumaticCraft;
import modtweaker2.mods.railcraft.Railcraft;
import modtweaker2.mods.tconstruct.TConstruct;
import modtweaker2.mods.tfcraft.TerraFirmaCraft;
import modtweaker2.mods.thaumcraft.Thaumcraft;
import modtweaker2.mods.thermalexpansion.ThermalExpansion;
import modtweaker2.utils.TweakerPlugin;
Expand Down Expand Up @@ -63,6 +64,7 @@ public void init(FMLInitializationEvent event) {
TweakerPlugin.register("Railcraft", Railcraft.class);
TweakerPlugin.register("Steamcraft", Steamcraft.class);
TweakerPlugin.register("TConstruct", TConstruct.class);
TweakerPlugin.register("terrafirmacraft", TerraFirmaCraft.class);
TweakerPlugin.register("Thaumcraft", Thaumcraft.class);
TweakerPlugin.register("ThermalExpansion", ThermalExpansion.class);
TweakerPlugin.register("Forestry", Forestry.class);
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/modtweaker2/mods/tfcraft/TFCHelper.java
@@ -0,0 +1,27 @@
package modtweaker2.mods.tfcraft;

import java.util.List;

import net.minecraft.item.ItemStack;

import com.bioxx.tfc.api.Crafting.AnvilManager;
import com.bioxx.tfc.api.Crafting.AnvilRecipe;
import com.bioxx.tfc.api.Crafting.BarrelManager;
import com.bioxx.tfc.api.Crafting.BarrelRecipe;
import com.bioxx.tfc.api.Crafting.KilnCraftingManager;
import com.bioxx.tfc.api.Crafting.KilnRecipe;
import com.bioxx.tfc.api.Crafting.QuernManager;
import com.bioxx.tfc.api.Crafting.QuernRecipe;

public class TFCHelper {

private TFCHelper(){}

public static List<AnvilRecipe> anvilRecipes = AnvilManager.getInstance().getRecipeList();
public static List<AnvilRecipe> anvilWeldRecipes = AnvilManager.getInstance().getWeldRecipeList();
public static List<BarrelRecipe> barrelRecipes = BarrelManager.getInstance().getRecipes();
public static List<KilnRecipe> kilnRecipes = KilnCraftingManager.getInstance().getRecipeList();
public static List<QuernRecipe> quernRecipes = QuernManager.getInstance().getRecipes();
public static List<ItemStack> quernVaildItems = QuernManager.getInstance().getValidItems();

}
21 changes: 21 additions & 0 deletions src/main/java/modtweaker2/mods/tfcraft/TerraFirmaCraft.java
@@ -0,0 +1,21 @@
package modtweaker2.mods.tfcraft;

import minetweaker.MineTweakerAPI;
import modtweaker2.mods.tfcraft.handlers.Anvil;
import modtweaker2.mods.tfcraft.handlers.Barrel;
import modtweaker2.mods.tfcraft.handlers.Heat;
import modtweaker2.mods.tfcraft.handlers.Kiln;
import modtweaker2.mods.tfcraft.handlers.Loom;
import modtweaker2.mods.tfcraft.handlers.Quern;

public class TerraFirmaCraft {

public TerraFirmaCraft(){
MineTweakerAPI.registerClass(Anvil.class);
MineTweakerAPI.registerClass(Barrel.class);
MineTweakerAPI.registerClass(Heat.class);
MineTweakerAPI.registerClass(Kiln.class);
MineTweakerAPI.registerClass(Loom.class);
MineTweakerAPI.registerClass(Quern.class);
}
}
99 changes: 99 additions & 0 deletions src/main/java/modtweaker2/mods/tfcraft/handlers/Anvil.java
@@ -0,0 +1,99 @@
package modtweaker2.mods.tfcraft.handlers;

import static modtweaker2.helpers.StackHelper.areEqual;
import static modtweaker2.helpers.InputHelper.toStack;
import static com.bioxx.tfc.api.Crafting.AnvilReq.getReqFromInt;

import java.util.ArrayList;

import net.minecraft.item.ItemStack;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.mods.tfcraft.TFCHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;

import com.bioxx.tfc.api.Crafting.AnvilManager;
import com.bioxx.tfc.api.Crafting.AnvilRecipe;


@ZenClass("mods.tfcraft.Anvil")
public class Anvil {

@ZenMethod
public static void add(IItemStack input1, IItemStack input2, String plan, int value, boolean flux, int req, IItemStack output){
MineTweakerAPI.apply(new Add(new AnvilRecipe(toStack(input1), toStack(input2), plan, value, flux, req, toStack(output))));
}

/**
* For parameter <code>req</code>:<p> 1==copper;<p> 2==bronze;<p> 3==Wrought Iron;<p>
* 4==Steel;<p> 5==Black Steel;<p> 6==Red Steel;<p> 7==Blue Steel;<p> default is stone.
*/
@ZenMethod
public static void addWeld(IItemStack input1, IItemStack input2, int req, IItemStack output){
MineTweakerAPI.apply(new AddWeld(new AnvilRecipe(toStack(input1), toStack(input2), true, getReqFromInt(req), toStack(output))));
}

@ZenMethod
public static void remove(IItemStack stack){
MineTweakerAPI.apply(new Remove(toStack(stack)));
}

@ZenMethod
public static void removeWeld(IItemStack stack){
MineTweakerAPI.apply(new RemoveWeld(toStack(stack)));
}

private static class Add extends BaseListAddition{
public Add(AnvilRecipe recipe) {
super("Anvil-Regular", TFCHelper.anvilRecipes, recipe);
}
}

private static class AddWeld extends BaseListAddition{
public AddWeld(AnvilRecipe recipe) {
super("Anvil-Weld", TFCHelper.anvilWeldRecipes, recipe);
}
}

private static class Remove extends BaseListRemoval{
public Remove(ItemStack out){
super("Anvil-Remove-Regular", TFCHelper.anvilRecipes, out);
}

@Override
public void apply() {
ArrayList<AnvilRecipe> toRemove = new ArrayList<AnvilRecipe>();
for (AnvilRecipe recipe : AnvilManager.getInstance().getRecipeList()){
if (recipe.getCraftingResult() != null && areEqual(recipe.getCraftingResult(), stack)){
toRemove.add(recipe);
}
}
for (AnvilRecipe aRecipe : toRemove){
TFCHelper.anvilRecipes.remove(aRecipe);
}
}
}

private static class RemoveWeld extends BaseListRemoval{
public RemoveWeld(ItemStack out){
super("Anvil-Remove-Weld", TFCHelper.anvilWeldRecipes, out);
}

@Override
public void apply() {
ArrayList<AnvilRecipe> toRemove = new ArrayList<AnvilRecipe>();
for (AnvilRecipe recipe : AnvilManager.getInstance().getRecipeList()){
if (recipe.getCraftingResult() != null && recipe.getCraftingResult() == stack){
toRemove.add(recipe);
}
}
for (AnvilRecipe aRecipe : toRemove){
TFCHelper.anvilWeldRecipes.remove(aRecipe);
}
}
}

}
99 changes: 99 additions & 0 deletions src/main/java/modtweaker2/mods/tfcraft/handlers/Barrel.java
@@ -0,0 +1,99 @@
package modtweaker2.mods.tfcraft.handlers;

import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;

import java.util.ArrayList;

import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.mods.tfcraft.TFCHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;

import com.bioxx.tfc.api.Crafting.BarrelLiquidToLiquidRecipe;
import com.bioxx.tfc.api.Crafting.BarrelManager;
import com.bioxx.tfc.api.Crafting.BarrelRecipe;

@ZenClass("mods.tfcraft.Barrel")
public class Barrel {

/**
* @param outputFluid If you want this recipe consume fluid, <code>outputFluid=inputFluid</code>
* @param time How long the recipe finished. Unit is TFC hour.
* @param techLv Set to 0 if you want vessel to be able to use your new recipe, otherwise you will set to 1
* @param removeFluid Set false if there is special need
* @param allowAny By default it is <code>true</code>
*/
@ZenMethod
public static void addSealed(IItemStack inputItem, ILiquidStack inputFluid, IItemStack outputItem, ILiquidStack outputFluid, int time, int techLv, boolean removeFluid, boolean allowAny){
MineTweakerAPI.apply(new AddRecipe(new BarrelRecipe(toStack(inputItem), toFluid(inputFluid), toStack(outputItem), toFluid(outputFluid), time).setMinTechLevel(techLv).setRemovesLiquid(removeFluid).setAllowAnyStack(allowAny)));
}


@ZenMethod
public static void addUnsealed(IItemStack inputItem, ILiquidStack inputFluid, IItemStack outputItem, ILiquidStack outputFluid, int techLv, boolean removeFluid, boolean allowAny){
MineTweakerAPI.apply(new AddRecipe(new BarrelRecipe(toStack(inputItem), toFluid(inputFluid), toStack(outputItem), toFluid(outputFluid)).setSealedRecipe(false).setMinTechLevel(techLv).setRemovesLiquid(removeFluid).setAllowAnyStack(allowAny)));
}

/**
*
* @param inputInBarrel The input fluid which is in barrel
* @param input The input fluid which is in a fluid container, like a water bucket
* @param output The output fluid
*/
@ZenMethod
public static void addFluidToFluid(ILiquidStack inputInBarrel, ILiquidStack input, ILiquidStack output){
MineTweakerAPI.apply(new AddRecipe(new BarrelLiquidToLiquidRecipe(toFluid(inputInBarrel), toFluid(input), toFluid(output))));
}

@ZenMethod
public static void remove(IItemStack output){
MineTweakerAPI.apply(new RemoveRecipe(toStack(output)));
}

@ZenMethod
public static void remove(ILiquidStack output){
MineTweakerAPI.apply(new RemoveRecipe(toFluid(output)));
}

private static class AddRecipe extends BaseListAddition{
public AddRecipe(BarrelRecipe recipe){
super("Barrel", TFCHelper.barrelRecipes, recipe);
}
}

private static class RemoveRecipe extends BaseListRemoval{
public RemoveRecipe(ItemStack stack){
super("Barrel-Remove", TFCHelper.barrelRecipes, stack);
}

public RemoveRecipe(FluidStack fluid){
super("Barrel-Remove", TFCHelper.barrelRecipes, fluid);
}

@Override
public void apply() {
ArrayList<BarrelRecipe> toRemove = new ArrayList<BarrelRecipe>();
for (BarrelRecipe recipe : BarrelManager.getInstance().getRecipes()){
if (recipe.getRecipeOutIS() != null && areEqual(recipe.getRecipeOutIS(), stack)){
toRemove.add(recipe);
}
}
for (BarrelRecipe recipe : BarrelManager.getInstance().getRecipes()){
if (recipe.getRecipeOutFluid() != null && recipe.getRecipeOutFluid().isFluidEqual(fluid)){
toRemove.add(recipe);
}
}
for (BarrelRecipe aRecipe : toRemove){
TFCHelper.barrelRecipes.remove(aRecipe);
}
}
}
}
61 changes: 61 additions & 0 deletions src/main/java/modtweaker2/mods/tfcraft/handlers/Heat.java
@@ -0,0 +1,61 @@
package modtweaker2.mods.tfcraft.handlers;

import static modtweaker2.helpers.InputHelper.toStack;
import minetweaker.MineTweakerAPI;
import minetweaker.OneWayAction;
import minetweaker.api.item.IItemStack;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;

import com.bioxx.tfc.api.HeatIndex;
import com.bioxx.tfc.api.HeatRegistry;

@ZenClass("mods.tfcraft.Heat")
public class Heat {

/**
* To add custom recipe in firepit, use this.
* @param input The input itemstack
* @param sh "Specific Heat", which means the multiplier of increasing speed of temp (by default the speed is 1C/gametick)
* @param mt "melt temperature"
* @param output The output itemstack when the item reach the certain temperature
* @see com.bioxx.tfc.Core.ItemHeat
*/
@ZenMethod
public static void add(IItemStack input, double sh, double mt, IItemStack output){
MineTweakerAPI.apply(new AddHeatIndex(toStack(input), sh, mt, toStack(output)));
}

private static class AddHeatIndex extends OneWayAction{

ItemStack in, out;
double sh, mt;

public AddHeatIndex(ItemStack in, double sh, double mt, ItemStack out){
this.in = in;
this.sh = sh;
this.mt = mt;
this.out = out;

this.apply();
}

@Override
public void apply() {
HeatRegistry.getInstance().addIndex(new HeatIndex(in, sh, mt, out));
}

@Override
public String describe() {
return "Add custom heat index for firepit";
}

@Override
public Object getOverrideKey() {
return null;
}

}

}
62 changes: 62 additions & 0 deletions src/main/java/modtweaker2/mods/tfcraft/handlers/Kiln.java
@@ -0,0 +1,62 @@
package modtweaker2.mods.tfcraft.handlers;

import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.areEqual;

import java.util.ArrayList;

import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.mods.tfcraft.TFCHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;

import com.bioxx.tfc.api.Crafting.KilnCraftingManager;
import com.bioxx.tfc.api.Crafting.KilnRecipe;

@ZenClass("mods.tfcraft.Kiln")
public class Kiln {

/** Deprecated, since pottery kiln will check <code>x instanceof ItemPotteryBase</code>
* <p>If you have a such item, you might consider to use it
*/
@Deprecated
@ZenMethod
public static void add(IItemStack input, int lv, IItemStack output){
MineTweakerAPI.apply(new AddRecipe(new KilnRecipe(toStack(input), lv, toStack(output))));
}

@ZenMethod
public static void remove(IItemStack stack){
MineTweakerAPI.apply(new RemoveRecipe(toStack(stack)));
}

private static class AddRecipe extends BaseListAddition{
public AddRecipe(KilnRecipe recipe) {
super("Kiln", TFCHelper.kilnRecipes, recipe);
}
}

private static class RemoveRecipe extends BaseListRemoval{
public RemoveRecipe(ItemStack out){
super("Kiln-Remove", TFCHelper.kilnRecipes, out);
}

@Override
public void apply() {
ArrayList<KilnRecipe> toRemove = new ArrayList<KilnRecipe>();
for (KilnRecipe recipe : KilnCraftingManager.getInstance().getRecipeList()){
if (recipe.getCraftingResult() != null && areEqual(recipe.getCraftingResult(), stack)){
toRemove.add(recipe);
}
}
for (KilnRecipe aRecipe : toRemove){
TFCHelper.kilnRecipes.remove(aRecipe);
}
}
}

}

3 comments on commit c757841

@Kittychanley
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I ask why value was included in the anvil recipe? Unless you decide that the last three actions for a recipe should all be red ones, there is no need to ever override the default value, which determines the location of the red arrow. If you're going to include it, it should not be a required field.

Edit: Also, by including the crafting value parameter, you completely override the random location for the arrow that the smithing system is based off of. So unlike all the other smithing recipes, once you know the steps for it, you'll be able to use those exact steps on every single world and instance of the game. For all the default recipes, stuff like world seed is taken into consideration, so sets of steps won't work across worlds.

Many of our recipes had multiple constructors to allow for flexibility and to let our code run in the background. By only including one of the constructors for each class, you're completely missing out on that flexibility.

@Yulife
Copy link
Collaborator Author

@Yulife Yulife commented on c757841 Apr 20, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@3TUSK
Copy link
Contributor

@3TUSK 3TUSK commented on c757841 Apr 20, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well... It is my fault. At first I thought the value parameter should be able to customize. (Seems I need to review everything about tfc anvil.)
Another thing is that there are some constructors which extends from the same constructor. What I wanted to do is to add the base one so that a modpack creator can customize the property of their recipe.
Whatever, I'm going to handle it asap.
@Kittychanley

Please sign in to comment.