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);
}
}
}
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);
}
Aggregations