Added virtual junctions and fixed current flow direction
This commit is contained in:
parent
7ae34a9204
commit
0dfcc9e98c
3 changed files with 46 additions and 27 deletions
|
@ -70,8 +70,12 @@ class TileBattery extends SpatialTile(Material.iron) with TIO with TElectric wit
|
||||||
def updateConnectionMask()
|
def updateConnectionMask()
|
||||||
{
|
{
|
||||||
electricNode.connectionMask = ForgeDirection.VALID_DIRECTIONS.filter(getIO(_) > 0).map(d => 1 << d.ordinal()).foldLeft(0)(_ | _)
|
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.positiveTerminals.addAll(getInputDirections())
|
||||||
electricNode.negativeTerminals.addAll(getOutputDirections())
|
electricNode.negativeTerminals.addAll(getOutputDirections())
|
||||||
|
electricNode.reconstruct()
|
||||||
|
markUpdate()
|
||||||
notifyChange()
|
notifyChange()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,8 +131,6 @@ class TileBattery extends SpatialTile(Material.iron) with TIO with TElectric wit
|
||||||
{
|
{
|
||||||
super.setIO(dir, packet)
|
super.setIO(dir, packet)
|
||||||
updateConnectionMask()
|
updateConnectionMask()
|
||||||
electricNode.reconstruct()
|
|
||||||
markUpdate()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override def onPlaced(entityLiving: EntityLivingBase, itemStack: ItemStack)
|
override def onPlaced(entityLiving: EntityLivingBase, itemStack: ItemStack)
|
||||||
|
|
|
@ -4,22 +4,19 @@ import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||||
import edx.core.Reference
|
import edx.core.Reference
|
||||||
import edx.mechanical.mech.grid.NodeMechanical
|
import edx.mechanical.mech.grid.NodeMechanical
|
||||||
import net.minecraft.block.material.Material
|
import net.minecraft.block.material.Material
|
||||||
import net.minecraft.entity.EntityLivingBase
|
|
||||||
import net.minecraft.entity.player.EntityPlayer
|
import net.minecraft.entity.player.EntityPlayer
|
||||||
import net.minecraft.item.ItemStack
|
|
||||||
import net.minecraft.nbt.NBTTagCompound
|
import net.minecraft.nbt.NBTTagCompound
|
||||||
import net.minecraft.util.{ChatComponentText, ResourceLocation}
|
import net.minecraft.util.{ChatComponentText, ResourceLocation}
|
||||||
import net.minecraftforge.client.model.AdvancedModelLoader
|
import net.minecraftforge.client.model.AdvancedModelLoader
|
||||||
import net.minecraftforge.common.util.ForgeDirection
|
import net.minecraftforge.common.util.ForgeDirection
|
||||||
import org.lwjgl.opengl.GL11
|
import org.lwjgl.opengl.GL11
|
||||||
|
import resonant.lib.content.prefab.TIO
|
||||||
import resonant.lib.grid.core.TSpatialNodeProvider
|
import resonant.lib.grid.core.TSpatialNodeProvider
|
||||||
import resonant.lib.prefab.tile.spatial.SpatialTile
|
import resonant.lib.prefab.tile.spatial.SpatialTile
|
||||||
import resonant.lib.prefab.tile.traits.{TElectric, TRotatable}
|
import resonant.lib.prefab.tile.traits.{TElectric, TRotatable}
|
||||||
import resonant.lib.render.RenderUtility
|
import resonant.lib.render.RenderUtility
|
||||||
import resonant.lib.transform.vector.Vector3
|
import resonant.lib.transform.vector.Vector3
|
||||||
|
|
||||||
import scala.collection.convert.wrapAll._
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A kinetic energy to electrical energy converter.
|
* A kinetic energy to electrical energy converter.
|
||||||
*
|
*
|
||||||
|
@ -33,7 +30,7 @@ object TileMotor
|
||||||
val texture = new ResourceLocation(Reference.domain, Reference.modelPath + "motor.png")
|
val texture = new ResourceLocation(Reference.domain, Reference.modelPath + "motor.png")
|
||||||
}
|
}
|
||||||
|
|
||||||
class TileMotor extends SpatialTile(Material.iron) with TElectric with TSpatialNodeProvider with TRotatable
|
class TileMotor extends SpatialTile(Material.iron) with TIO with TElectric with TSpatialNodeProvider with TRotatable
|
||||||
{
|
{
|
||||||
var mechNode = new NodeMechanical(this)
|
var mechNode = new NodeMechanical(this)
|
||||||
{
|
{
|
||||||
|
@ -49,26 +46,30 @@ class TileMotor extends SpatialTile(Material.iron) with TElectric with TSpatialN
|
||||||
textureName = "material_wood_surface"
|
textureName = "material_wood_surface"
|
||||||
normalRender = false
|
normalRender = false
|
||||||
isOpaqueCube = false
|
isOpaqueCube = false
|
||||||
|
ioMap = 0
|
||||||
nodes.add(electricNode)
|
nodes.add(electricNode)
|
||||||
nodes.add(mechNode)
|
nodes.add(mechNode)
|
||||||
|
|
||||||
electricNode.resistance = 100
|
electricNode.resistance = 100
|
||||||
electricNode.positiveTerminals.addAll(Seq(ForgeDirection.UP, ForgeDirection.SOUTH, ForgeDirection.EAST))
|
|
||||||
electricNode.negativeTerminals.addAll(Seq(ForgeDirection.DOWN, ForgeDirection.NORTH, ForgeDirection.WEST))
|
|
||||||
|
|
||||||
def toggleGearRatio() = (gearRatio + 1) % 3
|
def toggleGearRatio() = (gearRatio + 1) % 3
|
||||||
|
|
||||||
/**
|
override def start()
|
||||||
* Called when the block is placed by a living entity
|
|
||||||
* @param entityLiving - entity who placed the block
|
|
||||||
* @param itemStack - ItemStack the entity used to place the block
|
|
||||||
*/
|
|
||||||
override def onPlaced(entityLiving: EntityLivingBase, itemStack: ItemStack)
|
|
||||||
{
|
{
|
||||||
super.onPlaced(entityLiving, itemStack)
|
super.start()
|
||||||
|
updateConnectionMask()
|
||||||
|
}
|
||||||
|
|
||||||
if (!world.isRemote)
|
def updateConnectionMask()
|
||||||
mechNode.reconstruct()
|
{
|
||||||
|
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()
|
||||||
|
notifyChange()
|
||||||
|
markUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
override def update()
|
override def update()
|
||||||
|
@ -95,6 +96,19 @@ class TileMotor extends SpatialTile(Material.iron) with TElectric with TSpatialN
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override def setIO(dir: ForgeDirection, ioType: Int)
|
||||||
|
{
|
||||||
|
if (dir != getDirection || dir != getDirection.getOpposite)
|
||||||
|
{
|
||||||
|
super.setIO(dir, ioType)
|
||||||
|
|
||||||
|
//Auto-set opposite side for unreachable sides
|
||||||
|
if (ioType != 0)
|
||||||
|
super.setIO(dir.getOpposite, (ioType % 2) + 1)
|
||||||
|
updateConnectionMask()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
override def renderDynamic(pos: Vector3, frame: Float, pass: Int): Unit =
|
override def renderDynamic(pos: Vector3, frame: Float, pass: Int): Unit =
|
||||||
{
|
{
|
||||||
|
@ -123,13 +137,17 @@ class TileMotor extends SpatialTile(Material.iron) with TElectric with TSpatialN
|
||||||
|
|
||||||
override protected def configure(player: EntityPlayer, side: Int, hit: Vector3): Boolean =
|
override protected def configure(player: EntityPlayer, side: Int, hit: Vector3): Boolean =
|
||||||
{
|
{
|
||||||
if (!world.isRemote)
|
if (player.isSneaking)
|
||||||
{
|
{
|
||||||
gearRatio = (gearRatio + 1) % 3
|
if (!world.isRemote)
|
||||||
player.addChatComponentMessage(new ChatComponentText("Toggled gear ratio: " + gearRatio))
|
{
|
||||||
|
gearRatio = (gearRatio + 1) % 3
|
||||||
|
player.addChatComponentMessage(new ChatComponentText("Toggled gear ratio: " + gearRatio))
|
||||||
|
}
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return super.configure(player, side, hit)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -56,7 +56,7 @@ object PartFlatWire
|
||||||
|
|
||||||
class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOcclusion
|
class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOcclusion
|
||||||
{
|
{
|
||||||
private val dcNode = new NodeFlatWire(this)
|
private val electricNode = new NodeFlatWire(this)
|
||||||
/**
|
/**
|
||||||
* The current side the wire is placed on
|
* The current side the wire is placed on
|
||||||
*/
|
*/
|
||||||
|
@ -73,8 +73,7 @@ class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOc
|
||||||
* render to us not us to them)
|
* render to us not us to them)
|
||||||
*/
|
*/
|
||||||
var connectionMask = 0x00
|
var connectionMask = 0x00
|
||||||
|
nodes.add(electricNode)
|
||||||
nodes.add(dcNode)
|
|
||||||
|
|
||||||
def preparePlacement(side: Int, meta: Int)
|
def preparePlacement(side: Int, meta: Int)
|
||||||
{
|
{
|
||||||
|
@ -85,7 +84,7 @@ class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOc
|
||||||
override def setMaterial(i: Int)
|
override def setMaterial(i: Int)
|
||||||
{
|
{
|
||||||
super.setMaterial(i)
|
super.setMaterial(i)
|
||||||
dcNode.resistance = material.resistance
|
electricNode.resistance = material.resistance
|
||||||
}
|
}
|
||||||
|
|
||||||
override def update()
|
override def update()
|
||||||
|
@ -97,7 +96,7 @@ class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOc
|
||||||
{
|
{
|
||||||
if (!world.isRemote)
|
if (!world.isRemote)
|
||||||
{
|
{
|
||||||
println(dcNode)
|
println(electricNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Add table
Reference in a new issue