Search in sources :

Example 1 with RegItem

use of cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.RegItem in project FoodCraft-Reloaded by LasmGratel.

the class ItemLoader method registerOre.

@Load(LoaderState.AVAILABLE)
public void registerOre() {
    for (Field field : FCRItems.class.getFields()) {
        field.setAccessible(true);
        try {
            RegItem annoItem = field.getAnnotation(RegItem.class);
            if (annoItem == null)
                continue;
            Item item = (Item) field.get(null);
            Arrays.asList(annoItem.oreDict()).parallelStream().forEach(s -> OreDictionary.registerOre(s, item));
        } catch (Throwable e) {
            FoodCraftReloaded.getLogger().warn("Un-able to register item " + field.toGenericString(), e);
        }
    }
}
Also used : Field(java.lang.reflect.Field) RegItem(cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.RegItem) Item(net.minecraft.item.Item) RegItem(cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.RegItem) Load(cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.Load)

Example 2 with RegItem

use of cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.RegItem in project FoodCraft-Reloaded by LasmGratel.

the class ItemLoader method registerRenders.

@Load(side = Side.CLIENT)
public void registerRenders() {
    for (Field field : FCRItems.class.getFields()) {
        field.setAccessible(true);
        RegItem anno = field.getAnnotation(RegItem.class);
        try {
            if (anno == null)
                continue;
            Item item = (Item) field.get(null);
            if (item instanceof CustomModelMasking && ((CustomModelMasking) item).getModelLocation() != null) {
                ModelLoader.setCustomModelResourceLocation(item, 0, ((CustomModelMasking) item).getModelLocation());
            }
            if (item.getHasSubtypes()) {
                if (item instanceof IMetadatable) {
                    for (int i = 0; i < ((IMetadatable) item).getMaxMetadata(); i++) registerRender(item, i);
                }
            } else {
                registerRender(item, 0);
            }
        } catch (Exception e) {
            FoodCraftReloaded.getLogger().warn("Un-able to register item " + field.toGenericString(), e);
        }
    }
}
Also used : Field(java.lang.reflect.Field) RegItem(cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.RegItem) Item(net.minecraft.item.Item) RegItem(cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.RegItem) CustomModelMasking(cc.lasmgratel.foodcraftreloaded.minecraft.client.util.masking.CustomModelMasking) IMetadatable(cc.lasmgratel.foodcraftreloaded.minecraft.common.item.IMetadatable) Load(cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.Load)

Aggregations

Load (cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.Load)2 RegItem (cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.RegItem)2 Field (java.lang.reflect.Field)2 Item (net.minecraft.item.Item)2 CustomModelMasking (cc.lasmgratel.foodcraftreloaded.minecraft.client.util.masking.CustomModelMasking)1 IMetadatable (cc.lasmgratel.foodcraftreloaded.minecraft.common.item.IMetadatable)1