Got multimeter energy value rendering
This commit is contained in:
parent
a6c5eb6d72
commit
daff7a091f
5 changed files with 28 additions and 23 deletions
|
@ -75,8 +75,8 @@ public class GuiMultimeter extends GuiContainerBase
|
|||
this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 15, 4210752);
|
||||
this.fontRenderer.drawString(EnumColor.INDIGO + LanguageUtility.getLocal("gui.resonantinduction.multimeter.energy"), 35, 15, 4210752);
|
||||
this.renderUniversalDisplay(35, 25, this.multimeter.getNetwork().graph.get(0), mouseX, mouseY, Unit.JOULES);
|
||||
this.fontRenderer.drawString(EnumColor.INDIGO + LanguageUtility.getLocal("gui.resonantinduction.multimeter.energy"), 35, 35, 4210752);
|
||||
this.renderUniversalDisplay(35, 45, this.multimeter.getNetwork().graph.get(0), mouseX, mouseY, Unit.JOULES);
|
||||
this.fontRenderer.drawString(EnumColor.INDIGO + LanguageUtility.getLocal("gui.resonantinduction.multimeter.capacity"), 35, 35, 4210752);
|
||||
this.renderUniversalDisplay(35, 45, this.multimeter.getNetwork().graph.getPeak(), mouseX, mouseY, Unit.JOULES);
|
||||
this.fontRenderer.drawString(EnumColor.ORANGE + LanguageUtility.getLocal("gui.resonantinduction.multimeter.redstone"), 35, 58, 4210752);
|
||||
this.fontRenderer.drawString(EnumColor.RED + LanguageUtility.getLocal("gui.resonantinduction.multimeter." + this.multimeter.getMode().display), 35, 68, 4210752);
|
||||
this.fontRenderer.drawString(Unit.JOULES.name + "(s)", 35, 100, 4210752);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package resonantinduction.electrical.multimeter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import universalelectricity.api.net.IUpdate;
|
||||
|
@ -9,7 +10,7 @@ import universalelectricity.core.net.NetworkTickHandler;
|
|||
|
||||
public class MultimeterNetwork extends Network<MultimeterNetwork, PartMultimeter> implements IUpdate
|
||||
{
|
||||
public List<String> displayInformation;
|
||||
public final List<String> displayInformation = new ArrayList<String>();
|
||||
public Graph graph = new Graph(20 * 10);
|
||||
|
||||
/**
|
||||
|
@ -29,6 +30,14 @@ public class MultimeterNetwork extends Network<MultimeterNetwork, PartMultimeter
|
|||
public Vector3 size = new Vector3();
|
||||
|
||||
private long queueGraphValue = 0;
|
||||
private boolean doUpdate = false;
|
||||
|
||||
@Override
|
||||
public void addConnector(PartMultimeter connector)
|
||||
{
|
||||
super.addConnector(connector);
|
||||
NetworkTickHandler.addNetwork(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reconstruct()
|
||||
|
@ -46,28 +55,28 @@ public class MultimeterNetwork extends Network<MultimeterNetwork, PartMultimeter
|
|||
@Override
|
||||
public void update()
|
||||
{
|
||||
if (queueGraphValue > 0)
|
||||
{
|
||||
graph.add(queueGraphValue);
|
||||
queueGraphValue = 0;
|
||||
}
|
||||
graph.add(queueGraphValue);
|
||||
queueGraphValue = 0;
|
||||
displayInformation.clear();
|
||||
doUpdate = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return getConnectors().size() > 0;
|
||||
return doUpdate && continueUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean continueUpdate()
|
||||
{
|
||||
return canUpdate();
|
||||
return getConnectors().size() > 0;
|
||||
}
|
||||
|
||||
public void updateGraph(long detectedValue)
|
||||
{
|
||||
queueGraphValue += detectedValue;
|
||||
doUpdate = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -83,16 +92,16 @@ public class MultimeterNetwork extends Network<MultimeterNetwork, PartMultimeter
|
|||
|
||||
if (upperBound == null)
|
||||
{
|
||||
upperBound = node.getPosition().translate(0.5);
|
||||
upperBound = node.getPosition().translate(1);
|
||||
}
|
||||
|
||||
if (lowerBound == null)
|
||||
{
|
||||
lowerBound = node.getPosition().translate(0.5);
|
||||
lowerBound = node.getPosition();
|
||||
}
|
||||
|
||||
upperBound = upperBound.max(node.getPosition().translate(0.5));
|
||||
lowerBound = lowerBound.min(node.getPosition().translate(0.5));
|
||||
upperBound = upperBound.max(node.getPosition().translate(1));
|
||||
lowerBound = lowerBound.min(node.getPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -168,6 +168,7 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
|||
super.update();
|
||||
|
||||
this.ticks++;
|
||||
getNetwork().addConnector(this);
|
||||
|
||||
if (!world().isRemote)
|
||||
{
|
||||
|
@ -208,10 +209,7 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
|||
|
||||
if (getNetwork().graph.get(1) != detectedEnergy)
|
||||
{
|
||||
// writeDesc(getWriteStream());
|
||||
writeGraph(getWriteStream());
|
||||
// this.getWriteStream().writeByte(3).writeByte((byte)
|
||||
// detectMode.ordinal()).writeLong(detectedEnergy).writeLong(detectedAverageEnergy).writeLong(energyLimit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -220,9 +218,7 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
|||
{
|
||||
for (EntityPlayer player : playersUsing)
|
||||
{
|
||||
writeDesc(getWriteStream());
|
||||
// this.getWriteStream().writeByte(3).writeByte((byte)
|
||||
// detectMode.ordinal()).writeLong(detectedEnergy).writeLong(detectedAverageEnergy).writeLong(energyLimit);
|
||||
writeGraph(getWriteStream());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,14 +85,14 @@ public class RenderMultimeter
|
|||
* Only one block renders this text.
|
||||
* Render all the multimeter text
|
||||
*/
|
||||
if (part.getNetwork().center.distance(new Vector3(part.x(), part.y(), part.z()).translate(0.5)) < 0.8)
|
||||
if (part.getNetwork().center.distance(new Vector3(part.x(), part.y(), part.z()).translate(0.5)) < 1)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
|
||||
Vector3 centerTranslation = part.getNetwork().center.clone().subtract(part.x(), part.y(), part.z()).add(-0.5);
|
||||
GL11.glTranslated(centerTranslation.x, centerTranslation.y, centerTranslation.z);
|
||||
RenderUtility.rotateFaceBlockToSideOutwards(part.getDirection().getOpposite());
|
||||
GL11.glTranslated(0, 0.05, 0);
|
||||
GL11.glTranslated(0, 0.07, 0);
|
||||
String display = UnitDisplay.getDisplay(part.getNetwork().graph.get(0), Unit.JOULES);
|
||||
if (dir.offsetX == 0)
|
||||
RenderUtility.renderText(display, (float) (part.getNetwork().size.x * 0.9f), 0.5f);
|
||||
|
|
|
@ -141,7 +141,7 @@ tooltip.multimeter.lastSave=Last Detection: %v KJ
|
|||
|
||||
## GUI Strings that can't be any other localization
|
||||
gui.resonantinduction.multimeter.toggle=Toggle
|
||||
gui.resonantinduction.multimeter.averageEnergy=Average Energy:
|
||||
gui.resonantinduction.multimeter.capacity=Capacity:
|
||||
gui.resonantinduction.multimeter.energy=Energy:
|
||||
gui.resonantinduction.multimeter.redstone=Output Redstone If...
|
||||
|
||||
|
|
Loading…
Reference in a new issue