Induction Matrix now caps input based on provider transfer cap, displays input rate data in both main and stats interfaces

This commit is contained in:
aidancbrady 2015-07-06 13:55:40 -07:00
parent b01f31a65e
commit 87b7b838f0
4 changed files with 37 additions and 13 deletions

View file

@ -35,10 +35,10 @@ public class GuiInductionMatrix extends GuiMekanism
fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 6, 0x404040);
fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040);
fontRendererObj.drawString(LangUtils.localize("gui.energy") + ":", 53, 26, 0x00CD00);
fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 53, 35, 0x00CD00);
fontRendererObj.drawString(LangUtils.localize("gui.input") + ":", 53, 26, 0x00CD00);
fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.structure.lastInput) + "/t", 53, 35, 0x00CD00);
fontRendererObj.drawString(LangUtils.localize("gui.output") + ":", 53, 44, 0x00CD00);
fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput), 53, 53, 0x00CD00);
fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + "/t", 53, 53, 0x00CD00);
if(xAxis >= 7 && xAxis <= 39 && yAxis >= 14 && yAxis <= 72)
{

View file

@ -42,7 +42,7 @@ public class GuiMatrixStats extends GuiMekanism
@Override
public String getTooltip()
{
return LangUtils.localize("gui.outputting") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + "/t";
return LangUtils.localize("gui.receiving") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastInput) + "/t";
}
@Override
@ -51,6 +51,20 @@ public class GuiMatrixStats extends GuiMekanism
return tileEntity.structure.lastOutput/tileEntity.structure.transferCap;
}
}, MekanismUtils.getResource(ResourceType.GUI, "GuiMatrixStats.png"), 30, 13));
guiElements.add(new GuiRateBar(this, new IRateInfoHandler()
{
@Override
public String getTooltip()
{
return LangUtils.localize("gui.outputting") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + "/t";
}
@Override
public double getLevel()
{
return tileEntity.structure.lastOutput/tileEntity.structure.transferCap;
}
}, MekanismUtils.getResource(ResourceType.GUI, "GuiMatrixStats.png"), 38, 13));
}
@Override
@ -62,8 +76,8 @@ public class GuiMatrixStats extends GuiMekanism
String stats = LangUtils.localize("gui.matrixStats");
fontRendererObj.drawString(stats, (xSize/2)-(fontRendererObj.getStringWidth(stats)/2), 6, 0x404040);
fontRendererObj.drawString(LangUtils.localize("gui.energy") + ":", 53, 26, 0x797979);
fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()) + "/" + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()), 59, 35, 0x404040);
fontRendererObj.drawString(LangUtils.localize("gui.input") + ":", 53, 26, 0x797979);
fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.structure.lastInput) + "/" + MekanismUtils.getEnergyDisplay(tileEntity.structure.transferCap), 59, 35, 0x404040);
fontRendererObj.drawString(LangUtils.localize("gui.output") + ":", 53, 46, 0x797979);
fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + "/" + MekanismUtils.getEnergyDisplay(tileEntity.structure.transferCap), 59, 55, 0x404040);

View file

@ -156,6 +156,11 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement
return structure != null ? structure.remainingOutput : 0;
}
private double getMaxInput()
{
return structure != null ? structure.remainingInput : 0;
}
@Override
public void handlePacketData(ByteBuf dataStream)
{
@ -231,14 +236,15 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement
{
if(getConsumingSides().contains(from))
{
double toAdd = (int)Math.min(getMaxEnergy()-getEnergy(), maxReceive* general.FROM_TE);
double toAdd = (int)Math.min(Math.min(getMaxInput(), getMaxEnergy()-getEnergy()), maxReceive* general.FROM_TE);
if(!simulate)
{
setEnergy(getEnergy() + toAdd);
structure.remainingInput -= toAdd;
}
return (int)Math.round(toAdd* general.TO_TE);
return (int)Math.round(toAdd*general.TO_TE);
}
return 0;
@ -258,7 +264,7 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement
structure.remainingOutput -= toSend;
}
return (int)Math.round(toSend* general.TO_TE);
return (int)Math.round(toSend*general.TO_TE);
}
return 0;
@ -275,14 +281,14 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement
@Method(modid = "CoFHCore")
public int getEnergyStored(ForgeDirection from)
{
return (int)Math.round(getEnergy()* general.TO_TE);
return (int)Math.round(getEnergy()*general.TO_TE);
}
@Override
@Method(modid = "CoFHCore")
public int getMaxEnergyStored(ForgeDirection from)
{
return (int)Math.round(getMaxEnergy()* general.TO_TE);
return (int)Math.round(getMaxEnergy()*general.TO_TE);
}
@Override
@ -310,7 +316,9 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement
@Method(modid = "IC2")
public int addEnergy(int amount)
{
setEnergy(getEnergy() + amount*general.FROM_IC2);
double toUse = Math.min(Math.min(getMaxInput(), getMaxEnergy()-getEnergy()), amount*general.FROM_IC2);
setEnergy(getEnergy() + toUse);
structure.remainingInput -= toUse;
return (int)Math.round(getEnergy()*general.TO_IC2);
}
@ -421,8 +429,9 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement
return 0;
}
double toUse = Math.min(getMaxEnergy()-getEnergy(), amount);
double toUse = Math.min(Math.min(getMaxInput(), getMaxEnergy()-getEnergy()), amount);
setEnergy(getEnergy() + toUse);
structure.remainingInput -= toUse;
return toUse;
}

View file

@ -441,6 +441,7 @@ gui.inductionMatrix=Induction Matrix
gui.matrixStats=Matrix Statistics
gui.main=Main
gui.outputting=Outputting
gui.receiving=Receiving
gui.dimensions=Dimensions
gui.constituents=Constituents
gui.cells=cells