Package net.minecraft.inventory

Examples of net.minecraft.inventory.IInventory


        TileEntity back = Coord4D.get(this).getFromSide(ForgeDirection.getOrientation(facing).getOpposite()).getTileEntity(worldObj);
        TileEntity front = Coord4D.get(this).getFromSide(ForgeDirection.getOrientation(facing)).getTileEntity(worldObj);

        if(back instanceof IInventory && (front instanceof ILogisticalTransporter || front instanceof IInventory))
        {
          IInventory inventory = (IInventory)back;

          boolean sentItems = false;
          int min = 0;

          for(TransporterFilter filter : filters)
          {
            InvStack invStack = filter.getStackFromInventory(inventory, ForgeDirection.getOrientation(facing).getOpposite());

            if(invStack != null && invStack.getStack() != null)
            {
              if(filter.canFilter(invStack.getStack()))
              {
                if(filter instanceof TItemStackFilter)
                {
                  TItemStackFilter itemFilter = (TItemStackFilter)filter;

                  if(itemFilter.sizeMode)
                  {
                    min = itemFilter.min;
                  }
                }
               
                ItemStack used = emitItemToTransporter(front, invStack, filter.color, min);
               
                if(used != null)
                {
                  invStack.use(used.stackSize);
                  inventory.markDirty();
                  setActive(true);
                  sentItems = true;
                 
                  break;
                }
              }
            }
          }

          if(!sentItems && autoEject)
          {
            InvStack invStack = InventoryUtils.takeTopStack(inventory, ForgeDirection.getOrientation(facing).getOpposite().ordinal(), new FirstFinder());
           
            if(invStack != null && invStack.getStack() != null)
            {
              ItemStack used = emitItemToTransporter(front, invStack, color, 0);
             
              if(used != null)
              {
                invStack.use(used.stackSize);
                inventory.markDirty();
                setActive(true);
              }
            }
          }
View Full Code Here


    stacks.add(new ItemStack(getItemDropped(metadata, world.rand, 0), 1, damageDropped(metadata)));
   
    TileEntity te = world.getTileEntity(x, y, z);
   
    if(te instanceof IInventory) {
      IInventory invTe = (IInventory)te;
      for(int i = 0; i < invTe.getSizeInventory(); i++) {
        ItemStack stack = invTe.getStackInSlot(i);
        if(stack != null) {
          stacks.add(stack);
          if(!simulate) {
            invTe.setInventorySlotContents(i, null);
          }
        }
      }
    }
View Full Code Here

    if(te instanceof ISidedInventory) {
      this.inv = new SidedInventoryHelper((ISidedInventory)te, dir.getOpposite());
    }
    else {
      IInventory inv = (IInventory)te;
      World world = te.getWorldObj();
      if(world.getBlock(te.xCoord, te.yCoord, te.zCoord) == Blocks.chest) {
        inv = StaticUtils.Inventory.checkForDoubleChest(world, inv, te.xCoord, te.yCoord, te.zCoord);
      }
      this.inv = new InventoryHelper(inv);
View Full Code Here

  {
    // Drop everything inside inventory blocks
    TileEntity te = world.getTileEntity(x, y, z);
    if(te instanceof IInventory)
    {
      IInventory inventory = ((IInventory)te);
inv:    for(int i = 0; i < inventory.getSizeInventory(); i++)
      {
        ItemStack itemstack = inventory.getStackInSlot(i);
        if(itemstack == null)
        {
          continue;
        }
        float xOffset = world.rand.nextFloat() * 0.8F + 0.1F;
View Full Code Here

  {
    // Drop everything inside inventory blocks
    TileEntity te = world.getTileEntity(x, y, z);
    if(te instanceof IInventory)
    {
      IInventory inventory = ((IInventory)te);
inv:    for(int i = 0; i < inventory.getSizeInventory(); i++)
      {
        ItemStack itemstack = inventory.getStackInSlot(i);
        if(itemstack == null)
        {
          continue;
        }
        float xOffset = world.rand.nextFloat() * 0.8F + 0.1F;
View Full Code Here

  /**
   * Retrieves the baubles inventory for the supplied player
   */
  public static IInventory getBaubles(EntityPlayer player)
  {
    IInventory ot = null;
   
      try
      {
          if(getBaubles == null)
          {
View Full Code Here

  public void breakBlock(World world, int x, int y, int z, int blockId, int meta)
  {
    TileEntity te = world.getBlockTileEntity(x, y, z);
    if(te instanceof IInventory && !(te instanceof TileEntityDeepStorageUnit))
    {
      IInventory inventory = ((IInventory)te);
      inv: for(int i = 0; i < inventory.getSizeInventory(); i++)
      {
        if(te instanceof TileEntityFactoryInventory && !((TileEntityFactoryInventory)te).shouldDropSlotWhenBroken(i))
        {
          continue;
        }
       
        ItemStack itemstack = inventory.getStackInSlot(i);
        if(itemstack == null)
        {
          continue;
        }
        float xOffset = world.rand.nextFloat() * 0.8F + 0.1F;
View Full Code Here

          ItemStack istack = item.getEntityItem();
          if(player.isSneaking() || istack.isItemEqual(pstack) && ItemStack.areItemStackTagsEqual(istack, pstack))
            positionsBuilder.append(item.getEntityId()).append(";");

        } else if(e instanceof IInventory) {
          IInventory inv = (IInventory) e;
          if(scanInventory(inv, pstack))
            positionsBuilder.append(e.getEntityId()).append(";");

        } else if(e instanceof EntityHorse) {
          EntityHorse horse = (EntityHorse) e;
          AnimalChest chest = ReflectionHelper.getPrivateValue(EntityHorse.class, horse, LibObfuscation.HORSE_CHEST);
          if(scanInventory(chest, pstack))
            positionsBuilder.append(horse.getEntityId()).append(";");

        } else if(e instanceof EntityPlayer) {
          EntityPlayer player_ = (EntityPlayer) e;
          InventoryPlayer inv = player_.inventory;
          InventoryBaubles binv = PlayerHandler.getPlayerBaubles(player_);
          if(scanInventory(inv, pstack) || scanInventory(binv, pstack))
            positionsBuilder.append(player_.getEntityId()).append(";");

        } else if(e instanceof EntityVillager) {
          EntityVillager villager = (EntityVillager) e;
          ArrayList<MerchantRecipe> recipes = villager.getRecipes(player);
          if(pstack != null)
            for(MerchantRecipe recipe : recipes)
              if(!recipe.isRecipeDisabled() && (equalStacks(pstack, recipe.getItemToBuy()) || equalStacks(pstack, recipe.getItemToSell())))
                positionsBuilder.append(villager.getEntityId()).append(";");

        } else if(e instanceof EntityLivingBase) {
          EntityLivingBase living = (EntityLivingBase) e;
          ItemStack estack = living.getEquipmentInSlot(0);
          if(pstack != null && estack != null && equalStacks(estack, pstack))
            positionsBuilder.append(living.getEntityId()).append(";");
        }
      }

      if(pstack != null) {
        range = 12;
        int x = MathHelper.floor_double(player.posX);
        int y = MathHelper.floor_double(player.posY);
        int z = MathHelper.floor_double(player.posZ);
        for(int i = -range; i < range + 1; i++)
          for(int j = -range; j < range + 1; j++)
            for(int k = -range; k < range + 1; k++) {
              int xp = x + i;
              int yp = y + j;
              int zp = z + k;
              TileEntity tile = player.worldObj.getTileEntity(xp, yp, zp);
              if(tile != null && tile instanceof IInventory) {
                IInventory inv = (IInventory) tile;
                if(scanInventory(inv, pstack))
                  positionsBuilder.append(xp).append(",").append(yp).append(",").append(zp).append(";");
              }
            }
      }
View Full Code Here

      int totalMana = 0;
      int totalMaxMana = 0;
      boolean anyRequest = false;
      boolean creative = false;

      IInventory mainInv = player.inventory;
      IInventory baublesInv = PlayerHandler.getPlayerBaubles(player);

      int invSize = mainInv.getSizeInventory();
      int size = invSize;
      if(baublesInv != null)
        size += baublesInv.getSizeInventory();

      for(int i = 0; i < size; i++) {
        boolean useBaubles = i >= invSize;
        IInventory inv = useBaubles ? baublesInv : mainInv;
        ItemStack stack = inv.getStackInSlot(i - (useBaubles ? invSize : 0));

        if(stack != null) {
          Item item = stack.getItem();
          if(item instanceof IManaUsingItem)
            anyRequest = anyRequest || ((IManaUsingItem) item).usesMana(stack);
View Full Code Here

  }

  public static void insertItemIntoInventory(IInventory inventory, ItemStack stack, ForgeDirection side, int intoSlot, boolean doMove, boolean canStack) {
    if(stack == null) return;

    IInventory targetInventory = inventory;

    if(!doMove) {
      targetInventory = new GenericInventory("temporary.inventory", false, targetInventory.getSizeInventory());
      ((GenericInventory)targetInventory).copyFrom(inventory);
    }

    int i = 0;
    int[] attemptSlots = new int[0];
View Full Code Here

TOP

Related Classes of net.minecraft.inventory.IInventory

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.