Fixed some more multimeter renders
This commit is contained in:
parent
2a858059b4
commit
d6a9b3e69a
3 changed files with 45 additions and 30 deletions
|
@ -49,6 +49,7 @@ public class MultimeterNetwork extends Network<MultimeterNetwork, PartMultimeter
|
||||||
* If the screen is not a perfect rectangle, don't render.
|
* If the screen is not a perfect rectangle, don't render.
|
||||||
*/
|
*/
|
||||||
public boolean isEnabled = true;
|
public boolean isEnabled = true;
|
||||||
|
public PartMultimeter primaryRenderer = null;
|
||||||
|
|
||||||
public MultimeterNetwork()
|
public MultimeterNetwork()
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,7 +17,6 @@ import net.minecraft.util.MovingObjectPosition;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import resonantinduction.core.ResonantInduction;
|
import resonantinduction.core.ResonantInduction;
|
||||||
import resonantinduction.electrical.Electrical;
|
import resonantinduction.electrical.Electrical;
|
||||||
import resonantinduction.electrical.battery.TileBattery;
|
|
||||||
import resonantinduction.mechanical.network.IMechanical;
|
import resonantinduction.mechanical.network.IMechanical;
|
||||||
import universalelectricity.api.CompatibilityModule;
|
import universalelectricity.api.CompatibilityModule;
|
||||||
import universalelectricity.api.energy.IConductor;
|
import universalelectricity.api.energy.IConductor;
|
||||||
|
@ -103,7 +102,9 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
||||||
|
|
||||||
public void refresh()
|
public void refresh()
|
||||||
{
|
{
|
||||||
if (world() != null && !world().isRemote)
|
if (world() != null)
|
||||||
|
{
|
||||||
|
if (!world().isRemote)
|
||||||
{
|
{
|
||||||
for (Object obj : getConnections())
|
for (Object obj : getConnections())
|
||||||
{
|
{
|
||||||
|
@ -115,6 +116,11 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
||||||
|
|
||||||
getNetwork().reconstruct();
|
getNetwork().reconstruct();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getNetwork().primaryRenderer = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateDesc()
|
public void updateDesc()
|
||||||
|
@ -210,7 +216,7 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
||||||
|
|
||||||
getNetwork().markUpdate();
|
getNetwork().markUpdate();
|
||||||
|
|
||||||
if (ticks % 10 == 0)
|
if (ticks % 20 == 0)
|
||||||
{
|
{
|
||||||
if (outputRedstone != redstoneOn)
|
if (outputRedstone != redstoneOn)
|
||||||
{
|
{
|
||||||
|
@ -218,12 +224,9 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
||||||
tile().notifyPartChange(this);
|
tile().notifyPartChange(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (getNetwork().energyGraph.get(1) != detectedEnergy)
|
|
||||||
{
|
|
||||||
updateGraph();
|
updateGraph();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!world().isRemote)
|
if (!world().isRemote)
|
||||||
{
|
{
|
||||||
|
@ -244,18 +247,23 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
||||||
*/
|
*/
|
||||||
if (tileEntity instanceof IConductor)
|
if (tileEntity instanceof IConductor)
|
||||||
{
|
{
|
||||||
IConnector<IEnergyNetwork> conductor = ((IConductor) tileEntity).getInstance(receivingSide.getOpposite());
|
IConnector<IEnergyNetwork> instance = ((IConductor) tileEntity).getInstance(receivingSide);
|
||||||
|
|
||||||
if (conductor == null)
|
for (ForgeDirection dir : ForgeDirection.values())
|
||||||
{
|
{
|
||||||
conductor = ((IConductor) tileEntity).getInstance(ForgeDirection.UNKNOWN);
|
if (instance != null)
|
||||||
|
{
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conductor != null)
|
instance = ((IConnector) tileEntity).getInstance(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (instance != null)
|
||||||
{
|
{
|
||||||
// TODO: Conductor may always return null in some cases.
|
|
||||||
IEnergyNetwork network = conductor.getNetwork();
|
IEnergyNetwork network = instance.getNetwork();
|
||||||
getNetwork().energyGraph.queue(network.getLastBuffer());
|
getNetwork().energyGraph.queue(Math.max(network.getBuffer(), network.getLastBuffer()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,9 +271,14 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
||||||
{
|
{
|
||||||
IMechanical instance = ((IMechanical) tileEntity).getInstance(receivingSide);
|
IMechanical instance = ((IMechanical) tileEntity).getInstance(receivingSide);
|
||||||
|
|
||||||
if (instance == null)
|
for (ForgeDirection dir : ForgeDirection.values())
|
||||||
{
|
{
|
||||||
instance = ((IMechanical) tileEntity).getInstance(ForgeDirection.UNKNOWN);
|
if (instance != null)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
instance = ((IMechanical) tileEntity).getInstance(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (instance != null)
|
if (instance != null)
|
||||||
|
@ -575,12 +588,16 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
||||||
* Only one multimeter renders the text.
|
* Only one multimeter renders the text.
|
||||||
*/
|
*/
|
||||||
public boolean isPrimaryRendering()
|
public boolean isPrimaryRendering()
|
||||||
|
{
|
||||||
|
if (getNetwork().primaryRenderer == null || !getNetwork().isValidConnector(getNetwork().primaryRenderer))
|
||||||
{
|
{
|
||||||
for (PartMultimeter m : getNetwork().getConnectors())
|
for (PartMultimeter m : getNetwork().getConnectors())
|
||||||
{
|
{
|
||||||
return m == this;
|
getNetwork().primaryRenderer = m;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return getNetwork().primaryRenderer == this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,9 +153,7 @@ public class RenderMultimeter
|
||||||
|
|
||||||
if (part.getNetwork().energyCapacityGraph.get(0) > 0)
|
if (part.getNetwork().energyCapacityGraph.get(0) > 0)
|
||||||
{
|
{
|
||||||
String str = information.get(0);
|
information.add("Max: " + UnitDisplay.getDisplay(part.getNetwork().energyCapacityGraph.get(0), Unit.JOULES));
|
||||||
str = str + "/" + UnitDisplay.getDisplay(part.getNetwork().energyCapacityGraph.get(0), Unit.JOULES);
|
|
||||||
information.set(0, str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (part.getNetwork().torqueGraph.get(0) != 0)
|
if (part.getNetwork().torqueGraph.get(0) != 0)
|
||||||
|
@ -167,14 +165,14 @@ public class RenderMultimeter
|
||||||
information.add("Speed: " + UnitDisplay.roundDecimals(part.getNetwork().angularVelocityGraph.get(0)));
|
information.add("Speed: " + UnitDisplay.roundDecimals(part.getNetwork().angularVelocityGraph.get(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
GL11.glTranslatef(0, 0, -0.2f * (information.size() / 2));
|
GL11.glTranslatef(0, 0, -0.25f * (information.size() / 2));
|
||||||
|
|
||||||
for (int i = 0; i < information.size(); i++)
|
for (int i = 0; i < information.size(); i++)
|
||||||
{
|
{
|
||||||
String info = information.get(i);
|
String info = information.get(i);
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glTranslatef(0, 0, 0.2f * i);
|
GL11.glTranslatef(0, 0, 0.25f * i);
|
||||||
if (dir.offsetX == 0)
|
if (dir.offsetX == 0)
|
||||||
RenderUtility.renderText(info, (float) (part.getNetwork().size.x * 0.9f), 0.5f);
|
RenderUtility.renderText(info, (float) (part.getNetwork().size.x * 0.9f), 0.5f);
|
||||||
if (dir.offsetZ == 0)
|
if (dir.offsetZ == 0)
|
||||||
|
@ -186,5 +184,4 @@ public class RenderMultimeter
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue