@Override public List<String> getTooltips() { List<String> tt = new ArrayList<String>(); MerchantRecipeList merchantrecipelist = parent.getContainer().getTrades(); if (merchantrecipelist == null) { return tt; } MerchantRecipe r = merchantrecipelist.get(recipeIndex); if (r == null) { return tt; } if (r.isRecipeDisabled()) { tt.add(UtilChat.lang("merchant.deprecated")); } else { tt.add(UtilChat.lang("tile.tool_trade.button.tooltip")); } if (r.getItemToSell() != null) {// && r.getItemToSell().getItem() == Items.ENCHANTED_BOOK Map<Enchantment, Integer> map = EnchantmentHelper.getEnchantments(r.getItemToSell()); if (map != null) { for (Map.Entry<Enchantment, Integer> entry : map.entrySet()) { tt.add(entry.getKey().getTranslatedName(entry.getValue())); } } } return tt; } }
@Override public void useRecipe(@Nonnull MerchantRecipe recipe) { if (entity != null && entity.isEntityAlive() && !entity.world.isRemote) { recipe.incrementToolUses(); if (existingList != null) { NBTTagCompound nbt = entity.getEntityData(); nbt.setTag("Stock", existingList.getRecipiesAsTags()); ItemStack toSell = recipe.getItemToSell(); ItemStack toBuy = recipe.getItemToBuy(); AnimalTradeEvent event = new AnimalTradeEvent(entity, customer, toBuy, toSell); MinecraftForge.EVENT_BUS.post(event); } entity.playLivingSound(); } }
if(!pstack.isEmpty() && recipes != null) for(MerchantRecipe recipe : recipes) if(recipe != null && !recipe.isRecipeDisabled() && (equalStacks(pstack, recipe.getItemToBuy()) || equalStacks(pstack, recipe.getItemToSell()))) { entIdBuilder.add(villager.getEntityId()); break;
buy = rec.getItemToBuy(); buySecond = rec.getSecondItemToBuy(); sell = rec.getItemToSell();
if (merchantrecipe != null && !merchantrecipe.isRecipeDisabled()) { this.currentRecipe = merchantrecipe; this.setInventorySlotContents(2, merchantrecipe.getItemToSell().copy()); if (merchantrecipe != null && !merchantrecipe.isRecipeDisabled()) { this.currentRecipe = merchantrecipe; this.setInventorySlotContents(2, merchantrecipe.getItemToSell().copy());
private void updateTradingStackSizes(MerchantRecipeList recipeList) { if (recipeList != null) { for (Object obj : recipeList) { MerchantRecipe recipe = (MerchantRecipe) obj; ItemStack toSell = recipe.getItemToSell(); int stackSizeToSell = toSell.getCount(); ItemStack toBuy = recipe.getItemToBuy(); int stackSizeToBuy = toBuy.getCount(); ItemStack secondBuy = recipe.getSecondItemToBuy(); int stackSizeSecond = secondBuy.getCount(); if (stackSizeToSell > 1 && stackSizeToSell != MathHelper.floor(stackSizeToSell * 1.25F)) { stackSizeToSell = MathHelper.floor(stackSizeToSell * 1.25F); } else if (stackSizeToBuy > 1 && stackSizeToBuy != MathHelper.ceil(stackSizeToBuy / 1.25F)) { stackSizeToBuy = MathHelper.ceil(stackSizeToBuy / 1.25F); } else if (secondBuy != null && stackSizeSecond > 1 && stackSizeSecond != MathHelper.ceil(stackSizeSecond / 1.25F)) { stackSizeSecond = MathHelper.ceil(stackSizeSecond / 1.25F); } toSell.setCount(stackSizeToSell); toBuy.setCount(stackSizeToBuy); secondBuy.setCount(stackSizeSecond); } lastViewVillagerGui = true; } }
ModCyclic.proxy.renderItemOnGui(r.getSecondItemToBuy(), parent.itemRender, parent.fontRenderer, x, y); x += spacing; ModCyclic.proxy.renderItemOnGui(r.getItemToSell(), parent.itemRender, parent.fontRenderer, x, y); GlStateManager.popMatrix();
ItemStack purchased = trade.getItemToSell().copy(); player.entityDropItem(purchased, 1); this.merchant.useRecipe(trade);