mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 11:48:02 -04:00
also displaying the more specific 'no cpu' error message for servers
This commit is contained in:
parent
3ecf471ed0
commit
83e43f32fc
@ -2,6 +2,7 @@ package li.cil.oc.server.component
|
||||
|
||||
import li.cil.oc.Items
|
||||
import li.cil.oc.api.driver
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.api.network.{Message, Node}
|
||||
import li.cil.oc.common.inventory.ComponentInventory
|
||||
import li.cil.oc.common.inventory.ServerInventory
|
||||
@ -61,6 +62,14 @@ class Server(val rack: tileentity.Rack, val number: Int) extends Machine.Owner {
|
||||
case _ => 0
|
||||
}))
|
||||
|
||||
def hasCPU = inventory.items.exists {
|
||||
case Some(stack) => Registry.itemDriverFor(stack) match {
|
||||
case Some(driver) => driver.slot(stack) == Slot.Processor
|
||||
case _ => false
|
||||
}
|
||||
case _ => false
|
||||
}
|
||||
|
||||
override def world = rack.world
|
||||
|
||||
override def markAsChanged() = rack.markAsChanged()
|
||||
|
@ -104,6 +104,7 @@ class Machine(val owner: Machine.Owner) extends ManagedComponent with Context wi
|
||||
else if (componentCount > owner.maxComponents) {
|
||||
crash(Settings.namespace + (owner match {
|
||||
case t: tileentity.Case if !t.hasCPU => "gui.Error.NoCPU"
|
||||
case s: server.component.Server if !s.hasCPU => "gui.Error.NoCPU"
|
||||
case _ => "gui.Error.ComponentOverflow"
|
||||
}))
|
||||
false
|
||||
|
Loading…
x
Reference in New Issue
Block a user