diff --git a/src/main/scala/resonantinduction/core/grid/MultipartNode.scala b/src/main/scala/resonantinduction/core/grid/MultipartNode.scala index d912ab548..597e085fc 100644 --- a/src/main/scala/resonantinduction/core/grid/MultipartNode.scala +++ b/src/main/scala/resonantinduction/core/grid/MultipartNode.scala @@ -4,22 +4,31 @@ import codechicken.multipart.TMultiPart import net.minecraft.tileentity.TileEntity import net.minecraft.world.World import universalelectricity.api.core.grid.INodeProvider -import universalelectricity.core.grid.Node -import universalelectricity.core.transform.vector.VectorWorld +import universalelectricity.core.grid.node.NodeConnector /** * A node that works with Forge Multipart * @author Calclavia */ -abstract class MultipartNode[N](parent: INodeProvider) extends Node[N](parent) +abstract class MultipartNode(parent: INodeProvider) extends NodeConnector(parent) { override def world: World = { return if (parent.isInstanceOf[TMultiPart]) (parent.asInstanceOf[TMultiPart]).world else if (parent.isInstanceOf[TileEntity]) (parent.asInstanceOf[TileEntity]).getWorldObj else null } - override def position: VectorWorld = + override def x: Double = { - return if (parent.isInstanceOf[TMultiPart]) new VectorWorld(parent.asInstanceOf[TMultiPart].world, parent.asInstanceOf[TMultiPart].x, parent.asInstanceOf[TMultiPart].y, parent.asInstanceOf[TMultiPart].z) else if (parent.isInstanceOf[TileEntity]) new VectorWorld(parent.asInstanceOf[TileEntity]) else null + return if (parent.isInstanceOf[TMultiPart]) (parent.asInstanceOf[TMultiPart]).x else if (parent.isInstanceOf[TileEntity]) (parent.asInstanceOf[TileEntity]).xCoord else null + } + + override def y: Double = + { + return if (parent.isInstanceOf[TMultiPart]) (parent.asInstanceOf[TMultiPart]).y else if (parent.isInstanceOf[TileEntity]) (parent.asInstanceOf[TileEntity]).yCoord else null + } + + override def z: Double = + { + return if (parent.isInstanceOf[TMultiPart]) (parent.asInstanceOf[TMultiPart]).z else if (parent.isInstanceOf[TileEntity]) (parent.asInstanceOf[TileEntity]).zCoord else null } } diff --git a/src/main/scala/resonantinduction/core/grid/fluid/distribution/FluidDistributionGrid.scala b/src/main/scala/resonantinduction/core/grid/fluid/distribution/FluidDistributionGrid.scala index 237c46e5a..1cd1e22d1 100644 --- a/src/main/scala/resonantinduction/core/grid/fluid/distribution/FluidDistributionGrid.scala +++ b/src/main/scala/resonantinduction/core/grid/fluid/distribution/FluidDistributionGrid.scala @@ -3,14 +3,14 @@ package resonantinduction.core.grid.fluid.distribution import net.minecraftforge.common.util.ForgeDirection import net.minecraftforge.fluids._ import resonantinduction.core.grid.fluid.TileTankNode -import universalelectricity.core.grid.{TickingGrid, UpdateTicker} +import universalelectricity.core.grid.{GridTicking, UpdateTicker} /** * Used for multiblock tanks to distribute fluid. * * @author DarkCow, Calclavia */ -abstract class FluidDistributionGrid extends TickingGrid[TankNode](classOf[TankNode]) with IFluidHandler +abstract class FluidDistributionGrid extends GridTicking[TankNode](classOf[TankNode]) with IFluidHandler { val tank = new FluidTank(0) var needsUpdate = false diff --git a/src/main/scala/resonantinduction/core/grid/fluid/distribution/TankNode.scala b/src/main/scala/resonantinduction/core/grid/fluid/distribution/TankNode.scala index 96d4c6a5f..d5b076263 100644 --- a/src/main/scala/resonantinduction/core/grid/fluid/distribution/TankNode.scala +++ b/src/main/scala/resonantinduction/core/grid/fluid/distribution/TankNode.scala @@ -5,9 +5,9 @@ import net.minecraftforge.common.util.ForgeDirection import net.minecraftforge.fluids.{Fluid, FluidStack, FluidTankInfo, IFluidHandler} import resonant.lib.utility.WorldUtility import resonantinduction.core.grid.MultipartNode -import universalelectricity.api.core.grid.INodeProvider +import universalelectricity.api.core.grid.{ISave, IGridNode, INodeProvider} -class TankNode(parent: INodeProvider) extends MultipartNode[Any](parent) with IFluidHandler +class TankNode(parent: INodeProvider) extends MultipartNode(parent) with IFluidHandler with ISave with IGridNode { var maxFlowRate: Int = 20 var maxPressure: Int = 100 @@ -80,15 +80,13 @@ class TankNode(parent: INodeProvider) extends MultipartNode[Any](parent) with IF override protected def newGrid() = new TankGrid - override def load(nbt: NBTTagCompound) + def load(nbt: NBTTagCompound) { - super.load(nbt) pressure = nbt.getInteger("pressure") } - override def save(nbt: NBTTagCompound) + def save(nbt: NBTTagCompound) { - super.save(nbt) nbt.setInteger("pressure", pressure) } diff --git a/src/main/scala/resonantinduction/core/prefab/NodeTank.java b/src/main/scala/resonantinduction/core/prefab/NodeTank.java new file mode 100644 index 000000000..42f9942fb --- /dev/null +++ b/src/main/scala/resonantinduction/core/prefab/NodeTank.java @@ -0,0 +1,79 @@ +package resonantinduction.core.prefab; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidTank; +import net.minecraftforge.fluids.IFluidHandler; +import universalelectricity.api.core.grid.IConnector; +import universalelectricity.api.core.grid.INode; +import universalelectricity.api.core.grid.INodeProvider; +import universalelectricity.core.grid.Node; + +import java.util.Map; + +/** + * Created by robert on 8/14/2014. + */ +public class NodeTank extends FluidTank implements INode, IConnector { + + protected INodeProvider parent = null; + protected Map connections = null; + + public NodeTank(INodeProvider parent, int cap) + { + super(cap); + this.parent = parent; + } + + @Override + public void reconstruct() + { + + } + + @Override + public void deconstruct() + { + connections = null; + } + + @Override + public void recache() + { + + } + + + @Override + public Map getConnections(Class node) + { + if(node.isAssignableFrom(getClass())) + { + return connections; + } + return null; + } + + @Override + public boolean canConnect(ForgeDirection direction, Object object) + { + return connections != null && connections.containsKey(object); + } + + @Override + public void update(double deltaTime) { + + } + + @Override + public void load(NBTTagCompound nbt) + { + super.readFromNBT(nbt); + } + + @Override + public void save(NBTTagCompound nbt) + { + super.writeToNBT(nbt); + } +} diff --git a/src/main/scala/resonantinduction/core/prefab/TFluidHandler.scala b/src/main/scala/resonantinduction/core/prefab/TFluidHandler.scala new file mode 100644 index 000000000..e8a350f74 --- /dev/null +++ b/src/main/scala/resonantinduction/core/prefab/TFluidHandler.scala @@ -0,0 +1,31 @@ +package resonantinduction.core.prefab + +import net.minecraftforge.common.util.ForgeDirection +import net.minecraftforge.fluids._ + +/** + * Created by robert on 8/14/2014. + */ +trait TFluidHandler extends IFluidHandler +{ + var fluidTank : FluidTank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME) + + override def fill(from: ForgeDirection, resource: FluidStack, doFill: Boolean): Int = fluidTank.fill(resource, doFill) + + override def drain(from: ForgeDirection, resource: FluidStack, doDrain: Boolean): FluidStack = + { + if(resource != null && resource.isFluidEqual(fluidTank.getFluid)) + { + return drain(from, resource.amount, doDrain) + } + return null + } + + override def drain(from: ForgeDirection, maxDrain: Int, doDrain: Boolean): FluidStack = fluidTank.drain(maxDrain, doDrain) + + override def canFill(from: ForgeDirection, fluid: Fluid): Boolean = true + + override def canDrain(from: ForgeDirection, fluid: Fluid): Boolean = true + + override def getTankInfo(from: ForgeDirection): Array[FluidTankInfo] = Array[FluidTankInfo](fluidTank.getInfo) +} diff --git a/src/main/scala/resonantinduction/core/prefab/TFluidNode.scala b/src/main/scala/resonantinduction/core/prefab/TFluidNode.scala new file mode 100644 index 000000000..88469fc72 --- /dev/null +++ b/src/main/scala/resonantinduction/core/prefab/TFluidNode.scala @@ -0,0 +1,10 @@ +package resonantinduction.core.prefab + +import universalelectricity.api.core.grid.INodeProvider + +/** + * Created by robert on 8/14/2014. + */ +trait TFluidNode extends TFluidHandler with INodeProvider { + +} diff --git a/src/main/scala/resonantinduction/electrical/battery/EnergyDistributionNetwork.java b/src/main/scala/resonantinduction/electrical/battery/EnergyDistributionNetwork.java index b333619ac..9834b27fd 100644 --- a/src/main/scala/resonantinduction/electrical/battery/EnergyDistributionNetwork.java +++ b/src/main/scala/resonantinduction/electrical/battery/EnergyDistributionNetwork.java @@ -4,12 +4,8 @@ import java.util.Arrays; import java.util.LinkedHashSet; import java.util.Set; -import scala.reflect.ClassTag; -import universalelectricity.api.core.grid.electric.IEnergyNode; import universalelectricity.core.grid.Grid; -import universalelectricity.core.grid.NodeGrid; -import universalelectricity.core.grid.TickingGrid; -import universalelectricity.core.grid.node.EnergyNode; +import universalelectricity.core.grid.node.NodeEnergy; /** Energy network designed to allow several tiles to act as if they share the same energy * level */ @@ -20,7 +16,7 @@ public class EnergyDistributionNetwork extends Grid public EnergyDistributionNetwork() { - super(EnergyNode.class); + super(NodeEnergy.class); } public void redistribute(TileEnergyDistribution... exclusion) diff --git a/src/main/scala/resonantinduction/electrical/multimeter/MultimeterNetwork.java b/src/main/scala/resonantinduction/electrical/multimeter/MultimeterNetwork.java index 610caa18a..6b2db6bc9 100644 --- a/src/main/scala/resonantinduction/electrical/multimeter/MultimeterNetwork.java +++ b/src/main/scala/resonantinduction/electrical/multimeter/MultimeterNetwork.java @@ -10,7 +10,6 @@ import resonant.lib.utility.LanguageUtility; import universalelectricity.api.UnitDisplay; import universalelectricity.api.core.grid.IUpdate; import universalelectricity.core.grid.Grid; -import universalelectricity.core.grid.TickingGrid; import universalelectricity.core.grid.UpdateTicker; import universalelectricity.core.transform.vector.Vector3; diff --git a/src/main/scala/resonantinduction/electrical/transformer/ElectricTransformerNode.scala b/src/main/scala/resonantinduction/electrical/transformer/ElectricTransformerNode.scala index cad67c26a..f62dccf62 100644 --- a/src/main/scala/resonantinduction/electrical/transformer/ElectricTransformerNode.scala +++ b/src/main/scala/resonantinduction/electrical/transformer/ElectricTransformerNode.scala @@ -4,13 +4,13 @@ import net.minecraft.tileentity.TileEntity import net.minecraftforge.common.util.ForgeDirection import universalelectricity.api.core.grid.INodeProvider import universalelectricity.compatibility.Compatibility -import universalelectricity.core.grid.node.ElectricNode +import universalelectricity.core.grid.node.NodeElectric import universalelectricity.core.transform.vector.VectorWorld /** * Created by robert on 8/11/2014. */ -class ElectricTransformerNode(parent: INodeProvider) extends ElectricNode(parent: INodeProvider) +class ElectricTransformerNode(parent: INodeProvider) extends NodeElectric(parent: INodeProvider) { var connectionDirection : ForgeDirection = ForgeDirection.NORTH var input : Boolean = true; diff --git a/src/main/scala/resonantinduction/mechanical/fluid/pipe/PartPipe.java b/src/main/scala/resonantinduction/mechanical/fluid/pipe/PartPipe.java index 13ba0c6ec..1c89d5215 100644 --- a/src/main/scala/resonantinduction/mechanical/fluid/pipe/PartPipe.java +++ b/src/main/scala/resonantinduction/mechanical/fluid/pipe/PartPipe.java @@ -41,7 +41,6 @@ public class PartPipe extends PartFramedNode implements TSlott public void setMaterial(int i) { setMaterial(EnumPipeMaterial.values()[i]); - } @Override