Package powercrystals.core.inventory

Examples of powercrystals.core.inventory.IInventoryManager


      }
    }
    // (2) Try to put stack in chests that are in valid directions
    for(Entry<ForgeDirection, IInventory> chest : findChests(world, bp.x, bp.y, bp.z, dropdirections).entrySet())
    {
      IInventoryManager manager = InventoryManager.create((IInventory)chest.getValue(), chest.getKey().getOpposite());
      stack = manager.addItem(stack);
      if(stack == null || stack.stackSize == 0)
      {
        return null;
      }
    }
View Full Code Here


  @Override
  protected boolean activateMachine()
  {
    List<?> entities = worldObj.getEntitiesWithinAABB(EntityLiving.class, _areaManager.getHarvestArea().toAxisAlignedBB());
   
    IInventoryManager manager = InventoryManager.create(this, ForgeDirection.UNKNOWN);
   
    if(entities.size() > MFRConfig.breederShutdownThreshold.getInt())
    {
      setIdleTicks(getIdleTicksMax());
      return false;
    }
   
    for(Object o : entities)
    {
      if(o instanceof EntityAnimal)
      {
        EntityAnimal a = ((EntityAnimal)o);
       
        List<ItemStack> foodList;
        if(MFRRegistry.getBreederFoods().containsKey(a.getClass()))
        {
          foodList = MFRRegistry.getBreederFoods().get(a.getClass());
        }
        else
        {
          foodList = new ArrayList<ItemStack>();
          foodList.add(new ItemStack(Item.wheat));
        }
        for(ItemStack food : foodList)
        {
          int stackIndex = manager.findItem(food);
          if(stackIndex < 0)
          {
            continue;
          }
         
View Full Code Here

        if(chest.getKey() == getDirectionFacing())
        {
          continue;
        }
       
        IInventoryManager inventory = InventoryManager.create(chest.getValue(), chest.getKey());
        Map<Integer, ItemStack> contents = inventory.getContents();
       
        for(Entry<Integer, ItemStack> stack : contents.entrySet())
        {
          if(stack == null || stack.getValue() == null)
          {
            continue;
          }
         
          if(chest.getValue() instanceof ISidedInventory)
          {
            ISidedInventory sided = (ISidedInventory)chest.getValue();
            if(!sided.canExtractItem(stack.getKey(), stack.getValue(), chest.getKey().ordinal()))
            {
              continue;
            }
          }
         
          ItemStack stackToDrop = stack.getValue().copy();
          stackToDrop.stackSize = 1;
          ItemStack remaining = UtilInventory.dropStack(this, stackToDrop, this.getDirectionFacing(), this.getDirectionFacing());
         
          // remaining == null if dropped successfully.
          if(remaining == null)
          {
            inventory.removeItem(1, stackToDrop);
            break inv;
          }
        }
      }
    }
View Full Code Here

    if(world.isRemote || !(entity instanceof EntityMinecartContainer))
    {
      return;
    }
   
    IInventoryManager minecart = InventoryManager.create((EntityMinecartContainer)entity, ForgeDirection.UNKNOWN);
   
    for(Entry<ForgeDirection, IInventory> inventory : UtilInventory.findChests(world, x, y, z).entrySet())
    {
      IInventoryManager chest = InventoryManager.create(inventory.getValue(), inventory.getKey().getOpposite());
      for(Entry<Integer, ItemStack> contents : chest.getContents().entrySet())
      {
        if(contents.getValue() == null)
        {
          continue;
        }
        ItemStack stackToAdd = contents.getValue().copy();
       
        ItemStack remaining = minecart.addItem(stackToAdd);
       
        if(remaining != null)
        {
          stackToAdd.stackSize -= remaining.stackSize;
          if(stackToAdd.stackSize > 0)
          {
            chest.removeItem(stackToAdd.stackSize, stackToAdd);
          }
        }
        else
        {
          chest.removeItem(stackToAdd.stackSize, stackToAdd);
          break;
        }
      }
    }
  }
View Full Code Here

    if(world.isRemote || !(entity instanceof EntityMinecartContainer))
    {
      return;
    }
   
    IInventoryManager minecart = InventoryManager.create((EntityMinecartContainer)entity, ForgeDirection.UNKNOWN);
   
    for(Entry<Integer, ItemStack> contents : minecart.getContents().entrySet())
    {
      if(contents.getValue() == null)
      {
        continue;
      }
     
      ItemStack stackToAdd = contents.getValue().copy();
      ItemStack remaining = UtilInventory.dropStack(world, new BlockPosition(x, y, z), contents.getValue(), ForgeDirection.VALID_DIRECTIONS, ForgeDirection.UNKNOWN);
     
      if(remaining != null)
      {
        stackToAdd.stackSize -= remaining.stackSize;
      }
     
      minecart.removeItem(stackToAdd.stackSize, stackToAdd);
    }
  }
View Full Code Here

 
  @Override
  public List<ItemStack> ranch(World world, EntityLiving entity, IInventory rancher)
  {
    List<ItemStack> drops = new LinkedList<ItemStack>();
    IInventoryManager manager = InventoryManager.create(rancher, ForgeDirection.UP);
    int bucketIndex = manager.findItem(new ItemStack(Item.bucketEmpty));
    if(bucketIndex >= 0)
    {
      drops.add(new ItemStack(Item.bucketMilk));
      rancher.decrStackSize(bucketIndex, 1);
    }
View Full Code Here

  @Override
  public List<ItemStack> ranch(World world, EntityLiving entity, IInventory rancher)
  {
    List<ItemStack> drops = new LinkedList<ItemStack>();
   
    IInventoryManager manager = InventoryManager.create(rancher, ForgeDirection.UP);
    int bowlIndex = manager.findItem(new ItemStack(Item.bowlEmpty));
    if(bowlIndex >= 0)
    {
      drops.add(new ItemStack(Item.bowlSoup));
      rancher.decrStackSize(bowlIndex, 1);
    }
   
    int bucketIndex = manager.findItem(new ItemStack(Item.bucketEmpty));
    if(bucketIndex >= 0)
    {
      drops.add(new ItemStack(Item.bucketMilk));
      rancher.setInventorySlotContents(bucketIndex, null);
    }
View Full Code Here

TOP

Related Classes of powercrystals.core.inventory.IInventoryManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.