use of net.minecraft.entity.passive.EntityVillager.ListEnchantedItemForEmeralds 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);
}
Aggregations