Пример #1
0
  public static void givePlayerItem(
      EntityPlayerMP player, ItemStack stack, boolean infinite, boolean doGive) {
    if (stack.getItem() == null) {
      player.addChatComponentMessage(
          setColour(
              new ChatComponentTranslation("nei.chat.give.noitem"), EnumChatFormatting.WHITE));
      return;
    }

    int given = stack.stackSize;
    if (doGive) {
      if (infinite) {
        player.inventory.addItemStackToInventory(stack);
      } else {
        given -= InventoryUtils.insertItem(player.inventory, stack, false);
      }
    }

    sendNotice(
        player,
        new ChatComponentTranslation(
            "commands.give.success",
            stack.getChatComponent(),
            infinite ? "\u221E" : Integer.toString(given),
            player.getName()),
        "notify-item");
    player.openContainer.detectAndSendChanges();
  }
Пример #2
0
 public static boolean canItemFitInInventory(EntityPlayer player, ItemStack itemstack) {
   return InventoryUtils.insertItem(new InventoryRange(player.inventory, 0, 36), itemstack, true)
       == 0;
 }