Multimeter now works with fluids
This commit is contained in:
parent
a8a547265e
commit
466f5b0839
6 changed files with 128 additions and 34 deletions
|
@ -0,0 +1,62 @@
|
|||
package resonantinduction.electrical.multimeter;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
public class GraphI extends Graph<Integer>
|
||||
{
|
||||
public GraphI(int maxPoints)
|
||||
{
|
||||
super(maxPoints);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void queue(Integer value)
|
||||
{
|
||||
queue += value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doneQueue()
|
||||
{
|
||||
super.doneQueue();
|
||||
queue = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getDefault()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(NBTTagCompound nbt)
|
||||
{
|
||||
super.load(nbt);
|
||||
NBTTagList nbtList = nbt.getTagList("DataPoints");
|
||||
|
||||
for (int i = 0; i < nbtList.tagCount(); ++i)
|
||||
{
|
||||
NBTTagCompound nbtPoint = (NBTTagCompound) nbtList.tagAt(i);
|
||||
points.add(nbtPoint.getInteger("data"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound save()
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
NBTTagList data = new NBTTagList();
|
||||
|
||||
for (Integer value : points)
|
||||
{
|
||||
NBTTagCompound nbtPoint = new NBTTagCompound();
|
||||
nbtPoint.setInteger("data", value);
|
||||
data.appendTag(nbtPoint);
|
||||
}
|
||||
|
||||
nbt.setTag("DataPoints", data);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
}
|
|
@ -20,11 +20,16 @@ public class MultimeterNetwork extends Network<MultimeterNetwork, PartMultimeter
|
|||
*/
|
||||
private int maxData = 20 * 10;
|
||||
private final List<Graph> graphs = new ArrayList<Graph>();
|
||||
/**
|
||||
* Energy Related
|
||||
*/
|
||||
public final GraphL energyGraph = new GraphL(maxData);
|
||||
public final GraphL energyCapacityGraph = new GraphL(1);
|
||||
public final GraphL torqueGraph = new GraphL(maxData);
|
||||
public final GraphF angularVelocityGraph = new GraphF(maxData);
|
||||
|
||||
public final GraphI fluidGraph = new GraphI(maxData);
|
||||
|
||||
/**
|
||||
* The absolute center of the multimeter screens.
|
||||
*/
|
||||
|
@ -57,6 +62,7 @@ public class MultimeterNetwork extends Network<MultimeterNetwork, PartMultimeter
|
|||
graphs.add(energyCapacityGraph);
|
||||
graphs.add(torqueGraph);
|
||||
graphs.add(angularVelocityGraph);
|
||||
graphs.add(fluidGraph);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -102,6 +108,8 @@ public class MultimeterNetwork extends Network<MultimeterNetwork, PartMultimeter
|
|||
|
||||
@Override
|
||||
public void reconstruct()
|
||||
{
|
||||
if (getConnectors().size() > 0)
|
||||
{
|
||||
upperBound = null;
|
||||
lowerBound = null;
|
||||
|
@ -131,6 +139,7 @@ public class MultimeterNetwork extends Network<MultimeterNetwork, PartMultimeter
|
|||
|
||||
doUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void reconstructConnector(PartMultimeter node)
|
||||
|
|
|
@ -15,6 +15,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import resonantinduction.api.mechanical.IMechanical;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import resonantinduction.electrical.Electrical;
|
||||
|
@ -100,6 +102,13 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
|||
return getMultimeter(x, y, z) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preRemove()
|
||||
{
|
||||
if (!world().isRemote)
|
||||
getNetwork().split(this);
|
||||
}
|
||||
|
||||
public void refresh()
|
||||
{
|
||||
if (world() != null)
|
||||
|
@ -291,6 +300,17 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
|||
}
|
||||
}
|
||||
|
||||
if (tileEntity instanceof IFluidHandler)
|
||||
{
|
||||
FluidTankInfo[] fluidInfo = ((IFluidHandler) tileEntity).getTankInfo(receivingSide);
|
||||
|
||||
for(FluidTankInfo info : fluidInfo)
|
||||
{
|
||||
if(info.fluid != null)
|
||||
getNetwork().fluidGraph.queue(info.fluid.amount);
|
||||
}
|
||||
}
|
||||
|
||||
getNetwork().energyGraph.queue(CompatibilityModule.getEnergy(tileEntity, receivingSide));
|
||||
|
||||
/**
|
||||
|
|
|
@ -156,21 +156,24 @@ public class RenderMultimeter implements ISimpleItemRenderer
|
|||
|
||||
// TODO: Add other dispaly info support.
|
||||
List<String> information = new ArrayList<String>();
|
||||
|
||||
if (part.getNetwork().energyGraph.get(0) > 0)
|
||||
information.add(UnitDisplay.getDisplay(part.getNetwork().energyGraph.get(0), Unit.JOULES));
|
||||
|
||||
if (part.getNetwork().energyCapacityGraph.get(0) > 0)
|
||||
{
|
||||
information.add("Max: " + UnitDisplay.getDisplay(part.getNetwork().energyCapacityGraph.get(0), Unit.JOULES));
|
||||
}
|
||||
|
||||
if (part.getNetwork().torqueGraph.get(0) != 0)
|
||||
{
|
||||
information.add("Torque: " + UnitDisplay.getDisplayShort(part.getNetwork().torqueGraph.get(0), Unit.NEWTON_METER));
|
||||
}
|
||||
|
||||
if (part.getNetwork().angularVelocityGraph.get(0) != 0)
|
||||
{
|
||||
information.add("Speed: " + UnitDisplay.roundDecimals(part.getNetwork().angularVelocityGraph.get(0)));
|
||||
}
|
||||
|
||||
if (part.getNetwork().fluidGraph.get(0) != 0)
|
||||
information.add("Fluid: " + UnitDisplay.getDisplay(part.getNetwork().fluidGraph.get(0), Unit.LITER));
|
||||
|
||||
if (information.size() <= 0)
|
||||
information.add("No information");
|
||||
|
||||
float displacement = information.size() / 5f;
|
||||
float maxScale = (float) (part.getNetwork().size.x + part.getNetwork().size.z) * 0.005f;
|
||||
|
|
|
@ -26,7 +26,7 @@ public class BlockTesla extends BlockSidedIO implements ITileEntityProvider
|
|||
public BlockTesla(int id)
|
||||
{
|
||||
super(id, UniversalElectricity.machine);
|
||||
setTextureName(Reference.PREFIX + "machine");
|
||||
setTextureName(Reference.PREFIX + "material_metal_side");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -141,7 +141,7 @@ tooltip.wire.helpText=Higher voltages will increase transfer rate and decrease e
|
|||
tooltip.noShift=Hold %0shift %1for more information"
|
||||
# %0 is the color for the charge level, %1 is grey to reset it back to normal (optional), %v0 is the current charge, %v1 is the max charge
|
||||
tooltip.battery.energy=Energy: %0%v0 / %v1
|
||||
tooltip.multimeter.line1=Right click click to place,
|
||||
tooltip.multimeter.line1=Right click to place,
|
||||
tooltip.multimeter.line2=Control right click to scan data.
|
||||
tooltip.multimeter.noSave=No detection saved.
|
||||
tooltip.multimeter.lastSave=Last Detection: %v KJ
|
||||
|
|
Loading…
Reference in a new issue