Search in sources :

Example 11 with MMDMaterial

use of com.mcmoddev.lib.material.MMDMaterial in project BaseMetals by MinecraftModDevelopmentMods.

the class FallbackGeneratorData method setup.

/**
 */
public void setup() {
    for (final Entry<Integer, Map<MMDMaterial, List<String>>> matMap : materials.entrySet()) {
        final Map<MMDMaterial, List<String>> mats = matMap.getValue();
        final List<WorldGenMinable> spawnList = spawns.getOrDefault(matMap.getKey(), new ArrayList<>());
        final Predicate<IBlockState> pred = getPredicateForDimension(matMap.getKey());
        for (final Entry<MMDMaterial, List<String>> matList : mats.entrySet()) {
            MMDMaterial mat = matList.getKey();
            matList.getValue().stream().forEach(blockName -> spawnList.add(new WorldGenMinable(mat.getBlock(blockName).getDefaultState(), mat.getSpawnSize() > 0 ? mat.getSpawnSize() : 8, pred)));
        }
        spawns.put(matMap.getKey(), spawnList);
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) WorldGenMinable(net.minecraft.world.gen.feature.WorldGenMinable) MMDMaterial(com.mcmoddev.lib.material.MMDMaterial) ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 12 with MMDMaterial

use of com.mcmoddev.lib.material.MMDMaterial in project BaseMetals by MinecraftModDevelopmentMods.

the class ShieldUpgradeRecipe method getPlates.

private Map<String, NonNullList<ItemStack>> getPlates() {
    final Collection<MMDMaterial> allmats = Materials.getAllMaterials();
    final int hardness = ((Float) Materials.getMaterialByName(materialName).getStat(MaterialStats.HARDNESS)).intValue();
    final Map<String, NonNullList<ItemStack>> plates = new TreeMap<>();
    for (final MMDMaterial mat : allmats) {
        if (mat.getStat(MaterialStats.HARDNESS) >= hardness && (!mat.getName().equals(materialName))) {
            final NonNullList<ItemStack> mats = OreDictionary.getOres(Oredicts.PLATE + mat.getCapitalizedName());
            plates.put(mat.getName(), mats);
        }
    }
    return plates;
}
Also used : NonNullList(net.minecraft.util.NonNullList) MMDMaterial(com.mcmoddev.lib.material.MMDMaterial) TreeMap(java.util.TreeMap) ItemStack(net.minecraft.item.ItemStack)

Example 13 with MMDMaterial

use of com.mcmoddev.lib.material.MMDMaterial in project BaseMetals by MinecraftModDevelopmentMods.

the class ShieldUpgradeRecipe method getCost.

/**
 * @param inv
 * @return
 */
public int getCost(final InventoryCrafting inv) {
    final MMDMaterial shieldMat = Materials.getMaterialByName(materialName);
    final MMDMaterial upgradeMat = getUpgradeMat(inv);
    final float hardDiff = upgradeMat.getStat(MaterialStats.HARDNESS) - shieldMat.getStat(MaterialStats.HARDNESS);
    final int enchantCount = getEnchantCount(inv);
    final float diffVal = hardDiff * 5;
    final float enchantVal = upgradeMat.getStat(MaterialStats.MAGICAFFINITY) * enchantCount;
    Float finalVal = diffVal + enchantVal;
    if (finalVal < 5.0f) {
        finalVal = 5.0f;
    }
    return finalVal.intValue();
}
Also used : MMDMaterial(com.mcmoddev.lib.material.MMDMaterial)

Example 14 with MMDMaterial

use of com.mcmoddev.lib.material.MMDMaterial in project BaseMetals by MinecraftModDevelopmentMods.

the class ShieldUpgradeRecipe method matches.

@Override
public boolean matches(final InventoryCrafting inv, final World worldIn) {
    final NonNullList<ItemStack> upgradeMats = NonNullList.create();
    final Collection<MMDMaterial> allmats = Materials.getAllMaterials();
    final MMDMaterial input = Materials.getMaterialByName(materialName);
    final ItemStack base = new ItemStack(input.getItem(Names.SHIELD), 1, 0);
    for (final MMDMaterial mat : allmats) {
        if (mat.getStat(MaterialStats.HARDNESS) >= input.getStat(MaterialStats.HARDNESS) && mat.getName().equals(materialName)) {
            final NonNullList<ItemStack> mats = OreDictionary.getOres(Oredicts.PLATE + mat.getCapitalizedName());
            upgradeMats.addAll(mats);
        }
    }
    boolean[] matches = new boolean[] { false, false };
    for (int i = 0; i < inv.getSizeInventory(); i++) {
        final ItemStack curItem = inv.getStackInSlot(i);
        if (!curItem.isEmpty()) {
            final ItemStack comp = new ItemStack(curItem.getItem(), 1, curItem.getItemDamage());
            if (OreDictionary.itemMatches(base, comp, false)) {
                matches[0] = true;
            } else if (OreDictionary.containsMatch(false, upgradeMats, comp)) {
                matches[1] = true;
            }
        }
    }
    return matches[0] ? matches[1] : false;
}
Also used : MMDMaterial(com.mcmoddev.lib.material.MMDMaterial) ItemStack(net.minecraft.item.ItemStack)

Example 15 with MMDMaterial

use of com.mcmoddev.lib.material.MMDMaterial in project BaseMetals by MinecraftModDevelopmentMods.

the class BMeThermalExpansion method regShit.

/**
 * @param event The Event.
 */
@SubscribeEvent
public void regShit(final RegistryEvent.Register<IRecipe> event) {
    final List<String> materials = Arrays.asList(MaterialNames.ADAMANTINE, MaterialNames.ANTIMONY, MaterialNames.AQUARIUM, MaterialNames.BISMUTH, MaterialNames.BRASS, MaterialNames.COLDIRON, MaterialNames.CUPRONICKEL, MaterialNames.PEWTER, MaterialNames.STARSTEEL, MaterialNames.ZINC, MaterialNames.MERCURY, MaterialNames.REDSTONE);
    materials.stream().filter(Materials::hasMaterial).filter(materialName -> !Materials.getMaterialByName(materialName).isEmpty()).forEach(materialName -> {
        addFurnace(materialName);
        addCrucible(materialName);
        addPlatePress(materialName);
        addPressStorage(materialName);
        addPulverizer(materialName);
    });
    final MMDMaterial brass = Materials.getMaterialByName(MaterialNames.BRASS);
    final MMDMaterial copper = Materials.getMaterialByName(MaterialNames.COPPER);
    final MMDMaterial cupronickel = Materials.getMaterialByName(MaterialNames.CUPRONICKEL);
    final MMDMaterial nickel = Materials.getMaterialByName(MaterialNames.NICKEL);
    final MMDMaterial zinc = Materials.getMaterialByName(MaterialNames.ZINC);
    final MMDMaterial tin = Materials.getMaterialByName(MaterialNames.TIN);
    final MMDMaterial bronze = Materials.getMaterialByName(MaterialNames.BRONZE);
    if (hasMaterials(MaterialNames.COPPER, MaterialNames.ZINC, MaterialNames.BRASS) && materialsHaveItems(Arrays.asList(MaterialNames.COPPER, MaterialNames.ZINC, MaterialNames.BRASS), Names.INGOT.toString())) {
        ThermalExpansionHelper.addSmelterRecipe(4000, copper.getItemStack(Names.INGOT, 2), zinc.getItemStack(Names.INGOT, 1), brass.getItemStack(Names.INGOT, 3));
    }
    if (hasMaterials(MaterialNames.COPPER, MaterialNames.NICKEL, MaterialNames.CUPRONICKEL) && materialsHaveItems(Arrays.asList(MaterialNames.COPPER, MaterialNames.NICKEL, MaterialNames.CUPRONICKEL), Names.INGOT.toString())) {
        ThermalExpansionHelper.addSmelterRecipe(4000, copper.getItemStack(Names.INGOT, 3), nickel.getItemStack(Names.INGOT, 1), cupronickel.getItemStack(Names.INGOT, 4));
    }
    if (hasMaterials(MaterialNames.COPPER, MaterialNames.TIN, MaterialNames.BRONZE) && materialsHaveItems(Arrays.asList(MaterialNames.COPPER, MaterialNames.TIN, MaterialNames.BRONZE), Names.INGOT.toString())) {
        ThermalExpansionHelper.addSmelterRecipe(4000, copper.getItemStack(Names.INGOT, 3), tin.getItemStack(Names.INGOT, 1), bronze.getItemStack(Names.INGOT, 3));
    }
}
Also used : Arrays(java.util.Arrays) IRecipe(net.minecraft.item.crafting.IRecipe) Options(com.mcmoddev.lib.util.Config.Options) Materials(com.mcmoddev.lib.init.Materials) ThermalExpansion(com.mcmoddev.lib.integration.plugins.ThermalExpansion) MMDMaterial(com.mcmoddev.lib.material.MMDMaterial) ThermalExpansionHelper(cofh.api.util.ThermalExpansionHelper) MaterialNames(com.mcmoddev.basemetals.data.MaterialNames) Names(com.mcmoddev.lib.data.Names) IIntegration(com.mcmoddev.lib.integration.IIntegration) List(java.util.List) MMDPlugin(com.mcmoddev.lib.integration.MMDPlugin) MinecraftForge(net.minecraftforge.common.MinecraftForge) BaseMetals(com.mcmoddev.basemetals.BaseMetals) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) RegistryEvent(net.minecraftforge.event.RegistryEvent) Materials(com.mcmoddev.lib.init.Materials) MMDMaterial(com.mcmoddev.lib.material.MMDMaterial) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

MMDMaterial (com.mcmoddev.lib.material.MMDMaterial)45 List (java.util.List)9 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)9 BaseMetals (com.mcmoddev.basemetals.BaseMetals)8 Arrays (java.util.Arrays)8 MaterialNames (com.mcmoddev.basemetals.data.MaterialNames)7 Names (com.mcmoddev.lib.data.Names)7 Materials (com.mcmoddev.lib.init.Materials)7 ItemStack (net.minecraft.item.ItemStack)6 RegistryEvent (net.minecraftforge.event.RegistryEvent)6 IIntegration (com.mcmoddev.lib.integration.IIntegration)5 MMDPlugin (com.mcmoddev.lib.integration.MMDPlugin)5 IMMDObject (com.mcmoddev.lib.material.IMMDObject)5 Oredicts (com.mcmoddev.lib.util.Oredicts)5 MinecraftForge (net.minecraftforge.common.MinecraftForge)5 ImmutableList (com.google.common.collect.ImmutableList)4 Options (com.mcmoddev.lib.util.Config.Options)4 Item (net.minecraft.item.Item)4 IRecipe (net.minecraft.item.crafting.IRecipe)4 ThermalExpansionHelper (cofh.api.util.ThermalExpansionHelper)2