Posted July 19, 20169 yr I have figured out how to make a custom villagers, but I don't understand how trades work? I know how to make an ITradeList class but I don't understand how to continue. What I have so far: package orangeVillager61.MoDrops.villager; import net.minecraft.entity.passive.EntityVillager.EmeraldForItems; import net.minecraft.entity.passive.EntityVillager.ITradeList; import net.minecraft.entity.passive.EntityVillager.ListItemForEmeralds; import net.minecraft.entity.passive.EntityVillager.PriceInfo; import net.minecraft.init.Items; import orangeVillager61.MoDrops.items.MoDropsItems; public class SaltTrader_trades { public static final ITradeList[] trades = { }; }
July 19, 20169 yr You need to create and register a VillagerProfession using GameRegistry.register . You can then create one or more VillagerCareer s for the VillagerProfession and use VillagerCareer#addTrade to add trades to each VillagerCareer . Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
July 19, 20169 yr Author As stated I know how to make custom villagers, I don't know how to put the trades in the ITradeList file. I have added my custom villager file below. package orangeVillager61.MoDrops.villager; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraftforge.event.entity.EntityEvent; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.registry.VillagerRegistry; import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerCareer; import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession; import orangeVillager61.MoDrops.Config; public class SaltTrader{ public static boolean enableSaltTrader = Config.enableSaltTrader; protected static final VillagerRegistry.VillagerProfession PROFESSION = new VillagerRegistry.VillagerProfession("Salt Trader", "minecraft:textures/entity/villager/villager.png", "minecraft:textures/entity/villager/zombie_villager.png"); protected static final VillagerRegistry.VillagerCareer CAREER = new VillagerRegistry.VillagerCareer(PROFESSION, "Salt Trader").addTrade(1, SaltTrader_trades.trades[1]); public static void onInit(FMLInitializationEvent event){ VillagerRegistry.instance().register(PROFESSION); } }
July 19, 20169 yr Author My question still isn't answered, what are the functions are involved with the trade recipes?
July 19, 20169 yr Author Uhhhh, you have to look around and hope you see the classes that implement ITradeList.
July 19, 20169 yr Your IDE can almost certainly tell you which classes implement ITradeList . In IDEA, there's a small green circle with a down arrow in the side bar between the line numbers and code, clicking this brings up the implementations of that interface/method. Eclipse probably has something similar. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
July 19, 20169 yr This has nothing to do with arrays or anything. Just call addTrade as much as you want with every trade. I do Forge for free, however the servers to run it arn't free, so anything is appreciated. Consider supporting the team on Patreon
July 19, 20169 yr Author This has nothing to do with arrays or anything. Just call addTrade as much as you want with every trade. Ehm, how does one do that? Doesn't it want just one list?
July 19, 20169 yr This has nothing to do with arrays or anything. Just call addTrade as much as you want with every trade. Ehm, how does one do that? Doesn't it want one list? VillagerRegistry.VillagerCareer#addTrade is a vararg method, you can pass any number of ITradeList objects to it and Java will automatically wrap them in an array. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
July 19, 20169 yr Author new EmeraldForItems(MoDropsItems.salted_chicken_cooked, new PriceInfo(7, 10)), new ListItemForEmeralds(MoDropsItems.raw_horse_meat, new PriceInfo(-6, -2)) This is my attempt for the trades. The EmeraldForItems trade doesn't appear at all ingame.
July 19, 20169 yr Post your full code, not just a snippet of it. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
July 19, 20169 yr Author package orangeVillager61.MoDrops.villager; import net.minecraft.entity.passive.EntityVillager.EmeraldForItems; import net.minecraft.entity.passive.EntityVillager.ITradeList; import net.minecraft.entity.passive.EntityVillager.ListItemForEmeralds; import net.minecraft.entity.passive.EntityVillager.PriceInfo; import net.minecraft.init.Items; import orangeVillager61.MoDrops.items.MoDropsItems; public class SaltTrader_trades { public static final ITradeList[] trades = { new EmeraldForItems(MoDropsItems.salted_chicken_cooked, new PriceInfo(7, 10)), new ListItemForEmeralds(MoDropsItems.raw_horse_meat, new PriceInfo(-6, -2)) }; }
July 19, 20169 yr You only call VillagerCareer#addTrade with SaltTrader_trades.trades[1] , the second value in the array. You need to add both trades, not just one of them. There's no real need to store the trades in an array, you can simply create them inline when you call VillagerCareer#addTrade . Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
July 20, 20169 yr you can call add trade multiple times stop trying to be 'smart' and making this complicated I do Forge for free, however the servers to run it arn't free, so anything is appreciated. Consider supporting the team on Patreon
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.