Search in sources :

Example 1 with ITradeList

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

the class VillagerTrades method registerModSpecificTrades.

protected static void registerModSpecificTrades() {
    if (Materials.hasMaterial(MaterialNames.CHARCOAL)) {
        final MMDMaterial charcoal = Materials.getMaterialByName(MaterialNames.CHARCOAL);
        if (charcoal.hasItem(Names.POWDER)) {
            final Item charcoalPowder = charcoal.getItem(Names.POWDER);
            final ITradeList[] charcoalTrades = makePurchasePalette(1, 10, charcoalPowder);
            VillagerTradeHelper.insertTrades(SMITH_RL, ARMOR_SMITH_ID, 1, charcoalTrades);
            VillagerTradeHelper.insertTrades(SMITH_RL, WEAPON_SMITH_ID, 1, charcoalTrades);
            VillagerTradeHelper.insertTrades(SMITH_RL, TOOL_SMITH_ID, 1, charcoalTrades);
        }
    }
    if (Materials.hasMaterial(MaterialNames.COAL)) {
        final MMDMaterial coal = Materials.getMaterialByName(MaterialNames.COAL);
        if (coal.hasItem(Names.POWDER)) {
            final Item coalPowder = coal.getItem(Names.POWDER);
            final ITradeList[] coalTrades = makePurchasePalette(1, 10, coalPowder);
            VillagerTradeHelper.insertTrades(SMITH_RL, ARMOR_SMITH_ID, 1, coalTrades);
            VillagerTradeHelper.insertTrades(SMITH_RL, WEAPON_SMITH_ID, 1, coalTrades);
            VillagerTradeHelper.insertTrades(SMITH_RL, TOOL_SMITH_ID, 1, coalTrades);
        }
    }
}
Also used : Item(net.minecraft.item.Item) MMDMaterial(com.mcmoddev.lib.material.MMDMaterial) ITradeList(net.minecraft.entity.passive.EntityVillager.ITradeList)

Example 2 with ITradeList

use of net.minecraft.entity.passive.EntityVillager.ITradeList 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)

Aggregations

MMDMaterial (com.mcmoddev.lib.material.MMDMaterial)2 ITradeList (net.minecraft.entity.passive.EntityVillager.ITradeList)2 Item (net.minecraft.item.Item)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 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 ListEnchantedItemForEmeralds (net.minecraft.entity.passive.EntityVillager.ListEnchantedItemForEmeralds)1 PriceInfo (net.minecraft.entity.passive.EntityVillager.PriceInfo)1 ItemStack (net.minecraft.item.ItemStack)1