@Override
  public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
    // we always want to shiftclick the output into a pattern chest if present
    // note that we leave out a few checks/callbacks because we rely on how the stenciltable works
    if (index != 1) {
      return super.transferStackInSlot(playerIn, index);
    }

    Slot slot = (Slot) this.inventorySlots.get(index);
    if (slot == null || !slot.getHasStack()) {
      return null;
    }

    ItemStack itemstack = slot.getStack().copy();
    ItemStack ret = slot.getStack().copy();

    if (patternChestSideInventory != null) {
      if (moveToContainer(itemstack, patternChestSideInventory)) {
        return null;
      }

      return notifySlotAfterTransfer(playerIn, itemstack, ret, slot);
    }

    return super.transferStackInSlot(playerIn, index);
  }
  @Override
  public void onUpdate(ItemStack itemStack, World world, Entity entity, int par4, boolean par5) {
    if (!world.isRemote) {
      if (this.isAbsorbingFocillium) {
        if (getForceciumlevel(itemStack) < getMaxForceciumlevel()) {
          if ((entity instanceof EntityPlayer)) {
            List<Slot> slots = ((EntityPlayer) entity).inventoryContainer.inventorySlots;
            for (Slot slot : slots) {
              if ((slot.getStack() != null)
                  && (slot.getStack().getItem() == ModularForceFieldSystem.itemForcicium)) {
                setForceciumlevel(itemStack, getForceciumlevel(itemStack) + 1);

                if (slot.getStack().stackSize > 1) {
                  ItemStack forcecium =
                      new ItemStack(
                          ModularForceFieldSystem.itemForcicium, slot.getStack().stackSize - 1);
                  slot.putStack(forcecium);
                  break;
                }
                slot.putStack(null);

                break;
              }
            }
          }
        }

        itemStack.setItemDamage(getItemDamage(itemStack));
      }
    }
  }
Example #3
0
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int clickedIndex) {
    ItemStack returnedStack = null;
    Slot clickedSlot = (Slot) this.inventorySlots.get(clickedIndex);

    if (clickedSlot != null
        && clickedSlot.getHasStack()
        && (clickedSlot.getStack().getItem() instanceof IFood
            || clickedSlot.getStack().itemID == Item.bowlEmpty.itemID)) {
      ItemStack clickedStack = clickedSlot.getStack();
      returnedStack = clickedStack.copy();

      if (clickedIndex < 6) {
        if (!this.mergeItemStack(clickedStack, 6, inventorySlots.size(), true)) return null;
      } else if (clickedIndex >= 6 && clickedIndex < inventorySlots.size()) {
        if (!this.mergeItemStack(clickedStack, 0, 6, false)) return null;
      } else if (!this.mergeItemStack(clickedStack, 6, inventorySlots.size(), false)) return null;

      if (clickedStack.stackSize == 0) clickedSlot.putStack((ItemStack) null);
      else clickedSlot.onSlotChanged();

      if (clickedStack.stackSize == returnedStack.stackSize) return null;
      clickedSlot.onPickupFromSlot(player, clickedStack);
    }
    return returnedStack;
  }
 public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
   Slot slot = getSlot(par2);
   if (slot != null && slot.getHasStack()) {
     ItemStack stack = slot.getStack().copy();
     if (par2 == 0) {
       if (!mergeItemStack(slot.getStack(), 9, this.inventorySlots.size(), true)) {
         return null;
       } else {
         if (slot.getStack().stackSize == 0) {
           putStackInSlot(par2, null);
         } else {
           slot.onSlotChanged();
         }
         return stack;
       }
     } else if (par2 >= 9) {
       if (!mergeItemStack(slot.getStack(), 0, 1, true)) {
         return null;
       } else {
         if (slot.getStack().stackSize == 0) {
           slot.putStack(null);
         } else {
           slot.onSlotChanged();
         }
         return stack;
       }
     }
   }
   return null;
 }
  /** Updates the slots to reflect the stored patterns. */
  private void updatePatternSlots() {
    Iterator<ItemStack> iterator = null;

    // Get the list of stored pattern results
    if (this.kCoreHandler.hasCore()) {
      ArrayList<ItemStack> storedResults = this.kCoreHandler.getStoredOutputs();
      iterator = storedResults.iterator();
    }

    // Loop over all pattern slots
    for (Slot patternSlot : this.patternSlots) {
      // Is there an itemstack to put?
      if ((iterator != null) && (iterator.hasNext())) {
        // Put the result
        patternSlot.putStack(iterator.next());
      } else {
        // Clear the slot
        patternSlot.putStack(null);
      }

      // Update clients with change
      for (int cIndex = 0; cIndex < this.crafters.size(); ++cIndex) {
        ((ICrafting) this.crafters.get(cIndex))
            .sendSlotContents(this, patternSlot.slotNumber, patternSlot.getStack());
      }
    }
  }
  public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
    ItemStack stack = null;
    Slot slot = (Slot) this.inventorySlots.get(slotID);

    if (slot != null && slot.getHasStack()) {
      ItemStack slotStack = slot.getStack();
      stack = slotStack.copy();

      if (slotID < logic.getSizeInventory()) {
        if (!this.mergeItemStack(
            slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true)) {
          return null;
        }
      } else if (!this.mergeItemStack(slotStack, 0, logic.getSizeInventory(), false)) {
        return null;
      }

      if (slotStack.stackSize == 0) {
        slot.putStack((ItemStack) null);
      } else {
        slot.onSlotChanged();
      }
    }

    return stack;
  }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
    ItemStack stack = null;
    Slot slotObject = (Slot) inventorySlots.get(slot);
    int machInvSize = _ncw.getSizeInventory();

    if (slotObject != null && slotObject.getHasStack()) {
      ItemStack stackInSlot = slotObject.getStack();
      stack = stackInSlot.copy();

      if (slot < machInvSize) {
        if (!mergeItemStack(stackInSlot, machInvSize, inventorySlots.size(), true)) {
          return null;
        }
      } else if (!mergeItemStack(stackInSlot, 0, machInvSize, false)) {
        return null;
      }

      if (stackInSlot.stackSize == 0) {
        slotObject.putStack(null);
      } else {
        slotObject.onSlotChanged();
      }

      if (stackInSlot.stackSize == stack.stackSize) {
        return null;
      }

      slotObject.onPickupFromSlot(player, stackInSlot);
    }

    return stack;
  }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slot) {
    Slot slotObject = (Slot) inventorySlots.get(slot);
    if (slotObject != null && slotObject.getHasStack()) {
      ItemStack stackInSlot = slotObject.getStack();
      ItemStack stack = stackInSlot.copy();
      if (slot >= 0 && slot < kDecomposerInventoryEnd) {
        if (!mergeItemStack(stackInSlot, kPlayerInventorySlotStart, inventorySlots.size(), true))
          return null;
      } else if (stackInSlot.itemID == MinechemItems.testTube.itemID) {
        if (!mergeItemStack(
            stackInSlot,
            decomposer.kEmptyTestTubeSlotStart,
            decomposer.kEmptyTestTubeSlotEnd + 1,
            false)) return null;
      } else if (slot >= kPlayerInventorySlotStart) {
        if (!mergeItemStack(stackInSlot, decomposer.kInputSlot, decomposer.kInputSlot + 1, false))
          return null;
      } else if (!mergeItemStack(
          stackInSlot, kPlayerInventorySlotStart, inventorySlots.size(), true)) return null;

      if (stackInSlot.stackSize == 0) slotObject.putStack(null);
      else slotObject.onSlotChanged();

      return stack;
    }
    return null;
  }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotNum) {
    ItemStack itemCopy = null;
    Slot slot = (Slot) this.inventorySlots.get(slotNum);

    if (slot != null && slot.getHasStack()) {
      ItemStack item = slot.getStack();
      itemCopy = item.copy();

      if (slotNum < 9) {
        if (!this.mergeItemStack(item, 9, this.inventorySlots.size(), true)) {
          return null;
        }
      } else if (!this.mergeItemStack(item, 0, 9, false)) {
        return null;
      }

      if (item.stackSize == 0) {
        slot.putStack((ItemStack) null);
      } else {
        slot.onSlotChanged();
      }
    }

    return itemCopy;
  }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int slot_index) {
    ItemStack stack = null;
    Slot slot_object = (Slot) inventorySlots.get(slot_index);

    if (slot_object != null && slot_object.getHasStack()) {
      ItemStack stack_in_slot = slot_object.getStack();
      stack = stack_in_slot.copy();

      if (slot_index == 0) {
        if (!mergeItemStack(stack_in_slot, 1, inventorySlots.size(), true)) {
          return null;
        }
      } else if (!mergeItemStack(stack_in_slot, 0, 1, false)) {
        return null;
      }

      if (stack_in_slot.stackSize == 0) {
        slot_object.putStack(null);
      } else {
        slot_object.onSlotChanged();
      }
    }

    return stack;
  }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
    ItemStack stack = null;
    Slot slot = (Slot) inventorySlots.get(slotID);

    // null checks and checks if the item can be stacked (maxStackSize > 1)
    if (slot != null && slot.getHasStack()) {
      ItemStack stackInSlot = slot.getStack();
      stack = stackInSlot.copy();

      // merges the item into player inventory since its in the tileEntity
      if (slotID < tileEntity.getSizeInventory()) {
        if (!this.mergeItemStack(
            stackInSlot, tileEntity.getSizeInventory(), this.inventorySlots.size(), true)) {
          return null;
        }
      }
      // merge into tileEntity inventory, since it is in player's inventory
      else if (!this.mergeItemStack(stackInSlot, 0, tileEntity.getSizeInventory(), false)) {
        return null;
      }

      if (stackInSlot.stackSize == 0) {
        slot.putStack(null);
      } else {
        slot.onSlotChanged();
      }
    }
    return stack;
  }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
    ItemStack var3 = null;
    Slot var4 = (Slot) this.inventorySlots.get(par2);

    if (var4 != null && var4.getHasStack()) {
      ItemStack var5 = var4.getStack();
      var3 = var5.copy();

      if (par2 == 2) {
        if (!this.mergeItemStack(var5, 3, 39, true)) return null;

        var4.onSlotChange(var5, var3);
      } else if (par2 != 0 && par2 != 1) {
        if (par2 >= 3 && par2 < 30) {
          if (!this.mergeItemStack(var5, 30, 39, false)) return null;
        } else if (par2 >= 30 && par2 < 39 && !this.mergeItemStack(var5, 3, 30, false)) return null;
      } else if (!this.mergeItemStack(var5, 3, 39, false)) return null;

      if (var5.stackSize == 0) {
        var4.putStack((ItemStack) null);
      } else {
        var4.onSlotChanged();
      }

      if (var5.stackSize == var3.stackSize) return null;

      var4.onPickupFromSlot(par1EntityPlayer, var5);
    }

    return var3;
  }
Example #13
0
 public ItemStack getStackInSlot(int i) {
   ItemStack itemstack = null;
   Slot slot = (Slot) this.inventorySlots.get(i);
   if (slot != null && slot.getHasStack()) {
     ItemStack itemstack1 = slot.getStack();
     itemstack = itemstack1.copy();
     if (i == 0) {
       this.mergeItemStack(itemstack1, 9, 45, true);
     } else if (i >= 9 && i < 36) {
       this.mergeItemStack(itemstack1, 36, 45, false);
     } else if (i >= 36 && i < 45) {
       this.mergeItemStack(itemstack1, 9, 36, false);
     } else {
       this.mergeItemStack(itemstack1, 9, 45, false);
     }
     if (itemstack1.stackSize == 0) {
       slot.putStack(null);
     } else {
       slot.onSlotChanged();
     }
     if (itemstack1.stackSize != itemstack.stackSize) {
       slot.onPickupFromSlot(
           null, // Entityplayer
           itemstack1);
     } else {
       return null;
     }
   }
   return itemstack;
 }
Example #14
0
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
    if (slotIndex == 0) {
      return null;
    }

    Slot slot = this.getSlot(slotIndex);

    if (slot == null || !slot.getHasStack()) {
      return null;
    }

    ItemStack stack = slot.getStack();
    ItemStack newStack = stack.copy();

    if (slotIndex <= 91) {
      if (!this.mergeItemStack(stack, 92, 127, false)) {
        return null;
      }
    } else if (!EMCHelper.doesItemHaveEmc(stack) || !this.mergeItemStack(stack, 1, 91, false)) {
      return null;
    }

    if (stack.stackSize == 0) {
      slot.putStack(null);
    } else slot.onSlotChanged();
    slot.onPickupFromSlot(player, stack);
    return newStack;
  }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int id) {
    ItemStack stack = null;
    Slot slot = (Slot) this.inventorySlots.get(id);

    if (slot != null && slot.getHasStack()) {
      ItemStack stack1 = slot.getStack();
      stack = stack1.copy();

      ItemMatterUnit unit = ModuleCrafting.matterUnit;

      if (id < 4) { // tileInv->playerInv
        if (!this.mergeItemStack(stack1, 4, this.inventorySlots.size(), true)) return null;
      } else {
        // playerInv->tileInv
        if (unit.getMaterial(stack) == ModuleCrafting.imagPhase.mat) {
          if (!this.mergeItemStack(stack1, 2, 3, false)) return null;
        } else if (IFItemManager.instance.isSupported(stack)) {
          if (!this.mergeItemStack(stack1, 3, 4, false)) return null;
        } else {
          if (!this.mergeItemStack(stack1, 0, 1, false)) return null;
        }
      }

      if (stack1.stackSize == 0) {
        slot.putStack((ItemStack) null);
      } else {
        slot.onSlotChanged();
      }
    }

    return stack;
  }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
    ItemStack itemstack = null;
    Slot slot = this.inventorySlots.get(slotID);

    if (slot != null && slot.getHasStack()) {
      ItemStack itemstack1 = slot.getStack();
      itemstack = itemstack1.copy();

      if (slotID == 2) {
        if (!this.mergeItemStack(itemstack1, 3, 39, true)) return null;

        slot.onSlotChange(itemstack1, itemstack);
      } else if (slotID != 1 && slotID != 0) {
        if (TileScribe.isValidForScribe(itemstack1)) {
          if (!this.mergeItemStack(itemstack1, 0, 1, false)) return null;
        } else if (TileScribe.isBook(itemstack1)) {
          if (!this.mergeItemStack(itemstack1, 1, 2, false)) return null;
        } else if (slotID >= 3 && slotID < 30) {
          if (!this.mergeItemStack(itemstack1, 30, 39, false)) return null;
        } else if (slotID >= 30 && slotID < 39 && !this.mergeItemStack(itemstack1, 3, 30, false))
          return null;
      } else if (!this.mergeItemStack(itemstack1, 3, 39, false)) return null;

      if (itemstack1.stackSize == 0) slot.putStack((ItemStack) null);
      else slot.onSlotChanged();

      if (itemstack1.stackSize == itemstack.stackSize) return null;

      slot.onPickupFromSlot(player, itemstack1);
    }

    return itemstack;
  }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
    ItemStack var3 = null;
    final Slot var4 = (Slot) this.inventorySlots.get(par2);

    if (var4 != null && var4.getHasStack()) {
      final ItemStack var5 = var4.getStack();
      var3 = var5.copy();

      if (par2 < 27) {
        if (!this.mergeItemStack(var5, 27, this.inventorySlots.size(), true)) {
          return null;
        }
      } else if (!this.mergeItemStack(var5, 0, 27, false)) {
        return null;
      }

      if (var5.stackSize == 0) {
        var4.putStack((ItemStack) null);
      } else {
        var4.onSlotChanged();
      }
    }

    return var3;
  }
Example #18
0
  public ItemStack handle(EntityPlayer player, int mouseButton, Slot slot) {
    if (mouseButton > 0) {
      slot.putStack(null);
    } else if (mouseButton == 0) {
      ItemStack stack;
      InventoryPlayer playerInv = player.inventory;
      slot.onSlotChanged();
      ItemStack stackSlot = slot.getStack();
      ItemStack stackHeld = playerInv.getItemStack();

      if (stackSlot == null && stackHeld != null && slot.slotNumber != 22) {
        if (isItemValid(stackHeld)) {
          ItemStack copy = stackHeld.copy();
          copy.stackSize = 1;
          slot.putStack(copy);
        }
      }

      if (stackHeld == null) {
        if (tile instanceof TileFishSorter) {
          ((TileFishSorter) tile).swapSide(slot.slotNumber);
        }
      }
    }

    return null;
  }
Example #19
0
  @Override
  public List<String> getTooltip(PC_Vec2I position) {

    Slot slot = getSlotAtPosition(position);
    if (slot != null) {
      ItemStack itemstack = null;

      if (slot.getHasStack()) itemstack = slot.getStack();

      // if (slot instanceof PC_Slot && ((PC_Slot) slot).getBackgroundStack() != null && ((PC_Slot)
      // slot).renderTooltipWhenEmpty())
      // itemstack = ((PC_Slot) slot).getBackgroundStack();

      if (itemstack != null) {
        @SuppressWarnings("unchecked")
        List<String> l =
            itemstack.getTooltip(
                PC_ClientUtils.mc().thePlayer,
                PC_ClientUtils.mc().gameSettings.advancedItemTooltips);

        for (int k = 0; k < l.size(); ++k) {
          if (k == 0) {
            l.set(k, itemstack.getRarity().rarityColor + l.get(k));
          } else {
            l.set(k, EnumChatFormatting.GRAY + l.get(k));
          }
        }
        return l;
      }
    }
    return super.getTooltip(position);
  }
 private ItemStack slotClickPhantom(
     Slot slot, int mouseButton, int modifier, EntityPlayer player) {
   ItemStack stack = null;
   if (mouseButton == 2) {
     if (((IPhantomSlot) slot).canAdjust()) 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);
     } else if (stackHeld == null) {
       adjustPhantomSlot(slot, mouseButton, modifier);
       slot.onPickupFromSlot(player, playerInv.getItemStack());
     } else if (slot.isItemValid(stackHeld)) {
       if (ItemUtil.canStacksMerge(stackSlot, stackHeld))
         adjustPhantomSlot(slot, mouseButton, modifier);
       else fillPhantomSlot(slot, stackHeld, mouseButton);
     }
   }
   return stack;
 }
Example #21
0
 @Override
 public ItemStack transferStackInSlot(EntityPlayer entityplayer, int i) {
   ItemStack itemstack = null;
   Slot slot = (Slot) inventorySlots.get(i);
   if (slot != null && slot.getHasStack()) {
     ItemStack itemstack1 = slot.getStack();
     itemstack = itemstack1.copy();
     if (i == 0) {
       if (!mergeItemStack(itemstack1, 10, 46, true)) {
         return null;
       }
     } else if (i >= 10 && i < 37) {
       if (!mergeItemStack(itemstack1, 37, 46, false)) {
         return null;
       }
     } else if (i >= 37 && i < 46) {
       if (!mergeItemStack(itemstack1, 10, 37, false)) {
         return null;
       }
     } else if (!mergeItemStack(itemstack1, 10, 46, false)) {
       return null;
     }
     if (itemstack1.stackSize == 0) {
       slot.putStack(null);
     } else {
       slot.onSlotChanged();
     }
     if (itemstack1.stackSize != itemstack.stackSize) {
       slot.onPickupFromSlot(entityplayer, itemstack1);
     } else {
       return null;
     }
   }
   return itemstack;
 }
 @Override
 public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
   ItemStack result = null;
   Slot slot = getSlot(slotIndex);
   if (slot != null && slot.getHasStack()) {
     ItemStack stack = slot.getStack();
     result = stack.copy();
     if (slotIndex == 1) {
       if (!mergeItemStack(stack, 2, 38, true)) return null;
       slot.onSlotChange(stack, result);
     } else if (slotIndex != 0) {
       if (FurnaceRecipes.smelting().getSmeltingResult(stack) != null) {
         if (!this.mergeItemStack(stack, 0, 1, false)) return null;
       } else if (slotIndex >= 2 && slotIndex < 29) {
         if (!this.mergeItemStack(stack, 29, 38, false)) return null;
       } else if (slotIndex >= 29 && slotIndex < 38) {
         if (!this.mergeItemStack(stack, 2, 29, false)) return null;
       }
     } else if (!this.mergeItemStack(stack, 2, 38, false)) return null;
     if (stack.stackSize <= 0) slot.putStack(null);
     else slot.onSlotChanged();
     if (stack.stackSize == result.stackSize) return null;
     slot.onPickupFromSlot(player, stack);
   }
   return result;
 }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) {
    ItemStack newItemStack = null;
    Slot slot = (Slot) inventorySlots.get(slotIndex);

    if (slot != null && slot.getHasStack()) {
      ItemStack itemStack = slot.getStack();
      newItemStack = itemStack.copy();

      if (slotIndex < chestInventoryRows * chestInventoryColumns) {
        if (!this.mergeItemStack(
            itemStack, chestInventoryRows * chestInventoryColumns, inventorySlots.size(), false)) {
          return null;
        }
      } else if (!this.mergeItemStack(
          itemStack, 0, chestInventoryRows * chestInventoryColumns, false)) {
        return null;
      }

      if (itemStack.stackSize == 0) {
        slot.putStack(null);
      } else {
        slot.onSlotChanged();
      }
    }

    return newItemStack;
  }
  /**
   * Called when a player shift-clicks on a slot. You must override this or you will crash when
   * someone does that.
   */
  public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
    ItemStack itemstack = null;
    Slot slot = (Slot) this.inventorySlots.get(par2);

    if (slot != null && slot.getHasStack()) {
      ItemStack itemstack1 = slot.getStack();
      itemstack = itemstack1.copy();

      if (par2 < this.numRows * 9) {
        if (!this.mergeItemStack(itemstack1, this.numRows * 9, this.inventorySlots.size(), true)) {
          return null;
        }
      } else if (!this.mergeItemStack(itemstack1, 0, this.numRows * 9, false)) {
        return null;
      }

      if (itemstack1.stackSize == 0) {
        slot.putStack((ItemStack) null);
      } else {
        slot.onSlotChanged();
      }
    }

    return itemstack;
  }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
    ItemStack itemstack = null;
    Slot slot = (Slot) inventorySlots.get(slotIndex);

    if (slot != null && slot.getHasStack()) {
      ItemStack itemstack1 = slot.getStack();
      itemstack = itemstack1.copy();

      if ((slotIndex < 0 || slotIndex > 2) && slotIndex != 3) {
        if (!ingredientSlot.getHasStack() && ingredientSlot.isItemValid(itemstack1)) {
          if (!mergeItemStack(itemstack1, 3, 4, false)) return null;
        } else if (PotionSlot.canHoldPotion(itemstack)) {
          if (!mergeItemStack(itemstack1, 0, 3, false)) return null;
        } else if (slotIndex >= 4 && slotIndex < 31) {
          if (!mergeItemStack(itemstack1, 31, 40, false)) return null;
        } else if (slotIndex >= 31 && slotIndex < 40) {
          if (!mergeItemStack(itemstack1, 4, 31, false)) return null;
        } else if (!mergeItemStack(itemstack1, 4, 40, false)) return null;
      } else {
        if (!mergeItemStack(itemstack1, 4, 40, true)) return null;

        slot.onSlotChange(itemstack1, itemstack);
      }

      if (itemstack1.stackSize == 0) slot.putStack((ItemStack) null);
      else slot.onSlotChanged();

      if (itemstack1.stackSize == itemstack.stackSize) return null;

      slot.onPickupFromSlot(player, itemstack1);
    }

    return itemstack;
  }
Example #26
0
  private void renameItem() {
    String var1 = this.nameField.getText();
    Slot var2 = this.anvil.getSlot(0);

    if (var2 != null
        && var2.hasStack()
        && !var2.getStack().hasDisplayName()
        && var1.equals(var2.getStack().getDisplayName())) {
      var1 = "";
    }

    this.anvil.updateItemName(var1);
    this.mc.player.sendQueue.addToSendQueue(
        new PacketCustomPayload(
            "MC|ItemName", (new PacketBuffer(Unpooled.buffer())).writeString(var1)));
  }
Example #27
0
  @Override
  public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
    ItemStack itemstack = null;
    Slot slot = (Slot) this.inventorySlots.get(par2);

    if (slot != null && slot.getHasStack()) {
      ItemStack itemstack1 = slot.getStack();
      itemstack = itemstack1.copy();

      if (par2 == 0) {
        if (!this.mergeItemStack(itemstack1, 1, 37, true)) {
          return null;
        }
      } else if (par2 != 0) {
        if (par2 >= 1 && par2 < 37) {
          if (!this.mergeItemStack(itemstack1, 0, 1, false)) {
            return null;
          }
        }
      }
      slot.onSlotChanged();
      if (itemstack1.stackSize == 0) {
        slot.putStack((ItemStack) null);
      }

      slot.onPickupFromSlot(par1EntityPlayer, itemstack1);
    }

    return itemstack;
  }
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
    ItemStack stack = null;
    Slot slotObject = inventorySlots.get(slot);

    if (slotObject != null && slotObject.getHasStack()) {
      ItemStack stackInSlot = slotObject.getStack();
      stack = stackInSlot.copy();

      if (slot < slotCount) {
        if (!this.mergeItemStack(stackInSlot, slotCount, (slotCount + 36), true)) return null;
      } else {
        boolean b = false;
        for (int i = 0; i < slotCount; i++)
          if (this.getSlot(i).isItemValid(stackInSlot))
            if (this.mergeItemStack(stackInSlot, i, i + 1, false)) {
              b = true;
              break;
            }
        if (!b) return null;
      }

      if (stackInSlot.stackSize == 0) slotObject.putStack(null);
      else slotObject.onSlotChanged();

      if (stackInSlot.stackSize == stack.stackSize) return null;
      slotObject.onPickupFromSlot(player, stackInSlot);
    }
    return stack;
  }
  @Override
  public ItemStack slotClick(int id, int button, ClickType clickType, EntityPlayer player) {
    Slot slot = id < 0 ? null : this.inventorySlots.get(id);
    if (!(slot instanceof IESlot.Ghost)) return super.slotClick(id, button, clickType, player);
    // Spooky Ghost Slots!!!!
    ItemStack stack = null;
    ItemStack stackSlot = slot.getStack();
    if (stackSlot != null) stack = stackSlot.copy();

    if (button == 2) slot.putStack(null);
    else if (button == 0 || button == 1) {
      InventoryPlayer playerInv = player.inventory;
      ItemStack stackHeld = playerInv.getItemStack();
      if (stackSlot == null) {
        if (stackHeld != null && slot.isItemValid(stackHeld)) {
          slot.putStack(Utils.copyStackWithAmount(stackHeld, 1));
        }
      } else if (stackHeld == null) {
        slot.putStack(null);
      } else if (slot.isItemValid(stackHeld)) {
        slot.putStack(Utils.copyStackWithAmount(stackHeld, 1));
      }
    } else if (button == 5) {
      InventoryPlayer playerInv = player.inventory;
      ItemStack stackHeld = playerInv.getItemStack();
      if (!slot.getHasStack()) {
        slot.putStack(Utils.copyStackWithAmount(stackHeld, 1));
      }
    }
    return stack;
  }
  /** Called to transfer a stack from one inventory to the other eg. when shift clicking. */
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int i) {
    ItemStack itemstack = null;
    Slot slot = (Slot) inventorySlots.get(i);

    if (slot != null && slot.getHasStack()) {
      ItemStack itemstack1 = slot.getStack();
      itemstack = itemstack1.copy();

      if (i < 3 * 5) {
        if (!mergeItemStack(itemstack1, 3 * 5, inventorySlots.size(), true)) {
          return null;
        }
      } else if (!mergeItemStack(itemstack1, 0, 3 * 5, false)) {
        return null;
      }

      if (itemstack1.stackSize == 0) {
        slot.putStack(null);
      } else {
        slot.onSlotChanged();
      }
    }

    return itemstack;
  }