@Override public void addMerchantRecipe(IMerchant merchant, MerchantRecipeList recipeList, Random random) { recipeList.add(new MerchantRecipe(in, out)); } }
private void addDefaultEquipmentAndRecipies(int maxRecipesToAdd) { MerchantRecipeList rec = new MerchantRecipeList(); addRecipies(rec); if (buyingList == null) { buyingList = new MerchantRecipeList(); } for (int i = 0; i < maxRecipesToAdd && i < rec.size(); ++i) { buyingList.add(rec.get(i)); } }
@Override public void addMerchantRecipe(IMerchant merchant, MerchantRecipeList recipeList, Random random) { int actualPrice = 1; if (priceInfo != null) { actualPrice = priceInfo.getPrice(random); } ItemStack stackToPay = new ItemStack(Items.EMERALD, actualPrice, 0); recipeList.add(new MerchantRecipe(stackToPay, stack)); // DEBUG System.out.println("Merchant recipe list = "+recipeList.getRecipiesAsTags()); } }
@Override public void fromBytes(ByteBuf buf) { NBTTagCompound tags = ByteBufUtils.readTag(buf); career = tags.getInteger("h"); NBTTagCompound tradeTag = (NBTTagCompound) tags.getTag("trades"); trades = new MerchantRecipeList(); trades.readRecipiesFromTags(tradeTag); }
if (stock.isEmpty()) { existingList = new MerchantRecipeList(); } else { existingList = stock; existingList = new MerchantRecipeList(); MerchantRecipe recipe = new MerchantRecipe(cost, stack); existingList.add(recipe);
@Override public void writeEntityToNBT(NBTTagCompound compound) { super.writeEntityToNBT(compound); compound.setInteger("Riches", wealth); if (buyingList != null) { compound.setTag(OFFERS_TAG, buyingList.getRecipiesAsTags()); } }
@Override protected final void populateBuyingList() { this.tradingLevel++; if (this.buyingList == null) { this.buyingList = new MerchantRecipeList(); } ITradeList[] trades = this.getTrades(tradingLevel - 1); for (EntityVillager.ITradeList trade : trades) { trade.addMerchantRecipe(this, this.buyingList, this.rand); } } }
@Override public boolean processInteract(EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); final boolean flag = stack != ItemStack.EMPTY && stack.getItem() == Items.SPAWN_EGG; if (!flag && isEntityAlive() && !isTrading() && !isChild() && !player.isSneaking()) { if (!world.isRemote && (buyingList == null || !buyingList.isEmpty())) { setCustomer(player); player.displayVillagerTradeGui(this); } player.addStat(StatList.TALKED_TO_VILLAGER); return true; } else { return super.processInteract(player, hand); } }
private void addAdditionalRecipes(MerchantRecipeList list) { if (list.size() > 0) { list.remove(rand.nextInt(list.size())); } addRecipe(list, new ItemStack(ModItems.human_heart, 9), 2, this.getRNG(), 0.5F); addRecipe(list, 3, new ItemStack(ModItems.human_heart, 9), this.getRNG(), 0.5F); addRecipe(list, 1, new ItemStack(ModItems.blood_bottle, 3, ItemBloodBottle.AMOUNT), rand, 0.9F); }
@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 toBytes(ByteBuf buf) { NBTTagCompound tags = new NBTTagCompound(); tags.setInteger("h", career); NBTTagCompound tradeTag = trades.getRecipiesAsTags(); tags.setTag("trades", tradeTag); ByteBufUtils.writeTag(buf, tags); }
@Override public void readNBT(Capability<AnimalData> capability, AnimalData instance, EnumFacing side, NBTBase nbtBase) { NBTTagCompound nbt = (NBTTagCompound) nbtBase; instance.setMaximumTotalTrades(nbt.getInteger("MaximumTrades")); instance.setTotalTrades(nbt.getInteger("TotalTrades")); instance.setMerchantName(nbt.getString("MerchantName")); if (nbt.hasKey("Stock")) { NBTTagCompound stock = nbt.getCompoundTag("Stock"); MerchantRecipeList recipes = stock.isEmpty() ? new MerchantRecipeList() : new MerchantRecipeList(stock); instance.setStock(recipes); } } }
public boolean processInteract(EntityPlayer player, EnumHand hand) { ItemStack itemstack = player.getHeldItem(hand); boolean flag2 = itemstack.getItem() == ModItems.myrmex_jungle_staff || itemstack.getItem() == ModItems.myrmex_desert_staff; if(flag2){ this.onStaffInteract(player, itemstack); player.swingArm(hand); return true; } boolean flag = itemstack.getItem() == Items.NAME_TAG || itemstack.getItem() == Items.LEAD; if (flag) { itemstack.interactWithEntity(player, this, hand); return true; } else if (!this.holdingSpawnEggOfClass(itemstack, this.getClass()) && this.getGrowthStage() >= 2 && this.isEntityAlive() && !this.isTrading() && !this.isChild() && !player.isSneaking()) { if (this.buyingList == null) { this.populateBuyingList(); } if (hand == EnumHand.MAIN_HAND) { player.addStat(StatList.TALKED_TO_VILLAGER); } if (!this.world.isRemote && !this.buyingList.isEmpty() && (this.getHive() == null || !this.getHive().isPlayerReputationTooLowToTrade(player.getUniqueID()))) { this.setCustomer(player); player.displayVillagerTradeGui(this); } else if (this.buyingList.isEmpty()) { return super.processInteract(player, hand); } return true; } else { return super.processInteract(player, hand); } }
private void validateMerchantButtons() { MerchantRecipeList merchantrecipelist = getContainer().getTrades(); int s = merchantrecipelist.size(); int btnH = 20, btnW = 56; int x = this.xBtnStart; int y = this.yBtnStart; int currRow; int currCol; for (int i = 0; i < s; i++) { if (i >= merchButtons.size()) { currRow = i / btnColCount; currCol = i % btnColCount; x = this.xBtnStart + currCol * btnW; y = this.yBtnStart + currRow * btnH; GuiButtonPurchase slotBtn = this.addButton(new GuiButtonPurchase(lastUnusedButtonId, x, y, btnW, btnH, i, this)); merchButtons.add(slotBtn); lastUnusedButtonId++; } } }
public void doTrade(EntityPlayer player, int selectedMerchantRecipe) { MerchantRecipe trade = getTrades().get(selectedMerchantRecipe); if (trade.isRecipeDisabled()) { return;
public void addBuyItemStack(MerchantRecipeList recipeList, Random random, ItemStack stack, float chance, int price, int variation) { if (random.nextFloat() < chance) { MerchantRecipe recipe = new MerchantRecipe(stack, null, new ItemStack(Items.EMERALD, price + random.nextInt(variation))); recipeList.add(recipe); } }