added analyzer tool: right click on a block show its address. for computers it also shows the last error message, if any (if the computer crashed). for multi screens it always shows the address of the origin. shift-rightclick copies the address to the clipboard.

This commit is contained in:
Florian Nücke 2013-11-09 23:38:17 +01:00
parent a7d21190be
commit e885fafe41
4 changed files with 56 additions and 1 deletions

View File

@ -9,8 +9,8 @@ oc.block.ScreenBasic.name=Einfacher Bildschirm
oc.block.ScreenProfessional.name=Professioneller Bildschirm
oc.container.Computer=Computer
oc.container.DiskDrive=Diskettenlaufwerk
oc.item.Analyzer.name=Messgerät
oc.item.Disk.name=Diskette
oc.item.GraphicsCard.name=
oc.item.GraphicsCardAdvanced.name=Hochwertige Grafikkarte
oc.item.GraphicsCardBasic.name=Einfache Grafikkarte
oc.item.GraphicsCardProfessional.name=Professionelle Grafikkarte

View File

@ -9,6 +9,7 @@ oc.block.ScreenBasic.name=Basic Screen
oc.block.ScreenProfessional.name=Professional Screen
oc.container.Computer=Computer
oc.container.DiskDrive=Disk Drive
oc.item.Analyzer.name=Analyzer
oc.item.Disk.name=Floppy Disk
oc.item.GraphicsCardAdvanced.name=Advanced Graphics Card
oc.item.GraphicsCardBasic.name=Basic Graphics Card

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

View File

@ -0,0 +1,54 @@
package li.cil.oc.common.item
import cpw.mods.fml.common.network.Player
import li.cil.oc.Config
import li.cil.oc.api.network.Environment
import li.cil.oc.common.tileentity
import li.cil.oc.server.PacketSender
import net.minecraft.client.renderer.texture.IconRegister
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
import net.minecraft.world.World
class Analyzer(val parent: Delegator) extends Delegate {
val unlocalizedName = "Analyzer"
override def onItemUse(item: ItemStack, player: EntityPlayer, world: World, x: Int, y: Int, z: Int, side: Int, hitX: Float, hitY: Float, hitZ: Float) = {
world.getBlockTileEntity(x, y, z) match {
case computer: tileentity.Computer =>
if (!world.isRemote) {
computer.instance.lastError match {
case Some(value) => player.addChatMessage("Last error: " + value)
case _ =>
}
processAddress(computer, player)
}
true
case screen: tileentity.Screen =>
if (!world.isRemote) {
processAddress(screen.origin, player)
}
true
case environment: Environment =>
if (!world.isRemote) {
processAddress(environment, player)
}
true
case _ => super.onItemUse(item, player, world, x, y, z, side, hitX, hitY, hitZ)
}
}
private def processAddress(environment: Environment, player: EntityPlayer) {
val address = environment.node.address()
player.addChatMessage("Address: " + address)
if (player.isSneaking) {
PacketSender.sendClipboard(address, player.asInstanceOf[Player])
}
}
override def registerIcons(iconRegister: IconRegister) {
super.registerIcons(iconRegister)
icon = iconRegister.registerIcon(Config.resourceDomain + ":analyzer")
}
}