Added dynamic terminal field
This commit is contained in:
parent
f555eb9506
commit
6183c03fd1
3 changed files with 34 additions and 28 deletions
|
@ -25,8 +25,6 @@ object Settings
|
|||
var SHINY_SILVER = true
|
||||
@Config var allowTurbineStacking: Boolean = true
|
||||
// Power Settings
|
||||
@Config(category = "Power", key = "SolorPanel")
|
||||
var solarPower: Int = 50
|
||||
@Config(category = "Power")
|
||||
var fulminationOutputMultiplier: Double = 1
|
||||
@Config(category = "Power", key = "WindTubineRatio")
|
||||
|
|
|
@ -67,18 +67,6 @@ class TileBattery extends SpatialTile(Material.iron) with TIO with TElectric wit
|
|||
updateConnectionMask()
|
||||
}
|
||||
|
||||
def updateConnectionMask()
|
||||
{
|
||||
electricNode.connectionMask = ForgeDirection.VALID_DIRECTIONS.filter(getIO(_) > 0).map(d => 1 << d.ordinal()).foldLeft(0)(_ | _)
|
||||
electricNode.positiveTerminals.clear()
|
||||
electricNode.negativeTerminals.clear()
|
||||
electricNode.positiveTerminals.addAll(getInputDirections())
|
||||
electricNode.negativeTerminals.addAll(getOutputDirections())
|
||||
electricNode.reconstruct()
|
||||
markUpdate()
|
||||
notifyChange()
|
||||
}
|
||||
|
||||
override def update()
|
||||
{
|
||||
super.update()
|
||||
|
@ -95,15 +83,16 @@ class TileBattery extends SpatialTile(Material.iron) with TIO with TElectric wit
|
|||
val dissipatedEnergy = electricNode.power / 20
|
||||
energy -= dissipatedEnergy
|
||||
}
|
||||
else
|
||||
{
|
||||
//Recharge battery when current is flowing negative direction
|
||||
energy += electricNode.power / 20
|
||||
}
|
||||
|
||||
if (energy.prev != energy.value)
|
||||
markUpdate()
|
||||
}
|
||||
else
|
||||
{
|
||||
//Recharge battery when current is flowing negative direction
|
||||
energy += electricNode.power / 20
|
||||
}
|
||||
|
||||
|
||||
if (energy.prev != energy.value)
|
||||
markUpdate()
|
||||
|
||||
/**
|
||||
* Update packet when energy level changes.
|
||||
|
@ -141,6 +130,18 @@ class TileBattery extends SpatialTile(Material.iron) with TIO with TElectric wit
|
|||
updateConnectionMask()
|
||||
}
|
||||
|
||||
def updateConnectionMask()
|
||||
{
|
||||
electricNode.connectionMask = ForgeDirection.VALID_DIRECTIONS.filter(getIO(_) > 0).map(d => 1 << d.ordinal()).foldLeft(0)(_ | _)
|
||||
electricNode.positiveTerminals.clear()
|
||||
electricNode.negativeTerminals.clear()
|
||||
electricNode.positiveTerminals.addAll(getInputDirections())
|
||||
electricNode.negativeTerminals.addAll(getOutputDirections())
|
||||
electricNode.reconstruct()
|
||||
markUpdate()
|
||||
notifyChange()
|
||||
}
|
||||
|
||||
override def onPlaced(entityLiving: EntityLivingBase, itemStack: ItemStack)
|
||||
{
|
||||
if (!world.isRemote && itemStack.getItem.isInstanceOf[ItemBlockBattery])
|
||||
|
|
|
@ -1,24 +1,31 @@
|
|||
package edx.electrical.generator
|
||||
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
import edx.core.{Reference, Settings}
|
||||
import edx.core.Reference
|
||||
import net.minecraft.block.material.Material
|
||||
import net.minecraft.client.renderer.texture.IIconRegister
|
||||
import net.minecraft.util.IIcon
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import resonant.lib.content.prefab.TIO
|
||||
import resonant.lib.prefab.tile.mixed.TileElectric
|
||||
import resonant.lib.prefab.tile.spatial.SpatialBlock
|
||||
import resonant.lib.grid.core.TSpatialNodeProvider
|
||||
import resonant.lib.prefab.tile.spatial.{SpatialBlock, SpatialTile}
|
||||
import resonant.lib.prefab.tile.traits.TElectric
|
||||
import resonant.lib.render.block.RenderConnectedTexture
|
||||
import resonant.lib.transform.region.Cuboid
|
||||
|
||||
class TileSolarPanel extends TileElectric(Material.iron) with TIO with RenderConnectedTexture
|
||||
import scala.collection.convert.wrapAll._
|
||||
|
||||
class TileSolarPanel extends SpatialTile(Material.iron) with TElectric with TSpatialNodeProvider with TIO with RenderConnectedTexture
|
||||
{
|
||||
ioMap = 728
|
||||
textureName = "solarPanel_top"
|
||||
bounds = new Cuboid(0, 0, 0, 1, 0.3f, 1)
|
||||
isOpaqueCube = false
|
||||
|
||||
edgeTexture = Reference.prefix + "tankEdge"
|
||||
electricNode.dynamicTerminals
|
||||
electricNode.positiveTerminals.addAll(Seq(ForgeDirection.NORTH, ForgeDirection.EAST))
|
||||
electricNode.negativeTerminals.addAll(Seq(ForgeDirection.SOUTH, ForgeDirection.WEST))
|
||||
nodes.add(electricNode)
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
override def registerIcons(iconReg: IIconRegister)
|
||||
|
@ -51,7 +58,7 @@ class TileSolarPanel extends TileElectric(Material.iron) with TIO with RenderCon
|
|||
{
|
||||
if (!(world.isThundering || world.isRaining))
|
||||
{
|
||||
electricNode.generateVoltage(Settings.solarPower / 20)
|
||||
electricNode.generateVoltage(15)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue