Added ability to display capacity with multimeter
This commit is contained in:
parent
0178cb0b73
commit
d2bb7b870d
6 changed files with 71 additions and 30 deletions
|
@ -57,13 +57,15 @@ public abstract class RenderItemOverlayTile extends TileEntitySpecialRenderer
|
|||
if (inventory[i] != null)
|
||||
{
|
||||
Vector3 translation = new Vector3((double) (i / matrixX) / ((double) matrixX) + (0.5 / (matrixX)), 1.1, (double) (i % matrixZ) / ((double) matrixZ) + (0.5 / (matrixZ))).translate(-0.5);
|
||||
translation.scale(0.9);
|
||||
translation.translate(0, 0, 0.06);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5f, y + 0.5f, z + 0.5f);
|
||||
RenderUtility.rotateBlockBasedOnDirection(dir);
|
||||
GL11.glTranslated(translation.x, translation.y, translation.z);
|
||||
GL11.glScalef(0.7f, 0.7f, 0.7f);
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
|
||||
this.renderItem(tileEntity.worldObj, ForgeDirection.UP, inventory[i], new Vector3(0, 0, 0.2f), 0, 1);
|
||||
this.renderItem(tileEntity.worldObj, ForgeDirection.UP, inventory[i], new Vector3(0, 0, 0), 0, 1);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if (isLooking)
|
||||
|
@ -187,13 +189,10 @@ public abstract class RenderItemOverlayTile extends TileEntitySpecialRenderer
|
|||
|
||||
RenderItem renderItem = ((RenderItem) RenderManager.instance.getEntityClassRenderObject(EntityItem.class));
|
||||
|
||||
if (entityItem != null)
|
||||
{
|
||||
boolean fancyGraphics = RenderManager.instance.options.fancyGraphics;
|
||||
RenderManager.instance.options.fancyGraphics = true;
|
||||
renderItem.doRenderItem(entityItem, 0, 0, 0, 0, 0);
|
||||
RenderManager.instance.options.fancyGraphics = fancyGraphics;
|
||||
}
|
||||
boolean fancyGraphics = RenderManager.instance.options.fancyGraphics;
|
||||
RenderManager.instance.options.fancyGraphics = true;
|
||||
renderItem.doRenderItem(entityItem, 0, 0, 0, 0, 0);
|
||||
RenderManager.instance.options.fancyGraphics = fancyGraphics;
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public class Graph
|
|||
for (int i = 0; i < nbtList.tagCount(); ++i)
|
||||
{
|
||||
NBTTagCompound nbtPoint = (NBTTagCompound) nbtList.tagAt(i);
|
||||
add(nbtPoint.getLong("data"));
|
||||
points.add(nbtPoint.getLong("data"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -74,9 +74,9 @@ public class GuiMultimeter extends GuiContainerBase
|
|||
String s = LanguageUtility.getLocal("tile.resonantinduction:multimeter.name");
|
||||
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.renderUniversalDisplay(35, 25, this.multimeter.getNetwork().valueGraph.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.renderUniversalDisplay(35, 45, this.multimeter.getNetwork().valueGraph.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);
|
||||
|
|
|
@ -12,7 +12,8 @@ import universalelectricity.core.net.NetworkTickHandler;
|
|||
public class MultimeterNetwork extends Network<MultimeterNetwork, PartMultimeter> implements IUpdate
|
||||
{
|
||||
public final List<String> displayInformation = new ArrayList<String>();
|
||||
public Graph graph = new Graph(20 * 10);
|
||||
public Graph valueGraph = new Graph(20 * 10);
|
||||
public Graph capacityGraph = new Graph(20 * 10);
|
||||
|
||||
/**
|
||||
* The absolute center of the multimeter screens.
|
||||
|
@ -49,8 +50,9 @@ public class MultimeterNetwork extends Network<MultimeterNetwork, PartMultimeter
|
|||
@Override
|
||||
public void update()
|
||||
{
|
||||
graph.add(queueGraphValue);
|
||||
valueGraph.add(queueGraphValue);
|
||||
queueGraphValue = 0;
|
||||
capacityGraph.add(queueGraphCapacity);
|
||||
queueGraphCapacity = 0;
|
||||
displayInformation.clear();
|
||||
doUpdate = false;
|
||||
|
@ -107,6 +109,7 @@ public class MultimeterNetwork extends Network<MultimeterNetwork, PartMultimeter
|
|||
{
|
||||
PartMultimeter connector = it.next();
|
||||
connector.updateDesc();
|
||||
connector.updateGraph();
|
||||
}
|
||||
|
||||
doUpdate = true;
|
||||
|
|
|
@ -121,6 +121,11 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
|||
writeDesc(getWriteStream());
|
||||
}
|
||||
|
||||
public void updateGraph()
|
||||
{
|
||||
writeGraph(getWriteStream());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWorldJoin()
|
||||
{
|
||||
|
@ -176,7 +181,7 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
|||
|
||||
if (!world().isRemote)
|
||||
{
|
||||
long detectedEnergy = doGetDetectedEnergy();
|
||||
long detectedEnergy = getDetectedEnergy();
|
||||
|
||||
boolean outputRedstone = false;
|
||||
|
||||
|
@ -201,7 +206,7 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
|||
break;
|
||||
}
|
||||
|
||||
getNetwork().updateGraph(detectedEnergy, 0);
|
||||
getNetwork().updateGraph(detectedEnergy, getDetectedCapacity());
|
||||
|
||||
if (ticks % 10 == 0)
|
||||
{
|
||||
|
@ -211,9 +216,9 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
|||
tile().notifyPartChange(this);
|
||||
}
|
||||
|
||||
if (getNetwork().graph.get(1) != detectedEnergy)
|
||||
if (getNetwork().valueGraph.get(1) != detectedEnergy)
|
||||
{
|
||||
writeGraph(getWriteStream());
|
||||
updateGraph();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -222,7 +227,7 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
|||
{
|
||||
for (EntityPlayer player : playersUsing)
|
||||
{
|
||||
writeGraph(getWriteStream());
|
||||
updateGraph();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -252,7 +257,8 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
|||
public void writeGraph(MCDataOutput packet)
|
||||
{
|
||||
packet.writeByte(2);
|
||||
packet.writeNBTTagCompound(getNetwork().graph.save());
|
||||
packet.writeNBTTagCompound(getNetwork().valueGraph.save());
|
||||
packet.writeNBTTagCompound(getNetwork().capacityGraph.save());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -278,7 +284,8 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
|||
}
|
||||
else if (packetID == 2)
|
||||
{
|
||||
getNetwork().graph.load(packet.readNBTTagCompound());
|
||||
getNetwork().valueGraph.load(packet.readNBTTagCompound());
|
||||
getNetwork().capacityGraph.load(packet.readNBTTagCompound());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -288,7 +295,7 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
|||
toggleMode();
|
||||
}
|
||||
|
||||
public long doGetDetectedEnergy()
|
||||
public long getDetectedEnergy()
|
||||
{
|
||||
return getDetectedEnergy(getDirection().getOpposite(), getDetectedTile());
|
||||
}
|
||||
|
@ -326,6 +333,16 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
|||
return CompatibilityModule.getEnergy(tileEntity, side);
|
||||
}
|
||||
|
||||
public long getDetectedCapacity()
|
||||
{
|
||||
return getDetectedCapacity(getDirection().getOpposite(), getDetectedTile());
|
||||
}
|
||||
|
||||
public static long getDetectedCapacity(ForgeDirection side, TileEntity tileEntity)
|
||||
{
|
||||
return CompatibilityModule.getMaxEnergy(tileEntity, side);
|
||||
}
|
||||
|
||||
public void toggleMode()
|
||||
{
|
||||
if (!this.world().isRemote)
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package resonantinduction.electrical.multimeter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
@ -78,13 +81,17 @@ public class RenderMultimeter
|
|||
|
||||
public static void render(PartMultimeter part, double x, double y, double z)
|
||||
{
|
||||
ForgeDirection dir = part.getDirection();
|
||||
|
||||
/**
|
||||
* Render the shell of the multimeter.
|
||||
*/
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
|
||||
RenderUtility.rotateFaceBlockToSideOutwards(part.getDirection().getOpposite());
|
||||
RenderUtility.bind(TextureMap.locationBlocksTexture);
|
||||
// Render the main panel
|
||||
RenderUtility.renderCube(-0.5, -0.05, -0.5, 0.5, 0.05, 0.5, Archaic.blockMachinePart, ResonantInduction.loadedIconMap.get(Reference.PREFIX + "multimeter_screen"));
|
||||
ForgeDirection dir = part.getDirection();
|
||||
final int metadata = 8;
|
||||
// Render edges
|
||||
// UP
|
||||
|
@ -140,18 +147,33 @@ public class RenderMultimeter
|
|||
RenderUtility.rotateFaceBlockToSideOutwards(part.getDirection().getOpposite());
|
||||
GL11.glTranslated(0, 0.05, 0);
|
||||
|
||||
for (int i = 0; i < 1; i++)
|
||||
{
|
||||
// TODO: Add other dispaly info support.
|
||||
String display = UnitDisplay.getDisplay(part.getNetwork().graph.get(0), Unit.JOULES);
|
||||
// TODO: Add other dispaly info support.
|
||||
List<String> information = new ArrayList<String>();
|
||||
information.add(UnitDisplay.getDisplay(part.getNetwork().valueGraph.get(0), Unit.JOULES));
|
||||
|
||||
if (dir.offsetX == 0)
|
||||
RenderUtility.renderText(display, (float) (part.getNetwork().size.x * 0.9f), 0.5f);
|
||||
if (dir.offsetZ == 0)
|
||||
RenderUtility.renderText(display, (float) (part.getNetwork().size.z * 0.9f), 0.5f);
|
||||
if (part.getNetwork().capacityGraph.get(0) > 0)
|
||||
{
|
||||
String str = information.get(0);
|
||||
str = str + "/" + UnitDisplay.getDisplay(part.getNetwork().capacityGraph.get(0), Unit.JOULES);
|
||||
information.set(0, str);
|
||||
}
|
||||
|
||||
for (int i = 0; i < information.size(); i++)
|
||||
{
|
||||
String info = information.get(i);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0, 0, 0.3f * i);
|
||||
if (dir.offsetX == 0)
|
||||
RenderUtility.renderText(info, (float) (part.getNetwork().size.x * 0.9f), 0.5f);
|
||||
if (dir.offsetZ == 0)
|
||||
RenderUtility.renderText(info, (float) (part.getNetwork().size.z * 0.9f), 0.5f);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue