Search in sources :

Example 6 with Load

use of cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.Load 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)

Example 7 with Load

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

the class PropertiedFoodLoader method registerOreDict.

@Load(LoaderState.AVAILABLE)
public void registerOreDict() {
    for (Field field : FCRFoods.class.getFields()) {
        field.setAccessible(true);
        try {
            RegFood anno = field.getDeclaredAnnotation(RegFood.class);
            if (anno == null) {
                continue;
            }
            ItemPFood item = (ItemPFood) field.get(null);
            Arrays.asList(anno.oreDict()).forEach(s -> OreDictionary.registerOre(s, item));
            OreDictionary.registerOre("listAllfoods", item);
        } catch (IllegalAccessException | NullPointerException e) {
            FoodCraftReloaded.getLogger().warn("Un-able to register food " + field.toGenericString(), e);
        }
    }
}
Also used : Field(java.lang.reflect.Field) ItemPFood(cc.lasmgratel.foodcraftreloaded.minecraft.common.item.food.ItemPFood) RegFood(cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.RegFood) Load(cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.Load)

Aggregations

Load (cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.Load)7 Field (java.lang.reflect.Field)5 ItemBlock (net.minecraft.item.ItemBlock)3 CustomModelMasking (cc.lasmgratel.foodcraftreloaded.minecraft.client.util.masking.CustomModelMasking)2 RegBlock (cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.RegBlock)2 RegItem (cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.RegItem)2 Block (net.minecraft.block.Block)2 Item (net.minecraft.item.Item)2 DrinkRecipe (cc.lasmgratel.foodcraftreloaded.minecraft.api.recipe.DrinkRecipe)1 FluidFruitJuice (cc.lasmgratel.foodcraftreloaded.minecraft.common.fluid.FluidFruitJuice)1 FluidVegetableJuice (cc.lasmgratel.foodcraftreloaded.minecraft.common.fluid.FluidVegetableJuice)1 IMetadatable (cc.lasmgratel.foodcraftreloaded.minecraft.common.item.IMetadatable)1 ItemPFood (cc.lasmgratel.foodcraftreloaded.minecraft.common.item.food.ItemPFood)1 ItemKitchenKnife (cc.lasmgratel.foodcraftreloaded.minecraft.common.item.tool.ItemKitchenKnife)1 KitchenKnifeType (cc.lasmgratel.foodcraftreloaded.minecraft.common.item.tool.KitchenKnifeType)1 RegFood (cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.RegFood)1 ItemStack (net.minecraft.item.ItemStack)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 FluidStack (net.minecraftforge.fluids.FluidStack)1