public void setCurrentRecipeIndex(int par1) { this.currentRecipeIndex = par1; MerchantRecipeList offersList = CustomRecordHelper.getStoreCatalog(this.storeId); offersList.get(this.currentRecipeIndex); this.resetRecipeAndSlots(); }
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); } } } }
/** Called when the screen is unloaded. Used to disable keyboard repeat events */ @Override public void onGuiClosed() { boolean madeTrade = false; // Check if a trade was made ContainerRecordTrading auxContainer = (ContainerRecordTrading) this.inventorySlots; if (auxContainer != null) { madeTrade = auxContainer.madeAnyTrade(); } super.onGuiClosed(); // Spawns particles if a trade was made. // TODO: better particle effects if (this.mc.thePlayer != null) { Entity auxVillager = (Entity) this.theIMerchant; if (auxVillager != null && madeTrade) { CustomRecordHelper.spawnTradeParticles(this.mc.thePlayer.worldObj, auxVillager, this.rand); } } }
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); }
public InventoryRecordTrading(EntityPlayer par1EntityPlayer, IMerchant merchant) { this.theMerchant = merchant; this.storeId = CustomRecordHelper.getStoreID(((Entity) merchant).entityId); }