Some battery testing with DC circuit
This commit is contained in:
parent
ad85ffa8da
commit
0feb2c8bf1
|
@ -0,0 +1,44 @@
|
|||
package resonantinduction.core.prefab.pass;
|
||||
|
||||
import codechicken.multipart.PartMap;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
import codechicken.multipart.TileMultipart;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import universalelectricity.api.core.grid.INode;
|
||||
import universalelectricity.api.core.grid.INodeProvider;
|
||||
|
||||
/**
|
||||
* TNodeProvider Trait.
|
||||
* Keep this in Java for smoother ASM.
|
||||
* @author Calclavia
|
||||
*/
|
||||
public class TNodeProvider extends TileMultipart implements INodeProvider
|
||||
{
|
||||
public INode getNode(Class<? extends INode> nodeType, ForgeDirection from)
|
||||
{
|
||||
TMultiPart nodePart = partMap(from.ordinal());
|
||||
|
||||
if (nodePart == null)
|
||||
{
|
||||
nodePart = partMap(PartMap.CENTER.ordinal());
|
||||
}
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
if (from.ordinal() != i && (from.ordinal() ^ 1) != i)
|
||||
{
|
||||
if (nodePart == null)
|
||||
{
|
||||
nodePart = partMap(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nodePart instanceof INodeProvider)
|
||||
{
|
||||
return ((INodeProvider) nodePart).getNode(nodeType, from);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package resonantinduction.core.prefab.pass
|
||||
|
||||
import codechicken.multipart.{PartMap, TileMultipart}
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import universalelectricity.api.core.grid.{INode, INodeProvider}
|
||||
|
||||
/**
|
||||
* Multipart Trait
|
||||
* @author Calclavia
|
||||
*/
|
||||
class TNodeProvider extends TileMultipart with INodeProvider
|
||||
{
|
||||
def getNode(nodeType: Class[_ <: INode], from: ForgeDirection): INode =
|
||||
{
|
||||
var nodePart = partMap(from.ordinal)
|
||||
|
||||
if (nodePart == null)
|
||||
nodePart = partMap(PartMap.CENTER.ordinal)
|
||||
|
||||
if (nodePart.isInstanceOf[INodeProvider])
|
||||
return nodePart.asInstanceOf[INodeProvider].getNode(nodeType, from)
|
||||
|
||||
return null
|
||||
}
|
||||
}
|
|
@ -8,11 +8,12 @@ import net.minecraft.entity.EntityLivingBase
|
|||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import resonant.lib.content.prefab.java.TileElectric
|
||||
import resonant.content.prefab.java.TileAdvanced
|
||||
import resonant.lib.content.prefab.TElectric
|
||||
import resonant.lib.network.discriminator.{PacketTile, PacketType}
|
||||
import resonant.lib.network.handle.IPacketReceiver
|
||||
import resonant.lib.network.netty.AbstractPacket
|
||||
import universalelectricity.simulator.dc.micro.DCNode
|
||||
import universalelectricity.core.transform.vector.Vector3
|
||||
|
||||
/** A modular battery box that allows shared connections with boxes next to it.
|
||||
*
|
||||
|
@ -35,7 +36,7 @@ object TileBattery
|
|||
final val DEFAULT_WATTAGE: Long = getEnergyForTier(0)
|
||||
}
|
||||
|
||||
class TileBattery extends TileElectric(Material.iron) with IPacketReceiver
|
||||
class TileBattery extends TileAdvanced(Material.iron) with TElectric with IPacketReceiver
|
||||
{
|
||||
private var markClientUpdate: Boolean = false
|
||||
private var markDistributionUpdate: Boolean = false
|
||||
|
@ -43,29 +44,12 @@ class TileBattery extends TileElectric(Material.iron) with IPacketReceiver
|
|||
private var network: GridBattery = null
|
||||
|
||||
//Constructor
|
||||
setTextureName("material_metal_side")
|
||||
textureName = "material_metal_side"
|
||||
ioMap = 0.toShort
|
||||
saveIOMap = true
|
||||
normalRender(false)
|
||||
isOpaqueCube(false)
|
||||
itemBlock(classOf[ItemBlockBattery])
|
||||
|
||||
//TODO: Test, remove this
|
||||
private val node = new DCNode(this)
|
||||
{
|
||||
override def charge(terminal: ForgeDirection): Double = 0
|
||||
|
||||
/*
|
||||
{
|
||||
if (getInputDirections().contains(terminal))
|
||||
return 0
|
||||
else if (getOutputDirections().contains(terminal))
|
||||
return 0
|
||||
|
||||
return super.charge
|
||||
}
|
||||
*/
|
||||
}
|
||||
normalRender = false
|
||||
isOpaqueCube = false
|
||||
itemBlock = classOf[ItemBlockBattery]
|
||||
|
||||
override def update()
|
||||
{
|
||||
|
@ -73,8 +57,14 @@ class TileBattery extends TileElectric(Material.iron) with IPacketReceiver
|
|||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
//TODO: Test, remove this
|
||||
node.buffer(100)
|
||||
if (doCharge)
|
||||
{
|
||||
dcNode.negativeTerminals.addAll(getInputDirections())
|
||||
//TODO: Test, remove this
|
||||
dcNode.buffer(100)
|
||||
dcNode.update(1/20f)
|
||||
doCharge = false
|
||||
}
|
||||
|
||||
if (markDistributionUpdate && ticks % 5 == 0)
|
||||
{
|
||||
|
@ -88,6 +78,21 @@ class TileBattery extends TileElectric(Material.iron) with IPacketReceiver
|
|||
}
|
||||
}
|
||||
|
||||
var doCharge = false
|
||||
|
||||
override def activate(player: EntityPlayer, side: Int, hit: Vector3): Boolean =
|
||||
{
|
||||
super.activate(player, side, hit)
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (player.isSneaking)
|
||||
doCharge = !doCharge
|
||||
println(dcNode)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override def getDescPacket: AbstractPacket =
|
||||
{
|
||||
return new PacketTile(this, Array[Any](renderEnergyAmount, ioMap))
|
||||
|
|
|
@ -47,6 +47,7 @@ class TileSolarPanel extends TileElectric(Material.iron)
|
|||
{
|
||||
if (!(world.isThundering || world.isRaining))
|
||||
{
|
||||
println(dcNode)
|
||||
dcNode.buffer(Settings.solarPower / 20)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ trait TWire extends PartAbstract with TNodePartConnector with TMaterial[WireMate
|
|||
|
||||
override def getMaterialID = material.ordinal()
|
||||
|
||||
override protected def getItem = new ItemStack(ElectricalContent.itemInsulation, getMaterialID)
|
||||
override protected def getItem = new ItemStack(ElectricalContent.itemWire, getMaterialID)
|
||||
|
||||
/**
|
||||
* Packet Methods
|
||||
|
|
Loading…
Reference in a new issue