public ArmorExtendedContainer(InventoryPlayer inventoryplayer, ArmorExtended armor) {
    invPlayer = inventoryplayer;
    this.armor = armor;

    this.addSlotToContainer(new SlotAccessory(armor, 0, 80, 17));
    this.addSlotToContainer(new SlotAccessory(armor, 1, 80, 35));
    this.addSlotToContainer(new SlotAccessory(armor, 2, 116, 17));
    this.addSlotToContainer(new SlotAccessory(armor, 3, 116, 35));
    this.addSlotToContainer(new SlotAccessory(armor, 4, 152, 53));
    this.addSlotToContainer(new SlotAccessory(armor, 5, 152, 35));
    this.addSlotToContainer(new SlotAccessory(armor, 6, 152, 17));
    for (int playerArmor = 0; playerArmor < 4; ++playerArmor) {
      this.addSlotToContainer(
          new SlotArmorCopy(
              this,
              inventoryplayer,
              inventoryplayer.getSizeInventory() - 1 - playerArmor,
              98,
              8 + playerArmor * 18,
              playerArmor));
    }

    for (int column = 0; column < 3; column++) {
      for (int row = 0; row < 9; row++) {
        this.addSlotToContainer(
            new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18));
      }
    }

    for (int column = 0; column < 9; column++) {
      this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142));
    }
  }
  public ContainerPlayer(
      final InventoryPlayer par1InventoryPlayer, boolean par2, EntityPlayer par3EntityPlayer) {
    this.isLocalWorld = par2;
    this.thePlayer = par3EntityPlayer;
    this.addSlotToContainer(
        new SlotCrafting(
            par1InventoryPlayer.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.addSlotToContainer(new Slot(this.craftMatrix, j + i * 2, 88 + j * 18, 26 + i * 18));
      }
    }

    for (i = 0; i < 4; ++i) {
      final int k = i;
      this.addSlotToContainer(
          new Slot(
              par1InventoryPlayer, par1InventoryPlayer.getSizeInventory() - 1 - i, 8, 8 + i * 18) {
            private static final String __OBFID = "CL_00001755";
            /**
             * Returns the maximum stack size for a given slot (usually the same as
             * getInventoryStackLimit(), but 1 in the case of armor slots)
             */
            public int getSlotStackLimit() {
              return 1;
            }
            /**
             * Check if the stack is a valid item for this slot. Always true beside for the armor
             * slots.
             */
            public boolean isItemValid(ItemStack par1ItemStack) {
              if (par1ItemStack == null) return false;
              return par1ItemStack.getItem().isValidArmor(par1ItemStack, k, thePlayer);
            }
            /** Returns the icon index on items.png that is used as background image of the slot. */
            @SideOnly(Side.CLIENT)
            public IIcon getBackgroundIconIndex() {
              return ItemArmor.func_94602_b(k);
            }
          });
    }

    for (i = 0; i < 3; ++i) {
      for (j = 0; j < 9; ++j) {
        this.addSlotToContainer(
            new Slot(par1InventoryPlayer, j + (i + 1) * 9, 8 + j * 18, 84 + i * 18));
      }
    }

    for (i = 0; i < 9; ++i) {
      this.addSlotToContainer(new Slot(par1InventoryPlayer, i, 8 + i * 18, 142));
    }

    this.onCraftMatrixChanged(this.craftMatrix);
  }
예제 #3
0
  public ContainerPlayer(
      final InventoryPlayer par1InventoryPlayer, boolean par2, EntityPlayer par3EntityPlayer) {
    this.isLocalWorld = par2;
    this.thePlayer = par3EntityPlayer;
    this.addSlotToContainer(
        new SlotCrafting(
            par1InventoryPlayer.player, this.craftMatrix, this.craftResult, 0, 144, 36));
    int var4;
    int var5;

    for (var4 = 0; var4 < 2; ++var4) {
      for (var5 = 0; var5 < 2; ++var5) {
        this.addSlotToContainer(
            new Slot(this.craftMatrix, var5 + var4 * 2, 88 + var5 * 18, 26 + var4 * 18));
      }
    }

    for (var4 = 0; var4 < 4; ++var4) {
      final int var44 = var4;
      this.addSlotToContainer(
          new Slot(
              par1InventoryPlayer,
              par1InventoryPlayer.getSizeInventory() - 1 - var4,
              8,
              8 + var4 * 18) {
            private static final String __OBFID = "CL_00001755";

            public int getSlotStackLimit() {
              return 1;
            }

            public boolean isItemValid(ItemStack par1ItemStack) {
              return par1ItemStack == null
                  ? false
                  : (par1ItemStack.getItem() instanceof ItemArmor
                      ? ((ItemArmor) par1ItemStack.getItem()).armorType == var44
                      : (par1ItemStack.getItem() != Item.getItemFromBlock(Blocks.pumpkin)
                              && par1ItemStack.getItem() != Items.skull
                          ? false
                          : var44 == 0));
            }
          });
    }

    for (var4 = 0; var4 < 3; ++var4) {
      for (var5 = 0; var5 < 9; ++var5) {
        this.addSlotToContainer(
            new Slot(par1InventoryPlayer, var5 + (var4 + 1) * 9, 8 + var5 * 18, 84 + var4 * 18));
      }
    }

    for (var4 = 0; var4 < 9; ++var4) {
      this.addSlotToContainer(new Slot(par1InventoryPlayer, var4, 8 + var4 * 18, 142));
    }

    this.onCraftMatrixChanged(this.craftMatrix);
  }
예제 #4
0
 public void buyGun(int i, InventoryPlayer inventory, GunBoxType type) {
   if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
     FlansMod.proxy.buyGun(type, i);
   }
   if (i <= type.numGuns && type.guns[i] != null) {
     boolean canBuy = true;
     for (ItemStack check : type.gunParts[i]) {
       int numMatchingStuff = 0;
       for (int j = 0; j < inventory.getSizeInventory(); j++) {
         ItemStack stack = inventory.getStackInSlot(j);
         if (stack != null
             && stack.itemID == check.itemID
             && stack.getItemDamage() == check.getItemDamage()) {
           numMatchingStuff += stack.stackSize;
         }
       }
       if (numMatchingStuff < check.stackSize) {
         canBuy = false;
       }
     }
     if (canBuy) {
       for (ItemStack remove : type.gunParts[i]) {
         int amountLeft = remove.stackSize;
         for (int j = 0; j < inventory.getSizeInventory(); j++) {
           ItemStack stack = inventory.getStackInSlot(j);
           if (amountLeft > 0
               && stack != null
               && stack.itemID == remove.itemID
               && stack.getItemDamage() == remove.getItemDamage()) {
             amountLeft -= inventory.decrStackSize(j, amountLeft).stackSize;
           }
         }
       }
       if (!inventory.addItemStackToInventory(new ItemStack(type.guns[i].getItem()))) {
         // Drop gun on floor
       }
     } else {
       // Cant buy
       // TODO : Add flashing red squares around the items you lack
     }
   }
 }
예제 #5
0
  public ContainerPlayer(final InventoryPlayer playerInventory, boolean localWorld, Player player) {
    this.isLocalWorld = localWorld;
    this.thePlayer = player;
    this.addSlotToContainer(
        new SlotCrafting(playerInventory.player, this.craftMatrix, this.craftResult, 0, 144, 36));

    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j < 2; ++j) {
        this.addSlotToContainer(new Slot(this.craftMatrix, j + i * 2, 88 + j * 18, 26 + i * 18));
      }
    }

    for (int k = 0; k < 4; ++k) {
      final int k_f = k;
      this.addSlotToContainer(
          new Slot(playerInventory, playerInventory.getSizeInventory() - 1 - k, 8, 8 + k * 18) {
            public int getSlotStackLimit() {
              return 1;
            }

            public boolean isItemValid(ItemStack stack) {
              return stack == null
                  ? false
                  : (stack.getItem() instanceof ItemArmor
                      ? ((ItemArmor) stack.getItem()).armorType == k_f
                      : (stack.getItem() != Item.getItemFromBlock(Blocks.pumpkin)
                              && stack.getItem() != Items.skull
                          ? false
                          : k_f == 0));
            }
          });
    }

    for (int l = 0; l < 3; ++l) {
      for (int j1 = 0; j1 < 9; ++j1) {
        this.addSlotToContainer(
            new Slot(playerInventory, j1 + (l + 1) * 9, 8 + j1 * 18, 84 + l * 18));
      }
    }

    for (int i1 = 0; i1 < 9; ++i1) {
      this.addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 142));
    }

    this.onCraftMatrixChanged(this.craftMatrix);
  }
  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);
  }
  public ContainerCosArmor(
      InventoryPlayer invPlayer, InventoryCosArmor invCosArmor, EntityPlayer player) {
    this.player = player;

    // CraftingResult
    addSlotToContainer(new SlotCrafting(player, craftMatrix, craftResult, 0, 154, 28));

    // CraftingGrid
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++)
        addSlotToContainer(new Slot(craftMatrix, j + i * 2, 98 + j * 18, 18 + i * 18));

    // NormalArmor
    for (int i = 0; i < 4; i++) {
      final int j = i;
      final EntityPlayer k = player;
      addSlotToContainer(
          new Slot(
              invPlayer,
              invPlayer.getSizeInventory() - 1 - invPlayer.offHandInventory.size() - i,
              8,
              8 + i * 18) {

            @Override
            public int getSlotStackLimit() {
              return 1;
            }

            @SideOnly(Side.CLIENT)
            @Override
            public String getSlotTexture() {
              return ItemArmor.EMPTY_SLOT_NAMES[VALID_EQUIPMENT_SLOTS[j].getIndex()];
            }

            @Override
            public boolean isItemValid(ItemStack stack) {
              if (stack == null || stack.func_190926_b()) return false;

              return stack.getItem().isValidArmor(stack, VALID_EQUIPMENT_SLOTS[j], k);
            }
          });
    }

    // CosmeticArmor
    for (int i = 0; i < 4; i++) {
      final int j = i;
      final EntityPlayer k = player;
      addSlotToContainer(
          new Slot(invCosArmor, invCosArmor.getSizeInventory() - 1 - i, 98 + i * 18, 62) {

            @Override
            public int getSlotStackLimit() {
              return 1;
            }

            @SideOnly(Side.CLIENT)
            @Override
            public String getSlotTexture() {
              return ItemArmor.EMPTY_SLOT_NAMES[VALID_EQUIPMENT_SLOTS[j].getIndex()];
            }

            @Override
            public boolean isItemValid(ItemStack stack) {
              if (stack == null || stack.func_190926_b()) return false;

              return stack.getItem().isValidArmor(stack, VALID_EQUIPMENT_SLOTS[j], k);
            }
          });
    }

    // PlayerInventory
    for (int i = 0; i < 3; i++)
      for (int j = 0; j < 9; j++)
        addSlotToContainer(new Slot(invPlayer, j + (i + 1) * 9, 8 + j * 18, 84 + i * 18));

    // PlayerHotBar
    for (int i = 0; i < 9; i++) addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142));

    // Off-Hand Slot
    addSlotToContainer(
        new Slot(invPlayer, 40, 77, 62) {

          @SideOnly(Side.CLIENT)
          @Override
          public String getSlotTexture() {
            return "minecraft:items/empty_armor_slot_shield";
          }
        });

    onCraftMatrixChanged(craftMatrix);
  }