mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-15 10:21:45 -04:00
activating keyboards activates the screen they're attached to
This commit is contained in:
parent
33583dd52d
commit
3fa660acb7
@ -5,6 +5,7 @@ import li.cil.oc.api
|
|||||||
import li.cil.oc.common.tileentity
|
import li.cil.oc.common.tileentity
|
||||||
import net.minecraft.client.renderer.texture.IconRegister
|
import net.minecraft.client.renderer.texture.IconRegister
|
||||||
import net.minecraft.entity.EntityLivingBase
|
import net.minecraft.entity.EntityLivingBase
|
||||||
|
import net.minecraft.entity.player.EntityPlayer
|
||||||
import net.minecraft.item.ItemStack
|
import net.minecraft.item.ItemStack
|
||||||
import net.minecraft.util.Icon
|
import net.minecraft.util.Icon
|
||||||
import net.minecraft.world.{IBlockAccess, World}
|
import net.minecraft.world.{IBlockAccess, World}
|
||||||
@ -75,5 +76,19 @@ class Keyboard(val parent: SpecialDelegator) extends SpecialDelegate {
|
|||||||
world.setBlockToAir(x, y, z)
|
world.setBlockToAir(x, y, z)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer, side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) =
|
||||||
|
world.getBlockTileEntity(x, y, z) match {
|
||||||
|
case keyboard: tileentity.Keyboard =>
|
||||||
|
val (sx, sy, sz) = (
|
||||||
|
x + keyboard.facing.getOpposite.offsetX,
|
||||||
|
y + keyboard.facing.getOpposite.offsetY,
|
||||||
|
z + keyboard.facing.getOpposite.offsetZ)
|
||||||
|
Delegator.subBlock(world, sx, sy, sz) match {
|
||||||
|
case Some(screen: Screen) => screen.onBlockActivated(world, sx, sy, sz, player, keyboard.facing.getOpposite, 0, 0, 0)
|
||||||
|
case _ => super.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ)
|
||||||
|
}
|
||||||
|
case _ => super.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ)
|
||||||
|
}
|
||||||
|
|
||||||
override protected val validRotations = ForgeDirection.VALID_DIRECTIONS
|
override protected val validRotations = ForgeDirection.VALID_DIRECTIONS
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user