public void onContainerClosed(EntityPlayer player) {
    super.onContainerClosed(player);
    for (int i = 0; i < 4; ++i) {
      ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i);

      if (itemstack != null) {
        player.dropPlayerItemWithRandomChoice(itemstack, false);
      }
    }

    this.craftResult.setInventorySlotContents(0, (ItemStack) null);
    if (!player.worldObj.isRemote) {
      ModCompatability.setPlayerBaubles(player, invBaubles);
      TravellersGearAPI.setExtendedInventory(player, this.invTG.stackList);
      TravellersGear.packetHandler.sendToAll(new MessageNBTSync(player));
      //			PacketPipeline.INSTANCE.sendToAll(new PacketNBTSync(player));
    }
  }
  public ContainerTravellersInv(InventoryPlayer invPlayer) {
    this.player = invPlayer.player;
    this.invTG = new InventoryTG(this, player);
    if (!player.worldObj.isRemote)
      this.invTG.stackList = TravellersGearAPI.getExtendedInventory(player);
    this.invBaubles = ModCompatability.getNewBaublesInv(player);
    ModCompatability.setBaubleContainer(invBaubles, this);
    if (!player.worldObj.isRemote)
      ModCompatability.setBaubleInvStacklist(invBaubles, BaublesApi.getBaubles(player));

    crafting =
        addSlot(new SlotCrafting(invPlayer.player, this.craftMatrix, this.craftResult, 0, 144, 36));
    int i;
    int j;
    for (i = 0; i < 2; ++i) {
      for (j = 0; j < 2; ++j) {
        this.addSlot(new Slot(this.craftMatrix, j + i * 2, 106 + j * 18, 26 + i * 18));
      }
    }
    nonInventorySlots = 0 + (crafting >= 0 ? 5 : 0);

    vanillaArmor[0] =
        addSlot(
            new SlotRestricted(
                invPlayer,
                invPlayer.getSizeInventory() - 1 - 0,
                6,
                26,
                player,
                SlotRestricted.SlotType.VANILLA_HELM));
    vanillaArmor[1] =
        addSlot(
            new SlotRestricted(
                invPlayer,
                invPlayer.getSizeInventory() - 1 - 1,
                6,
                44,
                player,
                SlotRestricted.SlotType.VANILLA_CHEST));
    vanillaArmor[2] =
        addSlot(
            new SlotRestricted(
                invPlayer,
                invPlayer.getSizeInventory() - 1 - 2,
                6,
                62,
                player,
                SlotRestricted.SlotType.VANILLA_LEGS));
    vanillaArmor[3] =
        addSlot(
            new SlotRestricted(
                invPlayer,
                invPlayer.getSizeInventory() - 1 - 3,
                6,
                80,
                player,
                SlotRestricted.SlotType.VANILLA_BOOTS));
    nonInventorySlots +=
        (vanillaArmor[0] >= 0 ? 1 : 0)
            + (vanillaArmor[1] >= 0 ? 1 : 0)
            + (vanillaArmor[2] >= 0 ? 1 : 0)
            + (vanillaArmor[3] >= 0 ? 1 : 0);

    travGear[0] =
        addSlot(
            new SlotRestricted(this.invTG, 0, 42, 8, player, SlotRestricted.SlotType.TRAVEL_CLOAK));
    travGear[1] =
        addSlot(
            new SlotRestricted(
                this.invTG, 1, 78, 26, player, SlotRestricted.SlotType.TRAVEL_SHOULDER));
    travGear[2] =
        addSlot(
            new SlotRestricted(
                this.invTG, 2, 78, 62, player, SlotRestricted.SlotType.TRAVEL_VAMBRACE));
    travGear[3] =
        addSlot(
            new SlotRestricted(this.invTG, 3, 6, 98, player, SlotRestricted.SlotType.TRAVEL_TITLE));
    nonInventorySlots +=
        (travGear[0] >= 0 ? 1 : 0)
            + (travGear[1] >= 0 ? 1 : 0)
            + (travGear[2] >= 0 ? 1 : 0)
            + (travGear[3] >= 0 ? 1 : 0);

    if (TravellersGear.BAUBLES && invBaubles != null) {
      baubles[0] =
          addSlot(
              new SlotRestricted(
                  this.invBaubles, 0, 24, 8, player, SlotRestricted.SlotType.BAUBLE_NECK));
      baubles[1] =
          addSlot(
              new SlotRestricted(
                  this.invBaubles, 1, 24, 98, player, SlotRestricted.SlotType.BAUBLE_RING));
      baubles[2] =
          addSlot(
              new SlotRestricted(
                  this.invBaubles, 2, 42, 98, player, SlotRestricted.SlotType.BAUBLE_RING));
      baubles[3] =
          addSlot(
              new SlotRestricted(
                  this.invBaubles, 3, 78, 44, player, SlotRestricted.SlotType.BAUBLE_BELT));
      nonInventorySlots +=
          (baubles[0] >= 0 ? 1 : 0)
              + (baubles[1] >= 0 ? 1 : 0)
              + (baubles[2] >= 0 ? 1 : 0)
              + (baubles[3] >= 0 ? 1 : 0);
    }

    this.invMari = ModCompatability.getMariInventory(player);
    if (TravellersGear.MARI && invMari != null) {
      mari[0] =
          addSlot(
              new SlotRestricted(
                  this.invMari, 0, 60, 98, player, SlotRestricted.SlotType.MARI_RING));
      mari[1] =
          addSlot(
              new SlotRestricted(
                  this.invMari, 1, 78, 80, player, SlotRestricted.SlotType.MARI_BRACELET));
      mari[2] =
          addSlot(
              new SlotRestricted(
                  this.invMari, 2, 60, 8, player, SlotRestricted.SlotType.MARI_NECKLACE));
      nonInventorySlots += (mari[0] >= 0 ? 1 : 0) + (mari[1] >= 0 ? 1 : 0) + (mari[2] >= 0 ? 1 : 0);
    }

    this.invTConArmor = ModCompatability.getTConArmorInv(player);
    if (TravellersGear.TCON && invTConArmor != null) {
      tcon[0] =
          addSlot(
              new SlotRestricted(
                  this.invTConArmor, 1, 78, 98, player, SlotRestricted.SlotType.TINKERS_GLOVE));
      tcon[1] =
          addSlot(
              new SlotRestricted(
                  this.invTConArmor, 2, 78, 8, player, SlotRestricted.SlotType.TINKERS_BAG));
      tcon[2] =
          addSlot(
              new SlotRestricted(
                  this.invTConArmor, 6, 191, 31, player, SlotRestricted.SlotType.TINKERS_HEART_R));
      tcon[3] =
          addSlot(
              new SlotRestricted(
                  this.invTConArmor, 5, 191, 49, player, SlotRestricted.SlotType.TINKERS_HEART_Y));
      tcon[4] =
          addSlot(
              new SlotRestricted(
                  this.invTConArmor, 4, 191, 67, player, SlotRestricted.SlotType.TINKERS_HEART_G));
      //			tcon[5]=addSlot(new SlotRestricted(this.invTConArmor, 3, 6, 31, player,
      // SlotRestricted.SlotType.TINKERS_BELT));// (doesn't work)
      tcon[5] =
          addSlot(
              new SlotRestricted(
                  this.invTConArmor, 0, 6, 31, player, SlotRestricted.SlotType.TINKERS_MASK));
      nonInventorySlots +=
          (tcon[0] >= 0 ? 1 : 0)
              + (tcon[1] >= 0 ? 1 : 0)
              + (tcon[2] >= 0 ? 1 : 0)
              + (tcon[3] >= 0 ? 1 : 0)
              + (tcon[4] >= 0 ? 1 : 0)
              + (tcon[5] >= 0 ? 1 : 0);
    }
    // PLAYER INVENTORY
    playerInventorySlots = 0;
    playerHotbarSlots = 0;
    for (i = 0; i < 3; ++i)
      for (j = 0; j < 9; ++j)
        if (this.addSlot(
                new Slot(invPlayer, j + (i + 1) * 9, 6 + j * 18 + (j > 4 ? 10 : 0), 119 + i * 18))
            >= 0) playerInventorySlots++;
    for (i = 0; i < 9; ++i)
      if (this.addSlot(new Slot(invPlayer, i, 6 + i * 18 + (i > 4 ? 10 : 0), 173)) >= 0)
        playerHotbarSlots++;

    this.onCraftMatrixChanged(this.craftMatrix);
  }