Examples of InventoryPlayer


Examples of net.minecraft.entity.player.InventoryPlayer

    if (p_75144_3_ == 2 && p_75144_2_ == containerIndex) {
      return null;
    }
    ItemStack stack = null;
    InventoryPlayer inventoryPlayer = player.inventory;
    int i1;
    ItemStack itemstack3;

    if (p_75144_3_ == 5) {
      int l = this.field_94536_g;
      this.field_94536_g = func_94532_c(p_75144_2_);

      if ((l != 1 || this.field_94536_g != 2) && l != this.field_94536_g) {
        this.func_94533_d();
      } else if (inventoryPlayer.getItemStack() == null) {
        this.func_94533_d();
      } else if (this.field_94536_g == 0) {
        this.field_94535_f = func_94529_b(p_75144_2_);

        if (func_94528_d(this.field_94535_f)) {
          this.field_94536_g = 1;
          this.field_94537_h.clear();
        } else {
          this.func_94533_d();
        }
      } else if (this.field_94536_g == 1) {
        Slot slot = (Slot) this.inventorySlots.get(slotIndex);

        if (slot != null && func_94527_a(slot, inventoryPlayer.getItemStack(), true) && slot.isItemValid(inventoryPlayer.getItemStack())
            && inventoryPlayer.getItemStack().stackSize > this.field_94537_h.size() && this.canDragIntoSlot(slot)) {
          this.field_94537_h.add(slot);
        }
      } else if (this.field_94536_g == 2) {
        if (!this.field_94537_h.isEmpty()) {
          itemstack3 = inventoryPlayer.getItemStack().copy();
          i1 = inventoryPlayer.getItemStack().stackSize;
          Iterator<Slot> iterator = this.field_94537_h.iterator();

          while (iterator.hasNext()) {
            Slot slot1 = iterator.next();

            if (slot1 != null && func_94527_a(slot1, inventoryPlayer.getItemStack(), true) && slot1.isItemValid(inventoryPlayer.getItemStack())
                && inventoryPlayer.getItemStack().stackSize >= this.field_94537_h.size() && this.canDragIntoSlot(slot1)) {
              ItemStack itemstack1 = itemstack3.copy();
              int j1 = slot1.getHasStack() ? slot1.getStack().stackSize : 0;
              func_94525_a(this.field_94537_h, this.field_94535_f, itemstack1, j1);

              if (itemstack1.stackSize > itemstack1.getMaxStackSize()) {
                itemstack1.stackSize = itemstack1.getMaxStackSize();
              }
              if (itemstack1.stackSize > slot1.getSlotStackLimit()) {
                itemstack1.stackSize = slot1.getSlotStackLimit();
              }
              i1 -= itemstack1.stackSize - j1;
              slot1.putStack(itemstack1);
            }
          }

          itemstack3.stackSize = i1;

          if (itemstack3.stackSize <= 0) {
            itemstack3 = null;
          }
          inventoryPlayer.setItemStack(itemstack3);
        }
        this.func_94533_d();
      } else {
        this.func_94533_d();
      }
    } else if (this.field_94536_g != 0) {
      this.func_94533_d();
    } else {
      Slot slot2;
      int l1;
      ItemStack itemstack5;

      if ((p_75144_3_ == 0 || p_75144_3_ == 1) && (p_75144_2_ == 0 || p_75144_2_ == 1)) {
        if (slotIndex == -999) {
          if (inventoryPlayer.getItemStack() != null && slotIndex == -999) {
            if (p_75144_2_ == 0) {
              player.dropPlayerItemWithRandomChoice(inventoryPlayer.getItemStack(), true);
              inventoryPlayer.setItemStack((ItemStack) null);
            }

            if (p_75144_2_ == 1) {
              player.dropPlayerItemWithRandomChoice(inventoryPlayer.getItemStack().splitStack(1), true);

              if (inventoryPlayer.getItemStack().stackSize == 0) {
                inventoryPlayer.setItemStack((ItemStack) null);
              }
            }
          }
        } else if (p_75144_3_ == 1) {
          if (slotIndex < 0) {
            return null;
          }
          slot2 = (Slot) this.inventorySlots.get(slotIndex);

          if (slot2 != null && slot2.canTakeStack(player)) {
            itemstack3 = this.transferStackInSlot(player, slotIndex);

            if (itemstack3 != null) {
              Item item = itemstack3.getItem();
              stack = itemstack3.copy();

              if (slot2.getStack() != null && slot2.getStack().getItem() == item) {
                this.retrySlotClick(slotIndex, p_75144_2_, true, player);
              }
            }
          }
        } else {
          if (slotIndex < 0) {
            return null;
          }
          slot2 = (Slot) this.inventorySlots.get(slotIndex);

          if (slot2 != null) {
            itemstack3 = slot2.getStack();
            ItemStack itemstack4 = inventoryPlayer.getItemStack();

            if (itemstack3 != null) {
              stack = itemstack3.copy();
            }
            if (itemstack3 == null) {
              if (itemstack4 != null && slot2.isItemValid(itemstack4)) {
                l1 = p_75144_2_ == 0 ? itemstack4.stackSize : 1;

                if (l1 > slot2.getSlotStackLimit()) {
                  l1 = slot2.getSlotStackLimit();
                }
                if (itemstack4.stackSize >= l1) {
                  slot2.putStack(itemstack4.splitStack(l1));
                }
                if (itemstack4.stackSize == 0) {
                  inventoryPlayer.setItemStack((ItemStack) null);
                }
              }
            } else if (slot2.canTakeStack(player)) {
              if (itemstack4 == null) {
                l1 = p_75144_2_ == 0 ? itemstack3.stackSize : (itemstack3.stackSize + 1) / 2;
                itemstack5 = slot2.decrStackSize(l1);
                inventoryPlayer.setItemStack(itemstack5);

                if (itemstack3.stackSize == 0) {
                  slot2.putStack((ItemStack) null);
                }
                slot2.onPickupFromSlot(player, inventoryPlayer.getItemStack());
              } else if (slot2.isItemValid(itemstack4)) {
                if (itemstack3.getItem() == itemstack4.getItem() && itemstack3.getItemDamage() == itemstack4.getItemDamage()
                    && ItemStack.areItemStackTagsEqual(itemstack3, itemstack4)) {
                  l1 = p_75144_2_ == 0 ? itemstack4.stackSize : 1;

                  if (l1 > slot2.getSlotStackLimit() - itemstack3.stackSize) {
                    l1 = slot2.getSlotStackLimit() - itemstack3.stackSize;
                  }
                  if (l1 > itemstack4.getMaxStackSize() - itemstack3.stackSize) {
                    l1 = itemstack4.getMaxStackSize() - itemstack3.stackSize;
                  }
                  itemstack4.splitStack(l1);

                  if (itemstack4.stackSize == 0) {
                    inventoryPlayer.setItemStack((ItemStack) null);
                  }
                  itemstack3.stackSize += l1;
                  slot2.putStack(itemstack3);
                } else if (itemstack4.stackSize <= slot2.getSlotStackLimit()) {
                  slot2.putStack(itemstack4);
                  inventoryPlayer.setItemStack(itemstack3);
                }
              } else if (itemstack3.getItem() == itemstack4.getItem() && itemstack4.getMaxStackSize() > 1
                  && (!itemstack3.getHasSubtypes() || itemstack3.getItemDamage() == itemstack4.getItemDamage())
                  && ItemStack.areItemStackTagsEqual(itemstack3, itemstack4)) {
                l1 = itemstack3.stackSize;

                if (l1 > 0 && l1 + itemstack4.stackSize <= itemstack4.getMaxStackSize()) {
                  itemstack4.stackSize += l1;
                  itemstack3 = slot2.decrStackSize(l1);

                  if (itemstack3.stackSize == 0) {
                    slot2.putStack((ItemStack) null);
                  }
                  slot2.onPickupFromSlot(player, inventoryPlayer.getItemStack());
                }
              }
            }
            slot2.onSlotChanged();
          }
        }
      } else if (p_75144_3_ == 2 && p_75144_2_ >= 0 && p_75144_2_ < 9) {
        slot2 = (Slot) this.inventorySlots.get(slotIndex);

        if (slot2.canTakeStack(player)) {
          itemstack3 = inventoryPlayer.getStackInSlot(p_75144_2_);
          boolean flag = itemstack3 == null || slot2.inventory == inventoryPlayer && slot2.isItemValid(itemstack3);
          l1 = -1;

          if (!flag) {
            l1 = inventoryPlayer.getFirstEmptyStack();
            flag |= l1 > -1;
          }
          if (slot2.getHasStack() && flag) {
            itemstack5 = slot2.getStack();
            inventoryPlayer.setInventorySlotContents(p_75144_2_, itemstack5.copy());

            if ((slot2.inventory != inventoryPlayer || !slot2.isItemValid(itemstack3)) && itemstack3 != null) {
              if (l1 > -1) {
                inventoryPlayer.addItemStackToInventory(itemstack3);
                slot2.decrStackSize(itemstack5.stackSize);
                slot2.putStack((ItemStack) null);
                slot2.onPickupFromSlot(player, itemstack5);
              }
            } else {
              slot2.decrStackSize(itemstack5.stackSize);
              slot2.putStack(itemstack3);
              slot2.onPickupFromSlot(player, itemstack5);
            }
          } else if (!slot2.getHasStack() && itemstack3 != null && slot2.isItemValid(itemstack3)) {
            inventoryPlayer.setInventorySlotContents(p_75144_2_, (ItemStack) null);
            slot2.putStack(itemstack3);
          }
        }
      } else if (p_75144_3_ == 3 && player.capabilities.isCreativeMode && inventoryPlayer.getItemStack() == null && slotIndex >= 0) {
        slot2 = (Slot) this.inventorySlots.get(slotIndex);

        if (slot2 != null && slot2.getHasStack()) {
          itemstack3 = slot2.getStack().copy();
          itemstack3.stackSize = itemstack3.getMaxStackSize();
          inventoryPlayer.setItemStack(itemstack3);
        }
      } else if (p_75144_3_ == 4 && inventoryPlayer.getItemStack() == null && slotIndex >= 0) {
        slot2 = (Slot) this.inventorySlots.get(slotIndex);

        if (slot2 != null && slot2.getHasStack() && slot2.canTakeStack(player)) {
          itemstack3 = slot2.decrStackSize(p_75144_2_ == 0 ? 1 : slot2.getStack().stackSize);
          slot2.onPickupFromSlot(player, itemstack3);
          player.dropPlayerItemWithRandomChoice(itemstack3, true);
        }
      } else if (p_75144_3_ == 6 && slotIndex >= 0) {
        slot2 = (Slot) this.inventorySlots.get(slotIndex);
        itemstack3 = inventoryPlayer.getItemStack();

        if (itemstack3 != null && (slot2 == null || !slot2.getHasStack() || !slot2.canTakeStack(player))) {
          i1 = p_75144_2_ == 0 ? 0 : this.inventorySlots.size() - 1;
          l1 = p_75144_2_ == 0 ? 1 : -1;
View Full Code Here

Examples of net.minecraft.entity.player.InventoryPlayer

    return false;
  }

  public boolean doesRecipeExist(ICraftingPatternMAC pattern)
  {
    InventoryCrafting inv = new InventoryCrafting(new ContainerWorkbench(new InventoryPlayer(null), gridTE.getWorld(), 0, 0, 0)
    {
      public void onCraftMatrixChanged(IInventory par1IInventory)
      {
      }
    }, 3, 3);
View Full Code Here

Examples of net.minecraft.entity.player.InventoryPlayer

      {
        slot.putStack(null);
      }
    } else if (mouseButton == 0 || mouseButton == 1)
    {
      InventoryPlayer playerInv = player.inventory;
      slot.onSlotChanged();
      ItemStack stackSlot = slot.getStack();
      ItemStack stackHeld = playerInv.getItemStack();

      if (stackSlot != null)
      {
        stack = stackSlot.copy();
      }

      if (stackSlot == null)
      {
        if (stackHeld != null && slot.isItemValid(stackHeld))
        {
          fillPhantomSlot(slot, stackHeld, mouseButton, modifier);
        }
      } else if (stackHeld == null)
      {
        adjustPhantomSlot(slot, mouseButton, modifier);
        slot.onPickupFromSlot(player, playerInv.getItemStack());
      } else if (slot.isItemValid(stackHeld))
      {
        if (canStacksMerge(stackSlot, stackHeld))
        {
          adjustPhantomSlot(slot, mouseButton, modifier);
View Full Code Here

Examples of net.minecraft.entity.player.InventoryPlayer

      Slot slot = slotID < 0 ? null : getSlot( slotID );

      ItemStack stackInSlot;
      ItemStack playerStack;

      InventoryPlayer inventoryPlayer = player.inventory;

      switch( specialCase ) {
        case 1: // clicking on the crafting grid slots:
          if( flag == 1 ) { // clear on shift-clicking.
            slot.putStack( null );
            return null;
          }

          playerStack = inventoryPlayer.getItemStack();

          if( buttonPressed == 0 || playerStack == null ) {
            slot.putStack( null );

          } else if( buttonPressed == 1 ) {
            ItemStack copy = playerStack.copy();
            copy.stackSize = 1;
            slot.putStack( copy );
          }
          return null;

        case 2: // interacting with the hotkeys:
          ItemStack invStack = inventoryPlayer.getStackInSlot( buttonPressed );
          if( invStack != null ) {
            ItemStack copy = invStack.copy();
            copy.stackSize = 1;
            slot.putStack( copy );
          }
          return invStack;

        case 4: // pressing the DROP key.
          stackInSlot = slot.getStack();
          slot.putStack( null );
          return stackInSlot;

        case 5: // placing the dragged stuff.
          handleDragging( slotID, buttonPressed, player.inventory );

          this.detectAndSendChanges();
          break;

        case 6: // double click (clears the crafting grid).
          clearCraftingGrid();
          this.detectAndSendChanges();
          return null;

        case 10: // redirect the right click into a left click.
          return slotClick( slotID, 0, flag, player );

        case 11: // regular clicking on an output slot.

          if( !slot.getHasStack() || !slot.canTakeStack( player ) )
            return null;

          stackInSlot = ((SlotCraft) slot).getCraftedStack();
          playerStack = inventoryPlayer.getItemStack();

          if( playerStack == null ) { // Full extraction from slot.
            inventoryPlayer.setItemStack( stackInSlot );
            slot.onPickupFromSlot( player, inventoryPlayer.getItemStack() );
          } else {
            int sum = stackInSlot.stackSize + playerStack.stackSize;

            // Merge into player's hand.
            if( Utils.equalsStacks( stackInSlot, playerStack ) && sum <= stackInSlot.getMaxStackSize() ) {
              playerStack.stackSize = sum;
              slot.onPickupFromSlot( player, inventoryPlayer.getItemStack() );
            }
          }
          slot.onSlotChanged();
          return stackInSlot;

        case 12: // interacting with the hotkeys
          if( !slot.canTakeStack( player ) )
            return null;
          stackInSlot = ((SlotCraft) slot).getCraftedStack();

          if( stackInSlot == null )
          return null;

          playerStack = inventoryPlayer.getStackInSlot( buttonPressed );
          if( playerStack == null ) {
            inventoryPlayer.setInventorySlotContents( buttonPressed, stackInSlot );
            slot.onPickupFromSlot( player, stackInSlot );
          } else {
            int indx = inventoryPlayer.getFirstEmptyStack();
            if( indx > -1 ) {
              inventoryPlayer.setInventorySlotContents( buttonPressed, stackInSlot );
              inventoryPlayer.addItemStackToInventory( playerStack );
              slot.onPickupFromSlot( player, stackInSlot );
            }
          }
          return stackInSlot;
View Full Code Here

Examples of net.minecraft.entity.player.InventoryPlayer

          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) {
View Full Code Here

Examples of net.minecraft.entity.player.InventoryPlayer

    public EntityPlayer player;

    public ContainerCreativeInv(EntityPlayer player, ExtendedCreativeInv extraInv) {
        this.player = player;
        InventoryPlayer invPlayer = player.inventory;
        for (int row = 0; row < 6; row++)
            for (int col = 0; col < 9; col++)
                addSlotToContainer(new Slot(extraInv, col + row * 9, 8 + col * 18, 5 + row * 18));

        for (int row = 0; row < 3; ++row)
            for (int col = 0; col < 9; ++col)
                addSlotToContainer(new Slot(invPlayer, col + row * 9 + 9, 8 + col * 18, 118 + row * 18));

        for (int col = 0; col < 9; ++col)
            addSlotToContainer(new Slot(invPlayer, col, 8 + col * 18, 176));

        addSlotToContainer(new SlotBlockArmor(invPlayer, invPlayer.getSizeInventory() - 1, -15, 23, 0));
        for (int armorType = 1; armorType < 4; armorType++)
            addSlotToContainer(new SlotArmor(invPlayer, invPlayer.getSizeInventory() - 1 - armorType, -15, 23 + armorType * 18, armorType));
    }
View Full Code Here

Examples of net.minecraft.entity.player.InventoryPlayer

        new PacketCustom(NEISPH.channel, 14).writeByte(mode).sendToPlayer(player);
        player.addChatMessage(new ChatComponentTranslation("nei.chat.gamemode." + mode));
    }

    public static void cycleCreativeInv(EntityPlayerMP player, int steps) {
        InventoryPlayer inventory = player.inventory;

        //top down [row][col]
        ItemStack[][] slots = new ItemStack[10][9];
        PlayerSave playerSave = NEIServerConfig.forPlayer(player.getCommandSenderName());
View Full Code Here

Examples of net.minecraft.entity.player.InventoryPlayer

  }
   
  public void craftDriveable(EntityPlayer player, DriveableType type)
  {
    //Create a temporary copy of the player inventory for backup purposes
    InventoryPlayer temporaryInventory = new InventoryPlayer(null);
    temporaryInventory.copyInventory(player.inventory);
   
    //This becomes false if some recipe element is not found on the player
    boolean canCraft = true;
    //Iterate over rows then columns
    for(ItemStack recipeStack : type.recipe)
    {
      //The total amount of items found that match this recipe stack
      int totalAmountFound = 0;
      //Iterate over the player's inventory
      for(int n = 0; n < player.inventory.getSizeInventory(); n++)
      {
        //Get the stack in each slot
        ItemStack stackInSlot = player.inventory.getStackInSlot(n);
        //If the stack is what we want
        if(stackInSlot != null && stackInSlot.getItem() == recipeStack.getItem() && stackInSlot.getItemDamage() == recipeStack.getItemDamage())
        {
          //Work out the amount to take from the stack
          int amountFound = Math.min(stackInSlot.stackSize, recipeStack.stackSize - totalAmountFound);
          //Take it
          stackInSlot.stackSize -= amountFound;
          //Check for empty stacks
          if(stackInSlot.stackSize <= 0)
            stackInSlot = null;
          //Put the modified stack back in the inventory
          player.inventory.setInventorySlotContents(n, stackInSlot);
          //Increase the amount found counter
          totalAmountFound += amountFound;
          //If we have enough, stop looking
          if(totalAmountFound == recipeStack.stackSize)
            break;
        }
      }
      //If we didn't find enough, give the stack a red outline
      if(totalAmountFound < recipeStack.stackSize)
      {
        //For some reason, the player sent a craft packet, despite being unable to
        canCraft = false;
        break;
      }
    }
   
    //Some item was missing. Restore inventory and return
    if(!canCraft)
    {
      player.inventory.copyInventory(temporaryInventory);
      return;
    }
   
    //Now we no longer need the temporary inventory backup, so we will use it to find the best stack of engines   
    //Collect up all the engines into neat and tidy stacks so we can find if any of them are big enough and which of those stacks are best
    HashMap<PartType, ItemStack> engines = new HashMap<PartType, ItemStack>();
   
    //Find some suitable engines
    for(int n = 0; n < temporaryInventory.getSizeInventory(); n++)
    {
      //Get the stack in each slot
      ItemStack stackInSlot = temporaryInventory.getStackInSlot(n);
      //Check to see if its a part
      if(stackInSlot != null && stackInSlot.getItem() instanceof ItemPart)
      {
        PartType partType = ((ItemPart)stackInSlot.getItem()).type;
        //Check its an engine
View Full Code Here

Examples of net.minecraft.entity.player.InventoryPlayer

      if(!driving.isPartIntact(parent))
        return;
    }
   
    //Create a temporary copy of the player inventory for backup purposes
    InventoryPlayer temporaryInventory = new InventoryPlayer(null);
    temporaryInventory.copyInventory(driver.inventory);
   
    //This becomes false if some recipe element is not found on the player
    boolean canRepair = true;
   
    //Get the array of stacks needed
    ArrayList<ItemStack> stacksNeeded = driving.getDriveableType().getItemsRequired(part, driving.getDriveableData().engine);
    //Draw the stacks that should be in each slot
    for(ItemStack stackNeeded : stacksNeeded)
    {
      //The total amount of items found that match this recipe stack
      int totalAmountFound = 0;
      //Iterate over the temporary inventory
      for(int m = 0; m < temporaryInventory.getSizeInventory(); m++)
      {
        //Get the stack in each slot
        ItemStack stackInSlot = temporaryInventory.getStackInSlot(m);
        //If the stack is what we want
        if(stackInSlot != null && stackInSlot.getItem() == stackNeeded.getItem() && stackInSlot.getItemDamage() == stackNeeded.getItemDamage())
        {
          //Work out the amount to take from the stack
          int amountFound = Math.min(stackInSlot.stackSize, stackNeeded.stackSize - totalAmountFound);
          //Take it
          stackInSlot.stackSize -= amountFound;
          //Check for empty stacks
          if(stackInSlot.stackSize <= 0)
            stackInSlot = null;
          //Put the modified stack back in the inventory
          temporaryInventory.setInventorySlotContents(m, stackInSlot);
          //Increase the amount found counter
          totalAmountFound += amountFound;
          //If we have enough, stop looking
          if(totalAmountFound == stackNeeded.stackSize)
            break;
View Full Code Here

Examples of net.minecraft.entity.player.InventoryPlayer

     
      //If the part is damaged, draw the parts required to fix it
      if(broken)
      {
        //Create a temporary copy of the player inventory in order to work out whether the player has each of the itemstacks required
        InventoryPlayer temporaryInventory = new InventoryPlayer(null);
        temporaryInventory.copyInventory(driver.inventory);
       
        ArrayList<ItemStack> stacksNeeded = driving.getDriveableType().getItemsRequired(part, driving.getDriveableData().engine);
        //Draw the stacks that should be in each slot
        for(int n = 0; n < 7; n++)
        {
          //If there are more than 7 stacks, loop over them
          int stackNum = n + (FlansMod.ticker / 60) % Math.max(1, stacksNeeded.size() - 6);
          //If this is a valid stack
          if(stackNum < stacksNeeded.size())
          {
            //Get the item stack we need
            ItemStack stackNeeded = stacksNeeded.get(stackNum);
            //The total amount of items found that match this recipe stack
            int totalAmountFound = 0;
            //Iterate over the temporary inventory
            for(int m = 0; m < temporaryInventory.getSizeInventory(); m++)
            {
              //Get the stack in each slot
              ItemStack stackInSlot = temporaryInventory.getStackInSlot(m);
              //If the stack is what we want
              if(stackInSlot != null && stackInSlot.getItem() == stackNeeded.getItem() && stackInSlot.getItemDamage() == stackNeeded.getItemDamage())
              {
                //Work out the amount to take from the stack
                int amountFound = Math.min(stackInSlot.stackSize, stackNeeded.stackSize - totalAmountFound);
                //Take it
                stackInSlot.stackSize -= amountFound;
                //Check for empty stacks
                if(stackInSlot.stackSize <= 0)
                  stackInSlot = null;
                //Put the modified stack back in the inventory
                temporaryInventory.setInventorySlotContents(m, stackInSlot);
                //Increase the amount found counter
                totalAmountFound += amountFound;
                //If we have enough, stop looking
                if(totalAmountFound == stackNeeded.stackSize)
                  break;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.