Clean up for some Forestry handlers

* removed deprecated methods, those are for 1.7.10
* if a handler had 2 methods for 1 thing, I merged them and made the
differences optional
* param description
This commit is contained in:
Yulife 2016-07-13 18:18:56 +02:00
parent a83de3c459
commit 97d3ee6b62
7 changed files with 86 additions and 154 deletions

View file

@ -32,33 +32,17 @@ public class Carpenter {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Adds a shaped recipe for the Carpenter
* Adds shaped recipe to Carpenter
*
* @param output recipe output
* @param ingredients recipe ingredients
* @param packagingTime time per crafting operation
* @optionalParam box recipes casting item (optional)
* @param output recipe product
* @param ingredients required ingredients
* @param packagingTime amount of ticks per crafting operation
** @param fluidInput required mB of fluid (optional)
** @param box required box in top slot (optional)
** @param remainingItems no idea (optional)
*/
@ZenMethod
public static void addRecipe(IItemStack output, IIngredient[][] ingredients, int packagingTime, @Optional IItemStack box, @Optional IItemStack[] remainingItems) {
if (remainingItems == null) {
remainingItems = new IItemStack[0];
}
IDescriptiveRecipe craftRecipe = new DescriptiveRecipe(3, 3, toShapedObjects(ingredients), toStack(output), toStacks(remainingItems));
MineTweakerAPI.apply(new Add(new CarpenterRecipe(packagingTime, null, toStack(box), craftRecipe)));
}
/**
* Adds a shaped recipe for the Carpenter
*
* @param output recipe output
* @param ingredients recipe ingredients
* @param fluidInput recipe fluid amount
* @param packagingTime time per crafting operation
* @optionalParam box recipes casting item (optional)
*/
@ZenMethod
public static void addRecipe(IItemStack output, IIngredient[][] ingredients, ILiquidStack fluidInput, int packagingTime, @Optional IItemStack box, @Optional IItemStack[] remainingItems) {
public static void addRecipe(IItemStack output, IIngredient[][] ingredients, int packagingTime, @Optional ILiquidStack fluidInput, @Optional IItemStack box, @Optional IItemStack[] remainingItems) {
if (remainingItems == null) {
remainingItems = new IItemStack[0];
}
@ -91,24 +75,36 @@ public class Carpenter {
}
}
/**
* Adds shapeless recipe to Carpenter
*
* @param output recipe product
* @param ingredients required ingredients
* @param packagingTime amount of ticks per crafting operation
** @param fluidInput required mB of fluid (optional)
** @param box required box in top slot (optional)
** @param remainingItems no idea (optional)
*/
//TODO
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Removes a recipe for the Carpenter
* Removes recipe from Carpenter
*
* @param output = item output
* @optionalParam liquid = liquid input
* @param output = recipe result
** @param fluidInput = required type of fluid (optional)
*/
@ZenMethod
public static void removeRecipe(IIngredient output, @Optional IIngredient liquid) {
public static void removeRecipe(IIngredient output, @Optional IIngredient fluidInput) {
List<ICarpenterRecipe> recipes = new LinkedList<ICarpenterRecipe>();
for (ICarpenterRecipe recipe : RecipeManagers.carpenterManager.recipes()) {
if (recipe != null) {
ItemStack recipeResult = recipe.getCraftingGridRecipe().getRecipeOutput();
if (recipeResult != null && matches(output, toIItemStack(recipeResult))) {
if (liquid != null) {
if (matches(liquid, toILiquidStack(recipe.getFluidResource())))
if (fluidInput != null) {
if (matches(fluidInput, toILiquidStack(recipe.getFluidResource())))
recipes.add(recipe);
} else {
recipes.add(recipe);

View file

@ -33,31 +33,19 @@ public class Centrifuge {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Adds a recipe for the Centrifuge
*
* @param output List of items to produce with associated chance
* @param ingredient item input
* @param timePerItem time per item to process
* Adds recipe to Centrifuge
*
* @param output recipe product
* @param ingredients required ingredients
* @param packagingTime amount of ticks per crafting operation
*/
@ZenMethod
public static void addRecipe(WeightedItemStack[] output, IItemStack ingredient, int timePerItem) {
public static void addRecipe(WeightedItemStack[] output, IItemStack ingredients, int packagingTime) {
Map<ItemStack, Float> products = new HashMap<ItemStack, Float>();
for (WeightedItemStack product : output) {
products.put(toStack(product.getStack()), product.getChance());
}
MineTweakerAPI.apply(new Add(new CentrifugeRecipe(timePerItem, toStack(ingredient), products)));
}
@ZenMethod
@Deprecated
public static void addRecipe(int timePerItem, IItemStack itemInput, IItemStack[] output, int[] chances) {
Map<ItemStack, Float> products = new HashMap<ItemStack, Float>();
int i = 0;
for (IItemStack product : output) {
products.put(toStack(product), ((float) chances[i] / 100));
i++;
}
MineTweakerAPI.apply(new Add(new CentrifugeRecipe(timePerItem, toStack(itemInput), products)));
MineTweakerAPI.apply(new Add(new CentrifugeRecipe(packagingTime, toStack(ingredients), products)));
}
private static class Add extends ForestryListAddition<ICentrifugeRecipe, ICentrifugeManager> {
@ -77,7 +65,7 @@ public class Centrifuge {
/**
* Removes a recipe for the Centrifuge
*
* @param input item input
* @param input type of item in input
*/
@ZenMethod
public static void removeRecipe(IIngredient input) {

View file

@ -37,25 +37,20 @@ public class Fermenter {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Adds a fermenter recipe. Amount of fluid output is calculated: fermentationValue * fluidOutputModifier
* Adds recipe to fermenter
* Amount of fluid output: fermentationValue * fluidOutputModifier
* Note: the actual consumption of fluid input depends on the fermentation fuel
*
* @param fluidOutput type of fluid produced
* @param resource organic item
* @param fluidInput type of fluid required in input
* @param fermentationValue amount of inputFluid on organic item requires
* @param fluidOutputModifier Output multiplier (this is usually a from the input fluid
* @param fluidOutputModifier Output multiplier (this is usually a from the input fluid)
*/
@ZenMethod
public static void addRecipe(ILiquidStack fluidOutput, IItemStack resource, ILiquidStack fluidInput, int fermentationValue, float fluidOutputModifier) {
MineTweakerAPI.apply(new Add(new FermenterRecipe(toStack(resource), fermentationValue, fluidOutputModifier, getFluid(fluidOutput), toFluid(fluidInput))));
}
@Deprecated
@ZenMethod
public static void addRecipe(IItemStack resource, ILiquidStack fluidInput, int fermentationValue, float fluidOutputModifier, ILiquidStack fluidOutput) {
MineTweakerAPI.apply(new Add(new FermenterRecipe(toStack(resource), fermentationValue, fluidOutputModifier, getFluid(fluidOutput), toFluid(fluidInput))));
}
private static class Add extends ForestryListAddition<IFermenterRecipe, IFermenterManager> {
public Add(IFermenterRecipe recipe) {
@ -70,7 +65,12 @@ public class Fermenter {
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Removes recipe from Fermenter
*
* @param input type of item in input
*/
@ZenMethod
public static void removeRecipe(IIngredient input) {
List<IFermenterRecipe> recipes = new LinkedList<IFermenterRecipe>();
@ -109,7 +109,7 @@ public class Fermenter {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Adds fermenter fuel.
* Adds fermenter fuel
* Note: the actual consumption of fluid input depends on the fermentation fuel
*
* @param item Item that is a valid fuel for the fermenter
@ -136,7 +136,7 @@ public class Fermenter {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Removes a fermenter fuel.
* Removes fermenter fuel
*
* @param fermenterItem Item that is a valid fuel for the fermenter
*/

View file

@ -37,21 +37,15 @@ public class Moistener {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Adds a recipe for the Moistener
* Adds recipe to Moistener
*
* @param output recipe output
* @param resource organic item
* @param timePerItem time per item to process
* @param output recipe product
* @param input required item
* @param packagingTime amount of ticks per crafting operation
*/
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack resource, int timePerItem) {
MineTweakerAPI.apply(new Add(new MoistenerRecipe(toStack(resource), toStack(output), timePerItem)));
}
@Deprecated
@ZenMethod
public static void addRecipe(int timePerItem, IItemStack resource, IItemStack product) {
MineTweakerAPI.apply(new Add(new MoistenerRecipe(toStack(resource), toStack(product), timePerItem)));
public static void addRecipe(IItemStack output, IItemStack input, int packagingTime) {
MineTweakerAPI.apply(new Add(new MoistenerRecipe(toStack(input), toStack(output), packagingTime)));
}
private static class Add extends ForestryListAddition<IMoistenerRecipe, IMoistenerManager> {
@ -68,6 +62,11 @@ public class Moistener {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Removes recipe from Fermenter
*
* @param output recipe product
*/
@ZenMethod
public static void removeRecipe(IIngredient output) {
List<IMoistenerRecipe> recipes = new LinkedList<IMoistenerRecipe>();
@ -98,7 +97,7 @@ public class Moistener {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Adds moistener fuel.
* Adds Moistener fuel
*
* @param item The item to use
* @param product The item that leaves the moistener's working slot (i.e. mouldy wheat, decayed wheat, mulch)
@ -129,7 +128,7 @@ public class Moistener {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Removes a moistener fuel.
* Removes Moistener fuel.
*
* @param moistenerItem Item that is a valid fuel for the moistener
*/

View file

@ -28,38 +28,20 @@ public class Squeezer {
public static final String name = "Forestry Squeezer";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Adds a recipe without additional item output
*
* @param fluidOutput recipe fluid amount
* @param ingredients recipe ingredients
* @param timePerItem time per crafting operation
*/
@ZenMethod
public static void addRecipe(ILiquidStack fluidOutput, int timePerItem, IItemStack[] ingredients) {
MineTweakerAPI.apply(new Add(new SqueezerRecipe(timePerItem, toStacks(ingredients), toFluid(fluidOutput), null, 0)));
}
/**
* Adds a recipe with additional item output
* Adds recipe to Squeezer
*
* @param fluidOutput recipe fluid amount
* @param itemOutput recipe output
* @param ingredients recipe ingredients
* @param timePerItem time per crafting operation
** @param itemOutput recipe output (optional)
*/
@ZenMethod
public static void addRecipe(ILiquidStack fluidOutput, WeightedItemStack itemOutput, IItemStack[] ingredients, int timePerItem) {
public static void addRecipe(ILiquidStack fluidOutput, IItemStack[] ingredients, int timePerItem, @Optional WeightedItemStack itemOutput) {
MineTweakerAPI.apply(new Add(new SqueezerRecipe(timePerItem, toStacks(ingredients), toFluid(fluidOutput), toStack(itemOutput.getStack()), itemOutput.getChance())));
}
@ZenMethod
@Deprecated
public static void addRecipe(int timePerItem, IItemStack[] resources, ILiquidStack liquid, IItemStack remnants, int chance) {
MineTweakerAPI.apply(new Add(new SqueezerRecipe(timePerItem, toStacks(resources), toFluid(liquid), toStack(remnants), chance)));
}
private static class Add extends ForestryListAddition<ISqueezerRecipe, ISqueezerManager> {
public Add(ISqueezerRecipe recipe) {
super(Squeezer.name, RecipeManagers.squeezerManager);
@ -78,7 +60,7 @@ public class Squeezer {
* Removes a recipe for the Centrifuge
*
* @param liquid liquid output
* @param ingredients list of ingredients
** @param ingredients list of ingredients (optional)
*/
@ZenMethod
public static void removeRecipe(IIngredient liquid, @Optional IIngredient[] ingredients) {

View file

@ -29,7 +29,7 @@ public class Still {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Adds a recipe for the Still
* Adds recipe to Still
*
* @param fluidOutput recipe fluid amount
* @param fluidInput recipe fluid input
@ -43,15 +43,6 @@ public class Still {
MineTweakerAPI.apply(new Add(new StillRecipe(timePerUnit, toFluid(fluidInput), toFluid(fluidOutput))));
}
@Deprecated
@ZenMethod
public static void addRecipe(int timePerUnit, ILiquidStack input, ILiquidStack output) {
output.amount(output.getAmount() / 100);
input.amount(input.getAmount() / 100);
MineTweakerAPI.apply(new Add(new StillRecipe(timePerUnit, toFluid(input), toFluid(output))));
}
private static class Add extends ForestryListAddition<IStillRecipe, IStillManager> {
public Add(IStillRecipe recipe) {
super("Forestry Still", RecipeManagers.stillManager);
@ -67,19 +58,19 @@ public class Still {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Removes a recipe for the Still
* Removes recipe from Still
*
* @param output = liquid output
* @optionalParam liquid = liquid input
** @param fluidInput = liquid input (optional)
*/
@ZenMethod
public static void removeRecipe(IIngredient output, @Optional ILiquidStack input) {
public static void removeRecipe(IIngredient output, @Optional ILiquidStack fluidInput) {
List<IStillRecipe> recipes = new LinkedList<IStillRecipe>();
for (IStillRecipe r : RecipeManagers.stillManager.recipes()) {
if (r != null && r.getOutput() != null && matches(output, toILiquidStack(r.getOutput()))) {
if (input != null) {
if (matches(input, toILiquidStack(r.getInput()))) {
if (fluidInput != null) {
if (matches(fluidInput, toILiquidStack(r.getInput()))) {
recipes.add(r);
}
}

View file

@ -31,7 +31,7 @@ public class ThermionicFabricator {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Adds a smelting recipe for the Thermionic Fabricator
* Adds smelting recipe to Thermionic Fabricator
*
* @param fluidOutput recipe fluid amount
* @param itemInput recipe input input
@ -43,22 +43,16 @@ public class ThermionicFabricator {
MineTweakerAPI.apply(new AddSmelting(new FabricatorSmeltingRecipe(toStack(itemInput), FluidRegistry.getFluidStack("glass", fluidOutput), meltingPoint)));
}
@Deprecated
@ZenMethod
public static void addSmelting(IItemStack itemInput, int meltingPoint, int fluidOutput) {
//The machines internal tank accept only liquid glass, therefor this function only accept the amount and hardcode the fluid to glass
MineTweakerAPI.apply(new AddSmelting(new FabricatorSmeltingRecipe(toStack(itemInput), FluidRegistry.getFluidStack("glass", fluidOutput), meltingPoint)));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Adds a casting recipe for the Thermionic Fabricator
* Adds casting recipe to Thermionic Fabricator
*
* @param output recipe output item
* @param ingredients list of input items
* @param fluidInput recipe fluid input
* @param plan recipe plan item
* @param output recipe output item
* @param ingredients list of input items
* @param fluidInput recipe fluid input
** @param plan recipe plan item (optional)
** @param remainingItems no idea(optional)
*/
@ZenMethod
public static void addCast(IItemStack output, IIngredient[][] ingredients, int fluidInput, @Optional IItemStack plan, @Optional IItemStack[] remainingItems) {
@ -69,16 +63,6 @@ public class ThermionicFabricator {
MineTweakerAPI.apply(new AddCast(new FabricatorRecipe(toStack(plan), FluidRegistry.getFluidStack("glass", fluidInput), recipe)));
}
@Deprecated
@ZenMethod
public static void addCast(ILiquidStack fluidInput, IIngredient[][] ingredients, IItemStack plan, IItemStack output, @Optional IItemStack[] remainingItems) {
if (remainingItems == null) {
remainingItems = new IItemStack[0];
}
IDescriptiveRecipe recipe = new DescriptiveRecipe(3, 3, toShapedObjects(ingredients), toStack(output), toStacks(remainingItems));
MineTweakerAPI.apply(new AddCast(new FabricatorRecipe(toStack(plan), toFluid(fluidInput), recipe)));
}
/*
Implements the actions to add a recipe
Since the machine has two crafting Steps, this is a constructors for both
@ -111,6 +95,11 @@ public class ThermionicFabricator {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Removes smelting recipe from Thermionic Fabricator
*
* @param itemInput = item input
*/
@ZenMethod
public static void removeSmelting(IIngredient itemInput) {
List<IFabricatorSmeltingRecipe> recipes = new LinkedList<IFabricatorSmeltingRecipe>();
@ -128,6 +117,11 @@ public class ThermionicFabricator {
}
}
/**
* Removes casting recipe from Thermionic Fabricator
*
* @param product = recipe result
*/
@ZenMethod
public static void removeCast(IIngredient product) {
List<IFabricatorRecipe> recipes = new LinkedList<IFabricatorRecipe>();
@ -145,24 +139,6 @@ public class ThermionicFabricator {
}
}
@Deprecated
@ZenMethod
public static void removeCasts(IIngredient product) {
List<IFabricatorRecipe> recipes = new LinkedList<IFabricatorRecipe>();
for (IFabricatorRecipe r : RecipeManagers.fabricatorManager.recipes()) {
if (r != null && r.getRecipeOutput() != null && matches(product, toIItemStack(r.getRecipeOutput()))) {
recipes.add(r);
}
}
if (!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveCasts(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ThermionicFabricator.nameSmelting, product.toString()));
}
}
private static class RemoveSmelting extends ForestryListRemoval<IFabricatorSmeltingRecipe, IFabricatorSmeltingManager> {
public RemoveSmelting(List<IFabricatorSmeltingRecipe> recipes) {
super(ThermionicFabricator.nameSmelting, RecipeManagers.fabricatorSmeltingManager, recipes);