Fixes forestry issues

This commit is contained in:
Jared 2016-12-12 21:39:07 +02:00
parent 7884619f54
commit e4b485f852
9 changed files with 163 additions and 167 deletions

View file

@ -28,7 +28,7 @@ minecraft {
version = "${config.forge.version}"
runDir = "eclipse"
replace "@modVersion@", config.mod.version
mappings = "snapshot_20160518"
mappings = "snapshot_20161111"
}
sourceCompatibility = targetCompatibility = "1.8" // Need this here so eclipse task generates correctly.
compileJava {

View file

@ -1,3 +1,3 @@
minecraft.version=1.10.2
forge.version=1.10.2-12.18.2.2116
forge.version=1.10.2-12.18.3.2185
mod.version=2.0.7

View file

@ -13,13 +13,13 @@ public class AppliedEnergisticsHelper {
public static List<IInscriberRecipe> inscriber = null;
// public static List<IGrinderEntry> grinder = null;
public static List<IGrinderRecipe> grinder = null;
static {
try {
inscriber = new ArrayList<>(ReflectionHelper.getFinalObject(Api.INSTANCE.registries().inscriber(), "recipes"));
// grinder = new ArrayList<>(ReflectionHelper.getFinalObject(Api.INSTANCE.registries().grinder(), "recipes"));
grinder = new ArrayList<>(ReflectionHelper.getFinalObject(Api.INSTANCE.registries().grinder(), "recipes"));
} catch(Exception e) {
}
}
@ -75,7 +75,7 @@ public class AppliedEnergisticsHelper {
/**
* Compares two IGrinderEntry objects, if they are the same or have the same inputs
*/
public static boolean equals(IGrinderEntry r1, IGrinderEntry r2) {
public static boolean equals(IGrinderRecipe r1, IGrinderRecipe r2) {
if(r1 == r2) {
return true;
}

View file

@ -1,7 +1,7 @@
package modtweaker.mods.appeng.handlers;
import appeng.api.AEApi;
import appeng.api.features.IGrinderEntry;
import appeng.api.features.IGrinderRecipe;
import appeng.core.features.registries.entries.AppEngGrinderRecipe;
import com.blamejared.mtlib.helpers.*;
import com.blamejared.mtlib.utils.*;
@ -31,7 +31,7 @@ public class Grind {
*/
@ZenMethod
public static void addRecipe(WeightedItemStack[] outputs, IItemStack inputStack, int turns) {
IGrinderEntry recipe;
IGrinderRecipe recipe;
if(outputs.length == 1)
recipe = new AppEngGrinderRecipe(InputHelper.toStack(inputStack), InputHelper.toStack(outputs[0].getStack()), turns);
else if(outputs.length == 2)
@ -44,7 +44,7 @@ public class Grind {
}
// Check if the recipe is already present, we don't want to add duplicates
for(IGrinderEntry r : AEApi.instance().registries().grinder().getRecipes()) {
for(IGrinderRecipe 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;
@ -75,7 +75,7 @@ public class Grind {
}
// Create recipe
IGrinderEntry recipe;
IGrinderRecipe recipe;
if(outputStack2 != null && outputStack3 != null)
recipe = new AppEngGrinderRecipe(InputHelper.toStack(inputStack), InputHelper.toStack(outputStack), InputHelper.toStack(outputStack2), InputHelper.toStack(outputStack3), outputStack2Chance, outputStack3Chance, inputEnergy);
@ -85,7 +85,7 @@ public class Grind {
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()) {
for(IGrinderRecipe 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;
@ -104,7 +104,7 @@ public class Grind {
}
// Create recipe
IGrinderEntry recipe;
IGrinderRecipe recipe;
if(output2 != null && output3 != null)
recipe = new AppEngGrinderRecipe(InputHelper.toStack(input), InputHelper.toStack(output), InputHelper.toStack(output2), InputHelper.toStack(output3), chance2, chance3, energy);
@ -114,7 +114,7 @@ public class Grind {
recipe = new AppEngGrinderRecipe(InputHelper.toStack(input), InputHelper.toStack(output), energy);
// Check if the recipe is already present, we don't want to add duplicates
for(IGrinderEntry r : AEApi.instance().registries().grinder().getRecipes()) {
for(IGrinderRecipe 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(input))));
return;
@ -124,20 +124,20 @@ public class Grind {
MineTweakerAPI.apply(new Add(recipe));
}
private static class Add extends BaseListAddition<IGrinderEntry> {
private static class Add extends BaseListAddition<IGrinderRecipe> {
public Add(IGrinderEntry recipe) {
super(Grind.name, AEApi.instance().registries().grinder().getRecipes());
public Add(IGrinderRecipe recipe) {
super(Grind.name, AppliedEnergisticsHelper.grinder);
recipes.add(recipe);
}
@Override
public String getRecipeInfo(IGrinderEntry recipe) {
public String getRecipeInfo(IGrinderRecipe recipe) {
return LogHelper.getStackDescription(recipe.getInput());
}
@Override
protected boolean equals(IGrinderEntry recipe, IGrinderEntry otherRecipe) {
protected boolean equals(IGrinderRecipe recipe, IGrinderRecipe otherRecipe) {
return AppliedEnergisticsHelper.equals(recipe, otherRecipe);
}
}
@ -157,9 +157,9 @@ public class Grind {
}
// Get list of existing recipes, matching with parameter
LinkedList<IGrinderEntry> result = new LinkedList<IGrinderEntry>();
LinkedList<IGrinderRecipe> result = new LinkedList<IGrinderRecipe>();
for(IGrinderEntry entry : AEApi.instance().registries().grinder().getRecipes()) {
for(IGrinderRecipe entry : AEApi.instance().registries().grinder().getRecipes()) {
if(entry != null && entry.getOutput() != null && matches(input, toIItemStack(entry.getOutput()))) {
result.add(entry);
}
@ -173,14 +173,14 @@ public class Grind {
}
}
private static class Remove extends BaseListRemoval<IGrinderEntry> {
private static class Remove extends BaseListRemoval<IGrinderRecipe> {
public Remove(LinkedList<IGrinderEntry> recipes) {
super(Grind.name, AEApi.instance().registries().grinder().getRecipes(), recipes);
public Remove(LinkedList<IGrinderRecipe> recipes) {
super(Grind.name, AppliedEnergisticsHelper.grinder, recipes);
}
@Override
public String getRecipeInfo(IGrinderEntry recipe) {
public String getRecipeInfo(IGrinderRecipe recipe) {
return LogHelper.getStackDescription(recipe.getInput());
}
}

View file

@ -1,155 +1,148 @@
package modtweaker.mods.forestry.handlers;
import forestry.api.recipes.ICarpenterManager;
import forestry.api.recipes.ICarpenterRecipe;
import forestry.api.recipes.IDescriptiveRecipe;
import forestry.api.recipes.RecipeManagers;
import com.blamejared.mtlib.helpers.LogHelper;
import forestry.api.recipes.*;
import forestry.core.recipes.ShapedRecipeCustom;
import forestry.factory.recipes.CarpenterRecipeManager;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.item.*;
import minetweaker.api.liquid.ILiquidStack;
import com.blamejared.mtlib.helpers.LogHelper;
import modtweaker.mods.forestry.*;
import modtweaker.mods.forestry.recipes.CarpenterRecipe;
import modtweaker.mods.forestry.recipes.DescriptiveRecipe;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import stanhebben.zenscript.annotations.*;
import java.util.LinkedList;
import java.util.List;
import java.util.*;
import static com.blamejared.mtlib.helpers.InputHelper.*;
import static com.blamejared.mtlib.helpers.StackHelper.matches;
@ZenClass("mods.forestry.Carpenter")
public class Carpenter {
public static final String name = "Forestry Carpenter";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Adds shaped 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)
*/
@ZenMethod
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];
}
IDescriptiveRecipe craftRecipe = new DescriptiveRecipe(3, 3, toShapedObjects(ingredients), toStack(output), toStacks(remainingItems));
MineTweakerAPI.apply(new Add(new CarpenterRecipe(packagingTime, toFluid(fluidInput), toStack(box), craftRecipe)));
}
private static IItemStack[][] transform(IItemStack[] arr, int N) {
int M = (arr.length + N - 1) / N;
IItemStack[][] mat = new IItemStack[M][];
int start = 0;
for (int r = 0; r < M; r++) {
int L = Math.min(N, arr.length - start);
mat[r] = java.util.Arrays.copyOfRange(arr, start, start + L);
start += L;
}
return mat;
}
private static class Add extends ForestryListAddition<ICarpenterRecipe> {
public Add(ICarpenterRecipe recipe) {
super(Carpenter.name, ForestryHelper.carpenter);
recipes.add(recipe);
}
@Override
public void apply() {
super.apply();
successful.forEach(ent -> {
if (!CarpenterRecipeManager.getRecipeFluids().contains(ent.getFluidResource().getFluid())) {
CarpenterRecipeManager.getRecipeFluids().add(ent.getFluidResource().getFluid());
}
});
}
@Override
protected String getRecipeInfo(ICarpenterRecipe recipe) {
return LogHelper.getStackDescription(recipe.getCraftingGridRecipe().getRecipeOutput());
}
}
/**
* 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 recipe from Carpenter
*
* @param output = recipe result
* * @param fluidInput = required type of fluid (optional)
*/
@ZenMethod
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 (fluidInput != null) {
if (matches(fluidInput, toILiquidStack(recipe.getFluidResource())))
recipes.add(recipe);
} else {
recipes.add(recipe);
}
}
}
}
if (!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Carpenter.name, output.toString()));
}
}
private static class Remove extends ForestryListRemoval<ICarpenterRecipe, ICarpenterManager> {
public Remove(List<ICarpenterRecipe> recipes) {
super(Carpenter.name, RecipeManagers.carpenterManager, recipes);
}
@Override
public void apply() {
super.apply();
successful.forEach(ent -> {
if (CarpenterRecipeManager.getRecipeFluids().contains(ent.getFluidResource().getFluid())) {
CarpenterRecipeManager.getRecipeFluids().remove(ent.getFluidResource().getFluid());
}
});
}
@Override
protected String getRecipeInfo(ICarpenterRecipe recipe) {
return LogHelper.getStackDescription(recipe.getCraftingGridRecipe().getRecipeOutput());
}
}
public static final String name = "Forestry Carpenter";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Adds shaped 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)
*/
@ZenMethod
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];
}
MineTweakerAPI.apply(new Add(new CarpenterRecipe(packagingTime, toFluid(fluidInput), toStack(box), ShapedRecipeCustom.createShapedRecipe(toStack(output), toStacks(remainingItems)))));
}
private static IItemStack[][] transform(IItemStack[] arr, int N) {
int M = (arr.length + N - 1) / N;
IItemStack[][] mat = new IItemStack[M][];
int start = 0;
for(int r = 0; r < M; r++) {
int L = Math.min(N, arr.length - start);
mat[r] = java.util.Arrays.copyOfRange(arr, start, start + L);
start += L;
}
return mat;
}
private static class Add extends ForestryListAddition<ICarpenterRecipe> {
public Add(ICarpenterRecipe recipe) {
super(Carpenter.name, ForestryHelper.carpenter);
recipes.add(recipe);
}
@Override
public void apply() {
super.apply();
successful.forEach(ent -> {
if(!CarpenterRecipeManager.getRecipeFluids().contains(ent.getFluidResource().getFluid())) {
CarpenterRecipeManager.getRecipeFluids().add(ent.getFluidResource().getFluid());
}
});
}
@Override
protected String getRecipeInfo(ICarpenterRecipe recipe) {
return LogHelper.getStackDescription(recipe.getCraftingGridRecipe().getRecipeOutput());
}
}
/**
* 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 recipe from Carpenter
*
* @param output = recipe result
* * @param fluidInput = required type of fluid (optional)
*/
@ZenMethod
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(fluidInput != null) {
if(matches(fluidInput, toILiquidStack(recipe.getFluidResource())))
recipes.add(recipe);
} else {
recipes.add(recipe);
}
}
}
}
if(!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Carpenter.name, output.toString()));
}
}
private static class Remove extends ForestryListRemoval<ICarpenterRecipe, ICarpenterManager> {
public Remove(List<ICarpenterRecipe> recipes) {
super(Carpenter.name, RecipeManagers.carpenterManager, recipes);
}
@Override
public void apply() {
super.apply();
successful.forEach(ent -> {
if(CarpenterRecipeManager.getRecipeFluids().contains(ent.getFluidResource().getFluid())) {
CarpenterRecipeManager.getRecipeFluids().remove(ent.getFluidResource().getFluid());
}
});
}
@Override
protected String getRecipeInfo(ICarpenterRecipe recipe) {
return LogHelper.getStackDescription(recipe.getCraftingGridRecipe().getRecipeOutput());
}
}
}

View file

@ -36,7 +36,12 @@ public class DescriptiveRecipe implements IDescriptiveRecipe {
public ItemStack getRecipeOutput() {
return recipe.getRecipeOutput();
}
@Nonnull
public ItemStack func_77571_b() {
return recipe.getRecipeOutput();
}
@Override
public ItemStack[] getRemainingItems(InventoryCrafting inv) {
return remainingItems;
@ -47,11 +52,8 @@ public class DescriptiveRecipe implements IDescriptiveRecipe {
return recipe.getInput();
}
@Nonnull
@Override
public ItemStack func_77571_b() {
return recipe.getRecipeOutput();
}
@Override
public boolean matches(InventoryCrafting inventoryCrafting, World world) {

View file

@ -38,6 +38,7 @@ public class TConstructHelper {
modifiers = ReflectionHelper.getStaticObject(TinkerRegistry.class, "modifiers");
modifiers_clone = new THashMap<String, IModifier>(modifiers);
fuelList = new ArrayList<>(TinkerRegistry.getSmelteryFuels());
ReflectionHelper.getFinalObject()
} catch (Exception e) {
}
}