mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-26 14:35:04 -04:00
Merge pull request #9 from repo-alt/master-MC1.7.10
null check & a bit cleanup
This commit is contained in:
commit
8006f33b04
@ -16,25 +16,26 @@ object EventHandlerIndustrialCraft2 {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
def onGeolyzerAnalyze(e: GeolyzerEvent.Analyze) {
|
def onGeolyzerAnalyze(e: GeolyzerEvent.Analyze) {
|
||||||
val world = e.host.world
|
val world = e.host.world
|
||||||
val tile = world.getTileEntity(e.x, e.y, e.z) match {
|
world.getTileEntity(e.x, e.y, e.z) match {
|
||||||
case crop : ICropTile => {
|
case crop : ICropTile =>
|
||||||
crop.setScanLevel(4)
|
crop.setScanLevel(4)
|
||||||
val cc = crop.getCrop
|
val cc = crop.getCrop
|
||||||
e.data += "crop:name" -> cc.name()
|
if (cc != null) {
|
||||||
e.data += "crop:tier" -> Int.box(cc.tier)
|
e.data += "crop:name" -> cc.name()
|
||||||
e.data += "crop:size" -> Int.box(crop.getSize)
|
e.data += "crop:tier" -> Int.box(cc.tier)
|
||||||
e.data += "crop:maxSize" -> Int.box(cc.maxSize)
|
e.data += "crop:size" -> Int.box(crop.getSize)
|
||||||
e.data += "crop:growth" -> Int.box(crop.getGrowth)
|
e.data += "crop:maxSize" -> Int.box(cc.maxSize)
|
||||||
e.data += "crop:gain" -> Int.box(crop.getGain)
|
e.data += "crop:growth" -> Int.box(crop.getGrowth)
|
||||||
e.data += "crop:resistance" -> Int.box(crop.getResistance)
|
e.data += "crop:gain" -> Int.box(crop.getGain)
|
||||||
e.data += "crop:fertilizer" -> Int.box(crop.getNutrientStorage)
|
e.data += "crop:resistance" -> Int.box(crop.getResistance)
|
||||||
e.data += "crop:hydration" -> Int.box(crop.getHydrationStorage)
|
e.data += "crop:fertilizer" -> Int.box(crop.getNutrientStorage)
|
||||||
e.data += "crop:weedex" -> Int.box(crop.getWeedExStorage)
|
e.data += "crop:hydration" -> Int.box(crop.getHydrationStorage)
|
||||||
e.data += "crop:humidity" -> Int.box(crop.getHumidity)
|
e.data += "crop:weedex" -> Int.box(crop.getWeedExStorage)
|
||||||
e.data += "crop:nutrients" -> Int.box(crop.getNutrients)
|
e.data += "crop:humidity" -> Int.box(crop.getHumidity)
|
||||||
e.data += "crop:air" -> Int.box(crop.getAirQuality)
|
e.data += "crop:nutrients" -> Int.box(crop.getNutrients)
|
||||||
e.data += "crop:roots" -> Int.box(cc.getrootslength(crop))
|
e.data += "crop:air" -> Int.box(crop.getAirQuality)
|
||||||
}
|
e.data += "crop:roots" -> Int.box(cc.getrootslength(crop))
|
||||||
|
}
|
||||||
case _ => None
|
case _ => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -42,12 +43,12 @@ object EventHandlerIndustrialCraft2 {
|
|||||||
def onRobotApplyDamageRate(e: RobotUsedToolEvent.ApplyDamageRate) {
|
def onRobotApplyDamageRate(e: RobotUsedToolEvent.ApplyDamageRate) {
|
||||||
val optManagerBefore = e.toolBeforeUse.getItem match {
|
val optManagerBefore = e.toolBeforeUse.getItem match {
|
||||||
case item: ISpecialElectricItem => Option(item.getManager(e.toolBeforeUse))
|
case item: ISpecialElectricItem => Option(item.getManager(e.toolBeforeUse))
|
||||||
case item: IElectricItem => Option(ElectricItem.manager)
|
case _: IElectricItem => Option(ElectricItem.manager)
|
||||||
case _ => None
|
case _ => None
|
||||||
}
|
}
|
||||||
val optManagerAfter = e.toolAfterUse.getItem match {
|
val optManagerAfter = e.toolAfterUse.getItem match {
|
||||||
case item: ISpecialElectricItem => Option(item.getManager(e.toolAfterUse))
|
case item: ISpecialElectricItem => Option(item.getManager(e.toolAfterUse))
|
||||||
case item: IElectricItem => Option(ElectricItem.manager)
|
case _: IElectricItem => Option(ElectricItem.manager)
|
||||||
case _ => None
|
case _ => None
|
||||||
}
|
}
|
||||||
(optManagerBefore, optManagerAfter) match {
|
(optManagerBefore, optManagerAfter) match {
|
||||||
@ -96,7 +97,7 @@ object EventHandlerIndustrialCraft2 {
|
|||||||
def charge(stack: ItemStack, amount: Double, simulate: Boolean): Double = {
|
def charge(stack: ItemStack, amount: Double, simulate: Boolean): Double = {
|
||||||
(stack.getItem match {
|
(stack.getItem match {
|
||||||
case item: ISpecialElectricItem => Option(item.getManager(stack))
|
case item: ISpecialElectricItem => Option(item.getManager(stack))
|
||||||
case item: IElectricItem => Option(ElectricItem.manager)
|
case _: IElectricItem => Option(ElectricItem.manager)
|
||||||
case _ => None
|
case _ => None
|
||||||
}) match {
|
}) match {
|
||||||
case Some(manager) => amount - Power.fromEU(manager.charge(stack, Power.toEU(amount), Int.MaxValue, true, false))
|
case Some(manager) => amount - Power.fromEU(manager.charge(stack, Power.toEU(amount), Int.MaxValue, true, false))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user