Merge pull request #427 from laod/jei-hack

Improve forestry recipe JEI behavior. Moistener still broken.
This commit is contained in:
Jared 2017-03-11 16:53:09 +02:00 committed by GitHub
commit 2876c6ddb5
10 changed files with 121 additions and 5 deletions

View file

@ -4,6 +4,7 @@ import com.blamejared.mtlib.helpers.LogHelper;
import com.blamejared.mtlib.utils.BaseListAddition;
import forestry.api.recipes.IForestryRecipe;
import forestry.api.recipes.ICraftingProvider;
import mezz.jei.api.recipe.*;
import minetweaker.MineTweakerAPI;
import java.util.*;
@ -15,7 +16,7 @@ public abstract class ForestryListAddition<T extends IForestryRecipe> extends Ba
super(name, new ArrayList(manager.recipes()));
this.manager = manager;
}
@Override
protected abstract String getRecipeInfo(T recipe);
@ -25,7 +26,10 @@ public abstract class ForestryListAddition<T extends IForestryRecipe> extends Ba
if (recipe != null) {
if (manager.addRecipe(recipe)){
successful.add(recipe);
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(recipe);
IRecipeWrapper wrapped = wrapRecipe(recipe);
if (wrapped != null){
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(wrapped);
}
} else {
LogHelper.logError(String.format("Error adding %s Recipe for %s", name, getRecipeInfo(recipe)));
}
@ -42,11 +46,16 @@ public abstract class ForestryListAddition<T extends IForestryRecipe> extends Ba
if (!manager.removeRecipe(recipe)) {
LogHelper.logError(String.format("Error removing %s Recipe for %s", name, this.getRecipeInfo(recipe)));
}else{
MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(recipe);
IRecipeWrapper wrapped = wrapRecipe(recipe);
if (wrapped != null){
MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(wrapped);
}
}
} else {
LogHelper.logError(String.format("Error removing %s Recipe: null object", name));
}
}
}
public abstract IRecipeWrapper wrapRecipe(T recipe);
}

View file

@ -4,6 +4,7 @@ import forestry.api.recipes.ICraftingProvider;
import forestry.api.recipes.IForestryRecipe;
import com.blamejared.mtlib.helpers.LogHelper;
import com.blamejared.mtlib.utils.BaseListRemoval;
import mezz.jei.api.recipe.*;
import minetweaker.MineTweakerAPI;
import java.util.ArrayList;
@ -26,7 +27,10 @@ public abstract class ForestryListRemoval<T extends IForestryRecipe, C extends I
if (recipe != null) {
if (craftingProvider.removeRecipe(recipe)) {
successful.add(recipe);
MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(recipe);
IRecipeWrapper wrapped = wrapRecipe(recipe);
if (wrapped != null){
MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(wrapped);
}
} else {
LogHelper.logError(String.format("Error removing %s Recipe for %s", name, getRecipeInfo(recipe)));
}
@ -43,11 +47,16 @@ public abstract class ForestryListRemoval<T extends IForestryRecipe, C extends I
if (!craftingProvider.addRecipe(recipe)) {
LogHelper.logError(String.format("Error restoring %s Recipe for %s", name, getRecipeInfo(recipe)));
}else{
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(recipe);
IRecipeWrapper wrapped = wrapRecipe(recipe);
if (wrapped != null){
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(wrapped);
}
}
} else {
LogHelper.logError(String.format("Error restoring %s Recipe: null object", name));
}
}
}
public abstract IRecipeWrapper wrapRecipe(T recipe);
}

View file

@ -4,6 +4,8 @@ import com.blamejared.mtlib.helpers.LogHelper;
import forestry.api.recipes.*;
import forestry.core.recipes.ShapedRecipeCustom;
import forestry.factory.recipes.CarpenterRecipeManager;
import forestry.factory.recipes.jei.carpenter.*;
import mezz.jei.api.recipe.*;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.*;
import minetweaker.api.liquid.ILiquidStack;
@ -83,6 +85,11 @@ public class Carpenter {
protected String getRecipeInfo(ICarpenterRecipe recipe) {
return LogHelper.getStackDescription(recipe.getCraftingGridRecipe().getRecipeOutput());
}
@Override
public IRecipeWrapper wrapRecipe(ICarpenterRecipe recipe){
return new CarpenterRecipeWrapper(recipe);
}
}
/**
@ -151,5 +158,10 @@ public class Carpenter {
protected String getRecipeInfo(ICarpenterRecipe recipe) {
return LogHelper.getStackDescription(recipe.getCraftingGridRecipe().getRecipeOutput());
}
@Override
public IRecipeWrapper wrapRecipe(ICarpenterRecipe recipe){
return new CarpenterRecipeWrapper(recipe);
}
}
}

View file

@ -2,6 +2,7 @@ package modtweaker.mods.forestry.handlers;
import com.blamejared.mtlib.helpers.LogHelper;
import forestry.api.recipes.*;
import mezz.jei.api.recipe.*;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.*;
import modtweaker.mods.forestry.*;
@ -13,6 +14,7 @@ import java.util.*;
import static com.blamejared.mtlib.helpers.InputHelper.*;
import static com.blamejared.mtlib.helpers.StackHelper.matches;
import forestry.factory.recipes.jei.centrifuge.*;
@ZenClass("mods.forestry.Centrifuge")
@ -49,6 +51,11 @@ public class Centrifuge {
protected String getRecipeInfo(ICentrifugeRecipe recipe) {
return LogHelper.getStackDescription(recipe.getInput());
}
@Override
public IRecipeWrapper wrapRecipe(ICentrifugeRecipe recipe){
return new CentrifugeRecipeWrapper(recipe);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -85,5 +92,10 @@ public class Centrifuge {
protected String getRecipeInfo(ICentrifugeRecipe recipe) {
return LogHelper.getStackDescription(recipe.getInput());
}
@Override
public IRecipeWrapper wrapRecipe(ICentrifugeRecipe recipe){
return new CentrifugeRecipeWrapper(recipe);
}
}
}

View file

@ -5,6 +5,8 @@ import forestry.api.fuels.FuelManager;
import forestry.api.recipes.IFermenterManager;
import forestry.api.recipes.IFermenterRecipe;
import forestry.api.recipes.RecipeManagers;
import forestry.factory.recipes.jei.fermenter.*;
import mezz.jei.api.recipe.*;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
@ -61,6 +63,11 @@ public class Fermenter {
public String getRecipeInfo(IFermenterRecipe recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
@Override
public IRecipeWrapper wrapRecipe(IFermenterRecipe recipe){
return new FermenterRecipeWrapper(recipe, recipe.getResource());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -103,6 +110,11 @@ public class Fermenter {
protected String getRecipeInfo(IFermenterRecipe recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
@Override
public IRecipeWrapper wrapRecipe(IFermenterRecipe recipe){
return new FermenterRecipeWrapper(recipe, recipe.getResource());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View file

@ -4,6 +4,7 @@ import com.blamejared.mtlib.helpers.LogHelper;
import com.blamejared.mtlib.utils.*;
import forestry.api.fuels.*;
import forestry.api.recipes.*;
import mezz.jei.api.recipe.*;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.*;
import modtweaker.mods.forestry.*;
@ -47,6 +48,12 @@ public class Moistener {
public String getRecipeInfo(IMoistenerRecipe recipe) {
return LogHelper.getStackDescription(recipe.getProduct());
}
//It's not clear to me how the moistener recipes should be wrapped
@Override
public IRecipeWrapper wrapRecipe(IMoistenerRecipe recipe){
return null;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -81,6 +88,12 @@ public class Moistener {
public String getRecipeInfo(IMoistenerRecipe recipe) {
return LogHelper.getStackDescription(recipe.getProduct());
}
//It's not clear to me how the moistener recipes should be wrapped
@Override
public IRecipeWrapper wrapRecipe(IMoistenerRecipe recipe){
return null;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View file

@ -2,6 +2,8 @@ package modtweaker.mods.forestry.handlers;
import com.blamejared.mtlib.helpers.LogHelper;
import forestry.api.recipes.*;
import forestry.factory.recipes.jei.squeezer.*;
import mezz.jei.api.recipe.*;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.*;
import minetweaker.api.liquid.ILiquidStack;
@ -46,12 +48,18 @@ public class Squeezer {
public Add(ISqueezerRecipe recipe) {
super(Squeezer.name, RecipeManagers.squeezerManager);
recipes.add(recipe);
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(new SqueezerRecipeWrapper(recipe));
}
@Override
public String getRecipeInfo(ISqueezerRecipe recipe) {
return LogHelper.getStackDescription(recipe.getFluidOutput());
}
@Override
public IRecipeWrapper wrapRecipe(ISqueezerRecipe recipe){
return new SqueezerRecipeWrapper(recipe);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -106,5 +114,10 @@ public class Squeezer {
public String getRecipeInfo(ISqueezerRecipe recipe) {
return LogHelper.getStackDescription(recipe.getFluidOutput());
}
@Override
public IRecipeWrapper wrapRecipe(ISqueezerRecipe recipe){
return new SqueezerRecipeWrapper(recipe);
}
}
}

View file

@ -2,6 +2,8 @@ package modtweaker.mods.forestry.handlers;
import com.blamejared.mtlib.helpers.LogHelper;
import forestry.api.recipes.*;
import forestry.factory.recipes.jei.still.*;
import mezz.jei.api.recipe.*;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.liquid.ILiquidStack;
@ -48,6 +50,11 @@ public class Still {
public String getRecipeInfo(IStillRecipe recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
@Override
public IRecipeWrapper wrapRecipe(IStillRecipe recipe){
return new StillRecipeWrapper(recipe);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -90,5 +97,10 @@ public class Still {
public String getRecipeInfo(IStillRecipe recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
@Override
public IRecipeWrapper wrapRecipe(IStillRecipe recipe){
return new StillRecipeWrapper(recipe);
}
}
}

View file

@ -2,6 +2,8 @@ package modtweaker.mods.forestry.handlers;
import com.blamejared.mtlib.helpers.LogHelper;
import forestry.api.recipes.*;
import forestry.factory.recipes.jei.fabricator.*;
import mezz.jei.api.recipe.*;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.*;
import modtweaker.mods.forestry.*;
@ -71,6 +73,12 @@ public class ThermionicFabricator {
public String getRecipeInfo(IFabricatorSmeltingRecipe recipe) {
return LogHelper.getStackDescription(recipe.getResource());
}
//It's not clear to me how the smelting recipes should be wrapped
@Override
public IRecipeWrapper wrapRecipe(IFabricatorSmeltingRecipe recipe){
return null;
}
}
private static class AddCast extends ForestryListAddition<IFabricatorRecipe> {
@ -84,6 +92,11 @@ public class ThermionicFabricator {
public String getRecipeInfo(IFabricatorRecipe recipe) {
return LogHelper.getStackDescription(recipe.getRecipeOutput());
}
@Override
public IRecipeWrapper wrapRecipe(IFabricatorRecipe recipe){
return new FabricatorRecipeWrapper(recipe);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -142,6 +155,12 @@ public class ThermionicFabricator {
public String getRecipeInfo(IFabricatorSmeltingRecipe recipe) {
return LogHelper.getStackDescription(recipe.getResource());
}
//It's not clear to me how the smelting recipes should be wrapped
@Override
public IRecipeWrapper wrapRecipe(IFabricatorSmeltingRecipe recipe){
return null;
}
}
private static class RemoveCasts extends ForestryListRemoval<IFabricatorRecipe, IFabricatorManager> {
@ -154,5 +173,10 @@ public class ThermionicFabricator {
public String getRecipeInfo(IFabricatorRecipe recipe) {
return LogHelper.getStackDescription(recipe.getRecipeOutput());
}
@Override
public IRecipeWrapper wrapRecipe(IFabricatorRecipe recipe){
return new FabricatorRecipeWrapper(recipe);
}
}
}