diff --git a/src/main/scala/li/cil/oc/integration/appeng/DriverBlockInterface.scala b/src/main/scala/li/cil/oc/integration/appeng/DriverBlockInterface.scala index e48d3c401..8ff06a714 100644 --- a/src/main/scala/li/cil/oc/integration/appeng/DriverBlockInterface.scala +++ b/src/main/scala/li/cil/oc/integration/appeng/DriverBlockInterface.scala @@ -55,7 +55,7 @@ object DriverBlockInterface extends DriverSidedTileEntity { case component: Component => component.host match { case database: Database => val dbStack = database.getStackInSlot(entry - 1) - if (dbStack == null || size < 1) null + if (dbStack == null || size < 1 || dbStack.isEmpty) ItemStack.EMPTY else { dbStack.setCount(math.min(size, dbStack.getMaxStackSize)) dbStack @@ -65,9 +65,9 @@ object DriverBlockInterface extends DriverSidedTileEntity { case _ => throw new IllegalArgumentException("no such component") } } - else null - config.extractItem(slot, config.getStackInSlot(slot).getCount, true) - config.insertItem(slot, stack, true) + else ItemStack.EMPTY + config.extractItem(slot, config.getStackInSlot(slot).getCount, false) + config.insertItem(slot, stack, false) context.pause(0.5) result(true) } diff --git a/src/main/scala/li/cil/oc/integration/appeng/DriverExportBus.scala b/src/main/scala/li/cil/oc/integration/appeng/DriverExportBus.scala index 6c9ffb824..1b143c9c1 100644 --- a/src/main/scala/li/cil/oc/integration/appeng/DriverExportBus.scala +++ b/src/main/scala/li/cil/oc/integration/appeng/DriverExportBus.scala @@ -50,9 +50,10 @@ object DriverExportBus extends driver.DriverBlock { val side = args.checkSideAny(0) val part = host.getPart(side) - if(AEUtil.isExportBus(part.getItemStack(PartItemStack.PICK))) { + if (part != null && AEUtil.isExportBus(part.getItemStack(PartItemStack.PICK))) { val export = part.asInstanceOf[ISegmentedInventory with IConfigurableObject with IUpgradeableHost with IActionHost with IGridHost] - InventoryUtils.inventoryAt(new BlockPosition(host.getLocation.x, host.getLocation.y, host.getLocation.z).offset(side), side.getOpposite) match { + val location = host.getLocation + InventoryUtils.inventoryAt(new BlockPosition(location.x, location.y, location.z, Some(location.getWorld)).offset(side), side.getOpposite) match { case Some(inventory) => val targetSlot = args.checkSlot(inventory, 1) val config = export.getInventoryByName("config") diff --git a/src/main/scala/li/cil/oc/integration/appeng/PartEnvironmentBase.scala b/src/main/scala/li/cil/oc/integration/appeng/PartEnvironmentBase.scala index 7f8c38bc4..572090f75 100644 --- a/src/main/scala/li/cil/oc/integration/appeng/PartEnvironmentBase.scala +++ b/src/main/scala/li/cil/oc/integration/appeng/PartEnvironmentBase.scala @@ -9,6 +9,7 @@ import li.cil.oc.api.network.Component import li.cil.oc.api.network.ManagedEnvironment import li.cil.oc.util.ExtendedArguments._ import li.cil.oc.util.ResultWrapper.result +import net.minecraft.item.ItemStack import scala.reflect.ClassTag @@ -44,7 +45,7 @@ trait PartEnvironmentBase extends ManagedEnvironment { case component: Component => component.host match { case database: Database => val dbStack = database.getStackInSlot(entry - 1) - if (dbStack == null || size < 1) null + if (dbStack == null || size < 1 || dbStack.isEmpty) ItemStack.EMPTY else { dbStack.setCount(math.min(size, dbStack.getMaxStackSize)) dbStack @@ -54,9 +55,9 @@ trait PartEnvironmentBase extends ManagedEnvironment { case _ => throw new IllegalArgumentException("no such component") } } - else null - config.extractItem(slot, config.getStackInSlot(slot).getCount, true) - config.insertItem(slot, stack, true) + else ItemStack.EMPTY + config.extractItem(slot, config.getStackInSlot(slot).getCount, false) + config.insertItem(slot, stack, false) context.pause(0.5) result(true) case _ => result(Unit, "no matching part")