From fd5df3107dc788b3b0227324718f8a1b7ca14243 Mon Sep 17 00:00:00 2001 From: Tom Elfring Date: Mon, 26 Jun 2017 12:59:03 +0200 Subject: [PATCH] Reenable JEI --- .../client/jei/BaseRecipeCategory.java | 191 +++++++++++ .../mekanism/client/jei/GasStackHelper.java | 103 ++++++ .../client/jei/GuiElementHandler.java | 45 +++ .../java/mekanism/client/jei/MekanismJEI.java | 320 ++++++++++++++++++ .../client/jei/gas/GasStackRenderer.java | 230 +++++++++++++ .../AdvancedMachineRecipeCategory.java | 115 +++++++ .../machine/AdvancedMachineRecipeWrapper.java | 54 +++ .../client/jei/machine/BaseRecipeHandler.java | 46 +++ .../client/jei/machine/BaseRecipeWrapper.java | 9 + .../machine/ChanceMachineRecipeCategory.java | 105 ++++++ .../machine/ChanceMachineRecipeWrapper.java | 51 +++ .../jei/machine/MachineRecipeCategory.java | 90 +++++ .../jei/machine/MachineRecipeWrapper.java | 33 ++ ...ChemicalInjectionChamberRecipeWrapper.java | 50 +++ .../advanced/CombinerRecipeWrapper.java | 25 ++ .../OsmiumCompressorRecipeWrapper.java | 25 ++ .../PurificationChamberRecipeWrapper.java | 34 ++ .../machine/basic/CrusherRecipeWrapper.java | 13 + .../basic/EnrichmentRecipeWrapper.java | 13 + .../chance/PrecisionSawmillRecipeWrapper.java | 13 + .../ChemicalCrystallizerRecipeCategory.java | 76 +++++ .../ChemicalCrystallizerRecipeWrapper.java | 52 +++ ...micalDissolutionChamberRecipeCategory.java | 79 +++++ ...emicalDissolutionChamberRecipeWrapper.java | 58 ++++ .../ChemicalInfuserRecipeCategory.java | 76 +++++ .../ChemicalInfuserRecipeWrapper.java | 60 ++++ .../ChemicalOxidizerRecipeCategory.java | 98 ++++++ .../ChemicalOxidizerRecipeWrapper.java | 52 +++ .../ChemicalWasherRecipeCategory.java | 90 +++++ .../chemical/ChemicalWasherRecipeWrapper.java | 58 ++++ .../ElectrolyticSeparatorRecipeCategory.java | 137 ++++++++ .../ElectrolyticSeparatorRecipeWrapper.java | 56 +++ .../MetallurgicInfuserRecipeCategory.java | 131 +++++++ .../MetallurgicInfuserRecipeWrapper.java | 39 +++ .../jei/machine/other/PRCRecipeCategory.java | 142 ++++++++ .../jei/machine/other/PRCRecipeWrapper.java | 60 ++++ .../RotaryCondensentratorRecipeCategory.java | 87 +++++ .../RotaryCondensentratorRecipeWrapper.java | 76 +++++ .../other/SolarNeutronRecipeCategory.java | 70 ++++ .../other/SolarNeutronRecipeWrapper.java | 55 +++ .../ThermalEvaporationRecipeCategory.java | 83 +++++ .../ThermalEvaporationRecipeWrapper.java | 32 ++ .../generators/client/jei/GeneratorsJEI.java | 18 + 43 files changed, 3250 insertions(+) create mode 100644 src/main/java/mekanism/client/jei/BaseRecipeCategory.java create mode 100644 src/main/java/mekanism/client/jei/GasStackHelper.java create mode 100644 src/main/java/mekanism/client/jei/GuiElementHandler.java create mode 100644 src/main/java/mekanism/client/jei/MekanismJEI.java create mode 100644 src/main/java/mekanism/client/jei/gas/GasStackRenderer.java create mode 100644 src/main/java/mekanism/client/jei/machine/AdvancedMachineRecipeCategory.java create mode 100644 src/main/java/mekanism/client/jei/machine/AdvancedMachineRecipeWrapper.java create mode 100644 src/main/java/mekanism/client/jei/machine/BaseRecipeHandler.java create mode 100644 src/main/java/mekanism/client/jei/machine/BaseRecipeWrapper.java create mode 100644 src/main/java/mekanism/client/jei/machine/ChanceMachineRecipeCategory.java create mode 100644 src/main/java/mekanism/client/jei/machine/ChanceMachineRecipeWrapper.java create mode 100644 src/main/java/mekanism/client/jei/machine/MachineRecipeCategory.java create mode 100644 src/main/java/mekanism/client/jei/machine/MachineRecipeWrapper.java create mode 100644 src/main/java/mekanism/client/jei/machine/advanced/ChemicalInjectionChamberRecipeWrapper.java create mode 100644 src/main/java/mekanism/client/jei/machine/advanced/CombinerRecipeWrapper.java create mode 100644 src/main/java/mekanism/client/jei/machine/advanced/OsmiumCompressorRecipeWrapper.java create mode 100644 src/main/java/mekanism/client/jei/machine/advanced/PurificationChamberRecipeWrapper.java create mode 100644 src/main/java/mekanism/client/jei/machine/basic/CrusherRecipeWrapper.java create mode 100644 src/main/java/mekanism/client/jei/machine/basic/EnrichmentRecipeWrapper.java create mode 100644 src/main/java/mekanism/client/jei/machine/chance/PrecisionSawmillRecipeWrapper.java create mode 100644 src/main/java/mekanism/client/jei/machine/chemical/ChemicalCrystallizerRecipeCategory.java create mode 100644 src/main/java/mekanism/client/jei/machine/chemical/ChemicalCrystallizerRecipeWrapper.java create mode 100644 src/main/java/mekanism/client/jei/machine/chemical/ChemicalDissolutionChamberRecipeCategory.java create mode 100644 src/main/java/mekanism/client/jei/machine/chemical/ChemicalDissolutionChamberRecipeWrapper.java create mode 100644 src/main/java/mekanism/client/jei/machine/chemical/ChemicalInfuserRecipeCategory.java create mode 100644 src/main/java/mekanism/client/jei/machine/chemical/ChemicalInfuserRecipeWrapper.java create mode 100644 src/main/java/mekanism/client/jei/machine/chemical/ChemicalOxidizerRecipeCategory.java create mode 100644 src/main/java/mekanism/client/jei/machine/chemical/ChemicalOxidizerRecipeWrapper.java create mode 100644 src/main/java/mekanism/client/jei/machine/chemical/ChemicalWasherRecipeCategory.java create mode 100644 src/main/java/mekanism/client/jei/machine/chemical/ChemicalWasherRecipeWrapper.java create mode 100644 src/main/java/mekanism/client/jei/machine/other/ElectrolyticSeparatorRecipeCategory.java create mode 100644 src/main/java/mekanism/client/jei/machine/other/ElectrolyticSeparatorRecipeWrapper.java create mode 100644 src/main/java/mekanism/client/jei/machine/other/MetallurgicInfuserRecipeCategory.java create mode 100644 src/main/java/mekanism/client/jei/machine/other/MetallurgicInfuserRecipeWrapper.java create mode 100644 src/main/java/mekanism/client/jei/machine/other/PRCRecipeCategory.java create mode 100644 src/main/java/mekanism/client/jei/machine/other/PRCRecipeWrapper.java create mode 100644 src/main/java/mekanism/client/jei/machine/other/RotaryCondensentratorRecipeCategory.java create mode 100644 src/main/java/mekanism/client/jei/machine/other/RotaryCondensentratorRecipeWrapper.java create mode 100644 src/main/java/mekanism/client/jei/machine/other/SolarNeutronRecipeCategory.java create mode 100644 src/main/java/mekanism/client/jei/machine/other/SolarNeutronRecipeWrapper.java create mode 100644 src/main/java/mekanism/client/jei/machine/other/ThermalEvaporationRecipeCategory.java create mode 100644 src/main/java/mekanism/client/jei/machine/other/ThermalEvaporationRecipeWrapper.java create mode 100644 src/main/java/mekanism/generators/client/jei/GeneratorsJEI.java diff --git a/src/main/java/mekanism/client/jei/BaseRecipeCategory.java b/src/main/java/mekanism/client/jei/BaseRecipeCategory.java new file mode 100644 index 000000000..3773b0ae9 --- /dev/null +++ b/src/main/java/mekanism/client/jei/BaseRecipeCategory.java @@ -0,0 +1,191 @@ +package mekanism.client.jei; + +import mekanism.api.gas.GasStack; +import mekanism.client.gui.IGuiWrapper; +import mekanism.client.gui.element.GuiElement; +import mekanism.client.gui.element.GuiProgress.ProgressBar; +import mekanism.client.render.MekanismRenderer; +import mekanism.client.render.MekanismRenderer.FluidType; +import mekanism.common.util.LangUtils; +import mezz.jei.api.gui.IDrawable; +import mezz.jei.api.recipe.IRecipeCategory; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.FluidStack; +import org.lwjgl.opengl.GL11; + +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public abstract class BaseRecipeCategory implements IRecipeCategory, IGuiWrapper +{ + public static final GuiDummy gui = new GuiDummy(); + + public String recipeName; + public String unlocalizedName; + + public String guiTexture; + public ResourceLocation guiLocation; + + public ProgressBar progressBar; + + public int xOffset = 28; + public int yOffset = 16; + + public BaseRecipeCategory(String gui, String name, String unlocalized, ProgressBar progress) + { + guiTexture = gui; + guiLocation = new ResourceLocation(guiTexture); + + progressBar = progress; + + recipeName = name; + unlocalizedName = unlocalized; + + addGuiElements(); + } + + @Override + public String getUid() + { + return "mekanism." + recipeName; + } + + @Override + public String getTitle() + { + return LangUtils.localize(unlocalizedName); + } + + @Override + public String getModName() + { + return "Mekanism"; + } + + @Override + public void drawExtras(Minecraft minecraft) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + changeTexture(guiLocation); + + for(GuiElement e : guiElements) + { + e.renderBackground(0, 0, -xOffset, -yOffset); + } + } + + @Override + public void drawTexturedRect(int x, int y, int u, int v, int w, int h) + { + gui.drawTexturedModalRect(x, y, u, v, w, h); + } + + @Override + public void drawTexturedRectFromIcon(int x, int y, TextureAtlasSprite icon, int w, int h) + { + gui.drawTexturedModalRect(x, y, icon, w, h); + } + + @Override + public void displayTooltip(String s, int xAxis, int yAxis) {} + + @Override + public void displayTooltips(List list, int xAxis, int yAxis) {} + + @Override + public FontRenderer getFont() + { + return null; + } + + public void displayGauge(int length, int xPos, int yPos, int overlayX, int overlayY, int scale, FluidStack fluid, GasStack gas) + { + if(fluid == null && gas == null) + { + return; + } + + int start = 0; + + while(true) + { + int renderRemaining = 0; + + if(scale > 16) + { + renderRemaining = 16; + scale -= 16; + } + else { + renderRemaining = scale; + scale = 0; + } + + changeTexture(MekanismRenderer.getBlocksTexture()); + + if(fluid != null) + { + gui.drawTexturedModalRect(xPos, yPos + length - renderRemaining - start, MekanismRenderer.getFluidTexture(fluid.getFluid(), FluidType.STILL), 16, 16 - (16 - renderRemaining)); + } + else if(gas != null) + { + gui.drawTexturedModalRect(xPos, yPos + length - renderRemaining - start, gas.getGas().getSprite(), 16, 16 - (16 - renderRemaining)); + } + + start+=16; + + if(renderRemaining == 0 || scale == 0) + { + break; + } + } + + changeTexture(guiLocation); + gui.drawTexturedModalRect(xPos, yPos, overlayX, overlayY, 16, length+1); + } + + public void displayGauge(int xPos, int yPos, int sizeX, int sizeY, GasStack gas) + { + if(gas == null) + { + return; + } + + changeTexture(MekanismRenderer.getBlocksTexture()); + gui.drawTexturedModalRect(xPos, yPos, gas.getGas().getSprite(), sizeX, sizeY); + } + + public String stripTexture() + { + return guiTexture.replace("mekanism:gui/", ""); + } + + public void changeTexture(ResourceLocation texture) + { + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + } + + public Set guiElements = new HashSet(); + + public void addGuiElements() {} + + public static class GuiDummy extends Gui {} + + @Override + public IDrawable getIcon() + { + return null; + } + + @Override + public List getTooltipStrings(int mouseX, int mouseY) + { + return Collections.emptyList(); + } +} diff --git a/src/main/java/mekanism/client/jei/GasStackHelper.java b/src/main/java/mekanism/client/jei/GasStackHelper.java new file mode 100644 index 000000000..4612c54fe --- /dev/null +++ b/src/main/java/mekanism/client/jei/GasStackHelper.java @@ -0,0 +1,103 @@ +package mekanism.client.jei; + +import com.google.common.base.MoreObjects; +import mekanism.api.gas.Gas; +import mekanism.api.gas.GasStack; +import mezz.jei.api.ingredients.IIngredientHelper; +import net.minecraft.item.ItemStack; + +import javax.annotation.Nullable; +import java.awt.*; +import java.util.Collections; +import java.util.List; + +public class GasStackHelper implements IIngredientHelper +{ + @Override + public List expandSubtypes(List contained) + { + return contained; + } + + @Override + @Nullable + public GasStack getMatch(Iterable ingredients, GasStack toMatch) + { + for(GasStack stack : ingredients) + { + if(toMatch.getGas() == stack.getGas()) + { + return stack; + } + } + + return null; + } + + @Override + public String getDisplayName(GasStack ingredient) + { + return ingredient.getGas().getLocalizedName(); + } + + @Override + public String getUniqueId(GasStack ingredient) + { + return "gas:" + ingredient.getGas().getName(); + } + + @Override + public String getWildcardId(GasStack ingredient) + { + return getUniqueId(ingredient); + } + + @Override + public String getModId(GasStack ingredient) + { + return ingredient.getGas().getIcon().getResourceDomain(); + } + + @Override + public Iterable getColors(GasStack ingredient) + { + return Collections.emptyList(); + } + + @Override + public String getResourceId(GasStack ingredient) + { + return ingredient.getGas().getUnlocalizedName(); + } + + @Override + public ItemStack cheatIngredient(GasStack ingredient, boolean fullStack) + { + return ItemStack.EMPTY; + } + + @Override + public GasStack copyIngredient(GasStack ingredient) { + return ingredient.copy(); + } + + @Override + public String getErrorInfo(GasStack ingredient) + { + MoreObjects.ToStringHelper toStringHelper = MoreObjects.toStringHelper(GasStack.class); + + Gas gas = ingredient.getGas(); + + if(gas != null) + { + toStringHelper.add("Gas", gas.getLocalizedName()); + } + else { + toStringHelper.add("Gas", "null"); + } + + toStringHelper.add("Amount", ingredient.amount); + + return toStringHelper.toString(); + } +} diff --git a/src/main/java/mekanism/client/jei/GuiElementHandler.java b/src/main/java/mekanism/client/jei/GuiElementHandler.java new file mode 100644 index 000000000..dfba58809 --- /dev/null +++ b/src/main/java/mekanism/client/jei/GuiElementHandler.java @@ -0,0 +1,45 @@ +package mekanism.client.jei; + +import mekanism.client.gui.GuiMekanism; +import mekanism.client.gui.element.GuiElement; +import mezz.jei.api.gui.IAdvancedGuiHandler; +import net.minecraft.client.gui.inventory.GuiContainer; + +import java.awt.*; +import java.util.ArrayList; +import java.util.List; + +public class GuiElementHandler implements IAdvancedGuiHandler +{ + @Override + public Class getGuiContainerClass() + { + return GuiMekanism.class; + } + + @Override + public List getGuiExtraAreas(GuiContainer gui) + { + if(gui instanceof GuiMekanism) + { + List list = new ArrayList<>(); + + GuiMekanism guiMek = (GuiMekanism)gui; + + for(GuiElement element : guiMek.guiElements) + { + list.add(element.getBounds(guiMek.getXPos(), guiMek.getYPos()).toRectangle()); + } + + return list; + } + + return null; + } + + @Override + public Object getIngredientUnderMouse(GuiContainer guiContainer, int mouseX, int mouseY) + { + return null; + } +} diff --git a/src/main/java/mekanism/client/jei/MekanismJEI.java b/src/main/java/mekanism/client/jei/MekanismJEI.java new file mode 100644 index 000000000..adc3a52ed --- /dev/null +++ b/src/main/java/mekanism/client/jei/MekanismJEI.java @@ -0,0 +1,320 @@ +package mekanism.client.jei; + +import mekanism.api.gas.Gas; +import mekanism.api.gas.GasRegistry; +import mekanism.api.gas.GasStack; +import mekanism.client.gui.GuiChemicalCrystallizer; +import mekanism.client.gui.GuiChemicalDissolutionChamber; +import mekanism.client.gui.GuiChemicalInfuser; +import mekanism.client.gui.GuiChemicalInjectionChamber; +import mekanism.client.gui.GuiChemicalOxidizer; +import mekanism.client.gui.GuiChemicalWasher; +import mekanism.client.gui.GuiCombiner; +import mekanism.client.gui.GuiCrusher; +import mekanism.client.gui.GuiElectrolyticSeparator; +import mekanism.client.gui.GuiEnrichmentChamber; +import mekanism.client.gui.GuiMetallurgicInfuser; +import mekanism.client.gui.GuiOsmiumCompressor; +import mekanism.client.gui.GuiPRC; +import mekanism.client.gui.GuiPrecisionSawmill; +import mekanism.client.gui.GuiPurificationChamber; +import mekanism.client.gui.GuiRotaryCondensentrator; +import mekanism.client.gui.GuiSolarNeutronActivator; +import mekanism.client.gui.GuiThermalEvaporationController; +import mekanism.client.gui.element.GuiProgress.ProgressBar; +import mekanism.client.jei.gas.GasStackRenderer; +import mekanism.client.jei.machine.AdvancedMachineRecipeCategory; +import mekanism.client.jei.machine.AdvancedMachineRecipeWrapper; +import mekanism.client.jei.machine.BaseRecipeHandler; +import mekanism.client.jei.machine.ChanceMachineRecipeCategory; +import mekanism.client.jei.machine.ChanceMachineRecipeWrapper; +import mekanism.client.jei.machine.MachineRecipeCategory; +import mekanism.client.jei.machine.MachineRecipeWrapper; +import mekanism.client.jei.machine.advanced.ChemicalInjectionChamberRecipeWrapper; +import mekanism.client.jei.machine.advanced.CombinerRecipeWrapper; +import mekanism.client.jei.machine.advanced.OsmiumCompressorRecipeWrapper; +import mekanism.client.jei.machine.advanced.PurificationChamberRecipeWrapper; +import mekanism.client.jei.machine.basic.CrusherRecipeWrapper; +import mekanism.client.jei.machine.basic.EnrichmentRecipeWrapper; +import mekanism.client.jei.machine.chance.PrecisionSawmillRecipeWrapper; +import mekanism.client.jei.machine.chemical.ChemicalCrystallizerRecipeCategory; +import mekanism.client.jei.machine.chemical.ChemicalCrystallizerRecipeWrapper; +import mekanism.client.jei.machine.chemical.ChemicalDissolutionChamberRecipeCategory; +import mekanism.client.jei.machine.chemical.ChemicalDissolutionChamberRecipeWrapper; +import mekanism.client.jei.machine.chemical.ChemicalInfuserRecipeCategory; +import mekanism.client.jei.machine.chemical.ChemicalInfuserRecipeWrapper; +import mekanism.client.jei.machine.chemical.ChemicalOxidizerRecipeCategory; +import mekanism.client.jei.machine.chemical.ChemicalOxidizerRecipeWrapper; +import mekanism.client.jei.machine.chemical.ChemicalWasherRecipeCategory; +import mekanism.client.jei.machine.chemical.ChemicalWasherRecipeWrapper; +import mekanism.client.jei.machine.other.ElectrolyticSeparatorRecipeCategory; +import mekanism.client.jei.machine.other.ElectrolyticSeparatorRecipeWrapper; +import mekanism.client.jei.machine.other.MetallurgicInfuserRecipeCategory; +import mekanism.client.jei.machine.other.MetallurgicInfuserRecipeWrapper; +import mekanism.client.jei.machine.other.PRCRecipeCategory; +import mekanism.client.jei.machine.other.PRCRecipeWrapper; +import mekanism.client.jei.machine.other.RotaryCondensentratorRecipeCategory; +import mekanism.client.jei.machine.other.RotaryCondensentratorRecipeWrapper; +import mekanism.client.jei.machine.other.SolarNeutronRecipeCategory; +import mekanism.client.jei.machine.other.SolarNeutronRecipeWrapper; +import mekanism.client.jei.machine.other.ThermalEvaporationRecipeCategory; +import mekanism.client.jei.machine.other.ThermalEvaporationRecipeWrapper; +import mekanism.common.MekanismBlocks; +import mekanism.common.MekanismItems; +import mekanism.common.base.IFactory; +import mekanism.common.base.IFactory.RecipeType; +import mekanism.common.base.ITierItem; +import mekanism.common.block.states.BlockStateBasic.BasicBlockType; +import mekanism.common.block.states.BlockStateMachine.MachineType; +import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.recipe.machines.AdvancedMachineRecipe; +import mekanism.common.recipe.machines.BasicMachineRecipe; +import mekanism.common.recipe.machines.ChanceMachineRecipe; +import mekanism.common.recipe.machines.ChemicalInfuserRecipe; +import mekanism.common.recipe.machines.CrystallizerRecipe; +import mekanism.common.recipe.machines.DissolutionRecipe; +import mekanism.common.recipe.machines.MachineRecipe; +import mekanism.common.recipe.machines.MetallurgicInfuserRecipe; +import mekanism.common.recipe.machines.OxidationRecipe; +import mekanism.common.recipe.machines.PressurizedRecipe; +import mekanism.common.recipe.machines.SeparatorRecipe; +import mekanism.common.recipe.machines.SolarNeutronRecipe; +import mekanism.common.recipe.machines.ThermalEvaporationRecipe; +import mekanism.common.recipe.machines.WasherRecipe; +import mezz.jei.api.IModPlugin; +import mezz.jei.api.IModRegistry; +import mezz.jei.api.ISubtypeRegistry; +import mezz.jei.api.ISubtypeRegistry.ISubtypeInterpreter; +import mezz.jei.api.JEIPlugin; +import mezz.jei.api.ingredients.IModIngredientRegistration; +import mezz.jei.api.recipe.IRecipeCategory; +import mezz.jei.api.recipe.IRecipeWrapper; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; + +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +@JEIPlugin +public class MekanismJEI implements IModPlugin +{ + public static ISubtypeInterpreter NBT_INTERPRETER = itemStack -> { + String ret = Integer.toString(itemStack.getMetadata()); + + if(itemStack.getItem() instanceof ITierItem) + { + ret += ":" + ((ITierItem)itemStack.getItem()).getBaseTier(itemStack).getSimpleName(); + } + + if(itemStack.getItem() instanceof IFactory) + { + ret += ":" + RecipeType.values()[((IFactory)itemStack.getItem()).getRecipeType(itemStack)].getName(); + } + + return ret.isEmpty() ? null : ret.toLowerCase(); + }; + + @Override + public void registerItemSubtypes(ISubtypeRegistry registry) + { + registry.registerSubtypeInterpreter(Item.getItemFromBlock(MekanismBlocks.EnergyCube), NBT_INTERPRETER); + registry.registerSubtypeInterpreter(Item.getItemFromBlock(MekanismBlocks.MachineBlock), NBT_INTERPRETER); + registry.registerSubtypeInterpreter(Item.getItemFromBlock(MekanismBlocks.MachineBlock2), NBT_INTERPRETER); + registry.registerSubtypeInterpreter(Item.getItemFromBlock(MekanismBlocks.MachineBlock3), NBT_INTERPRETER); + registry.registerSubtypeInterpreter(Item.getItemFromBlock(MekanismBlocks.BasicBlock), NBT_INTERPRETER); + registry.registerSubtypeInterpreter(Item.getItemFromBlock(MekanismBlocks.BasicBlock2), NBT_INTERPRETER); + registry.registerSubtypeInterpreter(Item.getItemFromBlock(MekanismBlocks.GasTank), NBT_INTERPRETER); + registry.registerSubtypeInterpreter(Item.getItemFromBlock(MekanismBlocks.CardboardBox), NBT_INTERPRETER); + registry.registerSubtypeInterpreter(Item.getItemFromBlock(MekanismBlocks.Transmitter), NBT_INTERPRETER); + } + + @Override + public void registerIngredients(IModIngredientRegistration registry) + { + List list = GasRegistry.getRegisteredGasses().stream().filter(Gas::isVisible).map(g -> new GasStack(g, Fluid.BUCKET_VOLUME)).collect(Collectors.toList()); + registry.register(GasStack.class, list, new GasStackHelper(), new GasStackRenderer()); + } + + @Override + public void register(IModRegistry registry) + { + registry.addAdvancedGuiHandlers(new GuiElementHandler()); + + registry.getJeiHelpers().getIngredientBlacklist().addIngredientToBlacklist(new ItemStack(MekanismItems.ItemProxy)); + registry.getJeiHelpers().getIngredientBlacklist().addIngredientToBlacklist(new ItemStack(MekanismBlocks.BoundingBlock)); + + registerBasicMachine(registry, Recipe.ENRICHMENT_CHAMBER, "tile.MachineBlock.EnrichmentChamber.name", ProgressBar.BLUE, EnrichmentRecipeWrapper.class); + registerBasicMachine(registry, Recipe.CRUSHER, "tile.MachineBlock.Crusher.name", ProgressBar.CRUSH, CrusherRecipeWrapper.class); + + registerAdvancedMachine(registry, Recipe.COMBINER, "tile.MachineBlock.Combiner.name", ProgressBar.STONE, CombinerRecipeWrapper.class); + registerAdvancedMachine(registry, Recipe.PURIFICATION_CHAMBER, "tile.MachineBlock.PurificationChamber.name", ProgressBar.RED, PurificationChamberRecipeWrapper.class); + registerAdvancedMachine(registry, Recipe.OSMIUM_COMPRESSOR, "tile.MachineBlock.OsmiumCompressor.name", ProgressBar.RED, OsmiumCompressorRecipeWrapper.class); + registerAdvancedMachine(registry, Recipe.CHEMICAL_INJECTION_CHAMBER, "nei.chemicalInjectionChamber", ProgressBar.YELLOW, ChemicalInjectionChamberRecipeWrapper.class); + + registerChanceMachine(registry, Recipe.PRECISION_SAWMILL, "tile.MachineBlock2.PrecisionSawmill.name", ProgressBar.PURPLE, PrecisionSawmillRecipeWrapper.class); + + MetallurgicInfuserRecipeCategory metallurgicInfuserCategory = new MetallurgicInfuserRecipeCategory(registry.getJeiHelpers().getGuiHelper()); + registry.addRecipeCategories(metallurgicInfuserCategory); + registry.addRecipeHandlers(new BaseRecipeHandler(metallurgicInfuserCategory, MetallurgicInfuserRecipeWrapper.class)); + addRecipes(registry, Recipe.METALLURGIC_INFUSER, metallurgicInfuserCategory, MetallurgicInfuserRecipe.class, MetallurgicInfuserRecipeCategory.class, MetallurgicInfuserRecipeWrapper.class); + + ChemicalCrystallizerRecipeCategory chemicalCrystallizerCategory = new ChemicalCrystallizerRecipeCategory(registry.getJeiHelpers().getGuiHelper()); + registry.addRecipeCategories(chemicalCrystallizerCategory); + registry.addRecipeHandlers(new BaseRecipeHandler(chemicalCrystallizerCategory, ChemicalCrystallizerRecipeWrapper.class)); + addRecipes(registry, Recipe.CHEMICAL_CRYSTALLIZER, chemicalCrystallizerCategory, CrystallizerRecipe.class, ChemicalCrystallizerRecipeCategory.class, ChemicalCrystallizerRecipeWrapper.class); + + ChemicalDissolutionChamberRecipeCategory chemicalDissolutionChamberCategory = new ChemicalDissolutionChamberRecipeCategory(registry.getJeiHelpers().getGuiHelper()); + registry.addRecipeCategories(chemicalDissolutionChamberCategory); + registry.addRecipeHandlers(new BaseRecipeHandler(chemicalDissolutionChamberCategory, ChemicalDissolutionChamberRecipeWrapper.class)); + addRecipes(registry, Recipe.CHEMICAL_DISSOLUTION_CHAMBER, chemicalDissolutionChamberCategory, DissolutionRecipe.class, ChemicalDissolutionChamberRecipeCategory.class, ChemicalDissolutionChamberRecipeWrapper.class); + + ChemicalInfuserRecipeCategory chemicalInfuserCategory = new ChemicalInfuserRecipeCategory(registry.getJeiHelpers().getGuiHelper()); + registry.addRecipeCategories(chemicalInfuserCategory); + registry.addRecipeHandlers(new BaseRecipeHandler(chemicalInfuserCategory, ChemicalInfuserRecipeWrapper.class)); + addRecipes(registry, Recipe.CHEMICAL_INFUSER, chemicalInfuserCategory, ChemicalInfuserRecipe.class, ChemicalInfuserRecipeCategory.class, ChemicalInfuserRecipeWrapper.class); + + ChemicalOxidizerRecipeCategory chemicalOxidizerCategory = new ChemicalOxidizerRecipeCategory(registry.getJeiHelpers().getGuiHelper()); + registry.addRecipeCategories(chemicalOxidizerCategory); + registry.addRecipeHandlers(new BaseRecipeHandler(chemicalOxidizerCategory, ChemicalOxidizerRecipeWrapper.class)); + addRecipes(registry, Recipe.CHEMICAL_OXIDIZER, chemicalOxidizerCategory, OxidationRecipe.class, ChemicalOxidizerRecipeCategory.class, ChemicalOxidizerRecipeWrapper.class); + + ChemicalWasherRecipeCategory chemicalWasherCategory = new ChemicalWasherRecipeCategory(registry.getJeiHelpers().getGuiHelper()); + registry.addRecipeCategories(chemicalWasherCategory); + registry.addRecipeHandlers(new BaseRecipeHandler(chemicalWasherCategory, ChemicalWasherRecipeWrapper.class)); + addRecipes(registry, Recipe.CHEMICAL_WASHER, chemicalWasherCategory, WasherRecipe.class, ChemicalWasherRecipeCategory.class, ChemicalWasherRecipeWrapper.class); + + SolarNeutronRecipeCategory solarNeutronCategory = new SolarNeutronRecipeCategory(registry.getJeiHelpers().getGuiHelper()); + registry.addRecipeCategories(solarNeutronCategory); + registry.addRecipeHandlers(new BaseRecipeHandler(solarNeutronCategory, SolarNeutronRecipeWrapper.class)); + addRecipes(registry, Recipe.SOLAR_NEUTRON_ACTIVATOR, solarNeutronCategory, SolarNeutronRecipe.class, SolarNeutronRecipeCategory.class, SolarNeutronRecipeWrapper.class); + + ElectrolyticSeparatorRecipeCategory electrolyticSeparatorCategory = new ElectrolyticSeparatorRecipeCategory(registry.getJeiHelpers().getGuiHelper()); + registry.addRecipeCategories(electrolyticSeparatorCategory); + registry.addRecipeHandlers(new BaseRecipeHandler(electrolyticSeparatorCategory, ElectrolyticSeparatorRecipeWrapper.class)); + addRecipes(registry, Recipe.ELECTROLYTIC_SEPARATOR, electrolyticSeparatorCategory, SeparatorRecipe.class, ElectrolyticSeparatorRecipeCategory.class, ElectrolyticSeparatorRecipeWrapper.class); + + ThermalEvaporationRecipeCategory thermalEvaporationCategory = new ThermalEvaporationRecipeCategory(registry.getJeiHelpers().getGuiHelper()); + registry.addRecipeCategories(thermalEvaporationCategory); + registry.addRecipeHandlers(new BaseRecipeHandler(thermalEvaporationCategory, ThermalEvaporationRecipeWrapper.class)); + addRecipes(registry, Recipe.THERMAL_EVAPORATION_PLANT, thermalEvaporationCategory, ThermalEvaporationRecipe.class, ThermalEvaporationRecipeCategory.class, ThermalEvaporationRecipeWrapper.class); + + PRCRecipeCategory prcCategory = new PRCRecipeCategory(registry.getJeiHelpers().getGuiHelper()); + registry.addRecipeCategories(prcCategory); + registry.addRecipeHandlers(new BaseRecipeHandler(prcCategory, PRCRecipeWrapper.class)); + addRecipes(registry, Recipe.PRESSURIZED_REACTION_CHAMBER, prcCategory, PressurizedRecipe.class, PRCRecipeCategory.class, PRCRecipeWrapper.class); + + List condensentratorRecipes = new ArrayList(); + + RotaryCondensentratorRecipeCategory rotaryCondensentratorCategory = new RotaryCondensentratorRecipeCategory(registry.getJeiHelpers().getGuiHelper()); + registry.addRecipeCategories(rotaryCondensentratorCategory); + registry.addRecipeHandlers(new BaseRecipeHandler(rotaryCondensentratorCategory, RotaryCondensentratorRecipeWrapper.class)); + + for(Gas gas : GasRegistry.getRegisteredGasses()) + { + if(gas.hasFluid()) + { + condensentratorRecipes.add(new RotaryCondensentratorRecipeWrapper(gas.getFluid(), gas, true, rotaryCondensentratorCategory)); + condensentratorRecipes.add(new RotaryCondensentratorRecipeWrapper(gas.getFluid(), gas, false, rotaryCondensentratorCategory)); + } + } + + registry.addRecipes(condensentratorRecipes); + + registry.addRecipeClickArea(GuiEnrichmentChamber.class, 79, 40, 24, 7, "mekanism.enrichment_chamber"); + registry.addRecipeClickArea(GuiCrusher.class, 79, 40, 24, 7, "mekanism.crusher"); + registry.addRecipeClickArea(GuiCombiner.class, 79, 40, 24, 7, "mekanism.combiner"); + registry.addRecipeClickArea(GuiPurificationChamber.class, 79, 40, 24, 7, "mekanism.purification_chamber"); + registry.addRecipeClickArea(GuiOsmiumCompressor.class, 79, 40, 24, 7, "mekanism.osmium_compressor"); + registry.addRecipeClickArea(GuiChemicalInjectionChamber.class, 79, 40, 24, 7, "mekanism.chemical_injection_chamber"); + registry.addRecipeClickArea(GuiPrecisionSawmill.class, 79, 40, 24, 7, "mekanism.precision_sawmill"); + registry.addRecipeClickArea(GuiMetallurgicInfuser.class, 72, 47, 32, 8, "mekanism.metallurgic_infuser"); + registry.addRecipeClickArea(GuiChemicalCrystallizer.class, 53, 62, 48, 8, "mekanism.chemical_crystallizer"); + registry.addRecipeClickArea(GuiChemicalDissolutionChamber.class, 64, 40, 48, 8, "mekanism.chemical_dissolution_chamber"); + registry.addRecipeClickArea(GuiChemicalInfuser.class, 47, 39, 28, 8, "mekanism.chemical_infuser"); + registry.addRecipeClickArea(GuiChemicalInfuser.class, 101, 39, 28, 8, "mekanism.chemical_infuser"); + registry.addRecipeClickArea(GuiChemicalOxidizer.class, 64, 40, 48, 8, "mekanism.chemical_oxidizer"); + registry.addRecipeClickArea(GuiChemicalWasher.class, 61, 39, 55, 8, "mekanism.chemical_washer"); + registry.addRecipeClickArea(GuiSolarNeutronActivator.class, 64, 39, 48, 8, "mekanism.solar_neutron_activator"); + registry.addRecipeClickArea(GuiElectrolyticSeparator.class, 80, 30, 16, 6, "mekanism.electrolytic_separator"); + registry.addRecipeClickArea(GuiThermalEvaporationController.class, 49, 20, 78, 38, "mekanism.thermal_evaporation_plant"); + registry.addRecipeClickArea(GuiPRC.class, 75, 37, 36, 10, "mekanism.pressurized_reaction_chamber"); + registry.addRecipeClickArea(GuiRotaryCondensentrator.class, 64, 39, 48, 8, "mekanism.rotary_condensentrator"); + + registerRecipeItem(registry, MachineType.ENRICHMENT_CHAMBER); + registerRecipeItem(registry, MachineType.CRUSHER); + registerRecipeItem(registry, MachineType.COMBINER); + registerRecipeItem(registry, MachineType.PURIFICATION_CHAMBER); + registerRecipeItem(registry, MachineType.OSMIUM_COMPRESSOR); + registerRecipeItem(registry, MachineType.CHEMICAL_INJECTION_CHAMBER); + registerRecipeItem(registry, MachineType.PRECISION_SAWMILL); + registerRecipeItem(registry, MachineType.METALLURGIC_INFUSER); + registerRecipeItem(registry, MachineType.CHEMICAL_CRYSTALLIZER); + registerRecipeItem(registry, MachineType.CHEMICAL_DISSOLUTION_CHAMBER); + registerRecipeItem(registry, MachineType.CHEMICAL_INFUSER); + registerRecipeItem(registry, MachineType.CHEMICAL_OXIDIZER); + registerRecipeItem(registry, MachineType.CHEMICAL_WASHER); + registerRecipeItem(registry, MachineType.SOLAR_NEUTRON_ACTIVATOR); + registerRecipeItem(registry, MachineType.ELECTROLYTIC_SEPARATOR); + registerRecipeItem(registry, MachineType.PRESSURIZED_REACTION_CHAMBER); + registerRecipeItem(registry, MachineType.ROTARY_CONDENSENTRATOR); + + registry.addRecipeCategoryCraftingItem(BasicBlockType.THERMAL_EVAPORATION_CONTROLLER.getStack(1), "mekanism.thermal_evaporation_plant"); + } + + private void registerRecipeItem(IModRegistry registry, MachineType type) + { + registry.addRecipeCategoryCraftingItem(type.getStack(), "mekanism." + type.getName()); + } + + private void registerBasicMachine(IModRegistry registry, Recipe recipe, String unlocalized, ProgressBar bar, Class wrapper) + { + MachineRecipeCategory category = new MachineRecipeCategory(registry.getJeiHelpers().getGuiHelper(), recipe.name().toLowerCase(), unlocalized, bar); + + registry.addRecipeCategories(category); + registry.addRecipeHandlers(new BaseRecipeHandler(category, wrapper)); + + addRecipes(registry, recipe, category, BasicMachineRecipe.class, MachineRecipeCategory.class, wrapper); + } + + private void registerAdvancedMachine(IModRegistry registry, Recipe recipe, String unlocalized, ProgressBar bar, Class wrapper) + { + AdvancedMachineRecipeCategory category = new AdvancedMachineRecipeCategory(registry.getJeiHelpers().getGuiHelper(), recipe.name().toLowerCase(), unlocalized, bar); + + registry.addRecipeCategories(category); + registry.addRecipeHandlers(new BaseRecipeHandler(category, wrapper)); + + addRecipes(registry, recipe, category, AdvancedMachineRecipe.class, AdvancedMachineRecipeCategory.class, wrapper); + } + + private void registerChanceMachine(IModRegistry registry, Recipe recipe, String unlocalized, ProgressBar bar, Class wrapper) + { + ChanceMachineRecipeCategory category = new ChanceMachineRecipeCategory(registry.getJeiHelpers().getGuiHelper(), recipe.name().toLowerCase(), unlocalized, bar); + + registry.addRecipeCategories(category); + registry.addRecipeHandlers(new BaseRecipeHandler(category, wrapper)); + + addRecipes(registry, recipe, category, ChanceMachineRecipe.class, ChanceMachineRecipeCategory.class, wrapper); + } + + private void addRecipes(IModRegistry registry, Recipe type, IRecipeCategory cat, Class recipe, Class category, Class wrapper) + { + List recipes = new ArrayList<>(); + + for(Object obj : type.get().values()) + { + if(obj instanceof MachineRecipe) + { + try { + recipes.add(wrapper.getConstructor(recipe, category).newInstance(obj, cat)); + } catch (InstantiationException | NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + throw new IllegalStateException("Cannot find JEI wrapper constructor!"); + } + } + } + + registry.addRecipes(recipes); + } +} diff --git a/src/main/java/mekanism/client/jei/gas/GasStackRenderer.java b/src/main/java/mekanism/client/jei/gas/GasStackRenderer.java new file mode 100644 index 000000000..1f3c8ea37 --- /dev/null +++ b/src/main/java/mekanism/client/jei/gas/GasStackRenderer.java @@ -0,0 +1,230 @@ +package mekanism.client.jei.gas; + +import mekanism.api.gas.Gas; +import mekanism.api.gas.GasStack; +import mekanism.common.util.LangUtils; +import mezz.jei.api.gui.IDrawable; +import mezz.jei.api.ingredients.IIngredientRenderer; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.BufferBuilder; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.text.TextFormatting; +import net.minecraftforge.fluids.Fluid; + +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; + +public class GasStackRenderer implements IIngredientRenderer +{ + private static final int TEX_WIDTH = 16; + private static final int TEX_HEIGHT = 16; + private static final int MIN_FLUID_HEIGHT = 1; // ensure tiny amounts of gas are still visible + + private final int capacityMb; + private final TooltipMode tooltipMode; + private final int width; + private final int height; + @Nullable + private final IDrawable overlay; + + enum TooltipMode + { + SHOW_AMOUNT, + SHOW_AMOUNT_AND_CAPACITY, + ITEM_LIST + } + + public GasStackRenderer() + { + this(Fluid.BUCKET_VOLUME, TooltipMode.ITEM_LIST, TEX_WIDTH, TEX_HEIGHT, null); + } + + public GasStackRenderer(int capacityMb, boolean showCapacity, int width, int height, @Nullable IDrawable overlay) + { + this(capacityMb, showCapacity ? TooltipMode.SHOW_AMOUNT_AND_CAPACITY : TooltipMode.SHOW_AMOUNT, width, height, overlay); + } + + public GasStackRenderer(int capacityMb, TooltipMode tooltipMode, int width, int height, @Nullable IDrawable overlay) + { + this.capacityMb = capacityMb; + this.tooltipMode = tooltipMode; + this.width = width; + this.height = height; + this.overlay = overlay; + } + + @Override + public void render(Minecraft minecraft, final int xPosition, final int yPosition, @Nullable GasStack gasStack) + { + GlStateManager.enableBlend(); + GlStateManager.enableAlpha(); + + drawGas(minecraft, xPosition, yPosition, gasStack); + + GlStateManager.color(1, 1, 1, 1); + + if(overlay != null) + { + GlStateManager.pushMatrix(); + GlStateManager.translate(0, 0, 200); + overlay.draw(minecraft, xPosition, yPosition); + GlStateManager.popMatrix(); + } + + GlStateManager.disableAlpha(); + GlStateManager.disableBlend(); + } + + private void drawGas(Minecraft minecraft, final int xPosition, final int yPosition, @Nullable GasStack gasStack) + { + if(gasStack == null) + { + return; + } + + Gas gas = gasStack.getGas(); + + if(gas == null) + { + return; + } + + TextureAtlasSprite gasStillSprite = getStillGasSprite(minecraft, gas); + + int gasColor = 0xFFFFFFFF; + + int scaledAmount = (gasStack.amount * height) / capacityMb; + + if(gasStack.amount > 0 && scaledAmount < MIN_FLUID_HEIGHT) + { + scaledAmount = MIN_FLUID_HEIGHT; + } + + if(scaledAmount > height) + { + scaledAmount = height; + } + + drawTiledSprite(minecraft, xPosition, yPosition, width, height, gasColor, scaledAmount, gasStillSprite); + } + + private void drawTiledSprite(Minecraft minecraft, final int xPosition, final int yPosition, final int tiledWidth, final int tiledHeight, int color, int scaledAmount, TextureAtlasSprite sprite) + { + minecraft.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + setGLColorFromInt(color); + + final int xTileCount = tiledWidth / TEX_WIDTH; + final int xRemainder = tiledWidth - (xTileCount * TEX_WIDTH); + final int yTileCount = scaledAmount / TEX_HEIGHT; + final int yRemainder = scaledAmount - (yTileCount * TEX_HEIGHT); + + final int yStart = yPosition + tiledHeight; + + for(int xTile = 0; xTile <= xTileCount; xTile++) + { + for(int yTile = 0; yTile <= yTileCount; yTile++) + { + int width = (xTile == xTileCount) ? xRemainder : TEX_WIDTH; + int height = (yTile == yTileCount) ? yRemainder : TEX_HEIGHT; + int x = xPosition + (xTile * TEX_WIDTH); + int y = yStart - ((yTile + 1) * TEX_HEIGHT); + + if(width > 0 && height > 0) + { + int maskTop = TEX_HEIGHT - height; + int maskRight = TEX_WIDTH - width; + + drawTextureWithMasking(x, y, sprite, maskTop, maskRight, 100); + } + } + } + } + + private static TextureAtlasSprite getStillGasSprite(Minecraft minecraft, Gas gas) + { + TextureMap textureMapBlocks = minecraft.getTextureMapBlocks(); + ResourceLocation gasStill = gas.getIcon(); + TextureAtlasSprite gasStillSprite = null; + + if(gasStill != null) + { + gasStillSprite = textureMapBlocks.getTextureExtry(gasStill.toString()); + } + + if(gasStillSprite == null) + { + gasStillSprite = textureMapBlocks.getMissingSprite(); + } + + return gasStillSprite; + } + + private static void setGLColorFromInt(int color) + { + float red = (color >> 16 & 0xFF) / 255.0F; + float green = (color >> 8 & 0xFF) / 255.0F; + float blue = (color & 0xFF) / 255.0F; + + GlStateManager.color(red, green, blue, 1.0F); + } + + private static void drawTextureWithMasking(double xCoord, double yCoord, TextureAtlasSprite textureSprite, int maskTop, int maskRight, double zLevel) + { + double uMin = (double) textureSprite.getMinU(); + double uMax = (double) textureSprite.getMaxU(); + double vMin = (double) textureSprite.getMinV(); + double vMax = (double) textureSprite.getMaxV(); + uMax = uMax - (maskRight / 16.0 * (uMax - uMin)); + vMax = vMax - (maskTop / 16.0 * (vMax - vMin)); + + Tessellator tessellator = Tessellator.getInstance(); + BufferBuilder vertexBuffer = tessellator.getBuffer(); + vertexBuffer.begin(7, DefaultVertexFormats.POSITION_TEX); + vertexBuffer.pos(xCoord, yCoord + 16, zLevel).tex(uMin, vMax).endVertex(); + vertexBuffer.pos(xCoord + 16 - maskRight, yCoord + 16, zLevel).tex(uMax, vMax).endVertex(); + vertexBuffer.pos(xCoord + 16 - maskRight, yCoord + maskTop, zLevel).tex(uMax, vMin).endVertex(); + vertexBuffer.pos(xCoord, yCoord + maskTop, zLevel).tex(uMin, vMin).endVertex(); + tessellator.draw(); + } + + @Override + public List getTooltip(Minecraft minecraft, GasStack gasStack, ITooltipFlag tooltipFlag) + { + List tooltip = new ArrayList<>(); + Gas gasType = gasStack.getGas(); + + if(gasType == null) + { + return tooltip; + } + + String gasName = gasType.getLocalizedName(); + tooltip.add(gasName); + + if(tooltipMode == TooltipMode.SHOW_AMOUNT_AND_CAPACITY) + { + String amount = LangUtils.localizeWithFormat("jei.tooltip.liquid.amount.with.capacity", gasStack.amount, capacityMb); + tooltip.add(TextFormatting.GRAY + amount); + } + else if (tooltipMode == TooltipMode.SHOW_AMOUNT) + { + String amount = LangUtils.localizeWithFormat("jei.tooltip.liquid.amount", gasStack.amount); + tooltip.add(TextFormatting.GRAY + amount); + } + + return tooltip; + } + + @Override + public FontRenderer getFontRenderer(Minecraft minecraft, GasStack gasStack) { + return minecraft.fontRenderer; + } +} diff --git a/src/main/java/mekanism/client/jei/machine/AdvancedMachineRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/AdvancedMachineRecipeCategory.java new file mode 100644 index 000000000..5c0b461f4 --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/AdvancedMachineRecipeCategory.java @@ -0,0 +1,115 @@ +package mekanism.client.jei.machine; + +import mekanism.api.gas.GasStack; +import mekanism.client.gui.element.GuiPowerBar; +import mekanism.client.gui.element.GuiPowerBar.IPowerInfoHandler; +import mekanism.client.gui.element.GuiProgress; +import mekanism.client.gui.element.GuiProgress.IProgressInfoHandler; +import mekanism.client.gui.element.GuiProgress.ProgressBar; +import mekanism.client.gui.element.GuiSlot; +import mekanism.client.gui.element.GuiSlot.SlotOverlay; +import mekanism.client.gui.element.GuiSlot.SlotType; +import mekanism.client.jei.BaseRecipeCategory; +import mekanism.common.recipe.inputs.AdvancedMachineInput; +import mekanism.common.recipe.machines.AdvancedMachineRecipe; +import mekanism.common.recipe.outputs.ItemStackOutput; +import mekanism.common.util.MekanismUtils; +import mekanism.common.util.MekanismUtils.ResourceType; +import mezz.jei.api.IGuiHelper; +import mezz.jei.api.gui.IDrawable; +import mezz.jei.api.gui.IGuiItemStackGroup; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.ITickTimer; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.IRecipeWrapper; +import net.minecraft.client.Minecraft; +import net.minecraft.util.ResourceLocation; + +public class AdvancedMachineRecipeCategory extends BaseRecipeCategory +{ + public IGuiHelper guiHelper; + + public String recipeName; + public String unlocalizedName; + + public IDrawable background; + + public AdvancedMachineRecipe tempRecipe; + + public ITickTimer timer; + + public AdvancedMachineRecipeCategory(IGuiHelper helper, String name, String unlocalized, ProgressBar progress) + { + super("mekanism:gui/GuiAdvancedMachine.png", name, unlocalized, progress); + + guiHelper = helper; + + timer = helper.createTickTimer(20, 20, false); + background = guiHelper.createDrawable(new ResourceLocation(guiTexture), 28, 16, 144, 54); + } + + @Override + public void addGuiElements() + { + guiElements.add(new GuiSlot(SlotType.INPUT, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 55, 16)); + guiElements.add(new GuiSlot(SlotType.POWER, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 30, 34).with(SlotOverlay.POWER)); + guiElements.add(new GuiSlot(SlotType.EXTRA, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 55, 52)); + guiElements.add(new GuiSlot(SlotType.OUTPUT_LARGE, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 111, 30)); + + guiElements.add(new GuiPowerBar(this, new IPowerInfoHandler() { + @Override + public double getLevel() + { + return 1F; + } + }, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 164, 15)); + guiElements.add(new GuiProgress(new IProgressInfoHandler() + { + @Override + public double getProgress() + { + return (double)timer.getValue() / 20F; + } + }, progressBar, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 77, 37)); + } + + @Override + public void drawExtras(Minecraft minecraft) + { + super.drawExtras(minecraft); + + AdvancedMachineInput input = (AdvancedMachineInput)tempRecipe.getInput(); + + if(input.gasType != null) + { + displayGauge(33, 21, 6, 12, new GasStack(input.gasType, 1)); + } + } + + @Override + public IDrawable getBackground() + { + return background; + } + + @Override + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) + { + if(recipeWrapper instanceof AdvancedMachineRecipeWrapper) + { + tempRecipe = ((AdvancedMachineRecipeWrapper)recipeWrapper).recipe; + } + + AdvancedMachineInput input = (AdvancedMachineInput)tempRecipe.recipeInput; + + IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); + + itemStacks.init(0, true, 27, 0); + itemStacks.init(1, false, 87, 18); + itemStacks.init(2, false, 27, 36); + + itemStacks.set(0, input.itemStack); + itemStacks.set(1, ((ItemStackOutput)tempRecipe.recipeOutput).output); + itemStacks.set(2, ((AdvancedMachineRecipeWrapper)recipeWrapper).getFuelStacks(input.gasType)); + } +} diff --git a/src/main/java/mekanism/client/jei/machine/AdvancedMachineRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/AdvancedMachineRecipeWrapper.java new file mode 100644 index 000000000..56c95a857 --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/AdvancedMachineRecipeWrapper.java @@ -0,0 +1,54 @@ +package mekanism.client.jei.machine; + +import mekanism.api.gas.Gas; +import mekanism.common.recipe.inputs.AdvancedMachineInput; +import mekanism.common.recipe.machines.AdvancedMachineRecipe; +import mekanism.common.recipe.outputs.ItemStackOutput; +import mezz.jei.api.ingredients.IIngredients; +import net.minecraft.item.ItemStack; + +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; + +public abstract class AdvancedMachineRecipeWrapper extends BaseRecipeWrapper +{ + public AdvancedMachineRecipe recipe; + + public AdvancedMachineRecipeCategory category; + + public AdvancedMachineRecipeWrapper(AdvancedMachineRecipe r, AdvancedMachineRecipeCategory c) + { + recipe = r; + category = c; + } + + @Override + public void getIngredients(IIngredients ingredients) + { + ingredients.setInput(ItemStack.class, ((AdvancedMachineInput)recipe.getInput()).itemStack); + ingredients.setOutput(ItemStack.class, ((ItemStackOutput)recipe.getOutput()).output); + } + + @Nullable + @Override + public List getTooltipStrings(int mouseX, int mouseY) + { + List currenttip = new ArrayList(); + + if(mouseX >= 33 && mouseX <= 39 && mouseY >= 22 && mouseY <= 34) + { + currenttip.add(((AdvancedMachineInput)recipe.getInput()).gasType.getLocalizedName()); + } + + return currenttip; + } + + @Override + public AdvancedMachineRecipeCategory getCategory() + { + return category; + } + + public abstract List getFuelStacks(Gas gasType); +} diff --git a/src/main/java/mekanism/client/jei/machine/BaseRecipeHandler.java b/src/main/java/mekanism/client/jei/machine/BaseRecipeHandler.java new file mode 100644 index 000000000..7a1cbf331 --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/BaseRecipeHandler.java @@ -0,0 +1,46 @@ +package mekanism.client.jei.machine; + +import mekanism.client.jei.BaseRecipeCategory; +import mezz.jei.api.recipe.IRecipeHandler; +import mezz.jei.api.recipe.IRecipeWrapper; + +import javax.annotation.Nonnull; + +public class BaseRecipeHandler implements IRecipeHandler +{ + private final CATEGORY category; + + public Class wrapperClass; + + public BaseRecipeHandler(CATEGORY c, Class wrapper) + { + category = c; + + wrapperClass = wrapper; + } + + @Override + public Class getRecipeClass() + { + return wrapperClass; + } + + @Nonnull + @Override + public IRecipeWrapper getRecipeWrapper(@Nonnull WRAPPER recipe) + { + return recipe; + } + + @Override + public boolean isRecipeValid(@Nonnull WRAPPER recipe) + { + return recipe.getCategory() == category; + } + + @Override + public String getRecipeCategoryUid(@Nonnull WRAPPER recipe) + { + return category.getUid(); + } +} diff --git a/src/main/java/mekanism/client/jei/machine/BaseRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/BaseRecipeWrapper.java new file mode 100644 index 000000000..1bb315840 --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/BaseRecipeWrapper.java @@ -0,0 +1,9 @@ +package mekanism.client.jei.machine; + +import mekanism.client.jei.BaseRecipeCategory; +import mezz.jei.api.recipe.BlankRecipeWrapper; + +public abstract class BaseRecipeWrapper extends BlankRecipeWrapper +{ + public abstract BaseRecipeCategory getCategory(); +} diff --git a/src/main/java/mekanism/client/jei/machine/ChanceMachineRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/ChanceMachineRecipeCategory.java new file mode 100644 index 000000000..f652f9abc --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/ChanceMachineRecipeCategory.java @@ -0,0 +1,105 @@ +package mekanism.client.jei.machine; + +import mekanism.client.gui.element.GuiPowerBar; +import mekanism.client.gui.element.GuiPowerBar.IPowerInfoHandler; +import mekanism.client.gui.element.GuiProgress; +import mekanism.client.gui.element.GuiProgress.IProgressInfoHandler; +import mekanism.client.gui.element.GuiProgress.ProgressBar; +import mekanism.client.gui.element.GuiSlot; +import mekanism.client.gui.element.GuiSlot.SlotOverlay; +import mekanism.client.gui.element.GuiSlot.SlotType; +import mekanism.client.jei.BaseRecipeCategory; +import mekanism.common.recipe.inputs.ItemStackInput; +import mekanism.common.recipe.machines.ChanceMachineRecipe; +import mekanism.common.recipe.outputs.ChanceOutput; +import mekanism.common.util.MekanismUtils; +import mekanism.common.util.MekanismUtils.ResourceType; +import mezz.jei.api.IGuiHelper; +import mezz.jei.api.gui.IDrawable; +import mezz.jei.api.gui.IGuiItemStackGroup; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.ITickTimer; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.IRecipeWrapper; +import net.minecraft.util.ResourceLocation; + +public class ChanceMachineRecipeCategory extends BaseRecipeCategory +{ + public IGuiHelper guiHelper; + + public IDrawable background; + + public ChanceMachineRecipe tempRecipe; + + public ITickTimer timer; + + public ChanceMachineRecipeCategory(IGuiHelper helper, String name, String unlocalized, ProgressBar progress) + { + super("mekanism:gui/GuiBasicMachine.png", name, unlocalized, progress); + + guiHelper = helper; + + timer = helper.createTickTimer(20, 20, false); + + background = guiHelper.createDrawable(new ResourceLocation(guiTexture), 28, 16, 144, 54); + } + + @Override + public void addGuiElements() + { + guiElements.add(new GuiSlot(SlotType.INPUT, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 55, 16)); + guiElements.add(new GuiSlot(SlotType.POWER, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 55, 52).with(SlotOverlay.POWER)); + guiElements.add(new GuiSlot(SlotType.OUTPUT_WIDE, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 111, 30)); + + guiElements.add(new GuiPowerBar(this, new IPowerInfoHandler() { + @Override + public double getLevel() + { + return 1F; + } + }, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 164, 15)); + guiElements.add(new GuiProgress(new IProgressInfoHandler() + { + @Override + public double getProgress() + { + return (double)timer.getValue() / 20F; + } + }, progressBar, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 77, 37)); + } + + @Override + public IDrawable getBackground() + { + return background; + } + + @Override + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) + { + if(recipeWrapper instanceof ChanceMachineRecipeWrapper) + { + tempRecipe = ((ChanceMachineRecipeWrapper)recipeWrapper).recipe; + } + + IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); + + itemStacks.init(0, true, 27, 0); + itemStacks.init(1, false, 87, 18); + itemStacks.init(2, false, 103, 18); + + itemStacks.set(0, ((ItemStackInput)tempRecipe.recipeInput).ingredient); + + ChanceOutput output = (ChanceOutput)tempRecipe.getOutput(); + + if(output.hasPrimary()) + { + itemStacks.set(1, output.primaryOutput); + } + + if(output.hasSecondary()) + { + itemStacks.set(2, output.secondaryOutput); + } + } +} diff --git a/src/main/java/mekanism/client/jei/machine/ChanceMachineRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/ChanceMachineRecipeWrapper.java new file mode 100644 index 000000000..5f50c004d --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/ChanceMachineRecipeWrapper.java @@ -0,0 +1,51 @@ +package mekanism.client.jei.machine; + +import mekanism.common.recipe.inputs.ItemStackInput; +import mekanism.common.recipe.machines.ChanceMachineRecipe; +import mekanism.common.recipe.outputs.ChanceOutput; +import mezz.jei.api.ingredients.IIngredients; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.item.ItemStack; + +import javax.annotation.Nonnull; +import java.util.Arrays; + +public class ChanceMachineRecipeWrapper extends BaseRecipeWrapper +{ + public ChanceMachineRecipe recipe; + + public ChanceMachineRecipeCategory category; + + public ChanceMachineRecipeWrapper(ChanceMachineRecipe r, ChanceMachineRecipeCategory c) + { + recipe = r; + category = c; + } + + @Override + public void getIngredients(IIngredients ingredients) + { + ChanceOutput output = (ChanceOutput)recipe.getOutput(); + ingredients.setInput(ItemStack.class, ((ItemStackInput)recipe.getInput()).ingredient); + ingredients.setOutputs(ItemStack.class, Arrays.asList(output.primaryOutput, output.secondaryOutput)); + } + + @Override + public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) + { + ChanceOutput output = (ChanceOutput)recipe.getOutput(); + + if(output.hasSecondary()) + { + FontRenderer fontRendererObj = minecraft.fontRenderer; + fontRendererObj.drawString(Math.round(output.secondaryChance*100) + "%", 104, 41, 0x404040, false); + } + } + + @Override + public ChanceMachineRecipeCategory getCategory() + { + return category; + } +} diff --git a/src/main/java/mekanism/client/jei/machine/MachineRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/MachineRecipeCategory.java new file mode 100644 index 000000000..ca3bc09d8 --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/MachineRecipeCategory.java @@ -0,0 +1,90 @@ +package mekanism.client.jei.machine; + +import mekanism.client.gui.element.GuiPowerBar; +import mekanism.client.gui.element.GuiPowerBar.IPowerInfoHandler; +import mekanism.client.gui.element.GuiProgress; +import mekanism.client.gui.element.GuiProgress.IProgressInfoHandler; +import mekanism.client.gui.element.GuiProgress.ProgressBar; +import mekanism.client.gui.element.GuiSlot; +import mekanism.client.gui.element.GuiSlot.SlotOverlay; +import mekanism.client.gui.element.GuiSlot.SlotType; +import mekanism.client.jei.BaseRecipeCategory; +import mekanism.common.recipe.machines.BasicMachineRecipe; +import mekanism.common.util.MekanismUtils; +import mekanism.common.util.MekanismUtils.ResourceType; +import mezz.jei.api.IGuiHelper; +import mezz.jei.api.gui.IDrawable; +import mezz.jei.api.gui.IGuiItemStackGroup; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.ITickTimer; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.IRecipeWrapper; +import net.minecraft.util.ResourceLocation; + +public class MachineRecipeCategory extends BaseRecipeCategory +{ + public IGuiHelper guiHelper; + + public IDrawable background; + + public BasicMachineRecipe tempRecipe; + + public ITickTimer timer; + + public MachineRecipeCategory(IGuiHelper helper, String name, String unlocalized, ProgressBar progress) + { + super("mekanism:gui/GuiBasicMachine.png", name, unlocalized, progress); + + guiHelper = helper; + + timer = helper.createTickTimer(20, 20, false); + + background = guiHelper.createDrawable(new ResourceLocation(guiTexture), 28, 16, 144, 54); + } + + @Override + public void addGuiElements() + { + guiElements.add(new GuiSlot(SlotType.INPUT, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 55, 16)); + guiElements.add(new GuiSlot(SlotType.POWER, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 55, 52).with(SlotOverlay.POWER)); + guiElements.add(new GuiSlot(SlotType.OUTPUT_LARGE, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 111, 30)); + + guiElements.add(new GuiPowerBar(this, new IPowerInfoHandler() { + @Override + public double getLevel() + { + return 1F; + } + }, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 164, 15)); + guiElements.add(new GuiProgress(new IProgressInfoHandler() + { + @Override + public double getProgress() + { + return (double)timer.getValue() / 20F; + } + }, progressBar, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 77, 37)); + } + + @Override + public IDrawable getBackground() + { + return background; + } + + @Override + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) + { + if(recipeWrapper instanceof MachineRecipeWrapper) + { + tempRecipe = ((MachineRecipeWrapper)recipeWrapper).recipe; + } + + IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); + + itemStacks.init(0, true, 27, 0); + itemStacks.init(1, false, 87, 18); + + itemStacks.set(ingredients); + } +} diff --git a/src/main/java/mekanism/client/jei/machine/MachineRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/MachineRecipeWrapper.java new file mode 100644 index 000000000..684c53cb9 --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/MachineRecipeWrapper.java @@ -0,0 +1,33 @@ +package mekanism.client.jei.machine; + +import mekanism.common.recipe.inputs.ItemStackInput; +import mekanism.common.recipe.machines.BasicMachineRecipe; +import mekanism.common.recipe.outputs.ItemStackOutput; +import mezz.jei.api.ingredients.IIngredients; +import net.minecraft.item.ItemStack; + +public class MachineRecipeWrapper extends BaseRecipeWrapper +{ + public BasicMachineRecipe recipe; + + public MachineRecipeCategory category; + + public MachineRecipeWrapper(BasicMachineRecipe r, MachineRecipeCategory c) + { + recipe = r; + category = c; + } + + @Override + public void getIngredients(IIngredients ingredients) + { + ingredients.setInput(ItemStack.class, ((ItemStackInput)recipe.getInput()).ingredient); + ingredients.setOutput(ItemStack.class, ((ItemStackOutput)recipe.getOutput()).output); + } + + @Override + public MachineRecipeCategory getCategory() + { + return category; + } +} diff --git a/src/main/java/mekanism/client/jei/machine/advanced/ChemicalInjectionChamberRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/advanced/ChemicalInjectionChamberRecipeWrapper.java new file mode 100644 index 000000000..2a61f1433 --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/advanced/ChemicalInjectionChamberRecipeWrapper.java @@ -0,0 +1,50 @@ +package mekanism.client.jei.machine.advanced; + +import mekanism.api.gas.Gas; +import mekanism.client.jei.machine.AdvancedMachineRecipeCategory; +import mekanism.client.jei.machine.AdvancedMachineRecipeWrapper; +import mekanism.common.MekanismFluids; +import mekanism.common.Tier.GasTankTier; +import mekanism.common.recipe.machines.AdvancedMachineRecipe; +import mekanism.common.util.ListUtils; +import mekanism.common.util.MekanismUtils; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +import java.util.ArrayList; +import java.util.List; + +public class ChemicalInjectionChamberRecipeWrapper extends AdvancedMachineRecipeWrapper +{ + public ChemicalInjectionChamberRecipeWrapper(AdvancedMachineRecipe r, AdvancedMachineRecipeCategory c) + { + super(r, c); + } + + @Override + public List getFuelStacks(Gas gasType) + { + if(gasType == MekanismFluids.SulfuricAcid) + { + List fuels = new ArrayList(); + fuels.addAll(OreDictionary.getOres("dustSulfur")); + fuels.add(MekanismUtils.getFullGasTank(GasTankTier.BASIC, MekanismFluids.SulfuricAcid)); + + return fuels; + } + else if(gasType == MekanismFluids.Water) + { + return ListUtils.asList(MekanismUtils.getFullGasTank(GasTankTier.BASIC, MekanismFluids.Water)); + } + else if(gasType == MekanismFluids.HydrogenChloride) + { + List fuels = new ArrayList(); + fuels.addAll(OreDictionary.getOres("dustSalt")); + fuels.add(MekanismUtils.getFullGasTank(GasTankTier.BASIC, MekanismFluids.HydrogenChloride)); + + return fuels; + } + + return new ArrayList(); + } +} diff --git a/src/main/java/mekanism/client/jei/machine/advanced/CombinerRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/advanced/CombinerRecipeWrapper.java new file mode 100644 index 000000000..acef86b0f --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/advanced/CombinerRecipeWrapper.java @@ -0,0 +1,25 @@ +package mekanism.client.jei.machine.advanced; + +import mekanism.api.gas.Gas; +import mekanism.client.jei.machine.AdvancedMachineRecipeCategory; +import mekanism.client.jei.machine.AdvancedMachineRecipeWrapper; +import mekanism.common.recipe.machines.AdvancedMachineRecipe; +import mekanism.common.util.ListUtils; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; + +import java.util.List; + +public class CombinerRecipeWrapper extends AdvancedMachineRecipeWrapper +{ + public CombinerRecipeWrapper(AdvancedMachineRecipe r, AdvancedMachineRecipeCategory c) + { + super(r, c); + } + + @Override + public List getFuelStacks(Gas gasType) + { + return ListUtils.asList(new ItemStack(Blocks.COBBLESTONE)); + } +} diff --git a/src/main/java/mekanism/client/jei/machine/advanced/OsmiumCompressorRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/advanced/OsmiumCompressorRecipeWrapper.java new file mode 100644 index 000000000..6ee43da61 --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/advanced/OsmiumCompressorRecipeWrapper.java @@ -0,0 +1,25 @@ +package mekanism.client.jei.machine.advanced; + +import mekanism.api.gas.Gas; +import mekanism.client.jei.machine.AdvancedMachineRecipeCategory; +import mekanism.client.jei.machine.AdvancedMachineRecipeWrapper; +import mekanism.common.MekanismItems; +import mekanism.common.recipe.machines.AdvancedMachineRecipe; +import mekanism.common.util.ListUtils; +import net.minecraft.item.ItemStack; + +import java.util.List; + +public class OsmiumCompressorRecipeWrapper extends AdvancedMachineRecipeWrapper +{ + public OsmiumCompressorRecipeWrapper(AdvancedMachineRecipe r, AdvancedMachineRecipeCategory c) + { + super(r, c); + } + + @Override + public List getFuelStacks(Gas gasType) + { + return ListUtils.asList(new ItemStack(MekanismItems.Ingot, 1, 1)); + } +} diff --git a/src/main/java/mekanism/client/jei/machine/advanced/PurificationChamberRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/advanced/PurificationChamberRecipeWrapper.java new file mode 100644 index 000000000..36ed28d0b --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/advanced/PurificationChamberRecipeWrapper.java @@ -0,0 +1,34 @@ +package mekanism.client.jei.machine.advanced; + +import mekanism.api.gas.Gas; +import mekanism.client.jei.machine.AdvancedMachineRecipeCategory; +import mekanism.client.jei.machine.AdvancedMachineRecipeWrapper; +import mekanism.common.MekanismFluids; +import mekanism.common.Tier.GasTankTier; +import mekanism.common.recipe.machines.AdvancedMachineRecipe; +import mekanism.common.util.ListUtils; +import mekanism.common.util.MekanismUtils; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +import java.util.ArrayList; +import java.util.List; + +public class PurificationChamberRecipeWrapper extends AdvancedMachineRecipeWrapper +{ + public PurificationChamberRecipeWrapper(AdvancedMachineRecipe r, AdvancedMachineRecipeCategory c) + { + super(r, c); + } + + @Override + public List getFuelStacks(Gas gasType) + { + if(gasType == MekanismFluids.Oxygen) + { + return ListUtils.asList(new ItemStack(Items.FLINT), MekanismUtils.getFullGasTank(GasTankTier.BASIC, MekanismFluids.Oxygen)); + } + + return new ArrayList(); + } +} diff --git a/src/main/java/mekanism/client/jei/machine/basic/CrusherRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/basic/CrusherRecipeWrapper.java new file mode 100644 index 000000000..cd15ec112 --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/basic/CrusherRecipeWrapper.java @@ -0,0 +1,13 @@ +package mekanism.client.jei.machine.basic; + +import mekanism.client.jei.machine.MachineRecipeCategory; +import mekanism.client.jei.machine.MachineRecipeWrapper; +import mekanism.common.recipe.machines.BasicMachineRecipe; + +public class CrusherRecipeWrapper extends MachineRecipeWrapper +{ + public CrusherRecipeWrapper(BasicMachineRecipe r, MachineRecipeCategory c) + { + super(r, c); + } +} diff --git a/src/main/java/mekanism/client/jei/machine/basic/EnrichmentRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/basic/EnrichmentRecipeWrapper.java new file mode 100644 index 000000000..6333210a4 --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/basic/EnrichmentRecipeWrapper.java @@ -0,0 +1,13 @@ +package mekanism.client.jei.machine.basic; + +import mekanism.client.jei.machine.MachineRecipeCategory; +import mekanism.client.jei.machine.MachineRecipeWrapper; +import mekanism.common.recipe.machines.BasicMachineRecipe; + +public class EnrichmentRecipeWrapper extends MachineRecipeWrapper +{ + public EnrichmentRecipeWrapper(BasicMachineRecipe r, MachineRecipeCategory c) + { + super(r, c); + } +} diff --git a/src/main/java/mekanism/client/jei/machine/chance/PrecisionSawmillRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/chance/PrecisionSawmillRecipeWrapper.java new file mode 100644 index 000000000..145251061 --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/chance/PrecisionSawmillRecipeWrapper.java @@ -0,0 +1,13 @@ +package mekanism.client.jei.machine.chance; + +import mekanism.client.jei.machine.ChanceMachineRecipeCategory; +import mekanism.client.jei.machine.ChanceMachineRecipeWrapper; +import mekanism.common.recipe.machines.ChanceMachineRecipe; + +public class PrecisionSawmillRecipeWrapper extends ChanceMachineRecipeWrapper +{ + public PrecisionSawmillRecipeWrapper(ChanceMachineRecipe r, ChanceMachineRecipeCategory c) + { + super(r, c); + } +} diff --git a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalCrystallizerRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalCrystallizerRecipeCategory.java new file mode 100644 index 000000000..35e4de0ee --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalCrystallizerRecipeCategory.java @@ -0,0 +1,76 @@ +package mekanism.client.jei.machine.chemical; + +import mekanism.api.gas.GasStack; +import mekanism.client.jei.BaseRecipeCategory; +import mekanism.common.recipe.machines.CrystallizerRecipe; +import mezz.jei.api.IGuiHelper; +import mezz.jei.api.gui.IDrawable; +import mezz.jei.api.gui.IGuiItemStackGroup; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.ITickTimer; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.IRecipeWrapper; +import net.minecraft.client.Minecraft; +import net.minecraft.util.ResourceLocation; + +public class ChemicalCrystallizerRecipeCategory extends BaseRecipeCategory +{ + public IGuiHelper guiHelper; + + public IDrawable background; + + public CrystallizerRecipe tempRecipe; + + public ITickTimer timer; + + public ChemicalCrystallizerRecipeCategory(IGuiHelper helper) + { + super("mekanism:gui/nei/GuiChemicalCrystallizer.png", "chemical_crystallizer", "tile.MachineBlock2.ChemicalCrystallizer.name", null); + + guiHelper = helper; + + timer = helper.createTickTimer(20, 20, false); + + xOffset = 5; + yOffset = 3; + + background = guiHelper.createDrawable(new ResourceLocation(guiTexture), xOffset, yOffset, 147, 79); + } + + @Override + public void drawExtras(Minecraft minecraft) + { + super.drawExtras(minecraft); + + GasStack gas = tempRecipe.getInput().ingredient; + + float f = (float)timer.getValue() / 20F; + drawTexturedRect(53-xOffset, 61-yOffset, 176, 63, (int)(48*f), 8); + + if(gas != null) + { + displayGauge(58, 6-xOffset, 5-yOffset, 176, 4, 58, null, gas); + } + } + + @Override + public IDrawable getBackground() + { + return background; + } + + @Override + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) + { + if(recipeWrapper instanceof ChemicalCrystallizerRecipeWrapper) + { + tempRecipe = ((ChemicalCrystallizerRecipeWrapper)recipeWrapper).recipe; + } + + IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); + + itemStacks.init(0, false, 130-xOffset, 56-yOffset); + + itemStacks.set(0, tempRecipe.getOutput().output); + } +} diff --git a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalCrystallizerRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalCrystallizerRecipeWrapper.java new file mode 100644 index 000000000..c0a2f9c6b --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalCrystallizerRecipeWrapper.java @@ -0,0 +1,52 @@ +package mekanism.client.jei.machine.chemical; + +import mekanism.api.gas.GasStack; +import mekanism.client.jei.machine.BaseRecipeWrapper; +import mekanism.common.recipe.machines.CrystallizerRecipe; +import mekanism.common.util.LangUtils; +import mezz.jei.api.ingredients.IIngredients; +import net.minecraft.item.ItemStack; + +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; + +public class ChemicalCrystallizerRecipeWrapper extends BaseRecipeWrapper +{ + public CrystallizerRecipe recipe; + + public ChemicalCrystallizerRecipeCategory category; + + public ChemicalCrystallizerRecipeWrapper(CrystallizerRecipe r, ChemicalCrystallizerRecipeCategory c) + { + recipe = r; + category = c; + } + + @Override + public void getIngredients(IIngredients ingredients) + { + ingredients.setInput(GasStack.class, recipe.recipeInput.ingredient); + ingredients.setOutput(ItemStack.class, recipe.recipeOutput.output); + } + + @Nullable + @Override + public List getTooltipStrings(int mouseX, int mouseY) + { + List currenttip = new ArrayList(); + + if(mouseX >= 1 && mouseX <= 17 && mouseY >= 5-3 && mouseY <= 63-3) + { + currenttip.add(LangUtils.localizeGasStack(recipe.getInput().ingredient)); + } + + return currenttip; + } + + @Override + public ChemicalCrystallizerRecipeCategory getCategory() + { + return category; + } +} diff --git a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalDissolutionChamberRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalDissolutionChamberRecipeCategory.java new file mode 100644 index 000000000..dd89dd078 --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalDissolutionChamberRecipeCategory.java @@ -0,0 +1,79 @@ +package mekanism.client.jei.machine.chemical; + +import mekanism.api.gas.GasStack; +import mekanism.client.jei.BaseRecipeCategory; +import mekanism.common.MekanismFluids; +import mekanism.common.recipe.machines.DissolutionRecipe; +import mezz.jei.api.IGuiHelper; +import mezz.jei.api.gui.IDrawable; +import mezz.jei.api.gui.IGuiItemStackGroup; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.ITickTimer; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.IRecipeWrapper; +import net.minecraft.client.Minecraft; +import net.minecraft.util.ResourceLocation; + +public class ChemicalDissolutionChamberRecipeCategory extends BaseRecipeCategory +{ + public IGuiHelper guiHelper; + + public IDrawable background; + + public DissolutionRecipe tempRecipe; + + public ITickTimer timer; + + public ChemicalDissolutionChamberRecipeCategory(IGuiHelper helper) + { + super("mekanism:gui/nei/GuiChemicalDissolutionChamber.png", "chemical_dissolution_chamber", "gui.chemicalDissolutionChamber.short", null); + + guiHelper = helper; + + timer = helper.createTickTimer(20, 20, false); + + xOffset = 3; + yOffset = 3; + + background = guiHelper.createDrawable(new ResourceLocation(guiTexture), xOffset, yOffset, 170, 79); + } + + @Override + public void drawExtras(Minecraft minecraft) + { + super.drawExtras(minecraft); + + GasStack gas = tempRecipe.getOutput().output; + + float f = (float)timer.getValue() / 20F; + drawTexturedRect(64-xOffset, 40-yOffset, 176, 63, (int)(48*f), 8); + + displayGauge(58, 6-xOffset, 5-yOffset, 176, 4, 58, null, new GasStack(MekanismFluids.SulfuricAcid, 1)); + + if(gas != null) + { + displayGauge(58, 134-xOffset, 14-yOffset, 176, 4, 58, null, gas); + } + } + + @Override + public IDrawable getBackground() + { + return background; + } + + @Override + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) + { + if(recipeWrapper instanceof ChemicalDissolutionChamberRecipeWrapper) + { + tempRecipe = ((ChemicalDissolutionChamberRecipeWrapper)recipeWrapper).recipe; + } + + IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); + + itemStacks.init(0, true, 25-xOffset, 35-yOffset); + + itemStacks.set(0, tempRecipe.getInput().ingredient); + } +} diff --git a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalDissolutionChamberRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalDissolutionChamberRecipeWrapper.java new file mode 100644 index 000000000..0513d6af8 --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalDissolutionChamberRecipeWrapper.java @@ -0,0 +1,58 @@ +package mekanism.client.jei.machine.chemical; + +import mekanism.api.gas.GasStack; +import mekanism.client.jei.machine.BaseRecipeWrapper; +import mekanism.common.MekanismFluids; +import mekanism.common.recipe.machines.DissolutionRecipe; +import mekanism.common.util.LangUtils; +import mezz.jei.api.ingredients.IIngredients; +import net.minecraft.item.ItemStack; + +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; + +public class ChemicalDissolutionChamberRecipeWrapper extends BaseRecipeWrapper +{ + public DissolutionRecipe recipe; + + public ChemicalDissolutionChamberRecipeCategory category; + + public ChemicalDissolutionChamberRecipeWrapper(DissolutionRecipe r, ChemicalDissolutionChamberRecipeCategory c) + { + recipe = r; + category = c; + } + + @Override + public void getIngredients(IIngredients ingredients) + { + ingredients.setInput(GasStack.class, new GasStack(MekanismFluids.SulfuricAcid, 1000)); + ingredients.setInput(ItemStack.class, recipe.recipeInput.ingredient); + ingredients.setOutput(GasStack.class, recipe.recipeOutput.output); + } + + @Nullable + @Override + public List getTooltipStrings(int mouseX, int mouseY) + { + List currenttip = new ArrayList(); + + if(mouseX >= 6-3 && mouseX <= 22-3 && mouseY >= 5-3 && mouseY <= 63-3) + { + currenttip.add(MekanismFluids.SulfuricAcid.getLocalizedName()); + } + else if(mouseX >= 134-3 && mouseX <= 150-3 && mouseY >= 14-3 && mouseY <= 72-3) + { + currenttip.add(LangUtils.localizeGasStack(recipe.getOutput().output)); + } + + return currenttip; + } + + @Override + public ChemicalDissolutionChamberRecipeCategory getCategory() + { + return category; + } +} diff --git a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalInfuserRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalInfuserRecipeCategory.java new file mode 100644 index 000000000..10efbef17 --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalInfuserRecipeCategory.java @@ -0,0 +1,76 @@ +package mekanism.client.jei.machine.chemical; + +import mekanism.client.jei.BaseRecipeCategory; +import mekanism.common.recipe.machines.ChemicalInfuserRecipe; +import mezz.jei.api.IGuiHelper; +import mezz.jei.api.gui.IDrawable; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.ITickTimer; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.IRecipeWrapper; +import net.minecraft.client.Minecraft; +import net.minecraft.util.ResourceLocation; + +public class ChemicalInfuserRecipeCategory extends BaseRecipeCategory +{ + public IGuiHelper guiHelper; + + public IDrawable background; + + public ChemicalInfuserRecipe tempRecipe; + + public ITickTimer timer; + + public ChemicalInfuserRecipeCategory(IGuiHelper helper) + { + super("mekanism:gui/nei/GuiChemicalInfuser.png", "chemical_infuser", "tile.MachineBlock2.ChemicalInfuser.name", null); + + guiHelper = helper; + + timer = helper.createTickTimer(20, 20, false); + + xOffset = 3; + yOffset = 3; + + background = guiHelper.createDrawable(new ResourceLocation(guiTexture), xOffset, yOffset, 170, 80); + } + + @Override + public void drawExtras(Minecraft minecraft) + { + super.drawExtras(minecraft); + + drawTexturedRect(47-xOffset, 39-yOffset, 176, 71, 28, 8); + drawTexturedRect(101-xOffset, 39-yOffset, 176, 63, 28, 8); + + if(tempRecipe.getInput().leftGas != null) + { + displayGauge(58, 26-xOffset, 14-yOffset, 176, 4, 58, null, tempRecipe.getInput().leftGas); + } + + if(tempRecipe.getOutput().output != null) + { + displayGauge(58, 80-xOffset, 5-yOffset, 176, 4, 58, null, tempRecipe.getOutput().output); + } + + if(tempRecipe.getInput().rightGas != null) + { + displayGauge(58, 134-xOffset, 14-yOffset, 176, 4, 58, null, tempRecipe.getInput().rightGas); + } + } + + @Override + public IDrawable getBackground() + { + return background; + } + + @Override + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) + { + if(recipeWrapper instanceof ChemicalInfuserRecipeWrapper) + { + tempRecipe = ((ChemicalInfuserRecipeWrapper)recipeWrapper).recipe; + } + } +} diff --git a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalInfuserRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalInfuserRecipeWrapper.java new file mode 100644 index 000000000..7d4a67469 --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalInfuserRecipeWrapper.java @@ -0,0 +1,60 @@ +package mekanism.client.jei.machine.chemical; + +import mekanism.api.gas.GasStack; +import mekanism.client.jei.machine.BaseRecipeWrapper; +import mekanism.common.recipe.machines.ChemicalInfuserRecipe; +import mekanism.common.util.LangUtils; +import mezz.jei.api.ingredients.IIngredients; + +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class ChemicalInfuserRecipeWrapper extends BaseRecipeWrapper +{ + public ChemicalInfuserRecipe recipe; + + public ChemicalInfuserRecipeCategory category; + + public ChemicalInfuserRecipeWrapper(ChemicalInfuserRecipe r, ChemicalInfuserRecipeCategory c) + { + recipe = r; + category = c; + } + + @Override + public void getIngredients(IIngredients ingredients) + { + ingredients.setInputs(GasStack.class, Arrays.asList(recipe.recipeInput.leftGas, recipe.recipeInput.rightGas)); + ingredients.setOutput(GasStack.class, recipe.recipeOutput.output); + } + + @Nullable + @Override + public List getTooltipStrings(int mouseX, int mouseY) + { + List currenttip = new ArrayList(); + + if(mouseX >= 26-3 && mouseX <= 42-3 && mouseY >= 14-3 && mouseY <= 72-3) + { + currenttip.add(LangUtils.localizeGasStack(recipe.getInput().leftGas)); + } + else if(mouseX >= 80-3 && mouseX <= 96-3 && mouseY >= 5-3 && mouseY <= 63-3) + { + currenttip.add(LangUtils.localizeGasStack(recipe.getOutput().output)); + } + else if(mouseX >= 134-3 && mouseX <= 150-3 && mouseY >= 14-3 && mouseY <= 72-3) + { + currenttip.add(LangUtils.localizeGasStack(recipe.getInput().rightGas)); + } + + return currenttip; + } + + @Override + public ChemicalInfuserRecipeCategory getCategory() + { + return category; + } +} diff --git a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalOxidizerRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalOxidizerRecipeCategory.java new file mode 100644 index 000000000..26200d23a --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalOxidizerRecipeCategory.java @@ -0,0 +1,98 @@ +package mekanism.client.jei.machine.chemical; + +import mekanism.client.gui.element.GuiGasGauge; +import mekanism.client.gui.element.GuiGauge; +import mekanism.client.gui.element.GuiProgress; +import mekanism.client.gui.element.GuiProgress.IProgressInfoHandler; +import mekanism.client.gui.element.GuiProgress.ProgressBar; +import mekanism.client.gui.element.GuiSlot; +import mekanism.client.gui.element.GuiSlot.SlotType; +import mekanism.client.jei.BaseRecipeCategory; +import mekanism.common.recipe.machines.OxidationRecipe; +import mekanism.common.util.MekanismUtils; +import mekanism.common.util.MekanismUtils.ResourceType; +import mezz.jei.api.IGuiHelper; +import mezz.jei.api.gui.IDrawable; +import mezz.jei.api.gui.IGuiItemStackGroup; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.ITickTimer; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.IRecipeWrapper; +import net.minecraft.client.Minecraft; +import net.minecraft.util.ResourceLocation; + +public class ChemicalOxidizerRecipeCategory extends BaseRecipeCategory +{ + public IGuiHelper guiHelper; + + public IDrawable background; + + public OxidationRecipe tempRecipe; + + public GuiGasGauge gasOutput; + + public ITickTimer timer; + + public ChemicalOxidizerRecipeCategory(IGuiHelper helper) + { + super("mekanism:gui/GuiChemicalOxidizer.png", "chemical_oxidizer", "tile.MachineBlock2.ChemicalOxidizer.name", ProgressBar.LARGE_RIGHT); + + guiHelper = helper; + + timer = helper.createTickTimer(20, 20, false); + + xOffset = 20; + yOffset = 12; + + background = guiHelper.createDrawable(new ResourceLocation(guiTexture), xOffset, yOffset, 132, 62); + } + + @Override + public void addGuiElements() + { + guiElements.add(gasOutput = GuiGasGauge.getDummy(GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"), 133, 13)); + + guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"), 25, 35)); + + guiElements.add(new GuiProgress(new IProgressInfoHandler() + { + @Override + public double getProgress() + { + return (double)timer.getValue() / 20F; + } + }, progressBar, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"), 62, 39)); + } + + @Override + public void drawExtras(Minecraft minecraft) + { + super.drawExtras(minecraft); + + if(tempRecipe.getOutput().output != null) + { + gasOutput.setDummyType(tempRecipe.getOutput().output.getGas()); + gasOutput.renderScale(0, 0, -xOffset, -yOffset); + } + } + + @Override + public IDrawable getBackground() + { + return background; + } + + @Override + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) + { + if(recipeWrapper instanceof ChemicalOxidizerRecipeWrapper) + { + tempRecipe = ((ChemicalOxidizerRecipeWrapper)recipeWrapper).recipe; + } + + IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); + + itemStacks.init(0, true, 25-xOffset, 35-yOffset); + itemStacks.set(0, tempRecipe.getInput().ingredient); + } +} diff --git a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalOxidizerRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalOxidizerRecipeWrapper.java new file mode 100644 index 000000000..cd0ee2111 --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalOxidizerRecipeWrapper.java @@ -0,0 +1,52 @@ +package mekanism.client.jei.machine.chemical; + +import mekanism.api.gas.GasStack; +import mekanism.client.jei.machine.BaseRecipeWrapper; +import mekanism.common.recipe.machines.OxidationRecipe; +import mekanism.common.util.LangUtils; +import mezz.jei.api.ingredients.IIngredients; +import net.minecraft.item.ItemStack; + +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; + +public class ChemicalOxidizerRecipeWrapper extends BaseRecipeWrapper +{ + public OxidationRecipe recipe; + + public ChemicalOxidizerRecipeCategory category; + + public ChemicalOxidizerRecipeWrapper(OxidationRecipe r, ChemicalOxidizerRecipeCategory c) + { + recipe = r; + category = c; + } + + @Override + public void getIngredients(IIngredients ingredients) + { + ingredients.setInput(ItemStack.class, recipe.recipeInput.ingredient); + ingredients.setOutput(GasStack.class, recipe.recipeOutput.output); + } + + @Nullable + @Override + public List getTooltipStrings(int mouseX, int mouseY) + { + List currenttip = new ArrayList(); + + if(mouseX >= 134-20 && mouseX <= 150-20 && mouseY >= 14-12 && mouseY <= 72-12) + { + currenttip.add(LangUtils.localizeGasStack(recipe.getOutput().output)); + } + + return currenttip; + } + + @Override + public ChemicalOxidizerRecipeCategory getCategory() + { + return category; + } +} diff --git a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalWasherRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalWasherRecipeCategory.java new file mode 100644 index 000000000..bd7e9e479 --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalWasherRecipeCategory.java @@ -0,0 +1,90 @@ +package mekanism.client.jei.machine.chemical; + +import mekanism.client.jei.BaseRecipeCategory; +import mekanism.common.recipe.machines.WasherRecipe; +import mezz.jei.api.IGuiHelper; +import mezz.jei.api.gui.IDrawable; +import mezz.jei.api.gui.IGuiFluidStackGroup; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.ITickTimer; +import mezz.jei.api.gui.ITooltipCallback; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.IRecipeWrapper; +import net.minecraft.client.Minecraft; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.FluidStack; + +import java.util.List; + +public class ChemicalWasherRecipeCategory extends BaseRecipeCategory +{ + public IGuiHelper guiHelper; + + public IDrawable background; + public IDrawable fluidOverlay; + + public WasherRecipe tempRecipe; + + public ITickTimer timer; + + public ChemicalWasherRecipeCategory(IGuiHelper helper) + { + super("mekanism:gui/nei/GuiChemicalWasher.png", "chemical_washer", "tile.MachineBlock2.ChemicalWasher.name", null); + + guiHelper = helper; + + timer = helper.createTickTimer(20, 20, false); + + xOffset = 3; + yOffset = 3; + + background = guiHelper.createDrawable(new ResourceLocation(guiTexture), xOffset, yOffset, 170, 70); + fluidOverlay = guiHelper.createDrawable(new ResourceLocation(guiTexture), 176, 4, 16, 59); + } + + @Override + public void drawExtras(Minecraft minecraft) + { + super.drawExtras(minecraft); + + drawTexturedRect(61-xOffset, 39-yOffset, 176, 63, 55, 8); + + if(tempRecipe.getInput().ingredient != null) + { + displayGauge(58, 27-xOffset, 14-yOffset, 176, 4, 58, null, tempRecipe.getInput().ingredient); + } + + if(tempRecipe.getOutput().output != null) + { + displayGauge(58, 134-xOffset, 14-yOffset, 176, 4, 58, null, tempRecipe.getOutput().output); + } + } + + @Override + public IDrawable getBackground() + { + return background; + } + + @Override + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) + { + if(recipeWrapper instanceof ChemicalWasherRecipeWrapper) + { + tempRecipe = ((ChemicalWasherRecipeWrapper)recipeWrapper).recipe; + } + + IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks(); + + fluidStacks.init(0, true, 6-xOffset, 5-yOffset, 16, 58, 1000, false, fluidOverlay); + fluidStacks.set(0, ingredients.getInputs(FluidStack.class).get(0)); + fluidStacks.addTooltipCallback(new ITooltipCallback() { + + @Override + public void onTooltip(int slotIndex, boolean input, FluidStack ingredient, List tooltip) + { + tooltip.remove(1); + } + }); + } +} diff --git a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalWasherRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalWasherRecipeWrapper.java new file mode 100644 index 000000000..723daf92d --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalWasherRecipeWrapper.java @@ -0,0 +1,58 @@ +package mekanism.client.jei.machine.chemical; + +import mekanism.api.gas.GasStack; +import mekanism.client.jei.machine.BaseRecipeWrapper; +import mekanism.common.recipe.machines.WasherRecipe; +import mekanism.common.util.LangUtils; +import mezz.jei.api.ingredients.IIngredients; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; + +public class ChemicalWasherRecipeWrapper extends BaseRecipeWrapper +{ + public WasherRecipe recipe; + + public ChemicalWasherRecipeCategory category; + + public ChemicalWasherRecipeWrapper(WasherRecipe r, ChemicalWasherRecipeCategory c) + { + recipe = r; + category = c; + } + + @Override + public void getIngredients(IIngredients ingredients) + { + ingredients.setInput(FluidStack.class, new FluidStack(FluidRegistry.WATER, 1000)); + ingredients.setInput(GasStack.class, recipe.recipeInput.ingredient); + ingredients.setOutput(GasStack.class, recipe.recipeOutput.output); + } + + @Nullable + @Override + public List getTooltipStrings(int mouseX, int mouseY) + { + List currenttip = new ArrayList(); + + if(mouseX >= 27-3 && mouseX <= 43-3 && mouseY >= 14-3 && mouseY <= 72-3) + { + currenttip.add(LangUtils.localizeGasStack(recipe.getInput().ingredient)); + } + else if(mouseX >= 134-3 && mouseX <= 150-3 && mouseY >= 14-3 && mouseY <= 72-3) + { + currenttip.add(LangUtils.localizeGasStack(recipe.getOutput().output)); + } + + return currenttip; + } + + @Override + public ChemicalWasherRecipeCategory getCategory() + { + return category; + } +} diff --git a/src/main/java/mekanism/client/jei/machine/other/ElectrolyticSeparatorRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/other/ElectrolyticSeparatorRecipeCategory.java new file mode 100644 index 000000000..b4671305d --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/other/ElectrolyticSeparatorRecipeCategory.java @@ -0,0 +1,137 @@ +package mekanism.client.jei.machine.other; + +import mekanism.client.gui.element.GuiFluidGauge; +import mekanism.client.gui.element.GuiGasGauge; +import mekanism.client.gui.element.GuiGauge; +import mekanism.client.gui.element.GuiPowerBar; +import mekanism.client.gui.element.GuiPowerBar.IPowerInfoHandler; +import mekanism.client.gui.element.GuiProgress; +import mekanism.client.gui.element.GuiProgress.IProgressInfoHandler; +import mekanism.client.gui.element.GuiProgress.ProgressBar; +import mekanism.client.gui.element.GuiSlot; +import mekanism.client.gui.element.GuiSlot.SlotOverlay; +import mekanism.client.gui.element.GuiSlot.SlotType; +import mekanism.client.jei.BaseRecipeCategory; +import mekanism.common.recipe.machines.SeparatorRecipe; +import mekanism.common.util.MekanismUtils; +import mekanism.common.util.MekanismUtils.ResourceType; +import mezz.jei.api.IGuiHelper; +import mezz.jei.api.gui.IDrawable; +import mezz.jei.api.gui.IGuiFluidStackGroup; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.ITickTimer; +import mezz.jei.api.gui.ITooltipCallback; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.IRecipeWrapper; +import net.minecraft.client.Minecraft; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.FluidStack; + +import java.util.List; + +public class ElectrolyticSeparatorRecipeCategory extends BaseRecipeCategory +{ + public IGuiHelper guiHelper; + + public IDrawable background; + public IDrawable fluidOverlay; + + public GuiGasGauge leftGas; + public GuiGasGauge rightGas; + + public SeparatorRecipe tempRecipe; + + public ITickTimer timer; + + public ElectrolyticSeparatorRecipeCategory(IGuiHelper helper) + { + super("mekanism:gui/GuiElectrolyticSeparator.png", "electrolytic_separator", "tile.MachineBlock2.ElectrolyticSeparator.name", ProgressBar.BI); + + guiHelper = helper; + + timer = helper.createTickTimer(20, 20, false); + + xOffset = 4; + yOffset = 9; + + background = guiHelper.createDrawable(new ResourceLocation(guiTexture), xOffset, yOffset, 167, 62); + fluidOverlay = guiHelper.createDrawable(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, GuiGauge.Type.STANDARD.textureLocation), 19, 1, 16, 59); + } + + @Override + public void addGuiElements() + { + guiElements.add(GuiFluidGauge.getDummy(GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 5, 10)); + guiElements.add(leftGas = GuiGasGauge.getDummy(GuiGauge.Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 58, 18)); + guiElements.add(rightGas = GuiGasGauge.getDummy(GuiGauge.Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 100, 18)); + guiElements.add(new GuiPowerBar(this, new IPowerInfoHandler() { + @Override + public double getLevel() + { + return 1F; + } + }, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 164, 15)); + + guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 25, 34)); + guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 58, 51)); + guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 100, 51)); + guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 142, 34).with(SlotOverlay.POWER)); + + guiElements.add(new GuiProgress(new IProgressInfoHandler() + { + @Override + public double getProgress() + { + return 1; + } + }, progressBar, this, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 78, 29)); + } + + @Override + public void drawExtras(Minecraft minecraft) + { + super.drawExtras(minecraft); + + if(tempRecipe.getOutput().leftGas != null) + { + leftGas.setDummyType(tempRecipe.getOutput().leftGas.getGas()); + leftGas.renderScale(0, 0, -xOffset, -yOffset); + } + + if(tempRecipe.getOutput().rightGas != null) + { + rightGas.setDummyType(tempRecipe.getOutput().rightGas.getGas()); + rightGas.renderScale(0, 0, -xOffset, -yOffset); + } + + changeTexture(guiLocation); + } + + @Override + public IDrawable getBackground() + { + return background; + } + + @Override + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) + { + if(recipeWrapper instanceof ElectrolyticSeparatorRecipeWrapper) + { + tempRecipe = ((ElectrolyticSeparatorRecipeWrapper)recipeWrapper).recipe; + } + + IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks(); + + fluidStacks.init(0, true, 2, 2, 16, 58, tempRecipe.getInput().ingredient.amount, false, fluidOverlay); + fluidStacks.set(0, ingredients.getInputs(FluidStack.class).get(0)); + fluidStacks.addTooltipCallback(new ITooltipCallback() { + + @Override + public void onTooltip(int slotIndex, boolean input, FluidStack ingredient, List tooltip) + { + tooltip.remove(1); + } + }); + } +} diff --git a/src/main/java/mekanism/client/jei/machine/other/ElectrolyticSeparatorRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/other/ElectrolyticSeparatorRecipeWrapper.java new file mode 100644 index 000000000..4080f3734 --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/other/ElectrolyticSeparatorRecipeWrapper.java @@ -0,0 +1,56 @@ +package mekanism.client.jei.machine.other; + +import mekanism.api.gas.GasStack; +import mekanism.client.jei.machine.BaseRecipeWrapper; +import mekanism.common.recipe.machines.SeparatorRecipe; +import mezz.jei.api.ingredients.IIngredients; +import net.minecraftforge.fluids.FluidStack; + +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class ElectrolyticSeparatorRecipeWrapper extends BaseRecipeWrapper +{ + public SeparatorRecipe recipe; + + public ElectrolyticSeparatorRecipeCategory category; + + public ElectrolyticSeparatorRecipeWrapper(SeparatorRecipe r, ElectrolyticSeparatorRecipeCategory c) + { + recipe = r; + category = c; + } + + @Override + public void getIngredients(IIngredients ingredients) + { + ingredients.setInput(FluidStack.class, recipe.recipeInput.ingredient); + ingredients.setOutputs(GasStack.class, Arrays.asList(recipe.recipeOutput.leftGas, recipe.recipeOutput.rightGas)); + } + + @Nullable + @Override + public List getTooltipStrings(int mouseX, int mouseY) + { + List currenttip = new ArrayList(); + + if(mouseX >= 59-4 && mouseX <= 75-4 && mouseY >= 19-9 && mouseY <= 47-9) + { + currenttip.add(recipe.getOutput().leftGas.getGas().getLocalizedName()); + } + else if(mouseX >= 101-4 && mouseX <= 117-4 && mouseY >= 19-9 && mouseY <= 47-9) + { + currenttip.add(recipe.getOutput().rightGas.getGas().getLocalizedName()); + } + + return currenttip; + } + + @Override + public ElectrolyticSeparatorRecipeCategory getCategory() + { + return category; + } +} diff --git a/src/main/java/mekanism/client/jei/machine/other/MetallurgicInfuserRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/other/MetallurgicInfuserRecipeCategory.java new file mode 100644 index 000000000..7490d5b6e --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/other/MetallurgicInfuserRecipeCategory.java @@ -0,0 +1,131 @@ +package mekanism.client.jei.machine.other; + +import mekanism.api.infuse.InfuseObject; +import mekanism.api.infuse.InfuseRegistry; +import mekanism.api.infuse.InfuseType; +import mekanism.client.gui.element.GuiPowerBar; +import mekanism.client.gui.element.GuiPowerBar.IPowerInfoHandler; +import mekanism.client.gui.element.GuiProgress; +import mekanism.client.gui.element.GuiProgress.IProgressInfoHandler; +import mekanism.client.gui.element.GuiProgress.ProgressBar; +import mekanism.client.gui.element.GuiSlot; +import mekanism.client.gui.element.GuiSlot.SlotOverlay; +import mekanism.client.gui.element.GuiSlot.SlotType; +import mekanism.client.jei.BaseRecipeCategory; +import mekanism.client.render.MekanismRenderer; +import mekanism.common.recipe.machines.MetallurgicInfuserRecipe; +import mekanism.common.util.MekanismUtils; +import mekanism.common.util.MekanismUtils.ResourceType; +import mezz.jei.api.IGuiHelper; +import mezz.jei.api.gui.IDrawable; +import mezz.jei.api.gui.IGuiItemStackGroup; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.ITickTimer; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.IRecipeWrapper; +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class MetallurgicInfuserRecipeCategory extends BaseRecipeCategory +{ + public IGuiHelper guiHelper; + + public IDrawable background; + + public MetallurgicInfuserRecipe tempRecipe; + + public ITickTimer timer; + + public MetallurgicInfuserRecipeCategory(IGuiHelper helper) + { + super("mekanism:gui/GuiMetallurgicInfuser.png", "metallurgic_infuser", "tile.MachineBlock.MetallurgicInfuser.name", ProgressBar.MEDIUM); + + guiHelper = helper; + + timer = helper.createTickTimer(20, 20, false); + + xOffset = 5; + yOffset = 16; + + background = guiHelper.createDrawable(new ResourceLocation(guiTexture), xOffset, yOffset, 166, 54); + } + + @Override + public void addGuiElements() + { + guiElements.add(new GuiSlot(SlotType.EXTRA, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 16, 34)); + guiElements.add(new GuiSlot(SlotType.INPUT, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 50, 42)); + guiElements.add(new GuiSlot(SlotType.POWER, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 142, 34).with(SlotOverlay.POWER)); + guiElements.add(new GuiSlot(SlotType.OUTPUT, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 108, 42)); + + guiElements.add(new GuiPowerBar(this, new IPowerInfoHandler() { + @Override + public double getLevel() + { + return 1F; + } + }, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 164, 15)); + guiElements.add(new GuiProgress(new IProgressInfoHandler() { + @Override + public double getProgress() + { + return (double)timer.getValue() / 20F; + } + }, ProgressBar.MEDIUM, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 70, 46)); + } + + public static List getInfuseStacks(InfuseType type) + { + List ret = new ArrayList(); + + for(Map.Entry obj : InfuseRegistry.getObjectMap().entrySet()) + { + if(obj.getValue().type == type) + { + ret.add(obj.getKey()); + } + } + + return ret; + } + + @Override + public void drawExtras(Minecraft minecraft) + { + super.drawExtras(minecraft); + + InfuseType type = tempRecipe.getInput().infuse.type; + changeTexture(MekanismRenderer.getBlocksTexture()); + drawTexturedRectFromIcon(2, 2, type.sprite, 4, 52); + } + + @Override + public IDrawable getBackground() + { + return background; + } + + @Override + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) + { + if(recipeWrapper instanceof MetallurgicInfuserRecipeWrapper) + { + tempRecipe = ((MetallurgicInfuserRecipeWrapper)recipeWrapper).recipe; + } + + IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); + + itemStacks.init(0, true, 45, 26); + itemStacks.init(1, false, 103, 26); + itemStacks.init(2, true, 11, 18); + + itemStacks.set(0, tempRecipe.getInput().inputStack); + itemStacks.set(1, tempRecipe.getOutput().output); + itemStacks.set(2, getInfuseStacks(tempRecipe.getInput().infuse.type)); + } +} diff --git a/src/main/java/mekanism/client/jei/machine/other/MetallurgicInfuserRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/other/MetallurgicInfuserRecipeWrapper.java new file mode 100644 index 000000000..11c7f46c6 --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/other/MetallurgicInfuserRecipeWrapper.java @@ -0,0 +1,39 @@ +package mekanism.client.jei.machine.other; + +import mekanism.client.jei.machine.BaseRecipeWrapper; +import mekanism.common.recipe.machines.MetallurgicInfuserRecipe; +import mezz.jei.api.ingredients.IIngredients; +import net.minecraft.item.ItemStack; + +import java.util.Arrays; +import java.util.List; + +public class MetallurgicInfuserRecipeWrapper extends BaseRecipeWrapper +{ + public MetallurgicInfuserRecipe recipe; + + public MetallurgicInfuserRecipeCategory category; + + public MetallurgicInfuserRecipeWrapper(MetallurgicInfuserRecipe r, MetallurgicInfuserRecipeCategory c) + { + recipe = r; + category = c; + } + + @Override + public void getIngredients(IIngredients ingredients) + { + List inputStacks = Arrays.asList(recipe.recipeInput.inputStack); + List infuseStacks = MetallurgicInfuserRecipeCategory.getInfuseStacks(recipe.getInput().infuse.type); + + ingredients.setInput(ItemStack.class, recipe.recipeInput.inputStack); + ingredients.setInputLists(ItemStack.class, Arrays.asList(inputStacks, infuseStacks)); + ingredients.setOutput(ItemStack.class, recipe.recipeOutput.output); + } + + @Override + public MetallurgicInfuserRecipeCategory getCategory() + { + return category; + } +} diff --git a/src/main/java/mekanism/client/jei/machine/other/PRCRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/other/PRCRecipeCategory.java new file mode 100644 index 000000000..d9965ec04 --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/other/PRCRecipeCategory.java @@ -0,0 +1,142 @@ +package mekanism.client.jei.machine.other; + +import mekanism.client.gui.element.GuiFluidGauge; +import mekanism.client.gui.element.GuiGasGauge; +import mekanism.client.gui.element.GuiGauge; +import mekanism.client.gui.element.GuiPowerBar; +import mekanism.client.gui.element.GuiPowerBar.IPowerInfoHandler; +import mekanism.client.gui.element.GuiProgress; +import mekanism.client.gui.element.GuiProgress.IProgressInfoHandler; +import mekanism.client.gui.element.GuiProgress.ProgressBar; +import mekanism.client.gui.element.GuiSlot; +import mekanism.client.gui.element.GuiSlot.SlotOverlay; +import mekanism.client.gui.element.GuiSlot.SlotType; +import mekanism.client.jei.BaseRecipeCategory; +import mekanism.common.recipe.machines.PressurizedRecipe; +import mekanism.common.util.MekanismUtils; +import mekanism.common.util.MekanismUtils.ResourceType; +import mezz.jei.api.IGuiHelper; +import mezz.jei.api.gui.IDrawable; +import mezz.jei.api.gui.IGuiFluidStackGroup; +import mezz.jei.api.gui.IGuiItemStackGroup; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.ITickTimer; +import mezz.jei.api.gui.ITooltipCallback; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.IRecipeWrapper; +import net.minecraft.client.Minecraft; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.FluidStack; + +import java.util.List; + +public class PRCRecipeCategory extends BaseRecipeCategory +{ + public IGuiHelper guiHelper; + + public IDrawable background; + public IDrawable fluidOverlay; + + public GuiGasGauge gasInput; + public GuiGasGauge gasOutput; + + public PressurizedRecipe tempRecipe; + + public ITickTimer timer; + + public PRCRecipeCategory(IGuiHelper helper) + { + super("mekanism:gui/nei/GuiPRC.png", "pressurized_reaction_chamber", "tile.MachineBlock2.PressurizedReactionChamber.short.name", ProgressBar.MEDIUM); + + guiHelper = helper; + + timer = helper.createTickTimer(20, 20, false); + + xOffset = 3; + yOffset = 11; + + background = guiHelper.createDrawable(new ResourceLocation(guiTexture), xOffset, yOffset, 170, 68); + fluidOverlay = guiHelper.createDrawable(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, GuiGauge.Type.STANDARD.textureLocation), 19, 1, 16, 59); + } + + @Override + public void addGuiElements() + { + guiElements.add(new GuiSlot(SlotType.INPUT, this, guiLocation, 53, 34)); + guiElements.add(new GuiSlot(SlotType.POWER, this, guiLocation, 140, 18).with(SlotOverlay.POWER)); + guiElements.add(new GuiSlot(SlotType.OUTPUT, this, guiLocation, 115, 34)); + + guiElements.add(GuiFluidGauge.getDummy(GuiGauge.Type.STANDARD_YELLOW, this, guiLocation, 5, 10)); + guiElements.add(gasInput = GuiGasGauge.getDummy(GuiGauge.Type.STANDARD_RED, this, guiLocation, 28, 10)); + guiElements.add(gasOutput = GuiGasGauge.getDummy(GuiGauge.Type.SMALL_BLUE, this, guiLocation, 140, 40)); + + guiElements.add(new GuiPowerBar(this, new IPowerInfoHandler() { + @Override + public double getLevel() + { + return 1F; + } + }, guiLocation, 164, 15)); + guiElements.add(new GuiProgress(new IProgressInfoHandler() + { + @Override + public double getProgress() + { + return (float)timer.getValue() / 20F; + } + }, progressBar, this, guiLocation, 75, 37)); + } + + @Override + public void drawExtras(Minecraft minecraft) + { + super.drawExtras(minecraft); + + if(tempRecipe.getInput().getGas() != null) + { + gasInput.setDummyType(tempRecipe.getInput().getGas().getGas()); + gasInput.renderScale(0, 0, -xOffset, -yOffset); + } + + if(tempRecipe.getOutput().getGasOutput() != null) + { + gasOutput.setDummyType(tempRecipe.getOutput().getGasOutput().getGas()); + gasOutput.renderScale(0, 0, -xOffset, -yOffset); + } + } + + @Override + public IDrawable getBackground() + { + return background; + } + + @Override + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) + { + if(recipeWrapper instanceof PRCRecipeWrapper) + { + tempRecipe = ((PRCRecipeWrapper)recipeWrapper).recipe; + } + + IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); + + itemStacks.init(0, true, 53-xOffset, 34-yOffset); + itemStacks.init(1, false, 115-xOffset, 34-yOffset); + + itemStacks.set(0, tempRecipe.recipeInput.getSolid()); + itemStacks.set(1, tempRecipe.recipeOutput.getItemOutput()); + + IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks(); + + fluidStacks.init(0, true, 3, 0, 16, 58, tempRecipe.getInput().getFluid().amount, false, fluidOverlay); + fluidStacks.set(0, tempRecipe.recipeInput.getFluid()); + fluidStacks.addTooltipCallback(new ITooltipCallback() { + @Override + public void onTooltip(int slotIndex, boolean input, FluidStack ingredient, List tooltip) + { + tooltip.remove(1); + } + }); + } +} diff --git a/src/main/java/mekanism/client/jei/machine/other/PRCRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/other/PRCRecipeWrapper.java new file mode 100644 index 000000000..446d52888 --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/other/PRCRecipeWrapper.java @@ -0,0 +1,60 @@ +package mekanism.client.jei.machine.other; + +import mekanism.api.gas.GasStack; +import mekanism.client.jei.machine.BaseRecipeWrapper; +import mekanism.common.recipe.machines.PressurizedRecipe; +import mekanism.common.util.LangUtils; +import mezz.jei.api.ingredients.IIngredients; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; + +public class PRCRecipeWrapper extends BaseRecipeWrapper +{ + public PressurizedRecipe recipe; + + public PRCRecipeCategory category; + + public PRCRecipeWrapper(PressurizedRecipe r, PRCRecipeCategory c) + { + recipe = r; + category = c; + } + + @Override + public void getIngredients(IIngredients ingredients) + { + ingredients.setInput(ItemStack.class, recipe.recipeInput.getSolid()); + ingredients.setInput(FluidStack.class, recipe.recipeInput.getFluid()); + ingredients.setInput(GasStack.class, recipe.recipeInput.getGas()); + ingredients.setOutput(ItemStack.class, recipe.recipeOutput.getItemOutput()); + ingredients.setOutput(GasStack.class, recipe.recipeOutput.getGasOutput()); + } + + @Nullable + @Override + public List getTooltipStrings(int mouseX, int mouseY) + { + List currenttip = new ArrayList(); + + if(mouseX >= 29-3 && mouseX <= 45-3 && mouseY >= 11-12 && mouseY <= 69-12) + { + currenttip.add(LangUtils.localizeGasStack(recipe.getInput().getGas())); + } + else if(mouseX >= 141-3 && mouseX <= 157-3 && mouseY >= 41-12 && mouseY <= 69-12) + { + currenttip.add(LangUtils.localizeGasStack(recipe.getOutput().getGasOutput())); + } + + return currenttip; + } + + @Override + public PRCRecipeCategory getCategory() + { + return category; + } +} diff --git a/src/main/java/mekanism/client/jei/machine/other/RotaryCondensentratorRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/other/RotaryCondensentratorRecipeCategory.java new file mode 100644 index 000000000..964eac84b --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/other/RotaryCondensentratorRecipeCategory.java @@ -0,0 +1,87 @@ +package mekanism.client.jei.machine.other; + +import mekanism.api.gas.GasStack; +import mekanism.client.jei.BaseRecipeCategory; +import mezz.jei.api.IGuiHelper; +import mezz.jei.api.gui.IDrawable; +import mezz.jei.api.gui.IGuiFluidStackGroup; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.ITickTimer; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.IRecipeWrapper; +import net.minecraft.client.Minecraft; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.FluidStack; + +public class RotaryCondensentratorRecipeCategory extends BaseRecipeCategory +{ + public IGuiHelper guiHelper; + + public IDrawable background; + public IDrawable fluidOverlay; + + public RotaryCondensentratorRecipeWrapper tempRecipe; + + public ITickTimer timer; + + public RotaryCondensentratorRecipeCategory(IGuiHelper helper) + { + super("mekanism:gui/nei/GuiRotaryCondensentrator.png", "rotary_condensentrator", "nei.rotaryCondensentrator", null); + + guiHelper = helper; + + timer = helper.createTickTimer(20, 20, false); + + xOffset = 3; + yOffset = 12; + + background = guiHelper.createDrawable(new ResourceLocation(guiTexture), xOffset, yOffset, 170, 71); + fluidOverlay = guiHelper.createDrawable(new ResourceLocation(guiTexture), 176, 40, 16, 59); + } + + @Override + public void drawExtras(Minecraft minecraft) + { + super.drawExtras(minecraft); + + if(tempRecipe.condensentrating) + { + drawTexturedRect(64-xOffset, 39-yOffset, 176, 123, 48, 8); + } + else { + drawTexturedRect(64-xOffset, 39-yOffset, 176, 115, 48, 8); + } + + if(tempRecipe.gasType != null) + { + displayGauge(58, 26-xOffset, 14-yOffset, 176, 40, 58, null, new GasStack(tempRecipe.gasType, 1)); + } + } + + @Override + public IDrawable getBackground() + { + return background; + } + + @Override + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) + { + if(recipeWrapper instanceof RotaryCondensentratorRecipeWrapper) + { + tempRecipe = (RotaryCondensentratorRecipeWrapper)recipeWrapper; + } + + IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks(); + + fluidStacks.init(0, !tempRecipe.condensentrating, 134-xOffset, 14-yOffset, 16, 58, 1000, false, fluidOverlay); + + if(tempRecipe.condensentrating) + { + fluidStacks.set(0, ingredients.getOutputs(FluidStack.class).get(0)); + } + else { + fluidStacks.set(0, ingredients.getInputs(FluidStack.class).get(0)); + } + } +} diff --git a/src/main/java/mekanism/client/jei/machine/other/RotaryCondensentratorRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/other/RotaryCondensentratorRecipeWrapper.java new file mode 100644 index 000000000..9c87b1ea5 --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/other/RotaryCondensentratorRecipeWrapper.java @@ -0,0 +1,76 @@ +package mekanism.client.jei.machine.other; + +import mekanism.api.gas.Gas; +import mekanism.api.gas.GasStack; +import mekanism.client.jei.machine.BaseRecipeWrapper; +import mekanism.common.util.LangUtils; +import mezz.jei.api.ingredients.IIngredients; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; + +public class RotaryCondensentratorRecipeWrapper extends BaseRecipeWrapper +{ + public Fluid fluidType; + public Gas gasType; + + public boolean condensentrating = true; + + public RotaryCondensentratorRecipeCategory category; + + public RotaryCondensentratorRecipeWrapper(Fluid fluid, Gas gas, boolean b, RotaryCondensentratorRecipeCategory c) + { + fluidType = fluid; + gasType = gas; + + condensentrating = b; + category = c; + } + + @Override + public void getIngredients(IIngredients ingredients) + { + if(condensentrating) + { + ingredients.setInput(GasStack.class, new GasStack(gasType, 1000)); + ingredients.setOutput(FluidStack.class, new FluidStack(fluidType, 1000)); + } + else { + ingredients.setInput(FluidStack.class, new FluidStack(fluidType, 1000)); + ingredients.setOutput(GasStack.class, new GasStack(gasType, 1000)); + } + } + + @Override + public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) + { + FontRenderer fontRendererObj = minecraft.fontRenderer; + fontRendererObj.drawString(condensentrating ? LangUtils.localize("gui.condensentrating") : LangUtils.localize("gui.decondensentrating"), 6-3, 74-12, 0x404040, false); + } + + @Nullable + @Override + public List getTooltipStrings(int mouseX, int mouseY) + { + List currenttip = new ArrayList(); + + if(mouseX >= 26-3 && mouseX <= 42-3 && mouseY >= 14-12 && mouseY <= 72-12) + { + currenttip.add(gasType.getLocalizedName()); + } + + return currenttip; + } + + @Override + public RotaryCondensentratorRecipeCategory getCategory() + { + return category; + } +} diff --git a/src/main/java/mekanism/client/jei/machine/other/SolarNeutronRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/other/SolarNeutronRecipeCategory.java new file mode 100644 index 000000000..61605c171 --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/other/SolarNeutronRecipeCategory.java @@ -0,0 +1,70 @@ +package mekanism.client.jei.machine.other; + +import mekanism.client.jei.BaseRecipeCategory; +import mekanism.common.recipe.machines.SolarNeutronRecipe; +import mezz.jei.api.IGuiHelper; +import mezz.jei.api.gui.IDrawable; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.ITickTimer; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.IRecipeWrapper; +import net.minecraft.client.Minecraft; +import net.minecraft.util.ResourceLocation; + +public class SolarNeutronRecipeCategory extends BaseRecipeCategory +{ + public IGuiHelper guiHelper; + + public IDrawable background; + + public SolarNeutronRecipe tempRecipe; + + public ITickTimer timer; + + public SolarNeutronRecipeCategory(IGuiHelper helper) + { + super("mekanism:gui/nei/GuiSolarNeutronActivator.png", "solar_neutron_activator", "tile.MachineBlock3.SolarNeutronActivator.name", null); + + guiHelper = helper; + + timer = helper.createTickTimer(20, 20, false); + + xOffset = 3; + yOffset = 12; + + background = guiHelper.createDrawable(new ResourceLocation(guiTexture), xOffset, yOffset, 170, 70); + } + + @Override + public void drawExtras(Minecraft minecraft) + { + super.drawExtras(minecraft); + + drawTexturedRect(64-xOffset, 39-yOffset, 176, 58, 55, 8); + + if(tempRecipe.getInput().ingredient != null) + { + displayGauge(58, 26-xOffset, 14-yOffset, 176, 0, 58, null, tempRecipe.getInput().ingredient); + } + + if(tempRecipe.getOutput().output != null) + { + displayGauge(58, 134-xOffset, 14-yOffset, 176, 0, 58, null, tempRecipe.getOutput().output); + } + } + + @Override + public IDrawable getBackground() + { + return background; + } + + @Override + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) + { + if(recipeWrapper instanceof SolarNeutronRecipeWrapper) + { + tempRecipe = ((SolarNeutronRecipeWrapper)recipeWrapper).recipe; + } + } +} diff --git a/src/main/java/mekanism/client/jei/machine/other/SolarNeutronRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/other/SolarNeutronRecipeWrapper.java new file mode 100644 index 000000000..38f4cd42f --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/other/SolarNeutronRecipeWrapper.java @@ -0,0 +1,55 @@ +package mekanism.client.jei.machine.other; + +import mekanism.api.gas.GasStack; +import mekanism.client.jei.machine.BaseRecipeWrapper; +import mekanism.common.recipe.machines.SolarNeutronRecipe; +import mekanism.common.util.LangUtils; +import mezz.jei.api.ingredients.IIngredients; + +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; + +public class SolarNeutronRecipeWrapper extends BaseRecipeWrapper +{ + public SolarNeutronRecipe recipe; + + public SolarNeutronRecipeCategory category; + + public SolarNeutronRecipeWrapper(SolarNeutronRecipe r, SolarNeutronRecipeCategory c) + { + recipe = r; + category = c; + } + + @Override + public void getIngredients(IIngredients ingredients) + { + ingredients.setInput(GasStack.class, recipe.getInput().ingredient); + ingredients.setOutput(GasStack.class, recipe.getOutput().output); + } + + @Nullable + @Override + public List getTooltipStrings(int mouseX, int mouseY) + { + List currenttip = new ArrayList(); + + if(mouseX >= 26-3 && mouseX <= 42-3 && mouseY >= 14-12 && mouseY <= 72-12) + { + currenttip.add(LangUtils.localizeGasStack(recipe.getInput().ingredient)); + } + else if(mouseX >= 134-3 && mouseX <= 150-3 && mouseY >= 14-12 && mouseY <= 72-12) + { + currenttip.add(LangUtils.localizeGasStack(recipe.getOutput().output)); + } + + return currenttip; + } + + @Override + public SolarNeutronRecipeCategory getCategory() + { + return category; + } +} diff --git a/src/main/java/mekanism/client/jei/machine/other/ThermalEvaporationRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/other/ThermalEvaporationRecipeCategory.java new file mode 100644 index 000000000..89accc077 --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/other/ThermalEvaporationRecipeCategory.java @@ -0,0 +1,83 @@ +package mekanism.client.jei.machine.other; + +import mekanism.client.jei.BaseRecipeCategory; +import mekanism.common.recipe.machines.ThermalEvaporationRecipe; +import mezz.jei.api.IGuiHelper; +import mezz.jei.api.gui.IDrawable; +import mezz.jei.api.gui.IGuiFluidStackGroup; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.ITickTimer; +import mezz.jei.api.gui.ITooltipCallback; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.IRecipeWrapper; +import net.minecraft.client.Minecraft; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.FluidStack; + +import java.util.List; + +public class ThermalEvaporationRecipeCategory extends BaseRecipeCategory +{ + public IGuiHelper guiHelper; + + public IDrawable background; + public IDrawable fluidOverlay; + + public ThermalEvaporationRecipe tempRecipe; + + public ITickTimer timer; + + public ThermalEvaporationRecipeCategory(IGuiHelper helper) + { + super("mekanism:gui/nei/GuiThermalEvaporationController.png", "thermal_evaporation_plant", "gui.thermalEvaporationController.short", null); + + guiHelper = helper; + + timer = helper.createTickTimer(20, 20, false); + + xOffset = 3; + yOffset = 12; + + background = guiHelper.createDrawable(new ResourceLocation(guiTexture), xOffset, yOffset, 170, 62); + fluidOverlay = guiHelper.createDrawable(new ResourceLocation(guiTexture), 176, 0, 16, 59); + } + + @Override + public void drawExtras(Minecraft minecraft) + { + super.drawExtras(minecraft); + + drawTexturedRect(49-xOffset, 64-yOffset, 176, 59, 78, 8); + } + + @Override + public IDrawable getBackground() + { + return background; + } + + @Override + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) + { + if(recipeWrapper instanceof ThermalEvaporationRecipeWrapper) + { + tempRecipe = ((ThermalEvaporationRecipeWrapper)recipeWrapper).recipe; + } + + IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks(); + + fluidStacks.init(0, true, 7-xOffset, 14-yOffset, 16, 58, tempRecipe.getInput().ingredient.amount, false, fluidOverlay); + fluidStacks.init(1, false, 153-xOffset, 14-yOffset, 16, 58, tempRecipe.getOutput().output.amount, false, fluidOverlay); + + fluidStacks.set(0, tempRecipe.recipeInput.ingredient); + fluidStacks.set(1, tempRecipe.recipeOutput.output); + + fluidStacks.addTooltipCallback(new ITooltipCallback() { + @Override + public void onTooltip(int slotIndex, boolean input, FluidStack ingredient, List tooltip) + { + tooltip.remove(1); + } + }); + } +} diff --git a/src/main/java/mekanism/client/jei/machine/other/ThermalEvaporationRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/other/ThermalEvaporationRecipeWrapper.java new file mode 100644 index 000000000..ff22dc42f --- /dev/null +++ b/src/main/java/mekanism/client/jei/machine/other/ThermalEvaporationRecipeWrapper.java @@ -0,0 +1,32 @@ +package mekanism.client.jei.machine.other; + +import mekanism.client.jei.machine.BaseRecipeWrapper; +import mekanism.common.recipe.machines.ThermalEvaporationRecipe; +import mezz.jei.api.ingredients.IIngredients; +import net.minecraftforge.fluids.FluidStack; + +public class ThermalEvaporationRecipeWrapper extends BaseRecipeWrapper +{ + public ThermalEvaporationRecipe recipe; + + public ThermalEvaporationRecipeCategory category; + + public ThermalEvaporationRecipeWrapper(ThermalEvaporationRecipe r, ThermalEvaporationRecipeCategory c) + { + recipe = r; + category = c; + } + + @Override + public void getIngredients(IIngredients ingredients) + { + ingredients.setInput(FluidStack.class, recipe.getInput().ingredient); + ingredients.setOutput(FluidStack.class, recipe.getOutput().output); + } + + @Override + public ThermalEvaporationRecipeCategory getCategory() + { + return category; + } +} diff --git a/src/main/java/mekanism/generators/client/jei/GeneratorsJEI.java b/src/main/java/mekanism/generators/client/jei/GeneratorsJEI.java new file mode 100644 index 000000000..7464ca11a --- /dev/null +++ b/src/main/java/mekanism/generators/client/jei/GeneratorsJEI.java @@ -0,0 +1,18 @@ +package mekanism.generators.client.jei; + +import mekanism.client.jei.MekanismJEI; +import mekanism.generators.common.GeneratorsBlocks; +import mezz.jei.api.IModPlugin; +import mezz.jei.api.ISubtypeRegistry; +import mezz.jei.api.JEIPlugin; +import net.minecraft.item.Item; + +@JEIPlugin +public class GeneratorsJEI implements IModPlugin +{ + @Override + public void registerItemSubtypes(ISubtypeRegistry registry) + { + registry.registerSubtypeInterpreter(Item.getItemFromBlock(GeneratorsBlocks.Generator), MekanismJEI.NBT_INTERPRETER); + } +}