Fixed Solar Evaporation Controller recipe handler
This commit is contained in:
parent
62791baec7
commit
cd25811f31
3 changed files with 31 additions and 35 deletions
|
@ -102,6 +102,7 @@ public class NEIMekanismConfig implements IConfigureNEI
|
||||||
API.setGuiOffset(GuiChemicalWasher.class, ChemicalWasherRecipeHandler.xOffset, ChemicalWasherRecipeHandler.yOffset);
|
API.setGuiOffset(GuiChemicalWasher.class, ChemicalWasherRecipeHandler.xOffset, ChemicalWasherRecipeHandler.yOffset);
|
||||||
API.setGuiOffset(GuiChemicalCrystallizer.class, ChemicalCrystallizerRecipeHandler.xOffset, ChemicalCrystallizerRecipeHandler.yOffset);
|
API.setGuiOffset(GuiChemicalCrystallizer.class, ChemicalCrystallizerRecipeHandler.xOffset, ChemicalCrystallizerRecipeHandler.yOffset);
|
||||||
API.setGuiOffset(GuiPRC.class, PRCRecipeHandler.xOffset, PRCRecipeHandler.yOffset);
|
API.setGuiOffset(GuiPRC.class, PRCRecipeHandler.xOffset, PRCRecipeHandler.yOffset);
|
||||||
|
API.setGuiOffset(GuiSolarEvaporationController.class, SolarEvaporationRecipeHandler.xOffset, SolarEvaporationRecipeHandler.yOffset);
|
||||||
|
|
||||||
GuiContainerManager.addSlotClickHandler(new MekanismSlotClickHandler());
|
GuiContainerManager.addSlotClickHandler(new MekanismSlotClickHandler());
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,21 @@
|
||||||
package mekanism.client.nei;
|
package mekanism.client.nei;
|
||||||
|
|
||||||
import java.awt.*;
|
import static codechicken.lib.gui.GuiDraw.changeTexture;
|
||||||
import java.util.HashMap;
|
import static codechicken.lib.gui.GuiDraw.drawTexturedModalRect;
|
||||||
|
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import mekanism.client.gui.GuiSolarEvaporationController;
|
import mekanism.client.gui.GuiSolarEvaporationController;
|
||||||
import mekanism.common.ObfuscatedNames;
|
import mekanism.common.ObfuscatedNames;
|
||||||
|
import mekanism.common.recipe.RecipeHandler.Recipe;
|
||||||
|
import mekanism.common.recipe.machines.SolarEvaporationRecipe;
|
||||||
import mekanism.common.util.LangUtils;
|
import mekanism.common.util.LangUtils;
|
||||||
import mekanism.common.util.MekanismUtils;
|
import mekanism.common.util.MekanismUtils;
|
||||||
|
|
||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||||
import net.minecraftforge.fluids.FluidRegistry;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
@ -24,26 +26,13 @@ import codechicken.nei.PositionedStack;
|
||||||
import codechicken.nei.recipe.GuiRecipe;
|
import codechicken.nei.recipe.GuiRecipe;
|
||||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||||
|
|
||||||
import static codechicken.lib.gui.GuiDraw.changeTexture;
|
|
||||||
import static codechicken.lib.gui.GuiDraw.drawTexturedModalRect;
|
|
||||||
|
|
||||||
public class SolarEvaporationRecipeHandler extends BaseRecipeHandler
|
public class SolarEvaporationRecipeHandler extends BaseRecipeHandler
|
||||||
{
|
{
|
||||||
private int ticksPassed;
|
private int ticksPassed;
|
||||||
|
|
||||||
private static Map<FluidStack, FluidStack> recipes = new HashMap<FluidStack, FluidStack>();
|
|
||||||
|
|
||||||
public static int xOffset = 5;
|
public static int xOffset = 5;
|
||||||
public static int yOffset = 12;
|
public static int yOffset = 12;
|
||||||
|
|
||||||
static
|
|
||||||
{
|
|
||||||
if(recipes.isEmpty())
|
|
||||||
{
|
|
||||||
recipes.put(new FluidStack(FluidRegistry.WATER, 1), new FluidStack(FluidRegistry.getFluid("brine"), 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRecipeName()
|
public String getRecipeName()
|
||||||
{
|
{
|
||||||
|
@ -73,9 +62,15 @@ public class SolarEvaporationRecipeHandler extends BaseRecipeHandler
|
||||||
return "mekanism.solarevaporation";
|
return "mekanism.solarevaporation";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Entry<FluidStack, FluidStack>> getRecipes()
|
public Collection<SolarEvaporationRecipe> getRecipes()
|
||||||
{
|
{
|
||||||
return recipes.entrySet();
|
return Recipe.SOLAR_EVAPORATION_PLANT.get().values();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadTransferRects()
|
||||||
|
{
|
||||||
|
transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(49-xOffset, 20-yOffset, 78, 38), getRecipeId(), new Object[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -117,16 +112,16 @@ public class SolarEvaporationRecipeHandler extends BaseRecipeHandler
|
||||||
{
|
{
|
||||||
if(outputId.equals(getRecipeId()))
|
if(outputId.equals(getRecipeId()))
|
||||||
{
|
{
|
||||||
for(Map.Entry irecipe : getRecipes())
|
for(SolarEvaporationRecipe irecipe : getRecipes())
|
||||||
{
|
{
|
||||||
arecipes.add(new CachedIORecipe(irecipe));
|
arecipes.add(new CachedIORecipe(irecipe));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(outputId.equals("fluid") && results.length == 1 && results[0] instanceof FluidStack)
|
else if(outputId.equals("fluid") && results.length == 1 && results[0] instanceof FluidStack)
|
||||||
{
|
{
|
||||||
for(Map.Entry<FluidStack, FluidStack> irecipe : getRecipes())
|
for(SolarEvaporationRecipe irecipe : getRecipes())
|
||||||
{
|
{
|
||||||
if(((FluidStack)results[0]).isFluidEqual(irecipe.getValue()))
|
if(((FluidStack)results[0]).isFluidEqual(irecipe.recipeOutput.output))
|
||||||
{
|
{
|
||||||
arecipes.add(new CachedIORecipe(irecipe));
|
arecipes.add(new CachedIORecipe(irecipe));
|
||||||
}
|
}
|
||||||
|
@ -142,9 +137,9 @@ public class SolarEvaporationRecipeHandler extends BaseRecipeHandler
|
||||||
{
|
{
|
||||||
if(inputId.equals("fluid") && ingredients.length == 1 && ingredients[0] instanceof FluidStack)
|
if(inputId.equals("fluid") && ingredients.length == 1 && ingredients[0] instanceof FluidStack)
|
||||||
{
|
{
|
||||||
for(Map.Entry<FluidStack, FluidStack> irecipe : getRecipes())
|
for(SolarEvaporationRecipe irecipe : getRecipes())
|
||||||
{
|
{
|
||||||
if(irecipe.getKey().isFluidEqual((FluidStack)ingredients[0]))
|
if(irecipe.recipeInput.ingredient.isFluidEqual((FluidStack)ingredients[0]))
|
||||||
{
|
{
|
||||||
arecipes.add(new CachedIORecipe(irecipe));
|
arecipes.add(new CachedIORecipe(irecipe));
|
||||||
}
|
}
|
||||||
|
@ -284,9 +279,9 @@ public class SolarEvaporationRecipeHandler extends BaseRecipeHandler
|
||||||
fluidOutput = output;
|
fluidOutput = output;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CachedIORecipe(Map.Entry recipe)
|
public CachedIORecipe(SolarEvaporationRecipe recipe)
|
||||||
{
|
{
|
||||||
this((FluidStack)recipe.getKey(), (FluidStack)recipe.getValue());
|
this((FluidStack)recipe.recipeInput.ingredient, (FluidStack)recipe.recipeOutput.output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,10 +91,10 @@ public class TileEntitySolarEvaporationController extends TileEntitySolarEvapora
|
||||||
updateTemperature();
|
updateTemperature();
|
||||||
manageBuckets();
|
manageBuckets();
|
||||||
|
|
||||||
if(canOperate())
|
|
||||||
{
|
|
||||||
SolarEvaporationRecipe recipe = getRecipe();
|
SolarEvaporationRecipe recipe = getRecipe();
|
||||||
|
|
||||||
|
if(canOperate(recipe))
|
||||||
|
{
|
||||||
int outputNeeded = outputTank.getCapacity()-outputTank.getFluidAmount();
|
int outputNeeded = outputTank.getCapacity()-outputTank.getFluidAmount();
|
||||||
int inputStored = inputTank.getFluidAmount();
|
int inputStored = inputTank.getFluidAmount();
|
||||||
|
|
||||||
|
@ -192,19 +192,19 @@ public class TileEntitySolarEvaporationController extends TileEntitySolarEvapora
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canOperate()
|
public boolean canOperate(SolarEvaporationRecipe recipe)
|
||||||
{
|
{
|
||||||
if(!structured || height < 3 || height > 18 || inputTank.getFluid() == null || getTempMultiplier() == 0)
|
if(!structured || height < 3 || height > 18 || inputTank.getFluid() == null || getTempMultiplier() == 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getRecipe() == null)
|
if(recipe != null && recipe.canOperate(inputTank, outputTank))
|
||||||
{
|
{
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void manageBuckets()
|
private void manageBuckets()
|
||||||
|
|
Loading…
Reference in a new issue