More work, and more errors

This commit is contained in:
Robert S 2014-08-14 07:22:49 -04:00
parent dba9e66cd8
commit 0f17ae4269
10 changed files with 144 additions and 23 deletions

View file

@ -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
}
}

View file

@ -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

View file

@ -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)
}

View file

@ -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<Object, ForgeDirection> 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<Object, ForgeDirection> getConnections(Class<? extends INode> 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);
}
}

View file

@ -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)
}

View file

@ -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 {
}

View file

@ -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<TileEnergyDistribution>
public EnergyDistributionNetwork()
{
super(EnergyNode.class);
super(NodeEnergy.class);
}
public void redistribute(TileEnergyDistribution... exclusion)

View file

@ -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;

View file

@ -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;

View file

@ -41,7 +41,6 @@ public class PartPipe extends PartFramedNode<EnumPipeMaterial> implements TSlott
public void setMaterial(int i)
{
setMaterial(EnumPipeMaterial.values()[i]);
}
@Override