Don't display empty stacks.

This commit is contained in:
Vexatos 2017-05-24 18:26:35 +02:00
parent a766c6f213
commit ac756b6770
2 changed files with 4 additions and 1 deletions

View File

@ -36,7 +36,7 @@ class Drone(val parent: Delegator) extends traits.Delegate with CustomModel {
override protected def tooltipExtended(stack: ItemStack, tooltip: util.List[String]): Unit = {
if (KeyBindings.showExtendedTooltips) {
val info = new DroneData(stack)
for (component <- info.components if component != null) {
for (component <- info.components if !component.isEmpty) {
tooltip.add("- " + component.getDisplayName)
}
}

View File

@ -1,11 +1,14 @@
package li.cil.oc.util
import net.minecraft.item.ItemStack
import scala.math.ScalaNumber
object ResultWrapper {
def result(args: Any*): Array[AnyRef] = {
def unwrap(arg: Any): AnyRef = arg match {
case x: ScalaNumber => x.underlying
case x: ItemStack if x.isEmpty => null
case x => x.asInstanceOf[AnyRef]
}
Array(args map unwrap: _*)