Rewrote and abstracted EnergyStorage

This commit is contained in:
Calclavia 2015-01-21 11:12:44 +08:00
parent 60a7384241
commit 5c00d74116
5 changed files with 99 additions and 106 deletions

View file

@ -28,8 +28,8 @@ class GridBattery extends Grid[TileBattery]
totalCapacity = 0
for (connector <- this.getNodes)
{
totalEnergy += connector.energy.getEnergy
totalCapacity += connector.energy.getEnergyCapacity
totalEnergy += connector.energy.value
totalCapacity += connector.energy.max
lowestY = Math.min(connector.yCoord, lowestY)
highestY = Math.max(connector.yCoord, highestY)
//TODO: Update energy render
@ -53,7 +53,7 @@ class GridBattery extends Grid[TileBattery]
for (connector <- connectorsInlevel)
{
val tryInject: Double = Math.min(remainingRenderEnergy / levelSize, connector.energy.getEnergyCapacity)
val tryInject: Double = Math.min(remainingRenderEnergy / levelSize, connector.energy.max)
//TODO: Update energy render
used += tryInject
}
@ -74,13 +74,13 @@ class GridBattery extends Grid[TileBattery]
{
if (node != firstNode && !Arrays.asList(exclusion).contains(node))
{
val percentage: Double = node.energy.getEnergyCapacity / totalCapacity
val percentage: Double = node.energy.max / totalCapacity
val energyForBattery: Double = Math.max(totalEnergy * percentage, 0)
node.energy.setEnergy(energyForBattery)
node.energy.value = energyForBattery
remainingEnergy -= energyForBattery
}
}
firstNode.energy.setEnergy(Math.max(remainingEnergy, 0))
firstNode.energy.value = Math.max(remainingEnergy, 0)
}
}
}

View file

@ -16,12 +16,13 @@ import net.minecraftforge.client.model.AdvancedModelLoader
import net.minecraftforge.common.util.ForgeDirection
import org.lwjgl.opengl.GL11._
import resonant.api.items.ISimpleItemRenderer
import resonant.lib.content.prefab.{TElectric, TEnergyStorage, TIO}
import resonant.lib.content.prefab.{TElectric, TIO}
import resonant.lib.grid.core.TSpatialNodeProvider
import resonant.lib.grid.energy.EnergyStorage
import resonant.lib.network.discriminator.PacketType
import resonant.lib.network.handle.{TPacketReceiver, TPacketSender}
import resonant.lib.prefab.tile.spatial.SpatialTile
import resonant.lib.prefab.tile.traits.TEnergyProvider
import resonant.lib.render.RenderUtility
import resonant.lib.transform.vector.Vector3
import resonant.lib.utility.science.UnitDisplay
@ -46,7 +47,7 @@ object TileBattery
def getEnergyForTier(tier: Int) = Math.round(Math.pow(500000000, (tier / (maxTier + 0.7f)) + 1) / 500000000) * 500000000
}
class TileBattery extends SpatialTile(Material.iron) with TIO with TElectric with TSpatialNodeProvider with TPacketSender with TPacketReceiver with TEnergyStorage with ISimpleItemRenderer
class TileBattery extends SpatialTile(Material.iron) with TIO with TElectric with TSpatialNodeProvider with TPacketSender with TPacketReceiver with TEnergyProvider with ISimpleItemRenderer
{
var energyRenderLevel = 0
@ -66,6 +67,14 @@ class TileBattery extends SpatialTile(Material.iron) with TIO with TElectric wit
updateConnectionMask()
}
def updateConnectionMask()
{
dcNode.connectionMask = ForgeDirection.VALID_DIRECTIONS.filter(getIO(_) > 0).map(d => 1 << d.ordinal()).foldLeft(0)(_ | _)
dcNode.positiveTerminals.addAll(getInputDirections())
dcNode.negativeTerminals.addAll(getOutputDirections())
notifyChange()
}
override def update()
{
super.update()
@ -74,7 +83,7 @@ class TileBattery extends SpatialTile(Material.iron) with TIO with TElectric wit
{
if (isIndirectlyPowered)
{
if (energy.getEnergy > 0)
if (energy > 0)
{
//TODO: Voltage of battery should decrease over time.
dcNode.generateVoltage(500)
@ -89,7 +98,7 @@ class TileBattery extends SpatialTile(Material.iron) with TIO with TElectric wit
* Update packet when energy level changes.
*/
val prevEnergyLevel = energyRenderLevel
energyRenderLevel = Math.round((energy.getEnergy / TileBattery.getEnergyForTier(getBlockMetadata).toDouble) * 8).toInt
energyRenderLevel = Math.round((energy.value / TileBattery.getEnergyForTier(getBlockMetadata).toDouble) * 8).toInt
if (prevEnergyLevel != energyRenderLevel)
{
@ -101,7 +110,7 @@ class TileBattery extends SpatialTile(Material.iron) with TIO with TElectric wit
override def write(buf: ByteBuf, id: Int)
{
super.write(buf, id)
buf <<< energy.getEnergy
buf <<< energy.value
buf <<< energyRenderLevel.toByte
buf <<< ioMap
}
@ -109,8 +118,8 @@ class TileBattery extends SpatialTile(Material.iron) with TIO with TElectric wit
override def read(buf: ByteBuf, id: Int, packetType: PacketType)
{
super.read(buf, id, packetType)
energy.setCapacity(TileBattery.getEnergyForTier(metadata)).setMaxTransfer(energy.getEnergyCapacity)
energy.setEnergy(buf.readDouble())
energy.max = TileBattery.getEnergyForTier(metadata)
energy.value = buf.readDouble()
energyRenderLevel = buf.readByte()
ioMap = buf.readInt()
}
@ -123,20 +132,12 @@ class TileBattery extends SpatialTile(Material.iron) with TIO with TElectric wit
markUpdate()
}
def updateConnectionMask()
{
dcNode.connectionMask = ForgeDirection.VALID_DIRECTIONS.filter(getIO(_) > 0).map(d => 1 << d.ordinal()).foldLeft(0)(_ | _)
dcNode.positiveTerminals.addAll(getInputDirections())
dcNode.negativeTerminals.addAll(getOutputDirections())
notifyChange()
}
override def onPlaced(entityLiving: EntityLivingBase, itemStack: ItemStack)
{
if (!world.isRemote && itemStack.getItem.isInstanceOf[ItemBlockBattery])
{
energy.setCapacity(TileBattery.getEnergyForTier(ItemBlockBattery.getTier(itemStack))).setMaxTransfer(energy.getEnergyCapacity)
energy.setEnergy(itemStack.getItem.asInstanceOf[ItemBlockBattery].getEnergy(itemStack))
energy.max = (TileBattery.getEnergyForTier(ItemBlockBattery.getTier(itemStack)))
energy.value = itemStack.getItem.asInstanceOf[ItemBlockBattery].getEnergy(itemStack)
world.setBlockMetadataWithNotify(xi, yi, zi, ItemBlockBattery.getTier(itemStack), 3)
}
}
@ -147,7 +148,7 @@ class TileBattery extends SpatialTile(Material.iron) with TIO with TElectric wit
val itemStack: ItemStack = new ItemStack(getBlockType, 1)
val itemBlock: ItemBlockBattery = itemStack.getItem.asInstanceOf[ItemBlockBattery]
ItemBlockBattery.setTier(itemStack, world.getBlockMetadata(xi, yi, zi).asInstanceOf[Byte])
itemBlock.setEnergy(itemStack, energy.getEnergy)
itemBlock.setEnergy(itemStack, energy.value)
ret.add(itemStack)
return ret
}
@ -254,19 +255,19 @@ class TileBattery extends SpatialTile(Material.iron) with TIO with TElectric wit
* Render energy tooltip
*/
if (isPlayerLooking(Minecraft.getMinecraft.thePlayer))
RenderUtility.renderFloatingText(new UnitDisplay(UnitDisplay.Unit.JOULES, energy.getEnergy).symbol + " / " + new UnitDisplay(UnitDisplay.Unit.JOULES, energy.getEnergyCapacity).symbol, new Vector3(0, 0.9, 0))
RenderUtility.renderFloatingText(new UnitDisplay(UnitDisplay.Unit.JOULES, energy.value).symbol + " / " + new UnitDisplay(UnitDisplay.Unit.JOULES, energy.max).symbol, new Vector3(0, 0.9, 0))
glPopMatrix()
}
override def readFromNBT(nbt: NBTTagCompound)
{
super.readFromNBT(nbt)
energy.readFromNBT(nbt)
energy.load(nbt)
}
override def writeToNBT(nbt: NBTTagCompound)
{
super.writeToNBT(nbt)
energy.writeToNBT(nbt)
energy.save(nbt)
}
}

View file

@ -20,12 +20,13 @@ import net.minecraft.tileentity.TileEntity
import net.minecraft.util.ChatComponentText
import net.minecraft.world.World
import net.minecraftforge.common.util.ForgeDirection
import resonant.lib.content.prefab.{TEnergyStorage, TIO}
import resonant.lib.content.prefab.TIO
import resonant.lib.grid.energy.EnergyStorage
import resonant.lib.network.discriminator.{PacketTile, PacketType}
import resonant.lib.network.handle.{TPacketIDReceiver, TPacketSender}
import resonant.lib.network.handle.{TPacketReceiver, TPacketSender}
import resonant.lib.prefab.tile.mixed.TileElectric
import resonant.lib.prefab.tile.multiblock.reference.{IMultiBlockStructure, MultiBlockHandler}
import resonant.lib.prefab.tile.traits.TEnergyProvider
import resonant.lib.render.EnumColor
import resonant.lib.transform.vector.{Vector3, VectorWorld}
import resonant.lib.utility.{LanguageUtility, LinkUtility}
@ -45,7 +46,7 @@ object TileTesla
final val DEFAULT_COLOR: Int = 12
}
class TileTesla extends TileElectric(Material.iron) with IMultiBlockStructure[TileTesla] with ITesla with TPacketIDReceiver with TPacketSender with TEnergyStorage with TIO
class TileTesla extends TileElectric(Material.iron) with IMultiBlockStructure[TileTesla] with ITesla with TPacketReceiver with TPacketSender with TEnergyProvider with TIO
{
final val TRANSFER_CAP: Double = 10000D
@ -76,10 +77,8 @@ class TileTesla extends TileElectric(Material.iron) with IMultiBlockStructure[Ti
//Constructor
//TODO: Dummy
energy = new EnergyStorage(0)
energy.setCapacity(TRANSFER_CAP * 2)
energy.setMaxTransfer(TRANSFER_CAP)
setTextureName(Reference.prefix + "material_metal_side")
energy = new EnergyStorage
textureName = "material_metal_side"
normalRender = false
isOpaqueCube = false
@ -94,7 +93,7 @@ class TileTesla extends TileElectric(Material.iron) with IMultiBlockStructure[Ti
super.update
if (this.getMultiBlock.isPrimary)
{
if (this.ticks % (4 + this.worldObj.rand.nextInt(2)) == 0 && ((this.worldObj.isRemote && isTransfering) || (!this.energy.isEmpty && !this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord))))
if (this.ticks % (4 + this.worldObj.rand.nextInt(2)) == 0 && ((this.worldObj.isRemote && isTransfering) || (this.energy.value != 0 && !this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord))))
{
val topTesla: TileTesla = this.getTopTelsa
val topTeslaVector: Vector3 = toVector3
@ -108,10 +107,10 @@ class TileTesla extends TileElectric(Material.iron) with IMultiBlockStructure[Ti
val transferTile: TileEntity = this.linked.getTileEntity(dimWorld)
if (transferTile.isInstanceOf[TileTesla] && !transferTile.isInvalid)
{
this.transfer((transferTile.asInstanceOf[TileTesla]), Math.min(energy.getEnergy, TRANSFER_CAP))
this.transfer((transferTile.asInstanceOf[TileTesla]), Math.min(energy.value, TRANSFER_CAP))
if (this.zapCounter % 5 == 0 && Settings.SOUND_FXS)
{
this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, Reference.prefix + "electricshock", this.energy.getEnergy.asInstanceOf[Float] / TRANSFER_CAP.asInstanceOf[Float], 1.3f - 0.5f * (this.dyeID / 16f))
this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, Reference.prefix + "electricshock", energy.value.toFloat / TRANSFER_CAP.asInstanceOf[Float], 1.3f - 0.5f * (this.dyeID / 16f))
}
}
}
@ -158,7 +157,7 @@ class TileTesla extends TileElectric(Material.iron) with IMultiBlockStructure[Ti
}
if (teslaToTransfer.size > 0)
{
val transferEnergy: Double = this.energy.getEnergy / teslaToTransfer.size
val transferEnergy: Double = this.energy.value / teslaToTransfer.size
val sentPacket: Boolean = false
for (count <- 0 to 10)
@ -168,7 +167,7 @@ class TileTesla extends TileElectric(Material.iron) with IMultiBlockStructure[Ti
val tesla: ITesla = teslaToTransfer.poll
if (this.zapCounter % 5 == 0 && Settings.SOUND_FXS)
{
this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, Reference.prefix + "electricshock", this.energy.getEnergy.asInstanceOf[Float] / TRANSFER_CAP.asInstanceOf[Float], 1.3f - 0.5f * (this.dyeID / 16f))
this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, Reference.prefix + "electricshock", this.energy.value.asInstanceOf[Float] / TRANSFER_CAP.asInstanceOf[Float], 1.3f - 0.5f * (this.dyeID / 16f))
}
var targetVector: Vector3 = new Vector3(tesla.asInstanceOf[TileEntity])
var heightRange: Int = 1
@ -194,7 +193,7 @@ class TileTesla extends TileElectric(Material.iron) with IMultiBlockStructure[Ti
this.outputBlacklist.clear
this.doTransfer = false
}
if (!this.worldObj.isRemote && this.energy.didEnergyStateChange)
if (!this.worldObj.isRemote && this.energy.isLastEmpty)
{
this.sendPacket(2)
}
@ -241,35 +240,37 @@ class TileTesla extends TileElectric(Material.iron) with IMultiBlockStructure[Ti
}
if (`type` == 2)
{
data.add(this.energy.getEnergy > 0)
data.add(this.energy.value > 0)
}
return data
}
override def read(data: ByteBuf, id: Int, player: EntityPlayer, `type`: PacketType): Boolean =
override def read(buf: ByteBuf, id: Int, packetType: PacketType)
{
super.read(buf, id, packetType)
if (id == 1)
{
this.dyeID = data.readInt
this.canReceive = data.readBoolean
this.attackEntities = data.readBoolean
this.isLinkedClient = data.readBoolean
getMultiBlock.load(ByteBufUtils.readTag(data))
return true
this.dyeID = buf.readInt
this.canReceive = buf.readBoolean
this.attackEntities = buf.readBoolean
this.isLinkedClient = buf.readBoolean
getMultiBlock.load(ByteBufUtils.readTag(buf))
}
else
if (id == 2)
else if (id == 2)
{
this.isTransfering = data.readBoolean
return true
this.isTransfering = buf.readBoolean
}
else
if (id == 3)
else if (id == 3)
{
this.doTransfer = true
return true
}
return false
}
def getMultiBlock: MultiBlockHandler[TileTesla] =
{
if (multiBlock == null) multiBlock = new MultiBlockHandler[TileTesla](this)
return multiBlock
}
def teslaTransfer(e: Double, doTransfer: Boolean): Double =
@ -279,8 +280,8 @@ class TileTesla extends TileElectric(Material.iron) with IMultiBlockStructure[Ti
{
if (doTransfer)
{
this.energy.receiveEnergy(transferEnergy, true)
if (this.energy.didEnergyStateChange)
this.energy += transferEnergy
if (this.energy.isLastEmpty)
{
this.sendPacket(2)
}
@ -289,10 +290,10 @@ class TileTesla extends TileElectric(Material.iron) with IMultiBlockStructure[Ti
}
else
{
if (this.energy.getEnergy > 0)
if (energy.value > 0)
{
transferEnergy += this.energy.getEnergy
this.energy.setEnergy(0)
transferEnergy += energy.value
energy.value = 0
}
return getMultiBlock.get.teslaTransfer(transferEnergy, doTransfer)
}
@ -407,12 +408,6 @@ class TileTesla extends TileElectric(Material.iron) with IMultiBlockStructure[Ti
getMultiBlock.save(nbt)
}
def getMultiBlock: MultiBlockHandler[TileTesla] =
{
if (multiBlock == null) multiBlock = new MultiBlockHandler[TileTesla](this)
return multiBlock
}
def setLink(vector3: Vector3, dimID: Int, setOpponent: Boolean)
{
if (!worldObj.isRemote)

View file

@ -13,17 +13,17 @@ import net.minecraft.nbt.NBTTagCompound
import net.minecraft.util.IIcon
import net.minecraftforge.common.util.ForgeDirection
import resonant.api.tile.{IElectromagnet, IRotatable}
import resonant.lib.content.prefab.TEnergyStorage
import resonant.lib.grid.energy.EnergyStorage
import resonant.lib.network.discriminator.{PacketTile, PacketType}
import resonant.lib.network.handle.{TPacketIDReceiver, TPacketSender}
import resonant.lib.prefab.tile.mixed.TileElectricInventory
import resonant.lib.prefab.tile.traits.TEnergyProvider
import resonant.lib.transform.vector.Vector3
import resonant.lib.utility.BlockUtility
import scala.collection.JavaConversions._
class TileAccelerator extends TileElectricInventory(Material.iron) with IElectromagnet with IRotatable with TPacketIDReceiver with TPacketSender with TEnergyStorage
class TileAccelerator extends TileElectricInventory(Material.iron) with IElectromagnet with IRotatable with TPacketIDReceiver with TPacketSender with TEnergyProvider
{
final val DESC_PACKET_ID = 2
/**
@ -45,9 +45,7 @@ class TileAccelerator extends TileElectricInventory(Material.iron) with IElectro
//Constructor
//TODO: Dummy
energy = new EnergyStorage(0)
energy.setCapacity(Settings.ACCELERATOR_ENERGY_COST_PER_TICK * 20)
energy.setMaxTransfer(Settings.ACCELERATOR_ENERGY_COST_PER_TICK)
energy = new EnergyStorage
override def getSizeInventory: Int = 4
@ -56,13 +54,13 @@ class TileAccelerator extends TileElectricInventory(Material.iron) with IElectro
super.update
if (!worldObj.isRemote)
{
clientEnergy = energy.getEnergy
clientEnergy = energy.value
velocity = getParticleVel()
outputAntimatter()
if (worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord))
{
if (energy.checkExtract)
if (energy >= Settings.ACCELERATOR_ENERGY_COST_PER_TICK)
{
if (entityParticle == null)
{
@ -114,7 +112,7 @@ class TileAccelerator extends TileElectricInventory(Material.iron) with IElectro
worldObj.playSoundEffect(xCoord, yCoord, zCoord, Reference.prefix + "accelerator", 1.5f, (0.6f + (0.4 * (entityParticle.getParticleVelocity) / EntityParticle.ANITMATTER_CREATION_SPEED)).asInstanceOf[Float])
}
}
energy.extractEnergy
energy -= Settings.ACCELERATOR_ENERGY_COST_PER_TICK
}
else
{
@ -206,7 +204,7 @@ class TileAccelerator extends TileElectricInventory(Material.iron) with IElectro
override def getDescPacket: PacketTile =
{
return new PacketTile(xi, yi, zi, Array[Any](DESC_PACKET_ID, velocity, totalEnergyConsumed, antimatter, energy.getEnergy))
return new PacketTile(xi, yi, zi, Array[Any](DESC_PACKET_ID, velocity, totalEnergyConsumed, antimatter, energy.value))
}
/////////////////////////////////////////
@ -222,6 +220,20 @@ class TileAccelerator extends TileElectricInventory(Material.iron) with IElectro
return 0
}
override def getDirection: ForgeDirection =
{
return ForgeDirection.getOrientation(getBlockMetadata)
}
/////////////////////////////////////////
/// Save handling ///
////////////////////////////////////////
override def setDirection(direction: ForgeDirection)
{
world.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, direction.ordinal, 3)
}
override def activate(player: EntityPlayer, side: Int, hit: Vector3): Boolean =
{
player.openGui(Electrodynamics, 0, world, xi, yi, zi)
@ -229,7 +241,7 @@ class TileAccelerator extends TileElectricInventory(Material.iron) with IElectro
}
/////////////////////////////////////////
/// Save handling ///
/// Inventory Overrides ///
////////////////////////////////////////
override def read(buf: ByteBuf, id: Int, player: EntityPlayer, packet: PacketType): Boolean =
@ -242,7 +254,7 @@ class TileAccelerator extends TileElectricInventory(Material.iron) with IElectro
this.velocity = buf.readFloat()
this.totalEnergyConsumed = buf.readDouble()
this.antimatter = buf.readInt()
this.energy.setEnergy(buf.readDouble())
this.energy.value = buf.readDouble()
return true
}
}
@ -257,10 +269,6 @@ class TileAccelerator extends TileElectricInventory(Material.iron) with IElectro
antimatter = par1NBTTagCompound.getInteger("antimatter")
}
/////////////////////////////////////////
/// Inventory Overrides ///
////////////////////////////////////////
override def writeToNBT(par1NBTTagCompound: NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound)
@ -268,6 +276,10 @@ class TileAccelerator extends TileElectricInventory(Material.iron) with IElectro
par1NBTTagCompound.setInteger("antimatter", antimatter)
}
/////////////////////////////////////////
/// Field Getters & Setters ///
////////////////////////////////////////
override def canInsertItem(slotID: Int, itemStack: ItemStack, j: Int): Boolean =
{
return isItemValidForSlot(slotID, itemStack) && slotID != 2 && slotID != 3
@ -289,10 +301,6 @@ class TileAccelerator extends TileElectricInventory(Material.iron) with IElectro
return false
}
/////////////////////////////////////////
/// Field Getters & Setters ///
////////////////////////////////////////
override def canExtractItem(slotID: Int, itemstack: ItemStack, j: Int): Boolean =
{
return slotID == 2 || slotID == 3
@ -312,14 +320,4 @@ class TileAccelerator extends TileElectricInventory(Material.iron) with IElectro
}
return getIcon
}
override def getDirection: ForgeDirection =
{
return ForgeDirection.getOrientation(getBlockMetadata)
}
override def setDirection(direction: ForgeDirection)
{
world.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, direction.ordinal, 3)
}
}

View file

@ -13,23 +13,23 @@ import net.minecraftforge.common.util.ForgeDirection
import net.minecraftforge.fluids._
import resonant.api.tile.ITagRender
import resonant.engine.ResonantEngine
import resonant.lib.content.prefab.TEnergyStorage
import resonant.lib.grid.energy.EnergyStorage
import resonant.lib.mod.config.Config
import resonant.lib.network.discriminator.{PacketTile, PacketType}
import resonant.lib.network.handle.IPacketReceiver
import resonant.lib.prefab.tile.mixed.TileElectric
import resonant.lib.prefab.tile.traits.TEnergyProvider
import resonant.lib.transform.vector.Vector3
import resonant.lib.utility.science.UnitDisplay
import resonant.lib.utility.{FluidUtility, LanguageUtility}
object TilePlasmaHeater
{
var joules: Long = 10000000000L
var power: Long = 10000000000L
@Config var plasmaHeatAmount: Int = 100
}
class TilePlasmaHeater extends TileElectric(Material.iron) with IPacketReceiver with ITagRender with IFluidHandler with TEnergyStorage
class TilePlasmaHeater extends TileElectric(Material.iron) with IPacketReceiver with ITagRender with IFluidHandler with TEnergyProvider
{
final val tankInputDeuterium: FluidTank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME * 10)
final val tankInputTritium: FluidTank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME * 10)
@ -39,26 +39,25 @@ class TilePlasmaHeater extends TileElectric(Material.iron) with IPacketReceiver
//Constructor
//TODO: Dummy
energy = new EnergyStorage(0)
energy.setCapacity(TilePlasmaHeater.joules)
energy.setMaxTransfer(TilePlasmaHeater.joules / 20)
energy = new EnergyStorage
energy.max = TilePlasmaHeater.power
normalRender = false
isOpaqueCube = false
override def update()
{
super.update()
rotation = (rotation + energy.getEnergy / 10000f).asInstanceOf[Float]
rotation = (rotation + energy.value / 10000f).asInstanceOf[Float]
if (!worldObj.isRemote)
{
if (energy.checkExtract)
if (energy >= TilePlasmaHeater.power / 20)
{
if (tankInputDeuterium.getFluidAmount >= TilePlasmaHeater.plasmaHeatAmount && tankInputTritium.getFluidAmount >= TilePlasmaHeater.plasmaHeatAmount && tankOutput.getFluidAmount < tankOutput.getCapacity)
{
tankInputDeuterium.drain(TilePlasmaHeater.plasmaHeatAmount, true)
tankInputTritium.drain(TilePlasmaHeater.plasmaHeatAmount, true)
tankOutput.fill(new FluidStack(QuantumContent.FLUID_PLASMA, tankOutput.getCapacity), true)
energy.extractEnergy
energy -= TilePlasmaHeater.power / 20
}
}
}
@ -134,7 +133,7 @@ class TilePlasmaHeater extends TileElectric(Material.iron) with IPacketReceiver
{
if (energy != null)
{
map.put(LanguageUtility.getLocal("tooltip.energy") + ": " + new UnitDisplay(UnitDisplay.Unit.JOULES, energy.getEnergy), 0xFFFFFF)
map.put(LanguageUtility.getLocal("tooltip.energy") + ": " + new UnitDisplay(UnitDisplay.Unit.JOULES, energy.value), 0xFFFFFF)
}
if (tankInputDeuterium.getFluidAmount > 0)
{