コード例 #1
0
  public void setCurrentRecipeIndex(int par1) {
    this.currentRecipeIndex = par1;

    MerchantRecipeList offersList = CustomRecordHelper.getStoreCatalog(this.storeId);
    offersList.get(this.currentRecipeIndex);

    this.resetRecipeAndSlots();
  }
コード例 #2
0
  public void resetRecipeAndSlots() {
    this.currentRecipe = null;
    ItemStack var1 = this.theInventory[0];
    ItemStack var2 = this.theInventory[1];

    if (var1 == null) {
      var1 = var2;
      var2 = null;
    }

    if (var1 == null) {
      this.setInventorySlotContents(2, (ItemStack) null);
    } else {
      MerchantRecipeList var3 = CustomRecordHelper.getStoreCatalog(this.storeId);

      if (var3 != null) {
        // Direct approach, only checks for the current recipe selected
        MerchantRecipe slotRecipe = (MerchantRecipe) var3.get(this.currentRecipeIndex);
        boolean slot1Ok = false;
        boolean slot2Ok = false;

        slot1Ok =
            var1 != null
                && var1.itemID == slotRecipe.getItemToBuy().itemID
                && var1.stackSize >= slotRecipe.getItemToBuy().stackSize;
        if (slotRecipe.getSecondItemToBuy() == null) {
          slot2Ok = var2 == null;
        }
        if (slotRecipe.getSecondItemToBuy() != null) {
          slot2Ok =
              var2 != null
                  && var2.itemID == slotRecipe.getSecondItemToBuy().itemID
                  && var2.stackSize >= slotRecipe.getSecondItemToBuy().stackSize;
        }

        boolean validRecipe = slot1Ok && slot2Ok && !slotRecipe.func_82784_g();

        if (validRecipe) {
          this.currentRecipe = slotRecipe;
          this.setInventorySlotContents(2, slotRecipe.getItemToSell().copy());
        } else {
          this.setInventorySlotContents(2, (ItemStack) null);
        }
      }
    }
  }
コード例 #3
0
 public GuiRecordTrading(InventoryPlayer player, IMerchant merchant, World world) {
   super(new ContainerRecordTrading(player, merchant, world));
   this.theIMerchant = merchant;
   this.storeId = CustomRecordHelper.getStoreID(((Entity) merchant).entityId);
   this.recordList = CustomRecordHelper.getStoreCatalog(this.storeId);
 }