fix gtnh-found null fluid tank info crash

This commit is contained in:
Adrian Siekierka 2022-08-28 10:47:31 +02:00
parent 33eb8cb7fd
commit e84596e522
3 changed files with 8 additions and 3 deletions

View File

@ -47,6 +47,7 @@
* Fixed: Missing null check for Blood Magic integration.
* Fixed: [#3336] Missing null check for GregTech data stick NBTs.
* Fixed: [#3249] NullPointerException when remote terminal is missing.
* Fixed: Potential edge case crash with the Tank Controller Upgrade.
* Fixed: [#3401] 'rawSetForeground', 'rawSetBackground' not working correctly.
* Fixed: [#3265] Relay 'setStrength' unlimited upper bound. (JamesOrdner)
* (1.7.10) Fixed: [#3540] Server-side crash with Motion Sensor

View File

@ -52,7 +52,10 @@ trait WorldTankAnalytics extends WorldAware with SideRestricted {
def getTankCount(context: Context, args: Arguments): Array[AnyRef] = {
val facing = checkSideForAction(args, 0)
FluidUtils.fluidHandlerAt(position.offset(facing)) match {
case Some(handler) => result(handler.getTankInfo(facing.getOpposite).length)
case Some(handler) => handler.getTankInfo(facing.getOpposite) match {
case info: Array[FluidTankInfo] => result(info.length)
case _ => result(Unit, "no tank")
}
case _ => result(Unit, "no tank")
}
}

View File

@ -46,10 +46,11 @@ object ExtendedArguments {
def checkTankInfo(handler: IFluidHandler, side: ForgeDirection, n: Int) = {
val tank = args.checkInteger(n) - 1
if (tank < 0 || tank >= handler.getTankInfo(side).length) {
val tankInfo = handler.getTankInfo(side)
if (tankInfo == null || tank < 0 || tank >= tankInfo.length) {
throw new IllegalArgumentException("invalid tank index")
}
handler.getTankInfo(side)(tank)
tankInfo(tank)
}
def optTankInfo(handler: IFluidHandler, side: ForgeDirection, n: Int, default: FluidTankInfo) = {