Posted December 7, 20168 yr Hi. I'm trying to add some custom trades to villagers in 1.10.2. I've done it before in 1.7.10, but i noticed that since the IVillageTradeHandler interface is no longer present in the VillagerRegistry, I cannot do this the way i used to do it. The closest i can seem to find is the IVillageCreationHandler interface, but I'm getting a suspicion that this has nothing to do with trading, but more to do with Village World generation. How would you do this in 1.10.2 ?
December 7, 20168 yr http://www.minecraftforge.net/forum/index.php?topic=1676.0 Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
December 7, 20168 yr Altho the way I mentioned in the topic you posted is to override or cancel the default GUI/trading and then open my own. It seems Da9L may be looking to just "add" to the default villager trading options. I've managed to track a location down to "net.minecraftforge.fml.common.registry.VillagerRegistry.class" but other than that, I'm not sure "how" to just add to the default trading. EDIT: Oh wow re-reading that thread I posted in, I also gave the wrong suggestion of just stopping the default trading interface and using a custom one. Oops. Currently updating my Mod to 1.10.2 https://bitbucket.org/hugo_the_dwarf/riseoftristram2016/src?at=master
December 8, 20168 yr In my mod. Trade List: package cz.grossik.farmcraft2.village; import java.util.Random; import javax.annotation.Nonnull; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.village.MerchantRecipe; import net.minecraft.village.MerchantRecipeList; public class FC2VillagerTrades { public static ItemStack copyStackWithAmount(ItemStack stack, int amount) { if(stack==null) return null; ItemStack s2 = stack.copy(); s2.stackSize=amount; return s2; } public static class SeedsForItemstack implements EntityVillager.ITradeList { public ItemStack buyingItem; public EntityVillager.PriceInfo buyAmounts; public SeedsForItemstack(@Nonnull ItemStack item, @Nonnull EntityVillager.PriceInfo buyAmounts) { this.buyingItem = item; this.buyAmounts = buyAmounts; } @Override public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random) { recipeList.add(new MerchantRecipe(copyStackWithAmount(this.buyingItem, this.buyAmounts.getPrice(random)), Items.EMERALD)); } } public static class ItemstackForSeeds implements EntityVillager.ITradeList { public ItemStack sellingItem; public EntityVillager.PriceInfo priceInfo; public ItemstackForSeeds(Item par1Item, EntityVillager.PriceInfo priceInfo) { this.sellingItem = new ItemStack(par1Item); this.priceInfo = priceInfo; } public ItemstackForSeeds(ItemStack stack, EntityVillager.PriceInfo priceInfo) { this.sellingItem = stack; this.priceInfo = priceInfo; } @Override public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random) { int i = 1; if(this.priceInfo != null) i = this.priceInfo.getPrice(random); ItemStack itemstack; ItemStack itemstack1; if(i < 0) { itemstack = new ItemStack(Items.WHEAT_SEEDS); itemstack1 = copyStackWithAmount(sellingItem, -i); } else { itemstack = new ItemStack(Items.WHEAT_SEEDS, i, 0); itemstack1 = copyStackWithAmount(sellingItem, 1); } recipeList.add(new MerchantRecipe(itemstack, itemstack1)); } } } and register: VillagerRegistry.VillagerCareer career_fc2_farmer = new VillagerRegistry.VillagerCareer(villagerProfession_farmer, Main.MODID + ".farmer"); career_fc2_farmer.addTrade(1, new FC2VillagerTrades.ItemstackForSeeds(ItemHandler.BarleySeeds, new EntityVillager.PriceInfo(1, 2));
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.