Search in sources :

Example 1 with PriceInfo

use of net.minecraft.entity.passive.EntityVillager.PriceInfo in project BaseMetals by MinecraftModDevelopmentMods.

the class VillagerTrades method registerCommonTrades.

protected static void registerCommonTrades() {
    final String modid = Loader.instance().activeModContainer().getModId();
    final Map<Integer, List<ITradeList>> tradesTable = new HashMap<>();
    Materials.getMaterialsByMod(modid).stream().filter(material -> !material.isEmpty()).filter(material -> !material.isRare()).filter(material -> {
        final float val = material.getStat(MaterialStats.HARDNESS) + material.getStat(MaterialStats.STRENGTH) + material.getStat(MaterialStats.MAGICAFFINITY) + material.getToolHarvestLevel();
        return emeraldPurchaseValue(val) < 65 && emeraldSaleValue(val) < 65;
    }).forEach(material -> {
        makeArmorTrades(material);
        makeToolTrades(material);
        makeWeaponTrades(material);
        makeIngotTrades(material);
        if (material.getStat(MaterialStats.MAGICAFFINITY) > 5) {
            final float val = material.getStat(MaterialStats.HARDNESS) + material.getStat(MaterialStats.STRENGTH) + material.getStat(MaterialStats.MAGICAFFINITY) + material.getToolHarvestLevel();
            int tradeLevel = tradeLevel(val);
            int armorSmithKey = ARMOR_SMITH | (tradeLevel + 1);
            int weaponSmithKey = WEAPON_SMITH | (tradeLevel + 1);
            int toolSmithKeyOne = TOOL_SMITH | (tradeLevel + 1);
            int toolSmithKeyTwo = TOOL_SMITH | (tradeLevel + 2);
            int armorMod = (int) (material.getStat(MaterialStats.HARDNESS) / 2);
            int weaponMod = (int) (material.getBaseAttackDamage() / 2);
            int emeraldPurchaseValueBase = emeraldPurchaseValue(val);
            Arrays.asList(Names.SWORD, Names.CROSSBOW, Names.BOW).stream().filter(material::hasItem).forEach(name -> tradesTable.computeIfAbsent(weaponSmithKey, (Integer key) -> new ArrayList<>()).addAll(Collections.singletonList(new ListEnchantedItemForEmeralds(material.getItem(name), new PriceInfo(emeraldPurchaseValueBase + 7 + weaponMod - 1, emeraldPurchaseValueBase + 12 + weaponMod - 1)))));
            Arrays.asList(Names.HELMET, Names.CHESTPLATE, Names.LEGGINGS, Names.BOOTS).stream().filter(material::hasItem).forEach(name -> tradesTable.computeIfAbsent(armorSmithKey, (Integer key) -> new ArrayList<>()).addAll(Collections.singletonList(new ListEnchantedItemForEmeralds(material.getItem(name), new PriceInfo(emeraldPurchaseValueBase + 7 + armorMod, emeraldPurchaseValueBase + 12 + armorMod)))));
            Arrays.asList(Names.AXE, Names.HOE, Names.SHOVEL, Names.PICKAXE).stream().filter(material::hasItem).forEach(name -> tradesTable.computeIfAbsent(toolSmithKeyOne, (Integer key) -> new ArrayList<>()).addAll(Collections.singletonList(new ListEnchantedItemForEmeralds(material.getItem(name), new PriceInfo(emeraldPurchaseValueBase + 7, emeraldPurchaseValueBase + 12)))));
            tradesTable.computeIfAbsent(toolSmithKeyTwo, (Integer key) -> new ArrayList<>()).addAll(Collections.singletonList(new ListEnchantedItemForEmeralds(material.getItem(Names.CRACKHAMMER), new PriceInfo(emeraldPurchaseValueBase + 7, emeraldPurchaseValueBase + 12))));
        }
    });
    commitTrades(tradesTable);
}
Also used : IMerchant(net.minecraft.entity.IMerchant) Arrays(java.util.Arrays) MerchantRecipeList(net.minecraft.village.MerchantRecipeList) Loader(net.minecraftforge.fml.common.Loader) MerchantRecipe(net.minecraft.village.MerchantRecipe) Item(net.minecraft.item.Item) HashMap(java.util.HashMap) Random(java.util.Random) MMDMaterial(com.mcmoddev.lib.material.MMDMaterial) SharedStrings(com.mcmoddev.lib.data.SharedStrings) ArrayList(java.util.ArrayList) Names(com.mcmoddev.lib.data.Names) ItemStack(net.minecraft.item.ItemStack) List(java.util.List) MaterialStats(com.mcmoddev.lib.data.MaterialStats) VillagerTradeHelper(com.mcmoddev.basemetals.util.VillagerTradeHelper) ListEnchantedItemForEmeralds(net.minecraft.entity.passive.EntityVillager.ListEnchantedItemForEmeralds) Map(java.util.Map) PriceInfo(net.minecraft.entity.passive.EntityVillager.PriceInfo) Entry(java.util.Map.Entry) ResourceLocation(net.minecraft.util.ResourceLocation) ITradeList(net.minecraft.entity.passive.EntityVillager.ITradeList) Collections(java.util.Collections) Nonnull(javax.annotation.Nonnull) ListEnchantedItemForEmeralds(net.minecraft.entity.passive.EntityVillager.ListEnchantedItemForEmeralds) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) MerchantRecipeList(net.minecraft.village.MerchantRecipeList) ArrayList(java.util.ArrayList) List(java.util.List) ITradeList(net.minecraft.entity.passive.EntityVillager.ITradeList) PriceInfo(net.minecraft.entity.passive.EntityVillager.PriceInfo)

Example 2 with PriceInfo

use of net.minecraft.entity.passive.EntityVillager.PriceInfo in project pnc-repressurized by TeamPneumatic.

the class VillagerHandler method init.

public static void init() {
    mechanicProfession = new VillagerProfession(Names.MOD_ID + ":mechanic", Textures.VILLAGER_MECHANIC, "minecraft:textures/entity/zombie_villager/zombie_villager.png");
    VillagerCareer career = new VillagerCareer(mechanicProfession, Names.MOD_ID + ".mechanic");
    career.addTrade(1, new ListItemForEmeralds(Itemss.PCB_BLUEPRINT, new PriceInfo(10, 19)), new ListItemForEmeralds(Itemss.NUKE_VIRUS, new PriceInfo(1, 5)), new ListItemForEmeralds(Itemss.STOP_WORM, new PriceInfo(1, 5)));
    for (int i = 0; i < ItemAssemblyProgram.PROGRAMS_AMOUNT; i++) {
        career.addTrade(1, new ListItemForEmeralds(new ItemStack(Itemss.ASSEMBLY_PROGRAM, 1, i), new PriceInfo(5, 11)));
    }
}
Also used : VillagerCareer(net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerCareer) VillagerProfession(net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession) ItemStack(net.minecraft.item.ItemStack) ListItemForEmeralds(net.minecraft.entity.passive.EntityVillager.ListItemForEmeralds) PriceInfo(net.minecraft.entity.passive.EntityVillager.PriceInfo)

Aggregations

PriceInfo (net.minecraft.entity.passive.EntityVillager.PriceInfo)2 ItemStack (net.minecraft.item.ItemStack)2 VillagerTradeHelper (com.mcmoddev.basemetals.util.VillagerTradeHelper)1 MaterialStats (com.mcmoddev.lib.data.MaterialStats)1 Names (com.mcmoddev.lib.data.Names)1 SharedStrings (com.mcmoddev.lib.data.SharedStrings)1 MMDMaterial (com.mcmoddev.lib.material.MMDMaterial)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Random (java.util.Random)1 Nonnull (javax.annotation.Nonnull)1 IMerchant (net.minecraft.entity.IMerchant)1 ITradeList (net.minecraft.entity.passive.EntityVillager.ITradeList)1 ListEnchantedItemForEmeralds (net.minecraft.entity.passive.EntityVillager.ListEnchantedItemForEmeralds)1 ListItemForEmeralds (net.minecraft.entity.passive.EntityVillager.ListItemForEmeralds)1