net.minecraftforge.common.util.EnumHelper Java Examples

The following examples show how to use net.minecraftforge.common.util.EnumHelper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EnumUtils.java    From bartworks with MIT License 6 votes vote down vote up
public static OrePrefixes addNewOrePrefix(String enumName, String aRegularLocalName, String aLocalizedMaterialPre, String aLocalizedMaterialPost,
                                          boolean aIsUnificatable, boolean aIsMaterialBased, boolean aIsSelfReferencing,
                                          boolean aIsContainer, boolean aDontUnificateActively, boolean aIsUsedForBlocks,
                                          boolean aAllowNormalRecycling, boolean aGenerateDefaultItem, boolean aIsEnchantable,
                                          boolean aIsUsedForOreProcessing, int aMaterialGenerationBits, long aMaterialAmount,
                                          int aDefaultStackSize, int aTextureindex) {
    return EnumHelper.addEnum(OrePrefixes.class, enumName, new Class<?>[]{
            String.class, String.class, String.class,
            boolean.class, boolean.class, boolean.class,
            boolean.class, boolean.class, boolean.class,
            boolean.class, boolean.class, boolean.class,
            boolean.class, int.class, long.class,
            int.class, int.class
    }, new Object[]{
            aRegularLocalName, aLocalizedMaterialPre, aLocalizedMaterialPost,
            aIsUnificatable, aIsMaterialBased, aIsSelfReferencing,
            aIsContainer, aDontUnificateActively, aIsUsedForBlocks,
            aAllowNormalRecycling, aGenerateDefaultItem, aIsEnchantable,
            aIsUsedForOreProcessing, aMaterialGenerationBits, aMaterialAmount,
            aDefaultStackSize, aTextureindex
    });
}
 
Example #2
Source File: ArmorMaterial.java    From customstuff4 with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void doInit(InitPhase phase, ContentHelper helper)
{
    checkState(id != null && id.matches("[_a-zA-Z][_a-zA-Z0-9]*"), "Invalid id: " + id);

    int[] damageReduction = new int[] {
            armorBoots,
            armorLegs,
            armorChest,
            armorHelmet
    };

    material = EnumHelper.addArmorMaterial(id, textureName, durability, damageReduction, enchantability, equipSound, toughness);
    if (repairItem != null)
    {
        material.setRepairItem(repairItem.getItemStack().copy());
    }
}
 
Example #3
Source File: Materials.java    From BaseMetals with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected static void registerMaterial(String name, MetalMaterial m){

		allMaterials.put(name, m);
		
		String enumName = m.getEnumName();
		String texName = m.getName();
		int[] protection = m.getDamageReductionArray();
		int durability = m.getArmorMaxDamageFactor();
		ArmorMaterial am = EnumHelper.addArmorMaterial(enumName, texName, durability, protection, m.getEnchantability(), SoundEvents.ITEM_ARMOR_EQUIP_IRON, (m.hardness > 10 ? (int)(m.hardness / 5) : 0));
		if(am == null){
			// uh-oh
			FMLLog.severe("Failed to create armor material enum for "+m);
		}
		armorMaterialMap.put(m, am);
		FMLLog.info("Created armor material enum "+am);
		
		ToolMaterial tm = EnumHelper.addToolMaterial(enumName, m.getToolHarvestLevel(), m.getToolDurability(), m.getToolEfficiency(), m.getBaseAttackDamage(), m.getEnchantability());
		if(tm == null){
			// uh-oh
			FMLLog.severe("Failed to create tool material enum for "+m);
		}
		toolMaterialMap.put(m, tm);
		FMLLog.info("Created tool material enum "+tm);
	}
 
Example #4
Source File: EnumUtils.java    From bartworks with MIT License 5 votes vote down vote up
public static Element createNewElement(String enumName, long aProtons, long aNeutrons, long aAdditionalMass,
                                       long aHalfLifeSeconds, String aDecayTo, String aName, boolean aIsIsotope) {
    return EnumHelper.addEnum(Element.class, enumName, new Class[]{
            long.class, long.class, long.class,
            long.class, String.class, String.class,
            boolean.class
    }, new Object[]{
            aProtons, aNeutrons, aAdditionalMass,
            aHalfLifeSeconds, aDecayTo, aName,
            aIsIsotope
    });
}
 
Example #5
Source File: ToolMaterials.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
protected static void obsidianMaterial() {
	int harvestLevel = 3;
	int durability = 10;
	float miningSpeed = 10f;
	float damageVsEntities = 20f;
	int enchantability = 12;
	OBSIDIAN_MATERIAL = EnumHelper.addToolMaterial("OBSIDIAN", harvestLevel, durability, miningSpeed, damageVsEntities, enchantability);
	OBSIDIAN_MATERIAL.setRepairItem(new ItemStack(Blocks.OBSIDIAN));
}
 
Example #6
Source File: ToolMaterials.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
protected static void fireMaterial() {
	int harvestLevel = 3;
	int durability = 1000;
	float miningSpeed = 8f;
	float damageVsEntities = 9f;
	int enchantability = 20;
	FIRE_MATERIAL = EnumHelper.addToolMaterial("FIRE", harvestLevel, durability, miningSpeed, damageVsEntities, enchantability);
	FIRE_MATERIAL.setRepairItem(new ItemStack(Blocks.MAGMA));
}
 
Example #7
Source File: CraftEntity.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
public static void initMappings() {
    for (Map.Entry<Class<? extends Entity>, String> entry : cpw.mods.fml.common.registry.EntityRegistry.entityTypeMap.entrySet()) {
        Class<? extends Entity> entityClass = entry.getKey();
        String entityName = entry.getValue();
        int entityId = getEntityTypeIDfromClass(entityClass);

        Class<? extends org.bukkit.entity.Entity> bukkitEntityClass = CraftEntity.getEntityClass(entityClass);
        EnumHelper.addBukkitEntityType(entityName, bukkitEntityClass, entityId, false);
    }
}
 
Example #8
Source File: ItemQuantumGoggles.java    From qcraft-mod with Apache License 2.0 5 votes vote down vote up
public ItemQuantumGoggles()
{
    super(
        EnumHelper.addArmorMaterial( "qgoggles", 0, new int[]{ 0, 0, 0, 0 }, 0 ),
        s_renderIndex,
        0
    );
    setUnlocalizedName( "qcraft:goggles" );
    setCreativeTab( QCraft.getCreativeTab() );
    setHasSubtypes( true );
}
 
Example #9
Source File: Elytra.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
public Elytra() {
	super(EnumHelper.addArmorMaterial("elytra", 27, new int[] { 0, 0, 0, 0 }, 0), 0, 1);
	setMaxDamage(432);
	setMaxStackSize(1);
	setTextureName("elytra");
	setUnlocalizedName(Utils.getUnlocalisedName("elytra"));
	setCreativeTab(EtFuturum.enableElytra ? EtFuturum.creativeTab : null);
}
 
Example #10
Source File: GolemEnumHelper.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
private static void setValues(EnumGolemType[] values) {
    try {
        EnumHelper.setFailsafeFieldValue(getValuesField(), null, values);
    } catch (Exception ignored) { }
}
 
Example #11
Source File: BannerPatternHelper.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
@SuppressWarnings("unchecked")
public static void addPattern(String name, String id, ItemStack craftingItem) throws ClassNotFoundException {
	EnumHelper.addEnum((Class<Enum<?>>) Class.forName("ganymedes01.etfuturum.tileentities.TileEntityBanner$EnumBannerPattern"), name.toUpperCase(), new Class[] { String.class, String.class, ItemStack.class }, new Object[] { name, id, craftingItem });
}
 
Example #12
Source File: BannerPatternHelper.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
@SuppressWarnings("unchecked")
public static void addPattern(String name, String id, String craftingTop, String craftingMid, String craftingBot) throws ClassNotFoundException {
	EnumHelper.addEnum((Class<Enum<?>>) Class.forName("ganymedes01.etfuturum.tileentities.TileEntityBanner$EnumBannerPattern"), name.toUpperCase(), new Class[] { String.class, String.class, String.class, String.class, String.class }, new Object[] { name, id, craftingTop, craftingMid, craftingBot });
}