Move to native MT Style : AE2

This includes:
* Polish of Parameter names
* Explanation of Parameter names
* New Method that has the order of (Output, Input, Misc)
* Old Methods marked as @'Deprecated
This commit is contained in:
Yulife 2015-09-27 14:36:06 +02:00
parent 0c6a470a69
commit 8ad354077c
2 changed files with 89 additions and 9 deletions

View file

@ -27,7 +27,47 @@ public class Grind {
protected static final String name = "Applied Energistics 2 Grinder";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Adds a shaped recipe for the Carpenter
*
* @param outputStack - Product of the Recipe
* @param inputStack - Ingredient of the Recipe
* @optionalParam outputStack2 - Second product of the Recipe
* @optionalParam outputStack2Chance - Chance for the acquirement of the second product
* @optionalParam outputStack3 - Third product of the Recipe
* @optionalParam outputStack3Chance - Chance for the acquirement of the third product
* @param inputEnergy - Energy requirement of the Recipe
**/
@ZenMethod
public static void addRecipe(IItemStack outputStack, IItemStack inputStack, @Optional IItemStack outputStack2, @Optional float outputStack2Chance, @Optional IItemStack outputStack3, @Optional float outputStack3Chance, int inputEnergy) {
if(inputStack == null || outputStack == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
// Create recipe
IGrinderEntry recipe;
if(outputStack2 != null && outputStack3 != null)
recipe = new AppEngGrinderRecipe(InputHelper.toStack(inputStack), InputHelper.toStack(outputStack), InputHelper.toStack(outputStack2), InputHelper.toStack(outputStack3), outputStack2Chance, outputStack3Chance, inputEnergy);
else if(outputStack2 != null)
recipe = new AppEngGrinderRecipe(InputHelper.toStack(inputStack), InputHelper.toStack(outputStack), InputHelper.toStack(outputStack2), outputStack2Chance, inputEnergy);
else
recipe = new AppEngGrinderRecipe(InputHelper.toStack(inputStack), InputHelper.toStack(outputStack), inputEnergy);
// Check if the recipe is already present, we don't want to add duplicates
for(IGrinderEntry r : AEApi.instance().registries().grinder().getRecipes()) {
if(r != null && AppliedEnergisticsHelper.equals(r, recipe)) {
LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s. Command ignored!", name, LogHelper.getStackDescription(toStack(inputStack))));
return;
}
}
MineTweakerAPI.apply(new Add(recipe));
}
@Deprecated
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output, int energy, @Optional IItemStack output2, @Optional float chance2, @Optional IItemStack output3, @Optional float chance3) {
if(input == null || output == null) {
@ -76,10 +116,14 @@ public class Grind {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Adds a shaped recipe for the Carpenter
*
* @param outputStack - Product of the Recipe
**/
@ZenMethod
public static void removeRecipe(IIngredient output) {
if(output == null) {
public static void removeRecipe(IIngredient outputStack) {
if(outputStack == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
@ -88,7 +132,7 @@ public class Grind {
LinkedList<IGrinderEntry> result = new LinkedList<IGrinderEntry>();
for(IGrinderEntry entry : AEApi.instance().registries().grinder().getRecipes()) {
if(entry != null && entry.getOutput() != null && matches(output, toIItemStack(entry.getOutput()))) {
if(entry != null && entry.getOutput() != null && matches(outputStack, toIItemStack(entry.getOutput()))) {
result.add(entry);
}
}
@ -97,7 +141,7 @@ public class Grind {
if(!result.isEmpty()) {
MineTweakerAPI.apply(new Remove(result));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", name, output.toString()));
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", name, outputStack.toString()));
}
}

View file

@ -29,6 +29,37 @@ public class Inscriber {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Adds a shaped recipe for the Carpenter
*
* @param outputStack - Product of the Recipe
* @param inputArray - Ingredients of the Recipe
* @param inputStackPlateA - Ingredient of the Recipe for Plate Slot A
* @param inputStackPlateB - Ingredient of the Recipe for Plate Slot B
* @param typeString - Type that decides whether to consume the ItemStack in Plate Slot A/B
**/
@ZenMethod
public static void addRecipe(IItemStack outputStack, IItemStack[] inputArray, IItemStack inputStackPlateA, IItemStack inputStackPlateB, String typeString) {
if(inputArray == null || outputStack == null || (!typeString.equals("Press") && !typeString.equals("Inscribe"))) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", Inscriber.name));
return;
}
// Create recipe
IInscriberRecipe recipe = new InscriberRecipe(ArrayUtils.toArrayList(toStacks(inputArray)), toStack(outputStack), toStack(inputStackPlateA), toStack(inputStackPlateB), InscriberProcessType.valueOf(typeString));
// Check if the recipe is already present, we don't want to add duplicates
for(IInscriberRecipe r : AEApi.instance().registries().inscriber().getRecipes()) {
if(r != null && AppliedEnergisticsHelper.equals(r, recipe)) {
LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s. Command ignored!", Inscriber.name, LogHelper.getStackDescription(toStack(outputStack))));
return;
}
}
MineTweakerAPI.apply(new Add(recipe));
}
@Deprecated
@ZenMethod
public static void addRecipe(IItemStack[] imprintable, IItemStack plateA, IItemStack plateB, IItemStack out, String type) {
if(imprintable == null || out == null || (!type.equals("Press") && !type.equals("Inscribe"))) {
@ -96,9 +127,14 @@ public class Inscriber {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Adds a shaped recipe for the Carpenter
*
* @param outputStack - Product of the Recipe
**/
@ZenMethod
public static void removeRecipe(IIngredient output) {
if(output == null) {
public static void removeRecipe(IIngredient outputStack) {
if(outputStack == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", Inscriber.name));
return;
}
@ -107,7 +143,7 @@ public class Inscriber {
LinkedList<IInscriberRecipe> result = new LinkedList<IInscriberRecipe>();
for(IInscriberRecipe entry : AEApi.instance().registries().inscriber().getRecipes()) {
if(entry != null && entry.getOutput() != null && matches(output, toIItemStack(entry.getOutput()))) {
if(entry != null && entry.getOutput() != null && matches(outputStack, toIItemStack(entry.getOutput()))) {
result.add(entry);
}
}
@ -116,7 +152,7 @@ public class Inscriber {
if(!result.isEmpty()) {
MineTweakerAPI.apply(new Remove(result));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Inscriber.name, output.toString()));
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Inscriber.name, outputStack.toString()));
}
}