mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-27 23:14:23 -04:00
Centralized logic that prints last computer crash reason when analyzed.
This way it'll also work for third-party machines.
This commit is contained in:
parent
6bbb43ad18
commit
83a7efaa76
@ -206,19 +206,7 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
override def onAnalyze(player: EntityPlayer, side: Int, hitX: Float, hitY: Float, hitZ: Float) = {
|
||||
machine.lastError match {
|
||||
case value if value != null =>
|
||||
player.addChatMessage(Localization.Analyzer.LastError(value))
|
||||
case _ =>
|
||||
}
|
||||
player.addChatMessage(Localization.Analyzer.Components(machine.componentCount, machine.maxComponents))
|
||||
val list = machine.users
|
||||
if (list.size > 0) {
|
||||
player.addChatMessage(Localization.Analyzer.Users(list))
|
||||
}
|
||||
Array(machine.node)
|
||||
}
|
||||
override def onAnalyze(player: EntityPlayer, side: Int, hitX: Float, hitY: Float, hitZ: Float) = Array(machine.node)
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
|
@ -415,7 +415,7 @@ object Items extends ItemAPI {
|
||||
// 1.4.2
|
||||
val eeprom = new item.EEPROM()
|
||||
Recipes.addItem(eeprom, Constants.ItemName.EEPROM, "oc:eeprom")
|
||||
Recipes.addRecipe(createLuaBios(), "luaBios")
|
||||
Recipes.addRecipe(createLuaBios(), Constants.ItemName.LuaBios)
|
||||
Recipes.addSubItem(new item.MicrocontrollerCase(multi, Tier.One), Constants.ItemName.MicrocontrollerCaseTier1, "oc:microcontrollerCase1")
|
||||
|
||||
// 1.4.3
|
||||
|
@ -5,6 +5,7 @@ import li.cil.oc.Constants
|
||||
import li.cil.oc.Localization
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.machine.Machine
|
||||
import li.cil.oc.api.network.Analyzable
|
||||
import li.cil.oc.api.network._
|
||||
import li.cil.oc.common.tileentity
|
||||
@ -59,6 +60,20 @@ object Analyzer {
|
||||
private def analyzeNodes(nodes: Array[Node], player: EntityPlayer) = if (nodes != null) for (node <- nodes if node != null) {
|
||||
player match {
|
||||
case playerMP: EntityPlayerMP =>
|
||||
if (node != null) node.host match {
|
||||
case machine: Machine =>
|
||||
if (machine != null) {
|
||||
if (machine.lastError != null) {
|
||||
playerMP.addChatMessage(Localization.Analyzer.LastError(machine.lastError))
|
||||
}
|
||||
playerMP.addChatMessage(Localization.Analyzer.Components(machine.componentCount, machine.maxComponents))
|
||||
val list = machine.users
|
||||
if (list.length > 0) {
|
||||
playerMP.addChatMessage(Localization.Analyzer.Users(list))
|
||||
}
|
||||
}
|
||||
case _ =>
|
||||
}
|
||||
node match {
|
||||
case connector: Connector =>
|
||||
if (connector.localBufferSize > 0) {
|
||||
|
@ -214,19 +214,7 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
|
||||
override def onAnalyze(player: EntityPlayer, side: Int, hitX: Float, hitY: Float, hitZ: Float) = {
|
||||
slotAt(ForgeDirection.getOrientation(side), hitX, hitY, hitZ) match {
|
||||
case Some(slot) => servers(slot) match {
|
||||
case Some(server) =>
|
||||
val computer = server.machine
|
||||
computer.lastError match {
|
||||
case value if value != null =>
|
||||
player.addChatMessage(Localization.Analyzer.LastError(value))
|
||||
case _ =>
|
||||
}
|
||||
player.addChatMessage(Localization.Analyzer.Components(computer.componentCount, computer.maxComponents))
|
||||
val list = computer.users
|
||||
if (list.size > 0) {
|
||||
player.addChatMessage(Localization.Analyzer.Users(list))
|
||||
}
|
||||
Array(computer.node)
|
||||
case Some(server) => Array(server.machine.node)
|
||||
case _ => null
|
||||
}
|
||||
case _ => Array(sidedNode(ForgeDirection.getOrientation(side)))
|
||||
|
@ -5,7 +5,6 @@ import java.util
|
||||
|
||||
import cpw.mods.fml.relauncher.Side
|
||||
import cpw.mods.fml.relauncher.SideOnly
|
||||
import li.cil.oc.Localization
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.api.Machine
|
||||
import li.cil.oc.api.machine.MachineHost
|
||||
@ -209,17 +208,5 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
override def onAnalyze(player: EntityPlayer, side: Int, hitX: Float, hitY: Float, hitZ: Float) = {
|
||||
machine.lastError match {
|
||||
case value if value != null =>
|
||||
player.addChatMessage(Localization.Analyzer.LastError(value))
|
||||
case _ =>
|
||||
}
|
||||
player.addChatMessage(Localization.Analyzer.Components(machine.componentCount, machine.maxComponents))
|
||||
val list = machine.users
|
||||
if (list.size > 0) {
|
||||
player.addChatMessage(Localization.Analyzer.Users(list))
|
||||
}
|
||||
Array(machine.node)
|
||||
}
|
||||
override def onAnalyze(player: EntityPlayer, side: Int, hitX: Float, hitY: Float, hitZ: Float) = Array(machine.node)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user