only allow placing keyboards on screens

This commit is contained in:
Florian Nücke 2013-11-24 14:19:26 +01:00
parent 4623641fd6
commit 0325cbb61d
5 changed files with 18 additions and 6 deletions

View File

@ -52,10 +52,4 @@ object BlockRenderer extends ISimpleBlockRenderingHandler {
}
def renderWorldBlock(world: IBlockAccess, x: Int, y: Int, z: Int, block: Block, modelId: Int, renderer: RenderBlocks) = renderer.renderStandardBlock(block, x, y, z)
// Delegator.subBlock(block, world.getBlockMetadata(x, y, z)) match {
// case Some(keyboard: Keyboard) =>
// false
// case _ => renderer.renderStandardBlock(block, x, y, z)
// }
}

View File

@ -33,6 +33,8 @@ trait Delegate {
def canConnectRedstone(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) = false
def canPlaceBlockOnSide(world: World, x: Int, y: Int, z: Int, side: Int) = true
def colorMultiplier(world: IBlockAccess, x: Int, y: Int, z: Int) = getRenderColor
def collisionRayTrace(world: World, x: Int, y: Int, z: Int, origin: Vec3, direction: Vec3) =

View File

@ -110,6 +110,14 @@ class Delegator[Child <: Delegate](id: Int) extends Block(id, Material.iron) {
super.breakBlock(world, x, y, z, blockId, metadata)
}
override def canPlaceBlockOnSide(world: World, x: Int, y: Int, z: Int, side: Int, stack: ItemStack) =
subBlock(stack) match {
case Some(subBlock) => subBlock.canPlaceBlockOnSide(world, x, y, z, side)
case _ => super.canPlaceBlockOnSide(world, x, y, z, side, stack)
}
override def canBeReplacedByLeaves(world: World, x: Int, y: Int, z: Int) = false
override def canCreatureSpawn(creature: EnumCreatureType, world: World, x: Int, y: Int, z: Int) = false
override def damageDropped(metadata: Int) =

View File

@ -20,6 +20,13 @@ class Keyboard(val parent: SpecialDelegator) extends SpecialDelegate {
case _ =>
}
override def canPlaceBlockOnSide(world: World, x: Int, y: Int, z: Int, side: Int) =
ForgeDirection.VALID_DIRECTIONS.
map(side => world.getBlockTileEntity(x + side.offsetX, y + side.offsetY, z + side.offsetZ)).
collect {
case screen: tileentity.Screen => screen
}.exists(_.facing.ordinal() != side)
override def isBlockNormalCube(world: World, x: Int, y: Int, z: Int) = false
override def getLightOpacity(world: World, x: Int, y: Int, z: Int) = 0

View File

@ -275,6 +275,7 @@ class Robot(isRemote: Boolean) extends Computer(isRemote) with ISidedInventory w
computer.node.connect(gpu.node)
distributor.node.connect(battery)
buffer.node.connect(keyboard.node)
distributor.changeBuffer(distributor.globalBufferSize / 2) // TODO for testing only
}
}