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.
|
||||
*/
|
||||
public boolean isEnabled = true;
|
||||
public PartMultimeter primaryRenderer = null;
|
||||
|
||||
public MultimeterNetwork()
|
||||
{
|
||||
|
|
|
@ -17,7 +17,6 @@ import net.minecraft.util.MovingObjectPosition;
|
|||
import net.minecraftforge.common.ForgeDirection;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import resonantinduction.electrical.Electrical;
|
||||
import resonantinduction.electrical.battery.TileBattery;
|
||||
import resonantinduction.mechanical.network.IMechanical;
|
||||
import universalelectricity.api.CompatibilityModule;
|
||||
import universalelectricity.api.energy.IConductor;
|
||||
|
@ -103,17 +102,24 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
|||
|
||||
public void refresh()
|
||||
{
|
||||
if (world() != null && !world().isRemote)
|
||||
if (world() != null)
|
||||
{
|
||||
for (Object obj : getConnections())
|
||||
if (!world().isRemote)
|
||||
{
|
||||
if (obj instanceof PartMultimeter)
|
||||
for (Object obj : getConnections())
|
||||
{
|
||||
getNetwork().merge(((PartMultimeter) obj).getNetwork());
|
||||
if (obj instanceof PartMultimeter)
|
||||
{
|
||||
getNetwork().merge(((PartMultimeter) obj).getNetwork());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getNetwork().reconstruct();
|
||||
getNetwork().reconstruct();
|
||||
}
|
||||
else
|
||||
{
|
||||
getNetwork().primaryRenderer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -210,7 +216,7 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
|||
|
||||
getNetwork().markUpdate();
|
||||
|
||||
if (ticks % 10 == 0)
|
||||
if (ticks % 20 == 0)
|
||||
{
|
||||
if (outputRedstone != redstoneOn)
|
||||
{
|
||||
|
@ -218,10 +224,7 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
|||
tile().notifyPartChange(this);
|
||||
}
|
||||
|
||||
// if (getNetwork().energyGraph.get(1) != detectedEnergy)
|
||||
{
|
||||
updateGraph();
|
||||
}
|
||||
updateGraph();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -244,18 +247,23 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
|||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
instance = ((IConnector) tileEntity).getInstance(dir);
|
||||
}
|
||||
|
||||
if (conductor != null)
|
||||
if (instance != null)
|
||||
{
|
||||
// TODO: Conductor may always return null in some cases.
|
||||
IEnergyNetwork network = conductor.getNetwork();
|
||||
getNetwork().energyGraph.queue(network.getLastBuffer());
|
||||
|
||||
IEnergyNetwork network = instance.getNetwork();
|
||||
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);
|
||||
|
||||
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)
|
||||
|
@ -576,11 +589,15 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
|||
*/
|
||||
public boolean isPrimaryRendering()
|
||||
{
|
||||
for (PartMultimeter m : getNetwork().getConnectors())
|
||||
if (getNetwork().primaryRenderer == null || !getNetwork().isValidConnector(getNetwork().primaryRenderer))
|
||||
{
|
||||
return m == this;
|
||||
for (PartMultimeter m : getNetwork().getConnectors())
|
||||
{
|
||||
getNetwork().primaryRenderer = m;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return getNetwork().primaryRenderer == this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,9 +153,7 @@ public class RenderMultimeter
|
|||
|
||||
if (part.getNetwork().energyCapacityGraph.get(0) > 0)
|
||||
{
|
||||
String str = information.get(0);
|
||||
str = str + "/" + UnitDisplay.getDisplay(part.getNetwork().energyCapacityGraph.get(0), Unit.JOULES);
|
||||
information.set(0, str);
|
||||
information.add("Max: " + UnitDisplay.getDisplay(part.getNetwork().energyCapacityGraph.get(0), Unit.JOULES));
|
||||
}
|
||||
|
||||
if (part.getNetwork().torqueGraph.get(0) != 0)
|
||||
|
@ -167,14 +165,14 @@ public class RenderMultimeter
|
|||
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++)
|
||||
{
|
||||
String info = information.get(i);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0, 0, 0.2f * i);
|
||||
GL11.glTranslatef(0, 0, 0.25f * i);
|
||||
if (dir.offsetX == 0)
|
||||
RenderUtility.renderText(info, (float) (part.getNetwork().size.x * 0.9f), 0.5f);
|
||||
if (dir.offsetZ == 0)
|
||||
|
@ -186,5 +184,4 @@ public class RenderMultimeter
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue