diff --git a/src/main/java/mekanism/client/ClientProxy.java b/src/main/java/mekanism/client/ClientProxy.java index 66819f7ac..2a8bdd4dd 100644 --- a/src/main/java/mekanism/client/ClientProxy.java +++ b/src/main/java/mekanism/client/ClientProxy.java @@ -35,6 +35,7 @@ import mekanism.client.gui.GuiGasTank; import mekanism.client.gui.GuiInductionMatrix; import mekanism.client.gui.GuiLaserAmplifier; import mekanism.client.gui.GuiLaserTractorBeam; +import mekanism.client.gui.GuiMatrixStats; import mekanism.client.gui.GuiMetallurgicInfuser; import mekanism.client.gui.GuiOsmiumCompressor; import mekanism.client.gui.GuiPRC; @@ -503,6 +504,8 @@ public class ClientProxy extends CommonProxy return new GuiAmbientAccumulator(player, (TileEntityAmbientAccumulator)tileEntity); case 49: return new GuiInductionMatrix(player.inventory, (TileEntityInductionCasing)tileEntity); + case 50: + return new GuiMatrixStats(player.inventory, (TileEntityInductionCasing)tileEntity); } return null; diff --git a/src/main/java/mekanism/client/gui/GuiInductionMatrix.java b/src/main/java/mekanism/client/gui/GuiInductionMatrix.java index c8a705154..a1c56b4d0 100644 --- a/src/main/java/mekanism/client/gui/GuiInductionMatrix.java +++ b/src/main/java/mekanism/client/gui/GuiInductionMatrix.java @@ -1,14 +1,12 @@ package mekanism.client.gui; -import mekanism.api.energy.IStrictEnergyStorage; -import mekanism.client.gui.GuiEnergyGauge.IEnergyInfoHandler; +import mekanism.client.gui.GuiMatrixTab.MatrixTab; import mekanism.client.render.MekanismRenderer; import mekanism.common.inventory.container.ContainerInductionMatrix; import mekanism.common.tile.TileEntityInductionCasing; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; -import net.minecraftforge.fluids.FluidStack; import org.lwjgl.opengl.GL11; @@ -24,6 +22,7 @@ public class GuiInductionMatrix extends GuiMekanism { super(tentity, new ContainerInductionMatrix(inventory, tentity)); tileEntity = tentity; + guiElements.add(new GuiMatrixTab(this, tileEntity, MatrixTab.STAT, 6, MekanismUtils.getResource(ResourceType.GUI, "GuiInductionMatrix.png"))); } @Override @@ -32,12 +31,12 @@ public class GuiInductionMatrix extends GuiMekanism int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040); + fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 6, 0x404040); fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040); fontRendererObj.drawString(MekanismUtils.localize("gui.energy") + ":", 53, 26, 0x00CD00); - fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()) + "/" + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()), 53, 35, 0x00CD00); + fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 53, 35, 0x00CD00); fontRendererObj.drawString(MekanismUtils.localize("gui.output") + ":", 53, 44, 0x00CD00); - fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + "/" + MekanismUtils.getEnergyDisplay(tileEntity.structure.outputCap), 53, 53, 0x00CD00); + fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput), 53, 53, 0x00CD00); if(xAxis >= 7 && xAxis <= 39 && yAxis >= 14 && yAxis <= 72) { diff --git a/src/main/java/mekanism/client/gui/GuiMatrixStats.java b/src/main/java/mekanism/client/gui/GuiMatrixStats.java new file mode 100644 index 000000000..7fc97c66b --- /dev/null +++ b/src/main/java/mekanism/client/gui/GuiMatrixStats.java @@ -0,0 +1,63 @@ +package mekanism.client.gui; + +import mekanism.api.energy.IStrictEnergyStorage; +import mekanism.client.gui.GuiEnergyGauge.IEnergyInfoHandler; +import mekanism.client.gui.GuiMatrixTab.MatrixTab; +import mekanism.common.inventory.container.ContainerNull; +import mekanism.common.tile.TileEntityInductionCasing; +import mekanism.common.util.MekanismUtils; +import mekanism.common.util.MekanismUtils.ResourceType; +import net.minecraft.entity.player.InventoryPlayer; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class GuiMatrixStats extends GuiMekanism +{ + public TileEntityInductionCasing tileEntity; + + public GuiMatrixStats(InventoryPlayer inventory, TileEntityInductionCasing tentity) + { + super(tentity, new ContainerNull(inventory.player, tentity)); + tileEntity = tentity; + guiElements.add(new GuiMatrixTab(this, tileEntity, MatrixTab.MAIN, 6, MekanismUtils.getResource(ResourceType.GUI, "GuiMatrixStats.png"))); + guiElements.add(new GuiEnergyGauge(new IEnergyInfoHandler() + { + @Override + public IStrictEnergyStorage getEnergyStorage() + { + return tileEntity; + } + }, GuiEnergyGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiMatrixStats.png"), 6, 13)); + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + fontRendererObj.drawString(MekanismUtils.localize("gui.matrixStats"), 45, 6, 0x404040); + fontRendererObj.drawString(MekanismUtils.localize("gui.energy") + ":", 53, 26, 0x00CD00); + fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()) + "/" + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()), 53, 35, 0x00CD00); + fontRendererObj.drawString(MekanismUtils.localize("gui.output") + ":", 53, 44, 0x00CD00); + fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + "/" + MekanismUtils.getEnergyDisplay(tileEntity.structure.outputCap), 53, 53, 0x00CD00); + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiMatrixStats.png")); + 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); + } +} diff --git a/src/main/java/mekanism/client/gui/GuiMatrixTab.java b/src/main/java/mekanism/client/gui/GuiMatrixTab.java new file mode 100644 index 000000000..87eb3ac37 --- /dev/null +++ b/src/main/java/mekanism/client/gui/GuiMatrixTab.java @@ -0,0 +1,115 @@ +package mekanism.client.gui; + +import mekanism.api.Coord4D; +import mekanism.client.sound.SoundHandler; +import mekanism.common.Mekanism; +import mekanism.common.network.PacketSimpleGui.SimpleGuiMessage; +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; + +@SideOnly(Side.CLIENT) +public class GuiMatrixTab extends GuiElement +{ + private TileEntity tileEntity; + private MatrixTab tabType; + private int yPos; + + public GuiMatrixTab(IGuiWrapper gui, TileEntity tile, MatrixTab type, int y, ResourceLocation def) + { + super(type.getResource(), gui, def); + + tileEntity = tile; + tabType = type; + yPos = y; + } + + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) + { + return new Rectangle4i(guiWidth - 26, guiHeight + yPos, 26, 26); + } + + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) + { + mc.renderEngine.bindTexture(RESOURCE); + + guiObj.drawTexturedRect(guiWidth - 26, guiHeight + yPos, 0, 0, 26, 26); + + if(xAxis >= -21 && xAxis <= -3 && yAxis >= yPos+4 && yAxis <= yPos+22) + { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + yPos+4, 26, 0, 18, 18); + } + else { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + yPos+4, 26, 18, 18, 18); + } + + mc.renderEngine.bindTexture(defaultLocation); + } + + @Override + public void renderForeground(int xAxis, int yAxis) + { + mc.renderEngine.bindTexture(RESOURCE); + + if(xAxis >= -21 && xAxis <= -3 && yAxis >= yPos+4 && yAxis <= yPos+22) + { + displayTooltip(tabType.getDesc(), xAxis, yAxis); + } + + mc.renderEngine.bindTexture(defaultLocation); + } + + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} + + @Override + public void mouseClicked(int xAxis, int yAxis, int button) + { + if(button == 0) + { + if(xAxis >= -21 && xAxis <= -3 && yAxis >= yPos+4 && yAxis <= yPos+22) + { + tabType.openGui(tileEntity); + SoundHandler.playSound("gui.button.press"); + } + } + } + + public static enum MatrixTab + { + MAIN("GuiEnergyTab.png", 49, "gui.main"), + STAT("GuiStatsTab.png", 50, "gui.stats"); + + private String path; + private int guiId; + private String desc; + + private MatrixTab(String s, int id, String s1) + { + path = s; + guiId = id; + desc = s1; + } + + public ResourceLocation getResource() + { + return MekanismUtils.getResource(ResourceType.GUI_ELEMENT, path); + } + + public void openGui(TileEntity tile) + { + Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tile), guiId)); + } + + public String getDesc() + { + return MekanismUtils.localize(desc); + } + } +} diff --git a/src/main/java/mekanism/common/CommonProxy.java b/src/main/java/mekanism/common/CommonProxy.java index 2249c73d4..a1d91da11 100644 --- a/src/main/java/mekanism/common/CommonProxy.java +++ b/src/main/java/mekanism/common/CommonProxy.java @@ -484,6 +484,8 @@ public class CommonProxy return new ContainerNull(player, (TileEntityContainerBlock)tileEntity); case 49: return new ContainerInductionMatrix(player.inventory, (TileEntityInductionCasing)tileEntity); + case 50: + return new ContainerNull(player, (TileEntityContainerBlock)tileEntity); } return null; diff --git a/src/main/java/mekanism/common/util/HeatUtils.java b/src/main/java/mekanism/common/util/HeatUtils.java index 6c5013e80..8cfd36e98 100644 --- a/src/main/java/mekanism/common/util/HeatUtils.java +++ b/src/main/java/mekanism/common/util/HeatUtils.java @@ -11,26 +11,34 @@ public class HeatUtils { public static double[] simulate(IHeatTransfer source) { - double heatTransferred[] = new double[]{0,0}; + double heatTransferred[] = new double[] {0,0}; + for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { IHeatTransfer sink = source.getAdjacent(side); + if(sink != null) { double invConduction = sink.getInverseConductionCoefficient() + source.getInverseConductionCoefficient(); double heatToTransfer = source.getTemp() / invConduction; source.transferHeatTo(-heatToTransfer); sink.transferHeatTo(heatToTransfer); + if(!(sink instanceof IGridTransmitter)) + { heatTransferred[0] += heatToTransfer; + } + continue; } + //Transfer to air otherwise double invConduction = IHeatTransfer.AIR_INVERSE_COEFFICIENT + source.getInsulationCoefficient(side) + source.getInverseConductionCoefficient(); double heatToTransfer = source.getTemp() / invConduction; source.transferHeatTo(-heatToTransfer); heatTransferred[1] += heatToTransfer; } + return heatTransferred; } } diff --git a/src/main/java/mekanism/common/util/MekanismUtils.java b/src/main/java/mekanism/common/util/MekanismUtils.java index f7db768f3..958584395 100644 --- a/src/main/java/mekanism/common/util/MekanismUtils.java +++ b/src/main/java/mekanism/common/util/MekanismUtils.java @@ -664,12 +664,24 @@ public final class MekanismUtils } /** - * A better "isBlockIndirectlyGettingPowered()" that doesn't load chunks + * A better "isBlockIndirectlyGettingPowered()" that doesn't load chunks. * @param world - the world to perform the check in * @param coord - the coordinate of the block performing the check * @return if the block is indirectly getting powered by LOADED chunks */ public static boolean isGettingPowered(World world, Coord4D coord) + { + return isGettingPowered(world, coord, true); + } + + /** + * Extension of preceding isGettingPowered() method, used to define expansions of the check. + * @param world - the world to perform the check in + * @param coord - the coordinate of the block performing the check + * @param expand - whether or not the check should be recursively called on the surrounding coordinates + * @return if the block is indirectly getting powered by LOADED chunks + */ + public static boolean isGettingPowered(World world, Coord4D coord, boolean expand) { for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { @@ -677,14 +689,11 @@ public final class MekanismUtils if(sideCoord.exists(world) && sideCoord.getFromSide(side).exists(world)) { - if(sideCoord.getFromSide(side).exists(world)) + if(world.isBlockProvidingPowerTo(sideCoord.xCoord, sideCoord.yCoord, sideCoord.zCoord, side.getOpposite().ordinal()) > 0) { - if(world.getIndirectPowerLevelTo(sideCoord.xCoord, sideCoord.yCoord, sideCoord.zCoord, side.ordinal()) > 0) - { - return true; - } + return true; } - else if(world.isBlockProvidingPowerTo(sideCoord.xCoord, sideCoord.yCoord, sideCoord.zCoord, side.ordinal()) > 0) + else if(expand && isGettingPowered(world, sideCoord, false)) { return true; } diff --git a/src/main/java/mekanism/generators/client/gui/GuiReactorStats.java b/src/main/java/mekanism/generators/client/gui/GuiReactorStats.java index 58bf55931..3c3e93ecb 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiReactorStats.java +++ b/src/main/java/mekanism/generators/client/gui/GuiReactorStats.java @@ -30,7 +30,6 @@ public class GuiReactorStats extends GuiMekanism public TileEntityReactorController tileEntity; public static NumberFormat nf = NumberFormat.getIntegerInstance(); - public GuiReactorStats(InventoryPlayer inventory, final TileEntityReactorController tentity) { super(new ContainerNull(inventory.player, tentity)); diff --git a/src/main/resources/assets/mekanism/gui/GuiMatrixStats.png b/src/main/resources/assets/mekanism/gui/GuiMatrixStats.png new file mode 100644 index 000000000..90f248881 Binary files /dev/null and b/src/main/resources/assets/mekanism/gui/GuiMatrixStats.png differ diff --git a/src/main/resources/assets/mekanism/gui/elements/GuiEnergyTab.png b/src/main/resources/assets/mekanism/gui/elements/GuiEnergyTab.png new file mode 100644 index 000000000..01f8170f3 Binary files /dev/null and b/src/main/resources/assets/mekanism/gui/elements/GuiEnergyTab.png differ diff --git a/src/main/resources/assets/mekanism/gui/elements/GuiStatsTab.png b/src/main/resources/assets/mekanism/gui/elements/GuiStatsTab.png index 3aa65adc9..15127522d 100644 Binary files a/src/main/resources/assets/mekanism/gui/elements/GuiStatsTab.png and b/src/main/resources/assets/mekanism/gui/elements/GuiStatsTab.png differ diff --git a/src/main/resources/assets/mekanism/lang/en_US.lang b/src/main/resources/assets/mekanism/lang/en_US.lang index fb76db579..1346b905a 100644 --- a/src/main/resources/assets/mekanism/lang/en_US.lang +++ b/src/main/resources/assets/mekanism/lang/en_US.lang @@ -404,6 +404,8 @@ gui.heat=Heat gui.formed=Formed gui.incomplete=Incomplete gui.inductionMatrix=Induction Matrix +gui.matrixStats=Matrix Statistics +gui.main=Main gui.reactor.injectionRate=Injection Rate