Search in sources :

Example 1 with CustomModelMasking

use of cc.lasmgratel.foodcraftreloaded.minecraft.client.util.masking.CustomModelMasking in project FoodCraft-Reloaded by LasmGratel.

the class RegisterLoader method detectAndRegisterLiqueur.

public void detectAndRegisterLiqueur(RegistryEvent.Register<Item> event) {
    event.getRegistry().getKeys().stream().filter(s -> s.getResourcePath().contains("liqueur")).map(ForgeRegistries.ITEMS::getValue).collect(Collectors.toList()).forEach(liqueur -> {
        for (LiqueurType liqueurType : LiqueurTypes.values()) {
            if (liqueurType == LiqueurTypes.NORMAL)
                continue;
            ItemGeneratedLiqueur typedLiqueur = new ItemGeneratedLiqueur(MathHelper.floor(liqueurType.getHealModifier() * ((ItemFood) liqueur).getHealAmount(new ItemStack(liqueur))));
            typedLiqueur.setLiqueurType(liqueurType);
            typedLiqueur.setItemStackDisplayNameCallback(liqueur::getItemStackDisplayName);
            typedLiqueur.setRegistryName(liqueur.getRegistryName().getResourceDomain(), liqueurType.getUnlocalizedName() + "_" + liqueur.getRegistryName().getResourcePath());
            typedLiqueur.setUnlocalizedName(liqueur.getUnlocalizedName());
            event.getRegistry().register(typedLiqueur);
            OreDictionary.registerOre("listAll" + StringUtils.capitalize(liqueurType.getUnlocalizedName()) + "liqueur", typedLiqueur);
            OreDictionary.registerOre("listAllliqueur", typedLiqueur);
            OreDictionary.registerOre("listAllfoods", typedLiqueur);
            if (liqueur instanceof CustomModelMasking)
                FoodCraftReloadedMod.getLoader(LiqueurLoader.class).get().getLiqueurCustomModelMap().put(typedLiqueur, (CustomModelMasking) liqueur);
        }
    });
}
Also used : ItemGeneratedLiqueur(cc.lasmgratel.foodcraftreloaded.minecraft.common.item.food.ItemGeneratedLiqueur) Item(net.minecraft.item.Item) LiqueurTypes(cc.lasmgratel.foodcraftreloaded.minecraft.api.capability.liqueur.LiqueurTypes) ModelRegistryEvent(net.minecraftforge.client.event.ModelRegistryEvent) ItemFood(net.minecraft.item.ItemFood) FoodCraftReloadedMod(cc.lasmgratel.foodcraftreloaded.minecraft.common.FoodCraftReloadedMod) StringUtils(org.apache.commons.lang3.StringUtils) Collectors(java.util.stream.Collectors) LiqueurType(cc.lasmgratel.foodcraftreloaded.minecraft.api.capability.liqueur.LiqueurType) ItemStack(net.minecraft.item.ItemStack) MinecraftForge(net.minecraftforge.common.MinecraftForge) Load(cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.Load) LoaderState(net.minecraftforge.fml.common.LoaderState) Side(net.minecraftforge.fml.relauncher.Side) OreDictionary(net.minecraftforge.oredict.OreDictionary) CustomModelMasking(cc.lasmgratel.foodcraftreloaded.minecraft.client.util.masking.CustomModelMasking) MathHelper(net.minecraft.util.math.MathHelper) ForgeRegistries(net.minecraftforge.fml.common.registry.ForgeRegistries) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) RegistryEvent(net.minecraftforge.event.RegistryEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) LiqueurLoader(cc.lasmgratel.foodcraftreloaded.minecraft.common.loader.LiqueurLoader) ItemGeneratedLiqueur(cc.lasmgratel.foodcraftreloaded.minecraft.common.item.food.ItemGeneratedLiqueur) CustomModelMasking(cc.lasmgratel.foodcraftreloaded.minecraft.client.util.masking.CustomModelMasking) LiqueurType(cc.lasmgratel.foodcraftreloaded.minecraft.api.capability.liqueur.LiqueurType) ItemStack(net.minecraft.item.ItemStack)

Example 2 with CustomModelMasking

use of cc.lasmgratel.foodcraftreloaded.minecraft.client.util.masking.CustomModelMasking in project FoodCraft-Reloaded by LasmGratel.

the class BlockLoader method registerRenders.

@Load(side = Side.CLIENT)
public void registerRenders() {
    for (Field field : FCRBlocks.class.getFields()) {
        field.setAccessible(true);
        RegBlock anno = field.getAnnotation(RegBlock.class);
        if (anno == null)
            continue;
        try {
            Block block = (Block) field.get(null);
            if (block instanceof CustomModelMasking) {
                ModelLoader.setCustomStateMapper(block, b -> ((CustomModelMasking) b).getStateModelLocations());
                if (((CustomModelMasking) block).getModelLocation() != null) {
                    registerRender(Item.getItemFromBlock(block), 0, ((CustomModelMasking) block).getModelLocation());
                    return;
                }
            }
            registerRender(block, 0);
        } catch (Exception e) {
            FoodCraftReloaded.getLogger().warn("Un-able to register block " + field.toGenericString(), e);
        }
    }
}
Also used : Field(java.lang.reflect.Field) RegBlock(cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.RegBlock) CustomModelMasking(cc.lasmgratel.foodcraftreloaded.minecraft.client.util.masking.CustomModelMasking) RegBlock(cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.RegBlock) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) Load(cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.Load)

Example 3 with CustomModelMasking

use of cc.lasmgratel.foodcraftreloaded.minecraft.client.util.masking.CustomModelMasking 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

CustomModelMasking (cc.lasmgratel.foodcraftreloaded.minecraft.client.util.masking.CustomModelMasking)3 Load (cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.Load)3 Field (java.lang.reflect.Field)2 Item (net.minecraft.item.Item)2 LiqueurType (cc.lasmgratel.foodcraftreloaded.minecraft.api.capability.liqueur.LiqueurType)1 LiqueurTypes (cc.lasmgratel.foodcraftreloaded.minecraft.api.capability.liqueur.LiqueurTypes)1 FoodCraftReloadedMod (cc.lasmgratel.foodcraftreloaded.minecraft.common.FoodCraftReloadedMod)1 IMetadatable (cc.lasmgratel.foodcraftreloaded.minecraft.common.item.IMetadatable)1 ItemGeneratedLiqueur (cc.lasmgratel.foodcraftreloaded.minecraft.common.item.food.ItemGeneratedLiqueur)1 LiqueurLoader (cc.lasmgratel.foodcraftreloaded.minecraft.common.loader.LiqueurLoader)1 RegBlock (cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.RegBlock)1 RegItem (cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.RegItem)1 Collectors (java.util.stream.Collectors)1 Block (net.minecraft.block.Block)1 ItemBlock (net.minecraft.item.ItemBlock)1 ItemFood (net.minecraft.item.ItemFood)1 ItemStack (net.minecraft.item.ItemStack)1 MathHelper (net.minecraft.util.math.MathHelper)1 ModelRegistryEvent (net.minecraftforge.client.event.ModelRegistryEvent)1 MinecraftForge (net.minecraftforge.common.MinecraftForge)1