@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; } }
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;
protected void updateAITasks() { if (!this.isTrading() && this.timeUntilReset > 0) { --this.timeUntilReset; if (this.timeUntilReset <= 0) { if (this.needsInitilization) { for (MerchantRecipe merchantrecipe : this.buyingList) { if (merchantrecipe.isRecipeDisabled()) { merchantrecipe.increaseMaxTradeUses(this.rand.nextInt(6) + this.rand.nextInt(6) + 2); } } this.populateBuyingList(); this.needsInitilization = false; if (this.getHive() != null && this.lastBuyingPlayer != null) { this.world.setEntityState(this, (byte) 14); this.getHive().setWorld(this.world); this.getHive().modifyPlayerReputation(this.lastBuyingPlayer, 1); } } this.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 200, 0)); } } super.updateAITasks(); }
match = false; rec = (MerchantRecipe) list.get(r); disabled = (rec.isRecipeDisabled()) ? "[x] " : ""; buy = rec.getItemToBuy(); buySecond = rec.getSecondItemToBuy();
@SubscribeEvent public void onEntityInteractEvent(EntityInteract event) { if (event.getEntity() instanceof EntityPlayer == false) { return; } EntityPlayer player = (EntityPlayer) event.getEntity(); // ItemStack held = player.getHeldItemMainhand(); ItemStack itemstack = event.getItemStack(); if (itemstack != null && itemstack.getItem() instanceof ItemVillagerMagic && itemstack.getCount() > 0) { if (event.getTarget() instanceof EntityVillager) { EntityVillager villager = ((EntityVillager) event.getTarget()); int count = 0; for (MerchantRecipe merchantrecipe : villager.getRecipes(player)) { if (merchantrecipe.isRecipeDisabled()) { //vanilla code as of 1.9.4 odes this (2d6+2) merchantrecipe.increaseMaxTradeUses(villager.getEntityWorld().rand.nextInt(6) + villager.getEntityWorld().rand.nextInt(6) + 2); count++; } } if (count > 0) { UtilChat.addChatMessage(player, UtilChat.lang("item.apple_emerald.merchant") + count); consumeSelf(itemstack); } event.setCanceled(true);// stop the GUI inventory opening && horse mounting } } }
if (merchantrecipelist != null) { MerchantRecipe merchantrecipe = merchantrecipelist.canRecipeBeUsed(itemstack, itemstack1, this.currentRecipeIndex); 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());
GlStateManager.popMatrix(); if (r.isRecipeDisabled()) { parent.mc.getTextureManager().bindTexture(TRADE_REDX); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
public void doTrade(EntityPlayer player, int selectedMerchantRecipe) { MerchantRecipe trade = getTrades().get(selectedMerchantRecipe); if (trade.isRecipeDisabled()) { return;