Sprinkling in some comparator love.

This commit is contained in:
Florian Nücke 2015-01-03 17:51:16 +01:00
parent 6c63956b2f
commit 42d8d19ea1
10 changed files with 82 additions and 0 deletions

View File

@ -42,6 +42,16 @@ class Assembler extends SimpleBlock with traits.SpecialBlock with traits.PowerAc
// ----------------------------------------------------------------------- //
override def hasComparatorInputOverride = true
override def getComparatorInputOverride(world: World, x: Int, y: Int, z: Int, side: Int) =
world.getTileEntity(x, y, z) match {
case assembler: tileentity.Assembler if assembler.isAssembling => 15
case _ => 0
}
// ----------------------------------------------------------------------- //
override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer,
side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) = {
if (!player.isSneaking) {

View File

@ -77,6 +77,16 @@ class Case(val tier: Int) extends RedstoneAware with traits.PowerAcceptor {
// ----------------------------------------------------------------------- //
override def hasComparatorInputOverride = true
override def getComparatorInputOverride(world: World, x: Int, y: Int, z: Int, side: Int) =
world.getTileEntity(x, y, z) match {
case computer: tileentity.Case if computer.isRunning => 15
case _ => 0
}
// ----------------------------------------------------------------------- //
override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer,
side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) = {
if (!player.isSneaking && !Wrench.holdsApplicableWrench(player, BlockPosition(x, y, z))) {

View File

@ -44,6 +44,16 @@ class Disassembler extends SimpleBlock with traits.PowerAcceptor {
// ----------------------------------------------------------------------- //
override def hasComparatorInputOverride = true
override def getComparatorInputOverride(world: World, x: Int, y: Int, z: Int, side: Int) =
world.getTileEntity(x, y, z) match {
case disassembler: tileentity.Disassembler if disassembler.isActive => 15
case _ => 0
}
// ----------------------------------------------------------------------- //
override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer,
side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) = {
if (!player.isSneaking) {

View File

@ -37,6 +37,16 @@ class DiskDrive extends SimpleBlock {
// ----------------------------------------------------------------------- //
override def hasComparatorInputOverride = true
override def getComparatorInputOverride(world: World, x: Int, y: Int, z: Int, side: Int) =
world.getTileEntity(x, y, z) match {
case drive: tileentity.DiskDrive if drive.getStackInSlot(0) != null => 15
case _ => 0
}
// ----------------------------------------------------------------------- //
override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer,
side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) = {
world.getTileEntity(x, y, z) match {

View File

@ -63,6 +63,16 @@ class Microcontroller extends RedstoneAware with traits.PowerAcceptor {
// ----------------------------------------------------------------------- //
override def hasComparatorInputOverride = true
override def getComparatorInputOverride(world: World, x: Int, y: Int, z: Int, side: Int) =
world.getTileEntity(x, y, z) match {
case computer: tileentity.Microcontroller if computer.isRunning => 15
case _ => 0
}
// ----------------------------------------------------------------------- //
override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer,
side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) = {
if (!player.isSneaking && !Wrench.holdsApplicableWrench(player, BlockPosition(x, y, z))) {

View File

@ -25,6 +25,16 @@ class Raid extends SimpleBlock {
// ----------------------------------------------------------------------- //
override def hasComparatorInputOverride = true
override def getComparatorInputOverride(world: World, x: Int, y: Int, z: Int, side: Int) =
world.getTileEntity(x, y, z) match {
case raid: tileentity.Raid if raid.presence.forall(ok => ok) => 15
case _ => 0
}
// ----------------------------------------------------------------------- //
override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer,
side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) = {
world.getTileEntity(x, y, z) match {

View File

@ -115,6 +115,16 @@ class RobotProxy extends RedstoneAware with traits.SpecialBlock {
// ----------------------------------------------------------------------- //
override def hasComparatorInputOverride = true
override def getComparatorInputOverride(world: World, x: Int, y: Int, z: Int, side: Int) =
world.getTileEntity(x, y, z) match {
case proxy: tileentity.RobotProxy if proxy.isRunning => 15
case _ => 0
}
// ----------------------------------------------------------------------- //
override def getExplosionResistance(entity: Entity) = 10f
override def getDrops(world: World, x: Int, y: Int, z: Int, metadata: Int, fortune: Int) = {

View File

@ -53,6 +53,16 @@ class ServerRack extends RedstoneAware with traits.SpecialBlock with traits.Powe
// ----------------------------------------------------------------------- //
override def hasComparatorInputOverride = true
override def getComparatorInputOverride(world: World, x: Int, y: Int, z: Int, side: Int) =
world.getTileEntity(x, y, z) match {
case rack: tileentity.ServerRack if rack.anyRunning => 15
case _ => 0
}
// ----------------------------------------------------------------------- //
override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer,
side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) = {
if (!player.isSneaking) {

View File

@ -36,6 +36,7 @@ class Disassembler extends traits.Environment with traits.PowerAcceptor with tra
private def setActive(value: Boolean) = if (value != isActive) {
isActive = value
ServerPacketSender.sendDisassemblerActive(this, isActive)
world.notifyBlocksOfNeighborChange(x, y, z, block)
}
// ----------------------------------------------------------------------- //

View File

@ -279,6 +279,7 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
if (_isRunning(i) != isRunning) {
_isRunning(i) = isRunning
ServerPacketSender.sendServerState(this, i)
world.notifyBlocksOfNeighborChange(x, y, z, block)
}
}
isOutputEnabled = hasRedstoneCard