mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
Loads of JEI work- got basic machine and advanced machine stuff mostly working, still need to do chance machines and everything else
This commit is contained in:
1 parent
be863a4289
commit
bdc071582f
32 files changed
+845
-8
No files matched your search
@@ -0,0 +1,172 @@
|
||||
package mekanism.client.jei;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
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.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;
|
||||
|
||||
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 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 void drawExtras(Minecraft minecraft)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
changeTexture(guiLocation);
|
||||
|
||||
for(GuiElement e : guiElements)
|
||||
{
|
||||
e.renderBackground(0, 0, -28, -16);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawAnimations(Minecraft minecraft) {}
|
||||
|
||||
@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<String> 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<GuiElement> guiElements = new HashSet<GuiElement>();
|
||||
|
||||
public void addGuiElements() {}
|
||||
|
||||
public static class GuiDummy extends Gui {}
|
||||
}
|
||||
@@ -1,7 +1,40 @@
|
||||
package mekanism.client.jei;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.client.gui.GuiChemicalInjectionChamber;
|
||||
import mekanism.client.gui.GuiCombiner;
|
||||
import mekanism.client.gui.GuiCrusher;
|
||||
import mekanism.client.gui.GuiEnrichmentChamber;
|
||||
import mekanism.client.gui.GuiOsmiumCompressor;
|
||||
import mekanism.client.gui.GuiPurificationChamber;
|
||||
import mekanism.client.gui.element.GuiProgress.ProgressBar;
|
||||
import mekanism.client.jei.crafting.ShapedMekanismRecipeHandler;
|
||||
import mekanism.client.jei.crafting.ShapelessMekanismRecipeHandler;
|
||||
import mekanism.client.jei.machine.AdvancedMachineRecipeCategory;
|
||||
import mekanism.client.jei.machine.AdvancedMachineRecipeHandler;
|
||||
import mekanism.client.jei.machine.AdvancedMachineRecipeWrapper;
|
||||
import mekanism.client.jei.machine.MachineRecipeCategory;
|
||||
import mekanism.client.jei.machine.MachineRecipeHandler;
|
||||
import mekanism.client.jei.machine.MachineRecipeWrapper;
|
||||
import mekanism.client.jei.machine.advanced.ChemicalInjectionChamberRecipeHandler;
|
||||
import mekanism.client.jei.machine.advanced.ChemicalInjectionChamberRecipeWrapper;
|
||||
import mekanism.client.jei.machine.advanced.CombinerRecipeHandler;
|
||||
import mekanism.client.jei.machine.advanced.CombinerRecipeWrapper;
|
||||
import mekanism.client.jei.machine.advanced.OsmiumCompressorRecipeHandler;
|
||||
import mekanism.client.jei.machine.advanced.OsmiumCompressorRecipeWrapper;
|
||||
import mekanism.client.jei.machine.advanced.PurificationChamberRecipeHandler;
|
||||
import mekanism.client.jei.machine.advanced.PurificationChamberRecipeWrapper;
|
||||
import mekanism.client.jei.machine.basic.CrusherRecipeHandler;
|
||||
import mekanism.client.jei.machine.basic.CrusherRecipeWrapper;
|
||||
import mekanism.client.jei.machine.basic.EnrichmentRecipeHandler;
|
||||
import mekanism.client.jei.machine.basic.EnrichmentRecipeWrapper;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
import mekanism.common.MekanismItems;
|
||||
import mekanism.common.recipe.RecipeHandler.Recipe;
|
||||
import mekanism.common.recipe.machines.AdvancedMachineRecipe;
|
||||
import mekanism.common.recipe.machines.BasicMachineRecipe;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mezz.jei.api.IItemRegistry;
|
||||
import mezz.jei.api.IJeiHelpers;
|
||||
@@ -10,7 +43,6 @@ import mezz.jei.api.IModPlugin;
|
||||
import mezz.jei.api.IModRegistry;
|
||||
import mezz.jei.api.IRecipeRegistry;
|
||||
import mezz.jei.api.JEIPlugin;
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -24,8 +56,8 @@ public class MekanismJEI implements IModPlugin
|
||||
{
|
||||
registry.addAdvancedGuiHandlers(new GuiElementHandler());
|
||||
|
||||
registry.addRecipeHandlers(new IRecipeHandler[] {new ShapedMekanismRecipeHandler()});
|
||||
registry.addRecipeHandlers(new IRecipeHandler[] {new ShapelessMekanismRecipeHandler()});
|
||||
registry.addRecipeHandlers(new ShapedMekanismRecipeHandler());
|
||||
registry.addRecipeHandlers(new ShapelessMekanismRecipeHandler());
|
||||
|
||||
registry.getJeiHelpers().getItemBlacklist().addItemToBlacklist(new ItemStack(MekanismItems.ItemProxy));
|
||||
registry.getJeiHelpers().getItemBlacklist().addItemToBlacklist(new ItemStack(MekanismBlocks.BoundingBlock));
|
||||
@@ -38,6 +70,66 @@ public class MekanismJEI implements IModPlugin
|
||||
registry.getJeiHelpers().getNbtIgnoreList().ignoreNbtTagNames(Item.getItemFromBlock(MekanismBlocks.BasicBlock2), UNUSED_TAGS);
|
||||
registry.getJeiHelpers().getNbtIgnoreList().ignoreNbtTagNames(Item.getItemFromBlock(MekanismBlocks.GasTank), UNUSED_TAGS);
|
||||
registry.getJeiHelpers().getNbtIgnoreList().ignoreNbtTagNames(Item.getItemFromBlock(MekanismBlocks.CardboardBox), UNUSED_TAGS);
|
||||
|
||||
try {
|
||||
registerBasicMachine(registry, Recipe.ENRICHMENT_CHAMBER, "tile.MachineBlock.EnrichmentChamber.name", ProgressBar.BLUE, EnrichmentRecipeHandler.class, EnrichmentRecipeWrapper.class);
|
||||
registerBasicMachine(registry, Recipe.CRUSHER, "tile.MachineBlock.Crusher.name", ProgressBar.CRUSH, CrusherRecipeHandler.class, CrusherRecipeWrapper.class);
|
||||
|
||||
registerAdvancedMachine(registry, Recipe.COMBINER, "tile.MachineBlock.Combiner.name", ProgressBar.STONE, CombinerRecipeHandler.class, CombinerRecipeWrapper.class);
|
||||
registerAdvancedMachine(registry, Recipe.PURIFICATION_CHAMBER, "tile.MachineBlock.PurificationChamber.name", ProgressBar.RED, PurificationChamberRecipeHandler.class, PurificationChamberRecipeWrapper.class);
|
||||
registerAdvancedMachine(registry, Recipe.OSMIUM_COMPRESSOR, "tile.MachineBlock.OsmiumCompressor.name", ProgressBar.RED, OsmiumCompressorRecipeHandler.class, OsmiumCompressorRecipeWrapper.class);
|
||||
registerAdvancedMachine(registry, Recipe.CHEMICAL_INJECTION_CHAMBER, "nei.chemicalInjectionChamber", ProgressBar.YELLOW, ChemicalInjectionChamberRecipeHandler.class, ChemicalInjectionChamberRecipeWrapper.class);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
private void registerBasicMachine(IModRegistry registry, Recipe recipe, String unlocalized, ProgressBar bar, Class<? extends MachineRecipeHandler> handler, Class<? extends MachineRecipeWrapper> wrapper) throws Exception
|
||||
{
|
||||
MachineRecipeCategory category = new MachineRecipeCategory(registry.getJeiHelpers().getGuiHelper(), recipe.name().toLowerCase(), unlocalized, bar);
|
||||
|
||||
registry.addRecipeCategories(category);
|
||||
registry.addRecipeHandlers(handler.getConstructor(MachineRecipeCategory.class).newInstance(category));
|
||||
|
||||
List<MachineRecipeWrapper> recipes = new ArrayList<MachineRecipeWrapper>();
|
||||
|
||||
for(Object obj : recipe.get().values())
|
||||
{
|
||||
if(obj instanceof BasicMachineRecipe)
|
||||
{
|
||||
recipes.add(wrapper.getConstructor(BasicMachineRecipe.class, MachineRecipeCategory.class).newInstance((BasicMachineRecipe)obj, category));
|
||||
}
|
||||
}
|
||||
|
||||
registry.addRecipes(recipes);
|
||||
}
|
||||
|
||||
private void registerAdvancedMachine(IModRegistry registry, Recipe recipe, String unlocalized, ProgressBar bar, Class<? extends AdvancedMachineRecipeHandler> handler, Class<? extends AdvancedMachineRecipeWrapper> wrapper) throws Exception
|
||||
{
|
||||
AdvancedMachineRecipeCategory category = new AdvancedMachineRecipeCategory(registry.getJeiHelpers().getGuiHelper(), recipe.name().toLowerCase(), unlocalized, bar);
|
||||
|
||||
registry.addRecipeCategories(category);
|
||||
registry.addRecipeHandlers(handler.getConstructor(AdvancedMachineRecipeCategory.class).newInstance(category));
|
||||
|
||||
List<AdvancedMachineRecipeWrapper> recipes = new ArrayList<AdvancedMachineRecipeWrapper>();
|
||||
|
||||
for(Object obj : recipe.get().values())
|
||||
{
|
||||
if(obj instanceof AdvancedMachineRecipe)
|
||||
{
|
||||
recipes.add(wrapper.getConstructor(AdvancedMachineRecipe.class, AdvancedMachineRecipeCategory.class).newInstance((AdvancedMachineRecipe)obj, category));
|
||||
}
|
||||
}
|
||||
|
||||
registry.addRecipes(recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package mekanism.client.jei;
|
||||
package mekanism.client.jei.crafting;
|
||||
|
||||
import mekanism.common.recipe.ShapedMekanismRecipe;
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package mekanism.client.jei;
|
||||
package mekanism.client.jei.crafting;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package mekanism.client.jei;
|
||||
package mekanism.client.jei.crafting;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package mekanism.client.jei;
|
||||
package mekanism.client.jei.crafting;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -0,0 +1,29 @@
|
||||
package mekanism.client.jei.gas;
|
||||
|
||||
|
||||
public class GasStackHelper// implements IIngredientHelper<GasStack>
|
||||
{
|
||||
/*@Override
|
||||
public Collection<GasStack> expandSubtypes(Collection<GasStack> contained) {
|
||||
return contained;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GasStack getMatch(Iterable<GasStack> ingredients, @Nonnull Focus toMatch) {
|
||||
if (toMatch.getGas() == null) {
|
||||
return null;
|
||||
}
|
||||
for (GasStack GasStack : ingredients) {
|
||||
if (toMatch.getGas() == GasStack.getGas()) {
|
||||
return GasStack;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Focus createFocus(@Nonnull GasStack ingredient) {
|
||||
return new Focus(ingredient.getGas());
|
||||
}*/
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
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.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.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)
|
||||
{
|
||||
if(recipeWrapper instanceof AdvancedMachineRecipeWrapper)
|
||||
{
|
||||
tempRecipe = ((AdvancedMachineRecipeWrapper)recipeWrapper).recipe;
|
||||
}
|
||||
|
||||
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||
|
||||
itemStacks.init(0, true, 27, 0);
|
||||
itemStacks.init(1, false, 87, 18);
|
||||
|
||||
itemStacks.setFromRecipe(0, recipeWrapper.getInputs());
|
||||
itemStacks.setFromRecipe(1, recipeWrapper.getOutputs());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package mekanism.client.jei.machine;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
|
||||
public class AdvancedMachineRecipeHandler<T extends AdvancedMachineRecipeWrapper> implements IRecipeHandler<T>
|
||||
{
|
||||
private final AdvancedMachineRecipeCategory category;
|
||||
|
||||
public Class<T> wrapperClass;
|
||||
|
||||
public AdvancedMachineRecipeHandler(AdvancedMachineRecipeCategory c, Class<T> wrapper)
|
||||
{
|
||||
category = c;
|
||||
|
||||
wrapperClass = wrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<T> getRecipeClass()
|
||||
{
|
||||
return wrapperClass;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getRecipeCategoryUid()
|
||||
{
|
||||
return category.getUid();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper(@Nonnull T recipe)
|
||||
{
|
||||
return recipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecipeValid(@Nonnull T recipe)
|
||||
{
|
||||
return recipe.category == category;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package mekanism.client.jei.machine;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import mekanism.common.recipe.inputs.AdvancedMachineInput;
|
||||
import mekanism.common.recipe.machines.AdvancedMachineRecipe;
|
||||
import mekanism.common.recipe.outputs.ItemStackOutput;
|
||||
import mezz.jei.api.recipe.BlankRecipeWrapper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class AdvancedMachineRecipeWrapper extends BlankRecipeWrapper
|
||||
{
|
||||
public AdvancedMachineRecipe recipe;
|
||||
|
||||
public AdvancedMachineRecipeCategory category;
|
||||
|
||||
public AdvancedMachineRecipeWrapper(AdvancedMachineRecipe r, AdvancedMachineRecipeCategory c)
|
||||
{
|
||||
recipe = r;
|
||||
category = c;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<ItemStack> getInputs()
|
||||
{
|
||||
return Arrays.asList(((AdvancedMachineInput)recipe.getInput()).itemStack);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<ItemStack> getOutputs()
|
||||
{
|
||||
return Arrays.asList(((ItemStackOutput)recipe.getOutput()).output);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package mekanism.client.jei.machine;
|
||||
|
||||
public class ChanceMachineRecipeCategory {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package mekanism.client.jei.machine;
|
||||
|
||||
public class ChanceMachineRecipeHandler {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package mekanism.client.jei.machine;
|
||||
|
||||
public class ChanceMachineRecipeWrapper {
|
||||
|
||||
}
|
||||
@@ -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.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)
|
||||
{
|
||||
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.setFromRecipe(0, recipeWrapper.getInputs());
|
||||
itemStacks.setFromRecipe(1, recipeWrapper.getOutputs());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package mekanism.client.jei.machine;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
|
||||
public class MachineRecipeHandler<T extends MachineRecipeWrapper> implements IRecipeHandler<T>
|
||||
{
|
||||
private final MachineRecipeCategory category;
|
||||
|
||||
public Class<T> wrapperClass;
|
||||
|
||||
public MachineRecipeHandler(MachineRecipeCategory c, Class<T> wrapper)
|
||||
{
|
||||
category = c;
|
||||
|
||||
wrapperClass = wrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<T> getRecipeClass()
|
||||
{
|
||||
return wrapperClass;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getRecipeCategoryUid()
|
||||
{
|
||||
return category.getUid();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper(@Nonnull T recipe)
|
||||
{
|
||||
return recipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecipeValid(@Nonnull T recipe)
|
||||
{
|
||||
return recipe.category == category;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package mekanism.client.jei.machine;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import mekanism.common.recipe.inputs.ItemStackInput;
|
||||
import mekanism.common.recipe.machines.BasicMachineRecipe;
|
||||
import mekanism.common.recipe.outputs.ItemStackOutput;
|
||||
import mezz.jei.api.recipe.BlankRecipeWrapper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class MachineRecipeWrapper extends BlankRecipeWrapper
|
||||
{
|
||||
public BasicMachineRecipe recipe;
|
||||
|
||||
public MachineRecipeCategory category;
|
||||
|
||||
public MachineRecipeWrapper(BasicMachineRecipe r, MachineRecipeCategory c)
|
||||
{
|
||||
recipe = r;
|
||||
category = c;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<ItemStack> getInputs()
|
||||
{
|
||||
return Arrays.asList(((ItemStackInput)recipe.getInput()).ingredient);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<ItemStack> getOutputs()
|
||||
{
|
||||
return Arrays.asList(((ItemStackOutput)recipe.getOutput()).output);
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package mekanism.client.jei.machine.advanced;
|
||||
|
||||
import mekanism.client.jei.machine.AdvancedMachineRecipeCategory;
|
||||
import mekanism.client.jei.machine.AdvancedMachineRecipeHandler;
|
||||
|
||||
public class ChemicalInjectionChamberRecipeHandler extends AdvancedMachineRecipeHandler
|
||||
{
|
||||
public ChemicalInjectionChamberRecipeHandler(AdvancedMachineRecipeCategory c)
|
||||
{
|
||||
super(c, ChemicalInjectionChamberRecipeWrapper.class);
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package mekanism.client.jei.machine.advanced;
|
||||
|
||||
import mekanism.client.jei.machine.AdvancedMachineRecipeCategory;
|
||||
import mekanism.client.jei.machine.AdvancedMachineRecipeWrapper;
|
||||
import mekanism.common.recipe.machines.AdvancedMachineRecipe;
|
||||
|
||||
public class ChemicalInjectionChamberRecipeWrapper extends AdvancedMachineRecipeWrapper
|
||||
{
|
||||
public ChemicalInjectionChamberRecipeWrapper(AdvancedMachineRecipe r, AdvancedMachineRecipeCategory c)
|
||||
{
|
||||
super(r, c);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package mekanism.client.jei.machine.advanced;
|
||||
|
||||
import mekanism.client.jei.machine.AdvancedMachineRecipeCategory;
|
||||
import mekanism.client.jei.machine.AdvancedMachineRecipeHandler;
|
||||
|
||||
public class CombinerRecipeHandler extends AdvancedMachineRecipeHandler
|
||||
{
|
||||
public CombinerRecipeHandler(AdvancedMachineRecipeCategory c)
|
||||
{
|
||||
super(c, CombinerRecipeWrapper.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package mekanism.client.jei.machine.advanced;
|
||||
|
||||
import mekanism.client.jei.machine.AdvancedMachineRecipeCategory;
|
||||
import mekanism.client.jei.machine.AdvancedMachineRecipeWrapper;
|
||||
import mekanism.common.recipe.machines.AdvancedMachineRecipe;
|
||||
|
||||
public class CombinerRecipeWrapper extends AdvancedMachineRecipeWrapper
|
||||
{
|
||||
public CombinerRecipeWrapper(AdvancedMachineRecipe r, AdvancedMachineRecipeCategory c)
|
||||
{
|
||||
super(r, c);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package mekanism.client.jei.machine.advanced;
|
||||
|
||||
import mekanism.client.jei.machine.AdvancedMachineRecipeCategory;
|
||||
import mekanism.client.jei.machine.AdvancedMachineRecipeHandler;
|
||||
|
||||
public class OsmiumCompressorRecipeHandler extends AdvancedMachineRecipeHandler
|
||||
{
|
||||
public OsmiumCompressorRecipeHandler(AdvancedMachineRecipeCategory c)
|
||||
{
|
||||
super(c, OsmiumCompressorRecipeWrapper.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package mekanism.client.jei.machine.advanced;
|
||||
|
||||
import mekanism.client.jei.machine.AdvancedMachineRecipeCategory;
|
||||
import mekanism.client.jei.machine.AdvancedMachineRecipeWrapper;
|
||||
import mekanism.common.recipe.machines.AdvancedMachineRecipe;
|
||||
|
||||
public class OsmiumCompressorRecipeWrapper extends AdvancedMachineRecipeWrapper
|
||||
{
|
||||
public OsmiumCompressorRecipeWrapper(AdvancedMachineRecipe r, AdvancedMachineRecipeCategory c)
|
||||
{
|
||||
super(r, c);
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package mekanism.client.jei.machine.advanced;
|
||||
|
||||
import mekanism.client.jei.machine.AdvancedMachineRecipeCategory;
|
||||
import mekanism.client.jei.machine.AdvancedMachineRecipeHandler;
|
||||
|
||||
public class PurificationChamberRecipeHandler extends AdvancedMachineRecipeHandler
|
||||
{
|
||||
public PurificationChamberRecipeHandler(AdvancedMachineRecipeCategory c)
|
||||
{
|
||||
super(c, PurificationChamberRecipeWrapper.class);
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package mekanism.client.jei.machine.advanced;
|
||||
|
||||
import mekanism.client.jei.machine.AdvancedMachineRecipeCategory;
|
||||
import mekanism.client.jei.machine.AdvancedMachineRecipeWrapper;
|
||||
import mekanism.common.recipe.machines.AdvancedMachineRecipe;
|
||||
|
||||
public class PurificationChamberRecipeWrapper extends AdvancedMachineRecipeWrapper
|
||||
{
|
||||
public PurificationChamberRecipeWrapper(AdvancedMachineRecipe r, AdvancedMachineRecipeCategory c)
|
||||
{
|
||||
super(r, c);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package mekanism.client.jei.machine.basic;
|
||||
|
||||
import mekanism.client.jei.machine.MachineRecipeCategory;
|
||||
import mekanism.client.jei.machine.MachineRecipeHandler;
|
||||
|
||||
public class CrusherRecipeHandler extends MachineRecipeHandler
|
||||
{
|
||||
public CrusherRecipeHandler(MachineRecipeCategory c)
|
||||
{
|
||||
super(c, CrusherRecipeWrapper.class);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package mekanism.client.jei.machine.basic;
|
||||
|
||||
import mekanism.client.jei.machine.MachineRecipeCategory;
|
||||
import mekanism.client.jei.machine.MachineRecipeHandler;
|
||||
|
||||
public class EnrichmentRecipeHandler extends MachineRecipeHandler
|
||||
{
|
||||
public EnrichmentRecipeHandler(MachineRecipeCategory c)
|
||||
{
|
||||
super(c, EnrichmentRecipeWrapper.class);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package mekanism.client.jei.machine.chance;
|
||||
|
||||
public class PrecisionSawmillRecipeHandler {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package mekanism.client.jei.machine.chance;
|
||||
|
||||
public class PrecisionSawmillRecipeWrapper {
|
||||
|
||||
}
|
||||
@@ -83,6 +83,7 @@ public class AdvancedMachineInput extends MachineInput<AdvancedMachineInput>
|
||||
{
|
||||
return !other.isValid();
|
||||
}
|
||||
|
||||
return StackUtils.equalsWildcardWithNBT(itemStack, other.itemStack) && gasType.getID() == other.gasType.getID();
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,5 @@ public abstract class AdvancedMachineRecipe<RECIPE extends AdvancedMachineRecipe
|
||||
{
|
||||
getOutput().applyOutputs(inventory, outputIndex, true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user