diff --git a/src/main/scala/li/cil/oc/integration/ic2/EventHandlerIndustrialCraft2.scala b/src/main/scala/li/cil/oc/integration/ic2/EventHandlerIndustrialCraft2.scala index 7958ee611..f05b95611 100644 --- a/src/main/scala/li/cil/oc/integration/ic2/EventHandlerIndustrialCraft2.scala +++ b/src/main/scala/li/cil/oc/integration/ic2/EventHandlerIndustrialCraft2.scala @@ -16,25 +16,26 @@ object EventHandlerIndustrialCraft2 { @SubscribeEvent def onGeolyzerAnalyze(e: GeolyzerEvent.Analyze) { val world = e.host.world - val tile = world.getTileEntity(e.x, e.y, e.z) match { - case crop : ICropTile => { + world.getTileEntity(e.x, e.y, e.z) match { + case crop : ICropTile => crop.setScanLevel(4) val cc = crop.getCrop - e.data += "crop:name" -> cc.name() - e.data += "crop:tier" -> Int.box(cc.tier) - e.data += "crop:size" -> Int.box(crop.getSize) - e.data += "crop:maxSize" -> Int.box(cc.maxSize) - e.data += "crop:growth" -> Int.box(crop.getGrowth) - e.data += "crop:gain" -> Int.box(crop.getGain) - e.data += "crop:resistance" -> Int.box(crop.getResistance) - e.data += "crop:fertilizer" -> Int.box(crop.getNutrientStorage) - e.data += "crop:hydration" -> Int.box(crop.getHydrationStorage) - e.data += "crop:weedex" -> Int.box(crop.getWeedExStorage) - e.data += "crop:humidity" -> Int.box(crop.getHumidity) - e.data += "crop:nutrients" -> Int.box(crop.getNutrients) - e.data += "crop:air" -> Int.box(crop.getAirQuality) - e.data += "crop:roots" -> Int.box(cc.getrootslength(crop)) - } + if (cc != null) { + e.data += "crop:name" -> cc.name() + e.data += "crop:tier" -> Int.box(cc.tier) + e.data += "crop:size" -> Int.box(crop.getSize) + e.data += "crop:maxSize" -> Int.box(cc.maxSize) + e.data += "crop:growth" -> Int.box(crop.getGrowth) + e.data += "crop:gain" -> Int.box(crop.getGain) + e.data += "crop:resistance" -> Int.box(crop.getResistance) + e.data += "crop:fertilizer" -> Int.box(crop.getNutrientStorage) + e.data += "crop:hydration" -> Int.box(crop.getHydrationStorage) + e.data += "crop:weedex" -> Int.box(crop.getWeedExStorage) + e.data += "crop:humidity" -> Int.box(crop.getHumidity) + e.data += "crop:nutrients" -> Int.box(crop.getNutrients) + e.data += "crop:air" -> Int.box(crop.getAirQuality) + e.data += "crop:roots" -> Int.box(cc.getrootslength(crop)) + } case _ => None } } @@ -42,12 +43,12 @@ object EventHandlerIndustrialCraft2 { def onRobotApplyDamageRate(e: RobotUsedToolEvent.ApplyDamageRate) { val optManagerBefore = e.toolBeforeUse.getItem match { case item: ISpecialElectricItem => Option(item.getManager(e.toolBeforeUse)) - case item: IElectricItem => Option(ElectricItem.manager) + case _: IElectricItem => Option(ElectricItem.manager) case _ => None } val optManagerAfter = e.toolAfterUse.getItem match { case item: ISpecialElectricItem => Option(item.getManager(e.toolAfterUse)) - case item: IElectricItem => Option(ElectricItem.manager) + case _: IElectricItem => Option(ElectricItem.manager) case _ => None } (optManagerBefore, optManagerAfter) match { @@ -96,7 +97,7 @@ object EventHandlerIndustrialCraft2 { def charge(stack: ItemStack, amount: Double, simulate: Boolean): Double = { (stack.getItem match { case item: ISpecialElectricItem => Option(item.getManager(stack)) - case item: IElectricItem => Option(ElectricItem.manager) + case _: IElectricItem => Option(ElectricItem.manager) case _ => None }) match { case Some(manager) => amount - Power.fromEU(manager.charge(stack, Power.toEU(amount), Int.MaxValue, true, false))