Loads of GUI/NEI work. Tomorrow I need to get overlays to render on GuiElement slots

This commit is contained in:
Aidan C. Brady 2014-06-15 02:22:55 +02:00
parent 3a81058cbd
commit f2b914e216
27 changed files with 320 additions and 65 deletions

View file

@ -1,5 +1,6 @@
package mekanism.client.gui;
import codechicken.lib.vec.Rectangle4i;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.util.ResourceLocation;
@ -13,6 +14,12 @@ public class GuiBucketIO extends GuiElement
{
super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiBucket.png"), gui, def);
}
@Override
public Rectangle4i getBounds(int guiWidth, int guiHeight)
{
return new Rectangle4i(guiWidth - 26, guiHeight + 4, 26, 57);
}
@Override
public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight)

View file

@ -9,6 +9,7 @@ import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import codechicken.lib.vec.Rectangle4i;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -23,6 +24,12 @@ public class GuiConfigurationTab extends GuiElement
tileEntity = tile;
}
@Override
public Rectangle4i getBounds(int guiWidth, int guiHeight)
{
return new Rectangle4i(guiWidth - 26, guiHeight + 6, 26, 26);
}
@Override
public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight)

View file

@ -8,6 +8,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.util.ResourceLocation;
import codechicken.lib.vec.Rectangle4i;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -65,6 +66,8 @@ public abstract class GuiElement
{
return guiObj.getFont();
}
public abstract Rectangle4i getBounds(int guiWidth, int guiHeight);
public abstract void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight);

View file

@ -1,5 +1,6 @@
package mekanism.client.gui;
import codechicken.lib.vec.Rectangle4i;
import mekanism.api.energy.IStrictEnergyStorage;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.util.MekanismUtils;
@ -16,6 +17,12 @@ public class GuiEnergyGauge extends GuiGauge
infoHandler = handler;
}
@Override
public Rectangle4i getBounds(int guiWidth, int guiHeight)
{
return new Rectangle4i(guiWidth - 26, guiHeight + 6, 26, 26);
}
@Override
public int getScaledLevel()

View file

@ -2,6 +2,7 @@ package mekanism.client.gui;
import java.util.List;
import codechicken.lib.vec.Rectangle4i;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.util.ResourceLocation;
@ -19,6 +20,12 @@ public class GuiEnergyInfo extends GuiElement
infoHandler = handler;
}
@Override
public Rectangle4i getBounds(int guiWidth, int guiHeight)
{
return new Rectangle4i(guiWidth - 26, guiHeight + 138, 26, 26);
}
public static interface IInfoHandler
{

View file

@ -3,9 +3,10 @@ package mekanism.client.gui;
import mekanism.common.util.MekanismUtils;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidTank;
public class GuiFluidGauge extends GuiGauge
public class GuiFluidGauge extends GuiGauge<Fluid>
{
IFluidInfoHandler infoHandler;
@ -15,22 +16,45 @@ public class GuiFluidGauge extends GuiGauge
infoHandler = handler;
}
public static GuiFluidGauge getDummy(Type type, IGuiWrapper gui, ResourceLocation def, int x, int y)
{
GuiFluidGauge gauge = new GuiFluidGauge(null, type, gui, def, x, y);
gauge.dummy = true;
return gauge;
}
@Override
public int getScaledLevel()
{
if(dummy)
{
return height-2;
}
return infoHandler.getTank().getFluid() != null ? infoHandler.getTank().getFluidAmount()*(height-2) / infoHandler.getTank().getCapacity() : 0;
}
@Override
public IIcon getIcon()
{
if(dummy)
{
return dummyType.getIcon();
}
return infoHandler.getTank().getFluid().getFluid().getIcon();
}
@Override
public String getTooltipText()
{
if(dummy)
{
return dummyType.getLocalizedName();
}
return infoHandler.getTank().getFluid() != null ? infoHandler.getTank().getFluid().getFluid().getLocalizedName() + ": " + infoHandler.getTank().getFluidAmount() + "mB" : MekanismUtils.localize("gui.empty");
}

View file

@ -1,11 +1,12 @@
package mekanism.client.gui;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasTank;
import mekanism.common.util.MekanismUtils;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
public class GuiGasGauge extends GuiGauge
public class GuiGasGauge extends GuiGauge<Gas>
{
IGasInfoHandler infoHandler;
@ -15,22 +16,45 @@ public class GuiGasGauge extends GuiGauge
infoHandler = handler;
}
public static GuiGasGauge getDummy(Type type, IGuiWrapper gui, ResourceLocation def, int x, int y)
{
GuiGasGauge gauge = new GuiGasGauge(null, type, gui, def, x, y);
gauge.dummy = true;
return gauge;
}
@Override
public int getScaledLevel()
{
if(dummy)
{
return height-2;
}
return infoHandler.getTank().getGas() != null ? infoHandler.getTank().getStored()*(height-2) / infoHandler.getTank().getMaxGas() : 0;
}
@Override
public IIcon getIcon()
{
if(dummy)
{
return dummyType.getIcon();
}
return infoHandler.getTank().getGas().getGas().getIcon();
}
@Override
public String getTooltipText()
{
if(dummy)
{
return dummyType.getLocalizedName();
}
return (infoHandler.getTank().getGas() != null) ? infoHandler.getTank().getGas().getGas().getLocalizedName() + ": " + infoHandler.getTank().getStored() : MekanismUtils.localize("gui.empty");
}

View file

@ -1,12 +1,13 @@
package mekanism.client.gui;
import codechicken.lib.vec.Rectangle4i;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
public abstract class GuiGauge extends GuiElement
public abstract class GuiGauge<T> extends GuiElement
{
protected int xLocation;
protected int yLocation;
@ -15,6 +16,9 @@ public abstract class GuiGauge extends GuiElement
protected int height;
protected int number;
protected boolean dummy;
protected T dummyType;
public GuiGauge(Type type, IGuiWrapper gui, ResourceLocation def, int x, int y)
{
@ -39,11 +43,26 @@ public abstract class GuiGauge extends GuiElement
{
mc.renderEngine.bindTexture(RESOURCE);
guiObj.drawTexturedRect(guiWidth + xLocation, guiHeight + yLocation, 0, 0, width, height);
if(!dummy)
{
renderScale(xAxis, yAxis, guiWidth, guiHeight);
}
mc.renderEngine.bindTexture(defaultLocation);
}
public void renderScale(int xAxis, int yAxis, int guiWidth, int guiHeight)
{
if(getIcon() == null || getScaledLevel() == 0)
{
return;
}
int scale = getScaledLevel();
int start = 0;
guiObj.drawTexturedRect(guiWidth + xLocation, guiHeight + yLocation, 0, 0, width, height);
while(scale > 0)
{
int renderRemaining = 0;
@ -75,8 +94,6 @@ public abstract class GuiGauge extends GuiElement
mc.renderEngine.bindTexture(RESOURCE);
guiObj.drawTexturedRect(guiWidth + xLocation, guiHeight + yLocation, width, 0, width, height);
mc.renderEngine.bindTexture(defaultLocation);
}
@Override
@ -100,7 +117,17 @@ public abstract class GuiGauge extends GuiElement
}
public void setDummyType(T type)
{
dummyType = type;
}
@Override
public Rectangle4i getBounds(int guiWidth, int guiHeight)
{
return new Rectangle4i(guiWidth + xLocation, guiHeight + yLocation, width, height);
}
public static enum Type
{
STANDARD(18, 60, 1, "GuiGaugeStandard.png"),

View file

@ -180,6 +180,21 @@ public abstract class GuiMekanism extends GuiContainer implements IGuiWrapper
{
return fontRendererObj;
}
public void handleMouse(Slot slot, int slotIndex, int button, int modifier)
{
handleMouseClick(slot, slotIndex, button, modifier);
}
public int getXPos()
{
return (width - xSize) / 2;
}
public int getYPos()
{
return (height - ySize) / 2;
}
protected FontRenderer getFontRenderer()
{

View file

@ -1,5 +1,6 @@
package mekanism.client.gui;
import codechicken.lib.vec.Rectangle4i;
import mekanism.common.tile.TileEntityElectricBlock;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
@ -53,6 +54,12 @@ public class GuiPowerBar extends GuiElement
yLocation = y;
}
@Override
public Rectangle4i getBounds(int guiWidth, int guiHeight)
{
return new Rectangle4i(guiWidth + xLocation, guiHeight + yLocation, width, height);
}
public static abstract class IPowerInfoHandler
{
public String getTooltip()

View file

@ -1,5 +1,6 @@
package mekanism.client.gui;
import codechicken.lib.vec.Rectangle4i;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.util.ResourceLocation;
@ -26,6 +27,12 @@ public class GuiProgress extends GuiElement
this.type = type;
this.handler = handler;
}
@Override
public Rectangle4i getBounds(int guiWidth, int guiHeight)
{
return new Rectangle4i(guiWidth + xLocation, guiHeight + yLocation, type.width, type.height);
}
@Override
public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight)

View file

@ -1,5 +1,6 @@
package mekanism.client.gui;
import codechicken.lib.vec.Rectangle4i;
import mekanism.common.tile.TileEntityFactory;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
@ -15,6 +16,12 @@ public class GuiRecipeType extends GuiElement
tileEntity = tile;
}
@Override
public Rectangle4i getBounds(int guiWidth, int guiHeight)
{
return new Rectangle4i(guiWidth + 176, guiHeight + 70, 26, 63);
}
@Override
public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight)

View file

@ -1,5 +1,6 @@
package mekanism.client.gui;
import codechicken.lib.vec.Rectangle4i;
import mekanism.api.Coord4D;
import mekanism.client.sound.SoundHandler;
import mekanism.common.IRedstoneControl;
@ -21,6 +22,12 @@ public class GuiRedstoneControl extends GuiElement
tileEntity = tile;
}
@Override
public Rectangle4i getBounds(int guiWidth, int guiHeight)
{
return new Rectangle4i(guiWidth + 176, guiHeight + 138, 26, 26);
}
@Override
public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight)

View file

@ -1,5 +1,6 @@
package mekanism.client.gui;
import codechicken.lib.vec.Rectangle4i;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.util.ResourceLocation;
@ -36,6 +37,12 @@ public class GuiSlot extends GuiElement
this.overlay = overlay;
return this;
}
@Override
public Rectangle4i getBounds(int guiWidth, int guiHeight)
{
return new Rectangle4i(guiWidth + xLocation, guiHeight + yLocation, width, height);
}
@Override
public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight)

View file

@ -2,6 +2,7 @@ package mekanism.client.gui;
import java.util.ArrayList;
import codechicken.lib.vec.Rectangle4i;
import mekanism.api.Coord4D;
import mekanism.client.sound.SoundHandler;
import mekanism.common.Mekanism;
@ -24,6 +25,12 @@ public class GuiSortingTab extends GuiElement
tileEntity = tile;
}
@Override
public Rectangle4i getBounds(int guiWidth, int guiHeight)
{
return new Rectangle4i(guiWidth - 26, guiHeight + 34, 26, 35);
}
@Override
public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight)

View file

@ -1,5 +1,6 @@
package mekanism.client.gui;
import codechicken.lib.vec.Rectangle4i;
import mekanism.api.Coord4D;
import mekanism.client.sound.SoundHandler;
import mekanism.common.IUpgradeTile;
@ -20,6 +21,12 @@ public class GuiUpgradeManagement extends GuiElement
tileEntity = tile;
}
@Override
public Rectangle4i getBounds(int guiWidth, int guiHeight)
{
return new Rectangle4i(guiWidth + 176, guiHeight + 6, 26, 63);
}
@Override
public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight)

View file

@ -15,8 +15,8 @@ import mekanism.api.gas.Gas;
import mekanism.api.gas.GasStack;
import mekanism.client.gui.GuiElement;
import mekanism.client.gui.GuiPowerBar;
import mekanism.client.gui.GuiProgress;
import mekanism.client.gui.GuiPowerBar.IPowerInfoHandler;
import mekanism.client.gui.GuiProgress;
import mekanism.client.gui.GuiProgress.IProgressInfoHandler;
import mekanism.client.gui.GuiProgress.ProgressBar;
import mekanism.client.gui.GuiSlot;
@ -52,10 +52,10 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler
@Override
public void addGuiElements()
{
guiElements.add(new GuiSlot(SlotType.INPUT, this, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 55, 16));
guiElements.add(new GuiSlot(SlotType.POWER, this, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 30, 34).with(SlotOverlay.POWER));
guiElements.add(new GuiSlot(SlotType.EXTRA, this, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 55, 52));
guiElements.add(new GuiSlot(SlotType.OUTPUT_LARGE, this, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 111, 30));
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
@ -63,7 +63,7 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler
{
return ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F;
}
}, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 164, 15));
}, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 164, 15));
guiElements.add(new GuiProgress(new IProgressInfoHandler()
{
@Override
@ -71,7 +71,7 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler
{
return ticksPassed >= 40 ? (ticksPassed - 40) % 20 / 20.0F : 0.0F;
}
}, getProgressType(), this, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 77, 37));
}, getProgressType(), this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 77, 37));
}
@Override

View file

@ -113,6 +113,11 @@ public abstract class BaseRecipeHandler extends TemplateRecipeHandler implements
changeTexture(MekanismRenderer.getBlocksTexture());
gui.drawTexturedModelRectFromIcon(xPos, yPos, gas.getGas().getIcon(), sizeX, sizeY);
}
public String stripTexture()
{
return getGuiTexture().replace("mekanism:gui/", "");
}
/*
* true = usage, false = recipe

View file

@ -42,9 +42,9 @@ public abstract class ChanceMachineRecipeHandler extends BaseRecipeHandler
@Override
public void addGuiElements()
{
guiElements.add(new GuiSlot(SlotType.INPUT, this, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 55, 16));
guiElements.add(new GuiSlot(SlotType.POWER, this, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 55, 52).with(SlotOverlay.POWER));
guiElements.add(new GuiSlot(SlotType.OUTPUT_WIDE, this, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 111, 30));
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
@ -52,7 +52,7 @@ public abstract class ChanceMachineRecipeHandler extends BaseRecipeHandler
{
return ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F;
}
}, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 164, 15));
}, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 164, 15));
guiElements.add(new GuiProgress(new IProgressInfoHandler()
{
@Override
@ -60,7 +60,7 @@ public abstract class ChanceMachineRecipeHandler extends BaseRecipeHandler
{
return ticksPassed >= 20 ? (ticksPassed - 20) % 20 / 20.0F : 0.0F;
}
}, getProgressType(), this, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 77, 37));
}, getProgressType(), this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 77, 37));
}
@Override

View file

@ -0,0 +1,33 @@
package mekanism.client.nei;
import mekanism.client.gui.GuiElement;
import mekanism.client.gui.GuiMekanism;
import net.minecraft.client.gui.inventory.GuiContainer;
import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.api.INEIGuiAdapter;
public class ElementBoundHandler extends INEIGuiAdapter
{
@Override
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int width, int height)
{
if(gui instanceof GuiMekanism)
{
GuiMekanism guiMek = (GuiMekanism)gui;
System.out.println(x + " " + y + " " + width + " " + height + " " + guiMek.getXPos() + " " + guiMek.getYPos());
Rectangle4i rect = new Rectangle4i(x, y, width, height);
for(GuiElement element : guiMek.guiElements)
{
if(element.getBounds(guiMek.getXPos(), guiMek.getYPos()).intersects(rect))
{
return true;
}
}
}
return false;
}
}

View file

@ -2,7 +2,6 @@ package mekanism.client.nei;
import static codechicken.lib.gui.GuiDraw.changeTexture;
import static codechicken.lib.gui.GuiDraw.drawTexturedModalRect;
import static codechicken.lib.gui.GuiDraw.gui;
import java.awt.Rectangle;
import java.util.Map;
@ -11,8 +10,8 @@ import java.util.Set;
import mekanism.client.gui.GuiElement;
import mekanism.client.gui.GuiPowerBar;
import mekanism.client.gui.GuiProgress;
import mekanism.client.gui.GuiPowerBar.IPowerInfoHandler;
import mekanism.client.gui.GuiProgress;
import mekanism.client.gui.GuiProgress.IProgressInfoHandler;
import mekanism.client.gui.GuiProgress.ProgressBar;
import mekanism.client.gui.GuiSlot;
@ -41,9 +40,9 @@ public abstract class MachineRecipeHandler extends BaseRecipeHandler
@Override
public void addGuiElements()
{
guiElements.add(new GuiSlot(SlotType.INPUT, this, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 55, 16));
guiElements.add(new GuiSlot(SlotType.POWER, this, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 55, 52).with(SlotOverlay.POWER));
guiElements.add(new GuiSlot(SlotType.OUTPUT_LARGE, this, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 111, 30));
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
@ -51,7 +50,7 @@ public abstract class MachineRecipeHandler extends BaseRecipeHandler
{
return ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F;
}
}, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 164, 15));
}, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 164, 15));
guiElements.add(new GuiProgress(new IProgressInfoHandler()
{
@Override
@ -59,7 +58,7 @@ public abstract class MachineRecipeHandler extends BaseRecipeHandler
{
return ticksPassed >= 20 ? (ticksPassed - 20) % 20 / 20.0F : 0.0F;
}
}, getProgressType(), this, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 77, 37));
}, getProgressType(), this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 77, 37));
}
@Override

View file

@ -0,0 +1,33 @@
package mekanism.client.nei;
import mekanism.client.gui.GuiMekanism;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Slot;
import codechicken.nei.guihook.IContainerSlotClickHandler;
public class MekanismSlotClickHandler implements IContainerSlotClickHandler
{
@Override
public void beforeSlotClick(GuiContainer gui, int slotIndex, int button, Slot slot, int modifier)
{
}
@Override
public boolean handleSlotClick(GuiContainer gui, int slotIndex, int button, Slot slot, int modifier, boolean eventconsumed)
{
if(gui instanceof GuiMekanism)
{
((GuiMekanism)gui).handleMouse(slot, slotIndex, button, modifier);
return true;
}
return false;
}
@Override
public void afterSlotClick(GuiContainer gui, int slotIndex, int button, Slot slot, int modifier)
{
}
}

View file

@ -20,9 +20,9 @@ import mekanism.client.gui.GuiMetallurgicInfuser;
import mekanism.client.gui.GuiPowerBar;
import mekanism.client.gui.GuiPowerBar.IPowerInfoHandler;
import mekanism.client.gui.GuiProgress;
import mekanism.client.gui.GuiSlot;
import mekanism.client.gui.GuiProgress.IProgressInfoHandler;
import mekanism.client.gui.GuiProgress.ProgressBar;
import mekanism.client.gui.GuiSlot;
import mekanism.client.gui.GuiSlot.SlotOverlay;
import mekanism.client.gui.GuiSlot.SlotType;
import mekanism.common.recipe.RecipeHandler.Recipe;
@ -43,10 +43,10 @@ public class MetallurgicInfuserRecipeHandler extends BaseRecipeHandler
@Override
public void addGuiElements()
{
guiElements.add(new GuiSlot(SlotType.EXTRA, this, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 16, 34));
guiElements.add(new GuiSlot(SlotType.INPUT, this, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 50, 42));
guiElements.add(new GuiSlot(SlotType.POWER, this, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 142, 34).with(SlotOverlay.POWER));
guiElements.add(new GuiSlot(SlotType.OUTPUT, this, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 108, 42));
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
@ -54,14 +54,14 @@ public class MetallurgicInfuserRecipeHandler extends BaseRecipeHandler
{
return ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F;
}
}, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 164, 15));
}, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 164, 15));
guiElements.add(new GuiProgress(new IProgressInfoHandler() {
@Override
public double getProgress()
{
return ticksPassed >= 40 ? (ticksPassed - 40) % 20 / 20.0F : 0.0F;
}
}, ProgressBar.MEDIUM, this, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 70, 46));
}, ProgressBar.MEDIUM, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 70, 46));
}
@Override

View file

@ -21,6 +21,7 @@ import mekanism.common.Mekanism;
import net.minecraft.item.ItemStack;
import codechicken.nei.api.API;
import codechicken.nei.api.IConfigureNEI;
import codechicken.nei.guihook.GuiContainerManager;
public class NEIMekanismConfig implements IConfigureNEI
{
@ -98,6 +99,10 @@ public class NEIMekanismConfig implements IConfigureNEI
API.setGuiOffset(GuiChemicalWasher.class, ChemicalWasherRecipeHandler.xOffset, ChemicalWasherRecipeHandler.yOffset);
API.setGuiOffset(GuiChemicalCrystallizer.class, ChemicalCrystallizerRecipeHandler.xOffset, ChemicalCrystallizerRecipeHandler.yOffset);
API.setGuiOffset(GuiPRC.class, PRCRecipeHandler.xOffset, PRCRecipeHandler.yOffset);
GuiContainerManager.addSlotClickHandler(new MekanismSlotClickHandler());
API.registerNEIGuiHandler(new ElementBoundHandler());
API.hideItem(new ItemStack(Mekanism.BoundingBlock));
API.hideItem(new ItemStack(Mekanism.ItemProxy));

View file

@ -14,6 +14,9 @@ import mekanism.api.PressurizedReactants;
import mekanism.api.PressurizedRecipe;
import mekanism.api.gas.GasStack;
import mekanism.client.gui.GuiElement;
import mekanism.client.gui.GuiFluidGauge;
import mekanism.client.gui.GuiGasGauge;
import mekanism.client.gui.GuiGauge;
import mekanism.client.gui.GuiPRC;
import mekanism.client.gui.GuiPowerBar;
import mekanism.client.gui.GuiPowerBar.IPowerInfoHandler;
@ -23,7 +26,6 @@ import mekanism.client.gui.GuiProgress.ProgressBar;
import mekanism.client.gui.GuiSlot;
import mekanism.client.gui.GuiSlot.SlotOverlay;
import mekanism.client.gui.GuiSlot.SlotType;
import mekanism.client.nei.RotaryCondensentratorRecipeHandler.CachedIORecipe;
import mekanism.common.ObfuscatedNames;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.util.MekanismUtils;
@ -45,15 +47,23 @@ public class PRCRecipeHandler extends BaseRecipeHandler
{
private int ticksPassed;
public GuiFluidGauge fluidInput;
public GuiGasGauge gasInput;
public GuiGasGauge gasOutput;
public static int xOffset = 5;
public static int yOffset = 3;
public static int yOffset = 11;
@Override
public void addGuiElements()
{
guiElements.add(new GuiSlot(SlotType.INPUT, this, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 53, 34));
guiElements.add(new GuiSlot(SlotType.POWER, this, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 140, 18).with(SlotOverlay.POWER));
guiElements.add(new GuiSlot(SlotType.OUTPUT, this, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 115, 34));
guiElements.add(new GuiSlot(SlotType.INPUT, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 53, 34));
guiElements.add(new GuiSlot(SlotType.POWER, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 140, 18).with(SlotOverlay.POWER));
guiElements.add(new GuiSlot(SlotType.OUTPUT, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 115, 34));
guiElements.add(fluidInput = GuiFluidGauge.getDummy(GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiPRC.png"), 5, 10));
guiElements.add(gasInput = GuiGasGauge.getDummy(GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiPRC.png"), 28, 10));
guiElements.add(gasOutput = GuiGasGauge.getDummy(GuiGauge.Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiPRC.png"), 140, 40));
guiElements.add(new GuiPowerBar(this, new IPowerInfoHandler() {
@Override
@ -61,7 +71,7 @@ public class PRCRecipeHandler extends BaseRecipeHandler
{
return ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F;
}
}, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 164, 15));
}, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 164, 15));
guiElements.add(new GuiProgress(new IProgressInfoHandler()
{
@Override
@ -69,7 +79,7 @@ public class PRCRecipeHandler extends BaseRecipeHandler
{
return ticksPassed >= 20 ? (ticksPassed - 20) % 20 / 20.0F : 0.0F;
}
}, getProgressType(), this, MekanismUtils.getResource(ResourceType.GUI, getGuiTexture()), 75, 37));
}, getProgressType(), this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 75, 37));
}
public ProgressBar getProgressType()
@ -87,18 +97,18 @@ public class PRCRecipeHandler extends BaseRecipeHandler
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
changeTexture(getGuiTexture());
drawTexturedModalRect(-2, 0, 3, yOffset, 170, 80);
drawTexturedModalRect(-2, 0, 3, yOffset, 170, 68);
for(GuiElement e : guiElements)
{
e.renderBackground(0, 0, xOffset, yOffset);
e.renderBackground(0, 0, -xOffset, -yOffset);
}
}
@Override
public void loadTransferRects()
{
transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(70, 34, 36, 10), getRecipeId(), new Object[0]));
transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(75-xOffset, 37-yOffset, 36, 10), getRecipeId(), new Object[0]));
}
@Override
@ -111,7 +121,7 @@ public class PRCRecipeHandler extends BaseRecipeHandler
@Override
public String getRecipeName()
{
return MekanismUtils.localize("tile.MachineBlock2.PressurizedReactionChamber.name");
return MekanismUtils.localize("tile.MachineBlock2.PressurizedReactionChamber.short.name");
}
@Override
@ -129,7 +139,7 @@ public class PRCRecipeHandler extends BaseRecipeHandler
@Override
public int recipiesPerPage()
{
return 1;
return 2;
}
public String getRecipeId()
@ -140,30 +150,30 @@ public class PRCRecipeHandler extends BaseRecipeHandler
@Override
public String getGuiTexture()
{
return "nei/GuiPRC.png";
return "mekanism:gui/nei/GuiPRC.png";
}
@Override
public void drawExtras(int i)
{
CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i);
drawTexturedModalRect(47-xOffset, 39-yOffset, 176, 71, 28, 8);
drawTexturedModalRect(101-xOffset, 39-yOffset, 176, 63, 28, 8);
if(recipe.pressurizedRecipe.reactants.getFluid() != null)
{
displayGauge(58, 26-xOffset, 14-yOffset, 176, 4, 58, recipe.pressurizedRecipe.reactants.getFluid(), null);
fluidInput.setDummyType(recipe.pressurizedRecipe.reactants.getFluid().getFluid());
fluidInput.renderScale(0, 0, -xOffset, -yOffset);
}
if(recipe.pressurizedRecipe.reactants.getGas() != null)
{
displayGauge(58, 26-xOffset, 14-yOffset, 176, 4, 58, null, recipe.pressurizedRecipe.reactants.getGas());
gasInput.setDummyType(recipe.pressurizedRecipe.reactants.getGas().getGas());
gasInput.renderScale(0, 0, -xOffset, -yOffset);
}
if(recipe.pressurizedRecipe.products.getGasOutput() != null)
{
displayGauge(58, 80-xOffset, 5-yOffset, 176, 4, 58, null, recipe.pressurizedRecipe.products.getGasOutput());
gasOutput.setDummyType(recipe.pressurizedRecipe.products.getGasOutput().getGas());
gasOutput.renderScale(0, 0, -xOffset, -yOffset);
}
}
@ -252,15 +262,15 @@ public class PRCRecipeHandler extends BaseRecipeHandler
int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft);
int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop);
if(xAxis >= 80 && xAxis <= 96 && yAxis >= 5+13 && yAxis <= 63+13)
if(xAxis >= 6 && xAxis <= 22 && yAxis >= 11+13 && yAxis <= 69+13)
{
currenttip.add(((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.reactants.getFluid().getFluid().getLocalizedName());
}
else if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14+13 && yAxis <= 72+13)
else if(xAxis >= 29 && xAxis <= 45 && yAxis >= 11+13 && yAxis <= 69+13)
{
currenttip.add(((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.reactants.getGas().getGas().getLocalizedName());
}
else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+13 && yAxis <= 72+13)
else if(xAxis >= 141 && xAxis <= 157 && yAxis >= 41+13 && yAxis <= 69+13)
{
currenttip.add(((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.products.getGasOutput().getGas().getLocalizedName());
}
@ -279,15 +289,15 @@ public class PRCRecipeHandler extends BaseRecipeHandler
GasStack gas = null;
FluidStack fluid = null;
if(xAxis >= 80 && xAxis <= 96 && yAxis >= 5+13 && yAxis <= 63+13)
if(xAxis >= 6 && xAxis <= 22 && yAxis >= 11+13 && yAxis <= 69+13)
{
fluid = ((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.reactants.getFluid();
}
else if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14+13 && yAxis <= 72+13)
else if(xAxis >= 29 && xAxis <= 45 && yAxis >= 11+13 && yAxis <= 69+13)
{
gas = ((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.reactants.getGas();
}
else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+13 && yAxis <= 72+13)
else if(xAxis >= 141 && xAxis <= 157 && yAxis >= 41+13 && yAxis <= 69+13)
{
gas = ((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.products.getGasOutput();
}
@ -341,15 +351,15 @@ public class PRCRecipeHandler extends BaseRecipeHandler
GasStack gas = null;
FluidStack fluid = null;
if(xAxis >= 80 && xAxis <= 96 && yAxis >= 5+13 && yAxis <= 63+13)
if(xAxis >= 6 && xAxis <= 22 && yAxis >= 11+13 && yAxis <= 69+13)
{
fluid = ((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.reactants.getFluid();
}
else if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14+13 && yAxis <= 72+13)
else if(xAxis >= 29 && xAxis <= 45 && yAxis >= 11+13 && yAxis <= 69+13)
{
gas = ((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.reactants.getGas();
}
else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+13 && yAxis <= 72+13)
else if(xAxis >= 141 && xAxis <= 157 && yAxis >= 41+13 && yAxis <= 69+13)
{
gas = ((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.products.getGasOutput();
}
@ -417,8 +427,8 @@ public class PRCRecipeHandler extends BaseRecipeHandler
pressurizedRecipe = recipe;
input = new PositionedStack(recipe.reactants.getSolid(), 54, 35);
output = new PositionedStack(recipe.products.getItemOutput(), 116, 35);
input = new PositionedStack(recipe.reactants.getSolid(), 54-xOffset, 35-yOffset);
output = new PositionedStack(recipe.products.getItemOutput(), 116-xOffset, 35-yOffset);
}
public CachedIORecipe(Map.Entry recipe)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 3 KiB