Search in sources :

Example 1 with ArmorMaterial

use of net.minecraft.item.ItemArmor.ArmorMaterial in project BaseMetals by MinecraftModDevelopmentMods.

the class Materials method registerMaterial.

/**
 * Register a material.
 *
 * @param material
 *            the material to register
 * @return the material
 */
protected static MMDMaterial registerMaterial(@Nonnull final MMDMaterial material) {
    final String modId = Loader.instance().activeModContainer().getModId();
    final ResourceLocation loc = new ResourceLocation(modId, material.getName());
    if (REGISTRY.containsKey(loc)) {
        BaseMetals.logger.error("You asked registermaterial() to register an existing material, Don't do that! (Returning pre existing material instead");
        return Materials.getMaterialByName(material.getName());
    }
    material.setRegistryName(loc);
    REGISTRY.register(material);
    final String enumName = material.getEnumName();
    final String texName = material.getName();
    final int[] protection = material.getDamageReductionArray();
    final int durability = material.getArmorMaxDamageFactor();
    final ArmorMaterial armorMaterial = EnumHelper.addArmorMaterial(enumName, texName, durability, protection, material.getEnchantability(), SoundEvents.ITEM_ARMOR_EQUIP_IRON, material.getStat(MaterialStats.HARDNESS) > 10 ? (int) (material.getStat(MaterialStats.HARDNESS) / 5) : 0);
    if (armorMaterial == null) {
        // uh-oh
        BaseMetals.logger.error("Failed to create armor material enum for " + material);
    }
    armorMaterialMap.put(material, armorMaterial);
    final ToolMaterial toolMaterial = EnumHelper.addToolMaterial(enumName, material.getToolHarvestLevel(), material.getToolDurability(), material.getToolEfficiency(), material.getBaseAttackDamage(), material.getEnchantability());
    if (toolMaterial == null) {
        // uh-oh
        BaseMetals.logger.error("Failed to create tool material enum for " + material);
    }
    toolMaterialMap.put(material, toolMaterial);
    return material;
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) ToolMaterial(net.minecraft.item.Item.ToolMaterial) ArmorMaterial(net.minecraft.item.ItemArmor.ArmorMaterial)

Aggregations

ToolMaterial (net.minecraft.item.Item.ToolMaterial)1 ArmorMaterial (net.minecraft.item.ItemArmor.ArmorMaterial)1 ResourceLocation (net.minecraft.util.ResourceLocation)1