diff --git a/fml/src/main/java/cpw/mods/fml/common/registry/VillagerRegistry.java b/fml/src/main/java/cpw/mods/fml/common/registry/VillagerRegistry.java index 96f2c84e1..c9210026e 100644 --- a/fml/src/main/java/cpw/mods/fml/common/registry/VillagerRegistry.java +++ b/fml/src/main/java/cpw/mods/fml/common/registry/VillagerRegistry.java @@ -198,200 +198,7 @@ public class VillagerRegistry private boolean hasInit = false; private List professions = Lists.newArrayList(); - //This field is moved from EntityVillager over to here. - //It is nasty I know but it's vanilla. - private static final ITradeList[][][][] vanillaTrades = - { - { - { - { - new EmeraldForItems(Items.wheat, new PriceInfo(18, 22)), - new EmeraldForItems(Items.potato, new PriceInfo(15, 19)), - new EmeraldForItems(Items.carrot, new PriceInfo(15, 19)), - new ListItemForEmeralds(Items.bread, new PriceInfo(-4, -2)) - }, - { - new EmeraldForItems(Item.getItemFromBlock(Blocks.pumpkin), new PriceInfo(8, 13)), - new ListItemForEmeralds(Items.pumpkin_pie, new PriceInfo(-3, -2)) - }, - { - new EmeraldForItems(Item.getItemFromBlock(Blocks.melon_block), new PriceInfo(7, 12)), - new ListItemForEmeralds(Items.apple, new PriceInfo(-5, -7)) - }, - { - new ListItemForEmeralds(Items.cookie, new PriceInfo(-6, -10)), - new ListItemForEmeralds(Items.cake, new PriceInfo(1, 1)) - } - }, - { - { - new EmeraldForItems(Items.string, new PriceInfo(15, 20)), - new EmeraldForItems(Items.coal, new PriceInfo(16, 24)), - new ItemAndEmeraldToItem(Items.fish, new PriceInfo(6, 6), Items.field_179566_aV, new PriceInfo(6, 6)) - }, - { - new ListEnchantedItemForEmeralds(Items.fishing_rod, new PriceInfo(7, 8)) - } - }, - { - { - new EmeraldForItems(Item.getItemFromBlock(Blocks.wool), new PriceInfo(16, 22)), - new ListItemForEmeralds(Items.shears, new PriceInfo(3, 4)) - }, - { - new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 0), new PriceInfo(1, 2)), - new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 1), new PriceInfo(1, 2)), - new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 2), new PriceInfo(1, 2)), - new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 3), new PriceInfo(1, 2)), - new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 4), new PriceInfo(1, 2)), - new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 5), new PriceInfo(1, 2)), - new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 6), new PriceInfo(1, 2)), - new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 7), new PriceInfo(1, 2)), - new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 8), new PriceInfo(1, 2)), - new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 9), new PriceInfo(1, 2)), - new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 10), new PriceInfo(1, 2)), - new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 11), new PriceInfo(1, 2)), - new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 12), new PriceInfo(1, 2)), - new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 13), new PriceInfo(1, 2)), - new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 14), new PriceInfo(1, 2)), - new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 15), new PriceInfo(1, 2)) - } - }, - { - { - new EmeraldForItems(Items.string, new PriceInfo(15, 20)), - new ListItemForEmeralds(Items.arrow, new PriceInfo(-12, -8)) - }, - { - new ListItemForEmeralds(Items.bow, new PriceInfo(2, 3)), - new ItemAndEmeraldToItem(Item.getItemFromBlock(Blocks.gravel), new PriceInfo(10, 10), Items.flint, new PriceInfo(6, 10)) - } - } - }, - { - { - { - new EmeraldForItems(Items.paper, new PriceInfo(24, 36)), - new ListEnchantedBookForEmeralds() - }, - { - new EmeraldForItems(Items.book, new PriceInfo(8, 10)), - new ListItemForEmeralds(Items.compass, new PriceInfo(10, 12)), - new ListItemForEmeralds(Item.getItemFromBlock(Blocks.bookshelf), new PriceInfo(3, 4)) - }, - { - new EmeraldForItems(Items.written_book, new PriceInfo(2, 2)), - new ListItemForEmeralds(Items.clock, new PriceInfo(10, 12)), - new ListItemForEmeralds(Item.getItemFromBlock(Blocks.glass), new PriceInfo(-5, -3)) - }, - { - new ListEnchantedBookForEmeralds() - }, - { - new ListEnchantedBookForEmeralds() - }, - { - new ListItemForEmeralds(Items.name_tag, new PriceInfo(20, 22)) - } - } - }, - { - { - { - new EmeraldForItems(Items.rotten_flesh, new PriceInfo(36, 40)), - new EmeraldForItems(Items.gold_ingot, new PriceInfo(8, 10)) - }, - { - new ListItemForEmeralds(Items.redstone, new PriceInfo(-4, -1)), - new ListItemForEmeralds(new ItemStack(Items.dye, 1, EnumDyeColor.BLUE.func_176767_b()), - new PriceInfo(-2, -1)) - }, - { - new ListItemForEmeralds(Items.ender_eye, new PriceInfo(7, 11)), - new ListItemForEmeralds(Item.getItemFromBlock(Blocks.glowstone), new PriceInfo(-3, -1)) - }, - { - new ListItemForEmeralds(Items.experience_bottle, new PriceInfo(3, 11)) - } - } - }, - { - { - { - new EmeraldForItems(Items.coal, new PriceInfo(16, 24)), - new ListItemForEmeralds(Items.iron_helmet, new PriceInfo(4, 6)) - }, - { - new EmeraldForItems(Items.iron_ingot, new PriceInfo(7, 9)), - new ListItemForEmeralds(Items.iron_chestplate, new PriceInfo(10, 14)) - }, - { - new EmeraldForItems(Items.diamond, new PriceInfo(3, 4)), - new ListEnchantedItemForEmeralds(Items.diamond_chestplate, new PriceInfo(16, 19)) - }, - { - new ListItemForEmeralds(Items.chainmail_boots, new PriceInfo(5, 7)), - new ListItemForEmeralds(Items.chainmail_leggings, new PriceInfo(9, 11)), - new ListItemForEmeralds(Items.chainmail_helmet, new PriceInfo(5, 7)), - new ListItemForEmeralds(Items.chainmail_chestplate, new PriceInfo(11, 15)) - } - }, - { - { - new EmeraldForItems(Items.coal, new PriceInfo(16, 24)), - new ListItemForEmeralds(Items.iron_axe, new PriceInfo(6, 8)) - }, - { - new EmeraldForItems(Items.iron_ingot, new PriceInfo(7, 9)), - new ListEnchantedItemForEmeralds(Items.iron_sword, new PriceInfo(9, 10)) - }, - { - new EmeraldForItems(Items.diamond, new PriceInfo(3, 4)), - new ListEnchantedItemForEmeralds(Items.diamond_sword, new PriceInfo(12, 15)), - new ListEnchantedItemForEmeralds(Items.diamond_axe, new PriceInfo(9, 12)) - } - }, - { - { - new EmeraldForItems(Items.coal, new PriceInfo(16, 24)), - new ListEnchantedItemForEmeralds(Items.iron_shovel, new PriceInfo(5, 7)) - }, - { - new EmeraldForItems(Items.iron_ingot, new PriceInfo(7, 9)), - new ListEnchantedItemForEmeralds(Items.iron_pickaxe, new PriceInfo(9, 11)) - }, - { - new EmeraldForItems(Items.diamond, new PriceInfo(3, 4)), - new ListEnchantedItemForEmeralds(Items.diamond_pickaxe, new PriceInfo(12, 15)) - } - } - }, - { - { - { - new EmeraldForItems(Items.porkchop, new PriceInfo(14, 18)), - new EmeraldForItems(Items.chicken, new PriceInfo(14, 18)) - }, - { - new EmeraldForItems(Items.coal, new PriceInfo(16, 24)), - new ListItemForEmeralds(Items.cooked_porkchop, new PriceInfo(-7, -5)), - new ListItemForEmeralds(Items.cooked_chicken, new PriceInfo(-8, -6)) - } - }, - { - { - new EmeraldForItems(Items.leather, new PriceInfo(9, 12)), - new ListItemForEmeralds(Items.leather_leggings, new PriceInfo(2, 4)) - }, - { - new ListEnchantedItemForEmeralds(Items.leather_chestplate, new PriceInfo(7, 12)) - }, - { - new ListItemForEmeralds(Items.saddle, new PriceInfo(8, 10)) - } - } - } - }; + private void init() { @@ -401,33 +208,33 @@ public class VillagerRegistry VillagerProfession prof = new VillagerProfession("minecraft:farmer", "minecraft:textures/entity/villager/farmer.png"); { register(prof); - (new VillagerCareer(prof, "farmer" )).init(vanillaTrades[0][0]); - (new VillagerCareer(prof, "fisherman" )).init(vanillaTrades[0][1]); - (new VillagerCareer(prof, "shepherd" )).init(vanillaTrades[0][2]); - (new VillagerCareer(prof, "fletcher" )).init(vanillaTrades[0][3]); + (new VillagerCareer(prof, "farmer" )).init(VanillaTrades.trades[0][0]); + (new VillagerCareer(prof, "fisherman" )).init(VanillaTrades.trades[0][1]); + (new VillagerCareer(prof, "shepherd" )).init(VanillaTrades.trades[0][2]); + (new VillagerCareer(prof, "fletcher" )).init(VanillaTrades.trades[0][3]); } prof = new VillagerProfession("minecraft:librarian", "minecraft:textures/entity/villager/librarian.png"); { register(prof); - (new VillagerCareer(prof, "librarian")).init(vanillaTrades[1][0]); + (new VillagerCareer(prof, "librarian")).init(VanillaTrades.trades[1][0]); } prof = new VillagerProfession("minecraft:priest", "minecraft:textures/entity/villager/priest.png"); { register(prof); - (new VillagerCareer(prof, "cleric")).init(vanillaTrades[2][0]); + (new VillagerCareer(prof, "cleric")).init(VanillaTrades.trades[2][0]); } prof = new VillagerProfession("minecraft:smith", "minecraft:textures/entity/villager/smith.png"); { register(prof); - (new VillagerCareer(prof, "armor" )).init(vanillaTrades[3][0]); - (new VillagerCareer(prof, "weapon")).init(vanillaTrades[3][1]); - (new VillagerCareer(prof, "tool" )).init(vanillaTrades[3][2]); + (new VillagerCareer(prof, "armor" )).init(VanillaTrades.trades[3][0]); + (new VillagerCareer(prof, "weapon")).init(VanillaTrades.trades[3][1]); + (new VillagerCareer(prof, "tool" )).init(VanillaTrades.trades[3][2]); } prof = new VillagerProfession("minecraft:butcher", "minecraft:textures/entity/villager/butcher.png"); { register(prof); - (new VillagerCareer(prof, "butcher")).init(vanillaTrades[4][0]); - (new VillagerCareer(prof, "leather")).init(vanillaTrades[4][1]); + (new VillagerCareer(prof, "butcher")).init(VanillaTrades.trades[4][0]); + (new VillagerCareer(prof, "leather")).init(VanillaTrades.trades[4][1]); } } @@ -492,4 +299,203 @@ public class VillagerRegistry } //TODO: Figure out a good generic system for this. Put on hold for Patches. + + private static class VanillaTrades + { + //This field is moved from EntityVillager over to here. + //Moved to inner class to stop static initializer issues. + //It is nasty I know but it's vanilla. + private static final ITradeList[][][][] trades = + { + { + { + { + new EmeraldForItems(Items.wheat, new PriceInfo(18, 22)), + new EmeraldForItems(Items.potato, new PriceInfo(15, 19)), + new EmeraldForItems(Items.carrot, new PriceInfo(15, 19)), + new ListItemForEmeralds(Items.bread, new PriceInfo(-4, -2)) + }, + { + new EmeraldForItems(Item.getItemFromBlock(Blocks.pumpkin), new PriceInfo(8, 13)), + new ListItemForEmeralds(Items.pumpkin_pie, new PriceInfo(-3, -2)) + }, + { + new EmeraldForItems(Item.getItemFromBlock(Blocks.melon_block), new PriceInfo(7, 12)), + new ListItemForEmeralds(Items.apple, new PriceInfo(-5, -7)) + }, + { + new ListItemForEmeralds(Items.cookie, new PriceInfo(-6, -10)), + new ListItemForEmeralds(Items.cake, new PriceInfo(1, 1)) + } + }, + { + { + new EmeraldForItems(Items.string, new PriceInfo(15, 20)), + new EmeraldForItems(Items.coal, new PriceInfo(16, 24)), + new ItemAndEmeraldToItem(Items.fish, new PriceInfo(6, 6), Items.field_179566_aV, new PriceInfo(6, 6)) + }, + { + new ListEnchantedItemForEmeralds(Items.fishing_rod, new PriceInfo(7, 8)) + } + }, + { + { + new EmeraldForItems(Item.getItemFromBlock(Blocks.wool), new PriceInfo(16, 22)), + new ListItemForEmeralds(Items.shears, new PriceInfo(3, 4)) + }, + { + new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 0), new PriceInfo(1, 2)), + new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 1), new PriceInfo(1, 2)), + new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 2), new PriceInfo(1, 2)), + new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 3), new PriceInfo(1, 2)), + new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 4), new PriceInfo(1, 2)), + new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 5), new PriceInfo(1, 2)), + new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 6), new PriceInfo(1, 2)), + new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 7), new PriceInfo(1, 2)), + new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 8), new PriceInfo(1, 2)), + new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 9), new PriceInfo(1, 2)), + new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 10), new PriceInfo(1, 2)), + new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 11), new PriceInfo(1, 2)), + new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 12), new PriceInfo(1, 2)), + new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 13), new PriceInfo(1, 2)), + new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 14), new PriceInfo(1, 2)), + new ListItemForEmeralds(new ItemStack(Blocks.wool, 1, 15), new PriceInfo(1, 2)) + } + }, + { + { + new EmeraldForItems(Items.string, new PriceInfo(15, 20)), + new ListItemForEmeralds(Items.arrow, new PriceInfo(-12, -8)) + }, + { + new ListItemForEmeralds(Items.bow, new PriceInfo(2, 3)), + new ItemAndEmeraldToItem(Item.getItemFromBlock(Blocks.gravel), new PriceInfo(10, 10), Items.flint, new PriceInfo(6, 10)) + } + } + }, + { + { + { + new EmeraldForItems(Items.paper, new PriceInfo(24, 36)), + new ListEnchantedBookForEmeralds() + }, + { + new EmeraldForItems(Items.book, new PriceInfo(8, 10)), + new ListItemForEmeralds(Items.compass, new PriceInfo(10, 12)), + new ListItemForEmeralds(Item.getItemFromBlock(Blocks.bookshelf), new PriceInfo(3, 4)) + }, + { + new EmeraldForItems(Items.written_book, new PriceInfo(2, 2)), + new ListItemForEmeralds(Items.clock, new PriceInfo(10, 12)), + new ListItemForEmeralds(Item.getItemFromBlock(Blocks.glass), new PriceInfo(-5, -3)) + }, + { + new ListEnchantedBookForEmeralds() + }, + { + new ListEnchantedBookForEmeralds() + }, + { + new ListItemForEmeralds(Items.name_tag, new PriceInfo(20, 22)) + } + } + }, + { + { + { + new EmeraldForItems(Items.rotten_flesh, new PriceInfo(36, 40)), + new EmeraldForItems(Items.gold_ingot, new PriceInfo(8, 10)) + }, + { + new ListItemForEmeralds(Items.redstone, new PriceInfo(-4, -1)), + new ListItemForEmeralds(new ItemStack(Items.dye, 1, EnumDyeColor.BLUE.func_176767_b()), + new PriceInfo(-2, -1)) + }, + { + new ListItemForEmeralds(Items.ender_eye, new PriceInfo(7, 11)), + new ListItemForEmeralds(Item.getItemFromBlock(Blocks.glowstone), new PriceInfo(-3, -1)) + }, + { + new ListItemForEmeralds(Items.experience_bottle, new PriceInfo(3, 11)) + } + } + }, + { + { + { + new EmeraldForItems(Items.coal, new PriceInfo(16, 24)), + new ListItemForEmeralds(Items.iron_helmet, new PriceInfo(4, 6)) + }, + { + new EmeraldForItems(Items.iron_ingot, new PriceInfo(7, 9)), + new ListItemForEmeralds(Items.iron_chestplate, new PriceInfo(10, 14)) + }, + { + new EmeraldForItems(Items.diamond, new PriceInfo(3, 4)), + new ListEnchantedItemForEmeralds(Items.diamond_chestplate, new PriceInfo(16, 19)) + }, + { + new ListItemForEmeralds(Items.chainmail_boots, new PriceInfo(5, 7)), + new ListItemForEmeralds(Items.chainmail_leggings, new PriceInfo(9, 11)), + new ListItemForEmeralds(Items.chainmail_helmet, new PriceInfo(5, 7)), + new ListItemForEmeralds(Items.chainmail_chestplate, new PriceInfo(11, 15)) + } + }, + { + { + new EmeraldForItems(Items.coal, new PriceInfo(16, 24)), + new ListItemForEmeralds(Items.iron_axe, new PriceInfo(6, 8)) + }, + { + new EmeraldForItems(Items.iron_ingot, new PriceInfo(7, 9)), + new ListEnchantedItemForEmeralds(Items.iron_sword, new PriceInfo(9, 10)) + }, + { + new EmeraldForItems(Items.diamond, new PriceInfo(3, 4)), + new ListEnchantedItemForEmeralds(Items.diamond_sword, new PriceInfo(12, 15)), + new ListEnchantedItemForEmeralds(Items.diamond_axe, new PriceInfo(9, 12)) + } + }, + { + { + new EmeraldForItems(Items.coal, new PriceInfo(16, 24)), + new ListEnchantedItemForEmeralds(Items.iron_shovel, new PriceInfo(5, 7)) + }, + { + new EmeraldForItems(Items.iron_ingot, new PriceInfo(7, 9)), + new ListEnchantedItemForEmeralds(Items.iron_pickaxe, new PriceInfo(9, 11)) + }, + { + new EmeraldForItems(Items.diamond, new PriceInfo(3, 4)), + new ListEnchantedItemForEmeralds(Items.diamond_pickaxe, new PriceInfo(12, 15)) + } + } + }, + { + { + { + new EmeraldForItems(Items.porkchop, new PriceInfo(14, 18)), + new EmeraldForItems(Items.chicken, new PriceInfo(14, 18)) + }, + { + new EmeraldForItems(Items.coal, new PriceInfo(16, 24)), + new ListItemForEmeralds(Items.cooked_porkchop, new PriceInfo(-7, -5)), + new ListItemForEmeralds(Items.cooked_chicken, new PriceInfo(-8, -6)) + } + }, + { + { + new EmeraldForItems(Items.leather, new PriceInfo(9, 12)), + new ListItemForEmeralds(Items.leather_leggings, new PriceInfo(2, 4)) + }, + { + new ListEnchantedItemForEmeralds(Items.leather_chestplate, new PriceInfo(7, 12)) + }, + { + new ListItemForEmeralds(Items.saddle, new PriceInfo(8, 10)) + } + } + } + }; + } }