use sided inventory for accessors to agent inv

inventory calls such as `suck` and `suckFromSlot` were creating a
sideless inventory handler on the agents (drones and robots). The
sideless access was allowing the api calls to access slot indexes beyond
the intended main inventory size, and creep into their component
inventory (e.g. starting with slot index 69 on creatix), thus creating
a copy of the agent's first component (e.g. a Screen block)

This fix creates a sided inventory handler from the inventoryAt call,
fixing these cases.

closes #2935
This commit is contained in:
payonel 2018-09-27 01:41:23 -07:00
parent ea252ff475
commit 9aef16b2a3

View File

@ -47,7 +47,7 @@ object InventoryUtils {
def inventoryAt(position: BlockPosition, side: EnumFacing): Option[IItemHandler] = position.world match {
case Some(world) if world.blockExists(position) => world.getTileEntity(position) match {
case tile: TileEntity if tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side) => Option(tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side))
case tile: IInventory => Option(asItemHandler(tile))
case tile: IInventory => Option(asItemHandler(tile, side))
case _ => world.getEntitiesWithinAABB(classOf[Entity], position.bounds)
.filter(e => !e.isDead && e.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side))
.map(_.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side))