Some more TConstruct tweaks
This commit is contained in:
parent
d153adc91b
commit
ece7dca426
|
@ -4,6 +4,7 @@ import static modtweaker2.helpers.InputHelper.toFluid;
|
|||
import static modtweaker2.helpers.InputHelper.toIItemStack;
|
||||
import static modtweaker2.helpers.InputHelper.toILiquidStack;
|
||||
import static modtweaker2.helpers.InputHelper.toStack;
|
||||
import static modtweaker2.helpers.StackHelper.matches;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
|
@ -12,6 +13,7 @@ import java.util.List;
|
|||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.item.IngredientAny;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import modtweaker2.helpers.InputHelper;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
|
@ -32,18 +34,28 @@ public class Casting {
|
|||
|
||||
@ZenMethod
|
||||
public static void addBasinRecipe(IItemStack output, ILiquidStack metal, @Optional IItemStack cast, @Optional boolean consume, int delay) {
|
||||
if(metal == null || output == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
|
||||
return;
|
||||
}
|
||||
|
||||
MineTweakerAPI.apply(new Add(new CastingRecipe(toStack(output), toFluid(metal), toStack(cast), consume, delay, null), TConstructHelper.basinCasting));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addTableRecipe(IItemStack output, ILiquidStack metal, @Optional IItemStack cast, @Optional boolean consume, int delay) {
|
||||
if(metal == null || output == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
|
||||
return;
|
||||
}
|
||||
|
||||
MineTweakerAPI.apply(new Add(new CastingRecipe(toStack(output), toFluid(metal), toStack(cast), consume, delay, null), TConstructHelper.tableCasting));
|
||||
}
|
||||
|
||||
//Passes the list to the base list implementation, and adds the recipe
|
||||
private static class Add extends BaseListAddition<CastingRecipe> {
|
||||
public Add(CastingRecipe recipe, ArrayList<CastingRecipe> list) {
|
||||
super("TConstruct Casting", list);
|
||||
super(Casting.name, list);
|
||||
|
||||
this.recipes.add(recipe);
|
||||
}
|
||||
|
@ -57,62 +69,49 @@ public class Casting {
|
|||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void removeTableRecipe(IIngredient output) {
|
||||
removeRecipe(output, TConstructHelper.tableCasting, RecipeComponent.Output);
|
||||
public static void removeTableRecipe(IIngredient output, @Optional IIngredient material, @Optional IIngredient cast) {
|
||||
removeRecipe(output, material, cast, TConstructHelper.tableCasting);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeTableMaterial(IIngredient material) {
|
||||
removeRecipe(material, TConstructHelper.tableCasting, RecipeComponent.Material);
|
||||
public static void removeBasinRecipe(IIngredient output, @Optional IIngredient material, @Optional IIngredient cast) {
|
||||
removeRecipe(output, material, cast, TConstructHelper.basinCasting);
|
||||
}
|
||||
|
||||
public static void removeRecipe(IIngredient output, IIngredient material, IIngredient cast, List<CastingRecipe> list) {
|
||||
|
||||
@ZenMethod
|
||||
public static void removeCastRecipes(IIngredient cast) {
|
||||
removeRecipe(cast, TConstructHelper.tableCasting, RecipeComponent.Cast);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeBasinRecipe(IIngredient output) {
|
||||
removeRecipe(output, TConstructHelper.basinCasting, RecipeComponent.Output);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeBasinMaterial(IIngredient material) {
|
||||
removeRecipe(material, TConstructHelper.basinCasting, RecipeComponent.Material);
|
||||
}
|
||||
|
||||
|
||||
public static void removeRecipe(IIngredient ingredient, List<CastingRecipe> list, RecipeComponent component) {
|
||||
if(material == null) {
|
||||
material = IngredientAny.INSTANCE;
|
||||
}
|
||||
|
||||
if(cast == null) {
|
||||
cast = IngredientAny.INSTANCE;
|
||||
}
|
||||
|
||||
List<CastingRecipe> recipes = new LinkedList<CastingRecipe>();
|
||||
|
||||
for(CastingRecipe recipe : list) {
|
||||
if(recipe != null) {
|
||||
switch(component) {
|
||||
case Cast:
|
||||
if(recipe.cast != null && ingredient.contains(toIItemStack(recipe.cast))) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
break;
|
||||
case Output:
|
||||
if (recipe.output != null && ingredient.contains(toIItemStack(recipe.output))) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
break;
|
||||
case Material:
|
||||
if (recipe.castingMetal != null && ingredient.contains(toILiquidStack(recipe.castingMetal))) {
|
||||
// TODO: Currently broken, because MCLiquidStack equals() method always returns false
|
||||
recipes.add(recipe);
|
||||
}
|
||||
break;
|
||||
if (!matches(output, toIItemStack(recipe.output))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!matches(material, toILiquidStack(recipe.castingMetal))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!matches(cast, toIItemStack(recipe.cast))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(list, recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Casting.name, ingredient.toString()));
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for output %s, meterial %s and cast %s. Command ignored!", Casting.name, output.toString(), material.toString(), cast.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,10 +126,4 @@ public class Casting {
|
|||
return InputHelper.getStackDescription(recipe.output);
|
||||
}
|
||||
}
|
||||
|
||||
public enum RecipeComponent {
|
||||
Output,
|
||||
Cast,
|
||||
Material
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,11 @@ public class Drying {
|
|||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack input, IItemStack output, int time) {
|
||||
if(input == null || output == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
|
||||
return;
|
||||
}
|
||||
|
||||
MineTweakerAPI.apply(new Add(TConstructHelper.getDryingRecipe(toStack(input), time, toStack(output))));
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,11 @@ public class Smeltery {
|
|||
// Adding a TConstruct Alloy recipe
|
||||
@ZenMethod
|
||||
public static void addAlloy(ILiquidStack output, ILiquidStack[] input) {
|
||||
if(input == null || output == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameAlloy));
|
||||
return;
|
||||
}
|
||||
|
||||
MineTweakerAPI.apply(new AddAlloy(new AlloyMix(toFluid(output), new ArrayList<FluidStack>(Arrays.asList(toFluids(input))))));
|
||||
}
|
||||
|
||||
|
@ -104,6 +109,12 @@ public class Smeltery {
|
|||
// Adding a TConstruct Melting recipe
|
||||
@ZenMethod
|
||||
public static void addMelting(IIngredient input, ILiquidStack output, int temp, @Optional IItemStack block) {
|
||||
|
||||
if(input == null || output == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameMelting));
|
||||
return;
|
||||
}
|
||||
|
||||
List<MeltingRecipe> recipes = new LinkedList<MeltingRecipe>();
|
||||
|
||||
for(IItemStack in : input.getItems()) {
|
||||
|
@ -265,6 +276,11 @@ public class Smeltery {
|
|||
|
||||
@ZenMethod
|
||||
public static void addFuel(ILiquidStack liquid, int power, int duration) {
|
||||
if(liquid == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameFuel));
|
||||
return;
|
||||
}
|
||||
|
||||
Map<Fluid, Integer[]> recipes = new HashMap<Fluid, Integer[]>();
|
||||
|
||||
recipes.put(toFluid(liquid).getFluid(), new Integer[] {power, duration});
|
||||
|
|
Loading…
Reference in a new issue