mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-25 14:24:35 +00:00
commit 0d4dc5991e572793134c0c1af8bb35db528071ad Author: pupnewfster <[email protected]> Date: Thu Mar 7 19:25:28 2019 -0500 IntelliJ inspections, Unused Import commit c757d3236b6304b1d3295ad392b88677bccf3003 Author: pupnewfster <[email protected]> Date: Thu Mar 7 19:09:24 2019 -0500 IntelliJ inspections, Constant conditions & exceptions commit c63a821ef9fc705941052a876cc1ef950471912e Author: pupnewfster <[email protected]> Date: Thu Mar 7 17:41:31 2019 -0500 IntelliJ inspections, @NotNull/@Nullable problems commit 506bbfd3241336082b17e5d47f8cec496666dcff Author: pupnewfster <[email protected]> Date: Thu Mar 7 16:50:46 2019 -0500 IntelliJ inspections, Unused label commit bad10c2428346b5feb1816e4a78d7cc2bc1259f0 Author: pupnewfster <[email protected]> Date: Thu Mar 7 15:33:54 2019 -0500 IntelliJ inspections, Unused assignment commit bfe633afbfb6380d0f5ee2e8ab14f8981a455681 Author: pupnewfster <[email protected]> Date: Thu Mar 7 15:32:02 2019 -0500 IntelliJ inspections, 'equals()' between objects of inconvertible types commit 6d179f8639fad1a7c3fa01467c003a8fd309da09 Author: pupnewfster <[email protected]> Date: Thu Mar 7 15:29:28 2019 -0500 IntelliJ inspections, Unused import commit c21f1cfa5566308237dc8bddb8b79908e272a637 Author: pupnewfster <[email protected]> Date: Thu Mar 7 15:25:41 2019 -0500 IntelliJ inspections, Unused import commit e5d9e03af582c7315b057861b8f0019e46157dee Author: pupnewfster <[email protected]> Date: Thu Mar 7 15:23:10 2019 -0500 IntelliJ inspections, Redundant 'throws' clause commit 1c589ba5740411a5595e9fda177696670bc7b7df Author: pupnewfster <[email protected]> Date: Thu Mar 7 15:21:07 2019 -0500 IntelliJ inspections, Static member referenced by instance variable commit 6c17e9ca7fb22a0e285337133659e826f3bfdfee Author: pupnewfster <[email protected]> Date: Thu Mar 7 15:20:02 2019 -0500 IntelliJ inspections, Catch block may ignore exception commit 42b3cd788ceb7d6ce657d582bbbd8345a2ec5676 Author: pupnewfster <[email protected]> Date: Thu Mar 7 15:16:29 2019 -0500 IntelliJ inspections, Unnecessary label on 'break' statement commit f6abc3c66f3aca147edb274720cdb94bff568b0b Author: pupnewfster <[email protected]> Date: Thu Mar 7 15:15:29 2019 -0500 IntelliJ inspections, Too weak variable type leads to unnecessary cast commit 6356d1fea8d55907ae1c7b011223fbbc07236c1f Author: pupnewfster <[email protected]> Date: Thu Mar 7 15:11:17 2019 -0500 IntelliJ inspections, Redundant type cast commit 559c1a2ff523fd7e23f3750d5c801af73876f1d0 Author: pupnewfster <[email protected]> Date: Thu Mar 7 15:04:45 2019 -0500 IntelliJ inspections, Redundant type arguments commit ae816ec2a79cf4c8fee776db651a54f68c1dacaa Author: pupnewfster <[email protected]> Date: Thu Mar 7 15:01:27 2019 -0500 IntelliJ inspections, Redundant Collection operation commit 1da69b8baff922b98a32163c7d5f90aa77a6a8bc Author: pupnewfster <[email protected]> Date: Thu Mar 7 15:00:55 2019 -0500 IntelliJ inspections, Redundant array creation commit 7e3ef81a3597c596d2206c93442e950ac9183de0 Author: pupnewfster <[email protected]> Date: Thu Mar 7 15:00:11 2019 -0500 IntelliJ inspections, Condition is covered by further condition commit f298bbb9f31ecbe935ef6cbf98b56951434a05f8 Author: pupnewfster <[email protected]> Date: Thu Mar 7 14:58:10 2019 -0500 IntelliJ inspections, Redundant 'Collection.addAll()' call commit ce715c5cd724c4dc71ff2cb53e5bc12f16289f12 Author: pupnewfster <[email protected]> Date: Thu Mar 7 14:56:56 2019 -0500 IntelliJ inspections, 'Collection.toArray()' call style commit 0bde4b0eb23ac5d8f40a410ed55315e4a422a30c Author: pupnewfster <[email protected]> Date: Thu Mar 7 14:55:40 2019 -0500 IntelliJ inspections, Calls to 'Arrays.asList()' with too few arguments commit 6d06d11dcf9c077ed6b216a0bbd61434b10fc610 Author: pupnewfster <[email protected]> Date: Thu Mar 7 14:52:26 2019 -0500 IntelliJ inspections, Pointless arithmetic expression commit 6501d725af1eda5127489f77fd723396002b29b2 Author: pupnewfster <[email protected]> Date: Thu Mar 7 14:42:32 2019 -0500 IntelliJ inspections, Anonymous type can be replaced with lambda commit 85341ae5df9d63fb0ad7281c260c77d064adf0c2 Author: pupnewfster <[email protected]> Date: Thu Mar 7 14:41:40 2019 -0500 IntelliJ inspections, Explicit type can be replaced with <> commit 7e2feae7189b92cb513499aed113d4a2634622c6 Author: pupnewfster <[email protected]> Date: Thu Mar 7 14:38:47 2019 -0500 IntelliJ inspections, Unnecessary 'null' check before method call commit 2c75a38fe9a969f832cd5777f4fad81ef47d037b Author: pupnewfster <[email protected]> Date: Thu Mar 7 14:37:33 2019 -0500 IntelliJ inspections, 'switch' statement with too few branches commit 2e2aff57f7910aef5a68f41a1918e2c8a98509ec Author: pupnewfster <[email protected]> Date: Thu Mar 7 14:34:50 2019 -0500 IntelliJ inspections, Simplifiable conditional statement commit 243f6a975f8b3da5e70a5c1a116db2aedd10900e Author: pupnewfster <[email protected]> Date: Thu Mar 7 14:33:09 2019 -0500 IntelliJ inspections, Duplicate condition in 'if' statement commit a80c67fc30b737990e7805a8741dce120232badc Author: pupnewfster <[email protected]> Date: Thu Mar 7 14:32:17 2019 -0500 IntelliJ inspections, Unnecessary semicolon commit 5a7220ee574c9d38d71db07e4fa995a56fee1eed Author: pupnewfster <[email protected]> Date: Thu Mar 7 14:31:58 2019 -0500 IntelliJ inspections, Unnecessary enum/interface modifier commit f3a66f4462033d2f446c2961a1ad8e9cfde3ed36 Author: pupnewfster <[email protected]> Date: Thu Mar 7 14:30:36 2019 -0500 IntelliJ inspections, Unnecessary conversion to String commit 1662540be864db4669cd80c8c46a9b35be202b62 Author: pupnewfster <[email protected]> Date: Thu Mar 7 14:29:33 2019 -0500 IntelliJ inspections, C styled array declaration
316 lines
11 KiB
Java
316 lines
11 KiB
Java
package mekanism.client.gui;
|
|
|
|
import java.io.IOException;
|
|
|
|
import mekanism.api.Coord4D;
|
|
import mekanism.client.gui.element.GuiEnergyInfo;
|
|
import mekanism.client.gui.element.GuiPowerBar;
|
|
import mekanism.client.gui.element.GuiRedstoneControl;
|
|
import mekanism.client.gui.element.GuiSecurityTab;
|
|
import mekanism.client.gui.element.GuiSideConfigurationTab;
|
|
import mekanism.client.gui.element.GuiSlot;
|
|
import mekanism.client.gui.element.GuiSlot.SlotOverlay;
|
|
import mekanism.client.gui.element.GuiSlot.SlotType;
|
|
import mekanism.client.gui.element.GuiTransporterConfigTab;
|
|
import mekanism.client.gui.element.GuiUpgradeTab;
|
|
import mekanism.client.render.MekanismRenderer;
|
|
import mekanism.client.sound.SoundHandler;
|
|
import mekanism.common.Mekanism;
|
|
import mekanism.common.base.TileNetworkList;
|
|
import mekanism.common.inventory.container.ContainerFormulaicAssemblicator;
|
|
import mekanism.common.item.ItemCraftingFormula;
|
|
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
|
import mekanism.common.tile.TileEntityFormulaicAssemblicator;
|
|
import mekanism.common.util.LangUtils;
|
|
import mekanism.common.util.ListUtils;
|
|
import mekanism.common.util.MekanismUtils;
|
|
import mekanism.common.util.MekanismUtils.ResourceType;
|
|
import net.minecraft.client.renderer.GlStateManager;
|
|
import net.minecraft.client.renderer.RenderHelper;
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
|
import net.minecraft.init.SoundEvents;
|
|
import net.minecraft.inventory.Slot;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.util.ResourceLocation;
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
public class GuiFormulaicAssemblicator extends GuiMekanism
|
|
{
|
|
public TileEntityFormulaicAssemblicator tileEntity;
|
|
|
|
public ResourceLocation guiLocation = MekanismUtils.getResource(ResourceType.GUI, "GuiFormulaicAssemblicator.png");
|
|
|
|
public GuiFormulaicAssemblicator(InventoryPlayer inventory, TileEntityFormulaicAssemblicator tentity)
|
|
{
|
|
super(tentity, new ContainerFormulaicAssemblicator(inventory, tentity));
|
|
tileEntity = tentity;
|
|
guiElements.add(new GuiSecurityTab(this, tileEntity, guiLocation));
|
|
guiElements.add(new GuiUpgradeTab(this, tileEntity, guiLocation));
|
|
guiElements.add(new GuiRedstoneControl(this, tileEntity, guiLocation));
|
|
guiElements.add(new GuiSideConfigurationTab(this, tileEntity, guiLocation));
|
|
guiElements.add(new GuiTransporterConfigTab(this, 34, tileEntity, guiLocation));
|
|
guiElements.add(new GuiPowerBar(this, tileEntity, guiLocation, 159, 15));
|
|
guiElements.add(new GuiEnergyInfo(() ->
|
|
{
|
|
String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick);
|
|
return ListUtils.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy()));
|
|
}, this, guiLocation));
|
|
guiElements.add(new GuiSlot(SlotType.POWER, this, guiLocation, 151, 75).with(SlotOverlay.POWER));
|
|
|
|
ySize+=64;
|
|
}
|
|
|
|
@Override
|
|
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
|
{
|
|
int xAxis = (mouseX - (width - xSize) / 2);
|
|
int yAxis = (mouseY - (height - ySize) / 2);
|
|
|
|
fontRenderer.drawString(tileEntity.getName(), (xSize/2)-(fontRenderer.getStringWidth(tileEntity.getName())/2), 6, 0x404040);
|
|
fontRenderer.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
|
|
|
if(xAxis >= 44 && xAxis <= 60 && yAxis >= 75 && yAxis <= 91)
|
|
{
|
|
drawHoveringText(LangUtils.localize("gui.fillEmpty"), xAxis, yAxis);
|
|
}
|
|
|
|
if(xAxis >= 7 && xAxis <= 21 && yAxis >= 45 && yAxis <= 59)
|
|
{
|
|
drawHoveringText(LangUtils.localize("gui.encodeFormula"), xAxis, yAxis);
|
|
}
|
|
|
|
if(xAxis >= 71 && xAxis <= 87 && yAxis >= 75 && yAxis <= 91)
|
|
{
|
|
drawHoveringText(LangUtils.localize("gui.craftSingle"), xAxis, yAxis);
|
|
}
|
|
|
|
if(xAxis >= 89 && xAxis <= 105 && yAxis >= 75 && yAxis <= 91)
|
|
{
|
|
drawHoveringText(LangUtils.localize("gui.craftAvailable"), xAxis, yAxis);
|
|
}
|
|
|
|
if(xAxis >= 107 && xAxis <= 123 && yAxis >= 75 && yAxis <= 91)
|
|
{
|
|
drawHoveringText(LangUtils.localize("gui.autoModeToggle") + ": " + LangUtils.transOnOff(tileEntity.autoMode), xAxis, yAxis);
|
|
}
|
|
|
|
if(xAxis >= 26 && xAxis <= 42 && yAxis >= 75 && yAxis <= 91)
|
|
{
|
|
drawHoveringText(LangUtils.localize("gui.stockControl") + ": " + LangUtils.transOnOff(tileEntity.stockControl), xAxis, yAxis);
|
|
}
|
|
|
|
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
|
}
|
|
|
|
@Override
|
|
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
|
|
{
|
|
mc.renderEngine.bindTexture(guiLocation);
|
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
int guiWidth = (width - xSize) / 2;
|
|
int guiHeight = (height - ySize) / 2;
|
|
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
|
|
|
|
int xAxis = mouseX - guiWidth;
|
|
int yAxis = mouseY - guiHeight;
|
|
|
|
if(!tileEntity.autoMode)
|
|
{
|
|
if(xAxis >= 44 && xAxis <= 60 && yAxis >= 75 && yAxis <= 91)
|
|
{
|
|
drawTexturedModalRect(guiWidth + 44, guiHeight + 75, 176 + 62, 0, 16, 16);
|
|
}
|
|
else {
|
|
drawTexturedModalRect(guiWidth + 44, guiHeight + 75, 176 + 62, 16, 16, 16);
|
|
}
|
|
}
|
|
else {
|
|
drawTexturedModalRect(guiWidth + 44, guiHeight + 75, 176 + 62, 32, 16, 16);
|
|
}
|
|
|
|
if(!tileEntity.autoMode && tileEntity.isRecipe)
|
|
{
|
|
if(canEncode())
|
|
{
|
|
if(xAxis >= 7 && xAxis <= 21 && yAxis >= 45 && yAxis <= 59)
|
|
{
|
|
drawTexturedModalRect(guiWidth + 7, guiHeight + 45, 176, 0, 14, 14);
|
|
}
|
|
else {
|
|
drawTexturedModalRect(guiWidth + 7, guiHeight + 45, 176, 14, 14, 14);
|
|
}
|
|
}
|
|
else {
|
|
drawTexturedModalRect(guiWidth + 7, guiHeight + 45, 176, 28, 14, 14);
|
|
}
|
|
|
|
if(xAxis >= 71 && xAxis <= 87 && yAxis >= 75 && yAxis <= 91)
|
|
{
|
|
drawTexturedModalRect(guiWidth + 71, guiHeight + 75, 176 + 14, 0, 16, 16);
|
|
}
|
|
else {
|
|
drawTexturedModalRect(guiWidth + 71, guiHeight + 75, 176 + 14, 16, 16, 16);
|
|
}
|
|
|
|
if(xAxis >= 89 && xAxis <= 105 && yAxis >= 75 && yAxis <= 91)
|
|
{
|
|
drawTexturedModalRect(guiWidth + 89, guiHeight + 75, 176 + 30, 0, 16, 16);
|
|
}
|
|
else {
|
|
drawTexturedModalRect(guiWidth + 89, guiHeight + 75, 176 + 30, 16, 16, 16);
|
|
}
|
|
}
|
|
else {
|
|
drawTexturedModalRect(guiWidth + 7, guiHeight + 45, 176, 28, 14, 14);
|
|
drawTexturedModalRect(guiWidth + 71, guiHeight + 75, 176 + 14, 32, 16, 16);
|
|
drawTexturedModalRect(guiWidth + 89, guiHeight + 75, 176 + 30, 32, 16, 16);
|
|
}
|
|
|
|
if(tileEntity.formula != null)
|
|
{
|
|
if(xAxis >= 107 && xAxis <= 123 && yAxis >= 75 && yAxis <= 91)
|
|
{
|
|
drawTexturedModalRect(guiWidth + 107, guiHeight + 75, 176 + 46, 0, 16, 16);
|
|
}
|
|
else {
|
|
drawTexturedModalRect(guiWidth + 107, guiHeight + 75, 176 + 46, 16, 16, 16);
|
|
}
|
|
|
|
if(xAxis >= 26 && xAxis <= 42 && yAxis >= 75 && yAxis <= 91)
|
|
{
|
|
drawTexturedModalRect(guiWidth + 26, guiHeight + 75, 176 + 62, 48, 16, 16);
|
|
}
|
|
else {
|
|
drawTexturedModalRect(guiWidth + 26, guiHeight + 75, 176 + 62, 48 + 16, 16, 16);
|
|
}
|
|
}
|
|
else {
|
|
drawTexturedModalRect(guiWidth + 107, guiHeight + 75, 176 + 46, 32, 16, 16);
|
|
drawTexturedModalRect(guiWidth + 26, guiHeight + 75, 176 + 62, 48 + 32, 16, 16);
|
|
}
|
|
|
|
if(tileEntity.operatingTicks > 0)
|
|
{
|
|
int display = (int)((double)tileEntity.operatingTicks*22/(double)tileEntity.ticksRequired);
|
|
drawTexturedModalRect(guiWidth + 86, guiHeight + 43, 176, 48, display, 16);
|
|
}
|
|
|
|
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiSlot.png"));
|
|
drawTexturedModalRect(guiWidth + 90, guiHeight + 25, tileEntity.isRecipe ? 2 : 20, 39, 14, 12);
|
|
|
|
if(tileEntity.formula != null)
|
|
{
|
|
for(int i = 0; i < 9; i++)
|
|
{
|
|
ItemStack stack = tileEntity.formula.input.get(i);
|
|
|
|
if(!stack.isEmpty())
|
|
{
|
|
Slot slot = inventorySlots.inventorySlots.get(i+20);
|
|
GlStateManager.pushMatrix();
|
|
|
|
if(slot.getStack().isEmpty() || !slot.getStack().isItemEqual(stack))
|
|
{
|
|
drawGradientRect(guiWidth + slot.xPos, guiHeight + slot.yPos, guiWidth + slot.xPos + 16, guiHeight + slot.yPos + 16, -2137456640, -2137456640);
|
|
}
|
|
|
|
RenderHelper.enableGUIStandardItemLighting();
|
|
itemRender.renderItemAndEffectIntoGUI(stack, guiWidth + slot.xPos, guiHeight + slot.yPos);
|
|
MekanismRenderer.resetColor();
|
|
GlStateManager.popMatrix();
|
|
}
|
|
}
|
|
}
|
|
|
|
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
|
}
|
|
|
|
private boolean canEncode()
|
|
{
|
|
return tileEntity.formula == null && !tileEntity.inventory.get(2).isEmpty() && tileEntity.inventory.get(2).getItem() instanceof ItemCraftingFormula &&
|
|
((ItemCraftingFormula)tileEntity.inventory.get(2).getItem()).getInventory(tileEntity.inventory.get(2)) == null;
|
|
}
|
|
|
|
@Override
|
|
protected void mouseClicked(int mouseX, int mouseY, int button) throws IOException
|
|
{
|
|
super.mouseClicked(mouseX, mouseY, button);
|
|
|
|
if(button == 0)
|
|
{
|
|
int xAxis = (mouseX - (width - xSize) / 2);
|
|
int yAxis = (mouseY - (height - ySize) / 2);
|
|
|
|
if(!tileEntity.autoMode)
|
|
{
|
|
if(xAxis >= 44 && xAxis <= 60 && yAxis >= 75 && yAxis <= 91)
|
|
{
|
|
SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK);
|
|
|
|
TileNetworkList data = TileNetworkList.withContents(4);
|
|
|
|
Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data));
|
|
}
|
|
|
|
if(tileEntity.isRecipe)
|
|
{
|
|
if(canEncode())
|
|
{
|
|
if(xAxis >= 7 && xAxis <= 21 && yAxis >= 45 && yAxis <= 59)
|
|
{
|
|
SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK);
|
|
|
|
TileNetworkList data = TileNetworkList.withContents(1);
|
|
|
|
Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data));
|
|
}
|
|
}
|
|
|
|
if(xAxis >= 71 && xAxis <= 87 && yAxis >= 75 && yAxis <= 91)
|
|
{
|
|
SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK);
|
|
|
|
TileNetworkList data = TileNetworkList.withContents(2);
|
|
|
|
Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data));
|
|
}
|
|
|
|
if(xAxis >= 89 && xAxis <= 105 && yAxis >= 75 && yAxis <= 91)
|
|
{
|
|
SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK);
|
|
|
|
TileNetworkList data = TileNetworkList.withContents(3);
|
|
|
|
Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data));
|
|
}
|
|
}
|
|
}
|
|
|
|
if(tileEntity.formula != null)
|
|
{
|
|
if(xAxis >= 107 && xAxis <= 123 && yAxis >= 75 && yAxis <= 91)
|
|
{
|
|
SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK);
|
|
|
|
TileNetworkList data = TileNetworkList.withContents(0);
|
|
|
|
Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data));
|
|
}
|
|
|
|
if(xAxis >= 26 && xAxis <= 42 && yAxis >= 75 && yAxis <= 91)
|
|
{
|
|
SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK);
|
|
|
|
TileNetworkList data = TileNetworkList.withContents(5);
|
|
|
|
Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|