From 6d194879bfcb1edcbcf81382e11006b6571c0d2e Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 4 Dec 2016 13:27:06 +0100 Subject: [PATCH] Hardcode villager trades Closes #427 --- .../mod/gen/village/InitVillager.java | 14 ++++-- .../mod/gen/village/JamVillagerTradeList.java | 43 ------------------- 2 files changed, 11 insertions(+), 46 deletions(-) delete mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/JamVillagerTradeList.java diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/InitVillager.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/InitVillager.java index a6d2f9034..8224d7df8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/InitVillager.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/InitVillager.java @@ -21,6 +21,7 @@ import de.ellpeck.actuallyadditions.mod.gen.village.component.handler.VillageEng import de.ellpeck.actuallyadditions.mod.gen.village.component.handler.VillageJamHouseHandler; import de.ellpeck.actuallyadditions.mod.items.InitItems; import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals; +import de.ellpeck.actuallyadditions.mod.items.metalists.TheJams; import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; import de.ellpeck.actuallyadditions.mod.util.ModUtil; import net.minecraft.entity.passive.EntityVillager.PriceInfo; @@ -96,9 +97,16 @@ public final class InitVillager{ VillagerRegistry.instance().register(jamProfession); VillagerCareer career = new VillagerCareer(jamProfession, ModUtil.MOD_ID+".jammer"); - for(int i = 0; i < 3; i++){ - career.addTrade(i+1, new JamVillagerTradeList()); - } + career.addTrade(1, + new BasicTradeList(new PriceInfo(1, 4), new ItemStack(InitItems.itemJams, 1, TheJams.CU_BA_RA.ordinal()), new PriceInfo(1, 3)), + new BasicTradeList(new PriceInfo(1, 4), new ItemStack(InitItems.itemJams, 1, TheJams.GRA_KI_BA.ordinal()), new PriceInfo(1, 3))); + career.addTrade(2, + new BasicTradeList(new PriceInfo(1, 4), new ItemStack(InitItems.itemJams, 1, TheJams.PL_AP_LE.ordinal()), new PriceInfo(1, 3)), + new BasicTradeList(new PriceInfo(1, 4), new ItemStack(InitItems.itemJams, 1, TheJams.CH_AP_CI.ordinal()), new PriceInfo(1, 3)), + new BasicTradeList(new PriceInfo(1, 4), new ItemStack(InitItems.itemJams, 1, TheJams.HO_ME_KI.ordinal()), new PriceInfo(1, 3))); + career.addTrade(3, + new BasicTradeList(new PriceInfo(1, 4), new ItemStack(InitItems.itemJams, 1, TheJams.HO_ME_CO.ordinal()), new PriceInfo(1, 3)), + new BasicTradeList(new PriceInfo(1, 4), new ItemStack(InitItems.itemJams, 1, TheJams.PI_CO.ordinal()), new PriceInfo(1, 3))); VillagerRegistry.instance().registerVillageCreationHandler(new VillageJamHouseHandler()); MapGenStructureIO.registerStructureComponent(VillageComponentJamHouse.class, ModUtil.MOD_ID+":jamHouseStructure"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/JamVillagerTradeList.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/JamVillagerTradeList.java deleted file mode 100644 index facd1cb9c..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/JamVillagerTradeList.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file ("JamVillagerTradeList.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2016 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.gen.village; - -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheJams; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.IMerchant; -import net.minecraft.entity.passive.EntityVillager.ITradeList; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.village.MerchantRecipe; -import net.minecraft.village.MerchantRecipeList; - -import java.util.Random; - -public class JamVillagerTradeList implements ITradeList{ - - @Override - public void addMerchantRecipe(IMerchant merchant, MerchantRecipeList recipeList, Random random){ - for(int i = 0; i < random.nextInt(3)+3; i++){ - ItemStack jam = new ItemStack(InitItems.itemJams, 1, random.nextInt(TheJams.values().length)); - ItemStack emerald = new ItemStack(Items.EMERALD); - - if(random.nextFloat() >= 0.65F){ - //Jam as input - recipeList.add(new MerchantRecipe(StackUtil.setStackSize(jam, random.nextInt(3)+1), StackUtil.setStackSize(emerald, random.nextInt(2)+1))); - } - else{ - //Emeralds as input - recipeList.add(new MerchantRecipe(StackUtil.setStackSize(emerald, random.nextInt(6)+2), StackUtil.setStackSize(jam, random.nextInt(4)+2))); - } - } - } -}