Fixed some motor connection and power
This commit is contained in:
parent
efdbcc7fb6
commit
73d8aad645
3 changed files with 36 additions and 38 deletions
|
@ -13,49 +13,37 @@ trait TMultipartNode[A <: AnyRef] extends NodeConnector[A]
|
|||
{
|
||||
override def world: World =
|
||||
{
|
||||
if (parent != null)
|
||||
return parent match
|
||||
{
|
||||
if (parent.isInstanceOf[TMultiPart])
|
||||
return parent.asInstanceOf[TMultiPart].world
|
||||
else if (parent.isInstanceOf[TileEntity])
|
||||
return parent.asInstanceOf[TileEntity].getWorldObj
|
||||
case p: TMultiPart => p.world
|
||||
case p: TileEntity => p.getWorldObj
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override def x: Double =
|
||||
{
|
||||
if (parent != null)
|
||||
return parent match
|
||||
{
|
||||
if (parent.isInstanceOf[TMultiPart])
|
||||
return (parent.asInstanceOf[TMultiPart]).x
|
||||
else if (parent.isInstanceOf[TileEntity])
|
||||
return (parent.asInstanceOf[TileEntity]).xCoord
|
||||
case p: TMultiPart => p.x
|
||||
case p: TileEntity => p.xCoord
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
override def y: Double =
|
||||
{
|
||||
if (parent != null)
|
||||
return parent match
|
||||
{
|
||||
if (parent.isInstanceOf[TMultiPart])
|
||||
return (parent.asInstanceOf[TMultiPart]).y
|
||||
else if (parent.isInstanceOf[TileEntity])
|
||||
return (parent.asInstanceOf[TileEntity]).yCoord
|
||||
case p: TMultiPart => p.y
|
||||
case p: TileEntity => p.yCoord
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
override def z: Double =
|
||||
{
|
||||
if (parent != null)
|
||||
return parent match
|
||||
{
|
||||
if (parent.isInstanceOf[TMultiPart])
|
||||
return (parent.asInstanceOf[TMultiPart]).z
|
||||
else if (parent.isInstanceOf[TileEntity])
|
||||
return (parent.asInstanceOf[TileEntity]).zCoord
|
||||
case p: TMultiPart => p.z
|
||||
case p: TileEntity => p.zCoord
|
||||
}
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ class TileDust extends SpatialTile(Material.sand)
|
|||
{
|
||||
var resMaterial = ""
|
||||
isOpaqueCube = false
|
||||
creativeTab = null
|
||||
|
||||
override def bounds: Cuboid = new Cuboid(0, 0, 0, 1, (metadata + 1) / 8f, 1)
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.item.ItemStack
|
|||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraft.util.{ChatComponentText, ResourceLocation}
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import org.lwjgl.opengl.GL11
|
||||
import resonant.api.tile.IRotatable
|
||||
import resonant.lib.content.prefab.TElectric
|
||||
|
@ -34,6 +35,13 @@ object TileMotor
|
|||
class TileMotor extends TileAdvanced(Material.iron) with TElectric with TSpatialNodeProvider with IRotatable
|
||||
{
|
||||
var mechNode = new NodeMechanical(this)
|
||||
{
|
||||
override def canConnect(from: ForgeDirection): Boolean =
|
||||
{
|
||||
connectionMask = 1 << getDirection.getOpposite.ordinal
|
||||
return super.canConnect(from)
|
||||
}
|
||||
}
|
||||
|
||||
private var gearRatio = 0
|
||||
|
||||
|
@ -53,13 +61,15 @@ class TileMotor extends TileAdvanced(Material.iron) with TElectric with TSpatial
|
|||
override def onPlaced(entityLiving: EntityLivingBase, itemStack: ItemStack)
|
||||
{
|
||||
super.onPlaced(entityLiving, itemStack)
|
||||
mechNode.connectionMask = 1 << getDirection.getOpposite.ordinal
|
||||
|
||||
if (!world.isRemote)
|
||||
mechNode.reconstruct()
|
||||
}
|
||||
|
||||
override def update()
|
||||
{
|
||||
//TODO: Debug with free energy
|
||||
val deltaPower = 100d //Math.abs(mechNode.power - dcNode.power)
|
||||
val deltaPower = 10000d //Math.abs(mechNode.power - dcNode.power)
|
||||
|
||||
if (false && mechNode.power > dcNode.power)
|
||||
{
|
||||
|
@ -81,18 +91,6 @@ class TileMotor extends TileAdvanced(Material.iron) with TElectric with TSpatial
|
|||
}
|
||||
}
|
||||
|
||||
override protected def use(player: EntityPlayer, side: Int, hit: Vector3): Boolean =
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
gearRatio = (gearRatio + 1) % 3
|
||||
player.addChatComponentMessage(new ChatComponentText("Toggled gear ratio: " + gearRatio))
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
override def renderDynamic(pos: Vector3, frame: Float, pass: Int): Unit =
|
||||
{
|
||||
|
@ -118,4 +116,15 @@ class TileMotor extends TileAdvanced(Material.iron) with TElectric with TSpatial
|
|||
}
|
||||
|
||||
override def toString: String = "[TileMotor]" + x + "x " + y + "y " + z + "z "
|
||||
|
||||
override protected def configure(player: EntityPlayer, side: Int, hit: Vector3): Boolean =
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
gearRatio = (gearRatio + 1) % 3
|
||||
player.addChatComponentMessage(new ChatComponentText("Toggled gear ratio: " + gearRatio))
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue