Added NEI stack iteration implementation for Metallurgic infuses
This commit is contained in:
parent
2cf27c698d
commit
1ec410d67c
1 changed files with 20 additions and 16 deletions
|
@ -1,6 +1,11 @@
|
||||||
package mekanism.client.nei;
|
package mekanism.client.nei;
|
||||||
|
|
||||||
|
import static codechicken.core.gui.GuiDraw.changeTexture;
|
||||||
|
import static codechicken.core.gui.GuiDraw.drawTexturedModalRect;
|
||||||
|
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -19,7 +24,6 @@ import org.lwjgl.opengl.GL11;
|
||||||
import codechicken.nei.NEIServerUtils;
|
import codechicken.nei.NEIServerUtils;
|
||||||
import codechicken.nei.PositionedStack;
|
import codechicken.nei.PositionedStack;
|
||||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||||
import static codechicken.core.gui.GuiDraw.*;
|
|
||||||
|
|
||||||
public class MetallurgicInfuserRecipeHandler extends TemplateRecipeHandler
|
public class MetallurgicInfuserRecipeHandler extends TemplateRecipeHandler
|
||||||
{
|
{
|
||||||
|
@ -54,17 +58,19 @@ public class MetallurgicInfuserRecipeHandler extends TemplateRecipeHandler
|
||||||
return "mekanism.infuser";
|
return "mekanism.infuser";
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getInfuseStack(InfuseType type)
|
public List<ItemStack> getInfuseStacks(InfuseType type)
|
||||||
{
|
{
|
||||||
|
List<ItemStack> ret = new ArrayList<ItemStack>();
|
||||||
|
|
||||||
for(Map.Entry<ItemStack, InfuseObject> obj : InfuseRegistry.getObjectMap().entrySet())
|
for(Map.Entry<ItemStack, InfuseObject> obj : InfuseRegistry.getObjectMap().entrySet())
|
||||||
{
|
{
|
||||||
if(obj.getValue().type == type)
|
if(obj.getValue().type == type)
|
||||||
{
|
{
|
||||||
return obj.getKey();
|
ret.add(obj.getKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Entry<InfusionInput, InfusionOutput>> getRecipes()
|
public Set<Entry<InfusionInput, InfusionOutput>> getRecipes()
|
||||||
|
@ -119,7 +125,7 @@ public class MetallurgicInfuserRecipeHandler extends TemplateRecipeHandler
|
||||||
{
|
{
|
||||||
for(Map.Entry irecipe : getRecipes())
|
for(Map.Entry irecipe : getRecipes())
|
||||||
{
|
{
|
||||||
arecipes.add(new CachedIORecipe(irecipe, getInfuseStack(((InfusionInput)irecipe.getKey()).infusionType), ((InfusionInput)irecipe.getKey()).infusionType));
|
arecipes.add(new CachedIORecipe(irecipe, getInfuseStacks(((InfusionInput)irecipe.getKey()).infusionType), ((InfusionInput)irecipe.getKey()).infusionType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -140,7 +146,7 @@ public class MetallurgicInfuserRecipeHandler extends TemplateRecipeHandler
|
||||||
{
|
{
|
||||||
if(NEIServerUtils.areStacksSameTypeCrafting(((InfusionOutput)irecipe.getValue()).resource, result))
|
if(NEIServerUtils.areStacksSameTypeCrafting(((InfusionOutput)irecipe.getValue()).resource, result))
|
||||||
{
|
{
|
||||||
arecipes.add(new CachedIORecipe(irecipe, getInfuseStack(((InfusionInput)irecipe.getKey()).infusionType), ((InfusionInput)irecipe.getKey()).infusionType));
|
arecipes.add(new CachedIORecipe(irecipe, getInfuseStacks(((InfusionInput)irecipe.getKey()).infusionType), ((InfusionInput)irecipe.getKey()).infusionType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,16 +158,17 @@ public class MetallurgicInfuserRecipeHandler extends TemplateRecipeHandler
|
||||||
{
|
{
|
||||||
if(NEIServerUtils.areStacksSameTypeCrafting(((InfusionInput)irecipe.getKey()).inputStack, ingredient))
|
if(NEIServerUtils.areStacksSameTypeCrafting(((InfusionInput)irecipe.getKey()).inputStack, ingredient))
|
||||||
{
|
{
|
||||||
arecipes.add(new CachedIORecipe(irecipe, getInfuseStack(((InfusionInput)irecipe.getKey()).infusionType), ((InfusionInput)irecipe.getKey()).infusionType));
|
arecipes.add(new CachedIORecipe(irecipe, getInfuseStacks(((InfusionInput)irecipe.getKey()).infusionType), ((InfusionInput)irecipe.getKey()).infusionType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe
|
public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe
|
||||||
{
|
{
|
||||||
|
public List<ItemStack> infuseStacks;
|
||||||
|
|
||||||
public PositionedStack inputStack;
|
public PositionedStack inputStack;
|
||||||
public PositionedStack outputStack;
|
public PositionedStack outputStack;
|
||||||
public PositionedStack infuseStack;
|
|
||||||
|
|
||||||
public InfuseType infusionType;
|
public InfuseType infusionType;
|
||||||
|
|
||||||
|
@ -180,27 +187,24 @@ public class MetallurgicInfuserRecipeHandler extends TemplateRecipeHandler
|
||||||
@Override
|
@Override
|
||||||
public PositionedStack getOtherStack()
|
public PositionedStack getOtherStack()
|
||||||
{
|
{
|
||||||
return infuseStack;
|
return new PositionedStack(infuseStacks.get(cycleticks/40 % infuseStacks.size()), 12, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CachedIORecipe(ItemStack input, ItemStack output, ItemStack infuse, InfuseType type)
|
public CachedIORecipe(ItemStack input, ItemStack output, List<ItemStack> infuses, InfuseType type)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
inputStack = new PositionedStack(input, 46, 28);
|
inputStack = new PositionedStack(input, 46, 28);
|
||||||
outputStack = new PositionedStack(output, 104, 28);
|
outputStack = new PositionedStack(output, 104, 28);
|
||||||
|
|
||||||
if(infuse != null)
|
infuseStacks = infuses;
|
||||||
{
|
|
||||||
infuseStack = new PositionedStack(infuse, 12, 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
infusionType = type;
|
infusionType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CachedIORecipe(Map.Entry recipe, ItemStack infuse, InfuseType type)
|
public CachedIORecipe(Map.Entry recipe, List<ItemStack> infuses, InfuseType type)
|
||||||
{
|
{
|
||||||
this(((InfusionInput)recipe.getKey()).inputStack, ((InfusionOutput)recipe.getValue()).resource, infuse, type);
|
this(((InfusionInput)recipe.getKey()).inputStack, ((InfusionOutput)recipe.getValue()).resource, infuses, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue