Search in sources :

Example 1 with IVariantProvider

use of WayofTime.bloodmagic.client.IVariantProvider in project BloodMagic by WayofTime.

the class RegistrarBloodMagicItems method registerRenders.

@SideOnly(Side.CLIENT)
@SubscribeEvent
public static void registerRenders(ModelRegistryEvent event) {
    items.stream().filter(i -> i instanceof IVariantProvider).forEach(i -> {
        Int2ObjectMap<String> variants = new Int2ObjectOpenHashMap<>();
        ((IVariantProvider) i).gatherVariants(variants);
        for (Int2ObjectMap.Entry<String> variant : variants.int2ObjectEntrySet()) ModelLoader.setCustomModelResourceLocation(i, variant.getIntKey(), new ModelResourceLocation(i.getRegistryName(), variant.getValue()));
    });
    items.stream().filter(i -> i instanceof IMeshProvider).forEach(i -> {
        IMeshProvider mesh = (IMeshProvider) i;
        ResourceLocation loc = mesh.getCustomLocation();
        if (loc == null)
            loc = i.getRegistryName();
        Set<String> variants = Sets.newHashSet();
        mesh.gatherVariants(variants::add);
        for (String variant : variants) ModelLoader.registerItemVariants(i, new ModelResourceLocation(loc, variant));
        ModelLoader.setCustomMeshDefinition(i, mesh.getMeshDefinition());
    });
    RegistrarBloodMagicBlocks.blocks.stream().filter(b -> b instanceof IVariantProvider).forEach(b -> {
        Int2ObjectMap<String> variants = new Int2ObjectOpenHashMap<>();
        ((IVariantProvider) b).gatherVariants(variants);
        for (Int2ObjectMap.Entry<String> variant : variants.int2ObjectEntrySet()) ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(b), variant.getIntKey(), new ModelResourceLocation(b.getRegistryName(), variant.getValue()));
    });
}
Also used : WayofTime.bloodmagic.item.soul(WayofTime.bloodmagic.item.soul) Item(net.minecraft.item.Item) IVariantProvider(WayofTime.bloodmagic.client.IVariantProvider) WayofTime.bloodmagic.item(WayofTime.bloodmagic.item) ModelRegistryEvent(net.minecraftforge.client.event.ModelRegistryEvent) GameRegistry(net.minecraftforge.fml.common.registry.GameRegistry) EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) ComponentTypes(WayofTime.bloodmagic.item.types.ComponentTypes) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) IBMBlock(WayofTime.bloodmagic.block.IBMBlock) Lists(com.google.common.collect.Lists) Side(net.minecraftforge.fml.relauncher.Side) RegistryEvent(net.minecraftforge.event.RegistryEvent) Mod(net.minecraftforge.fml.common.Mod) ItemLivingArmour(WayofTime.bloodmagic.item.armour.ItemLivingArmour) ItemPackSelfSacrifice(WayofTime.bloodmagic.item.gear.ItemPackSelfSacrifice) ModelLoader(net.minecraftforge.client.model.ModelLoader) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) EnumHelper(net.minecraftforge.common.util.EnumHelper) IMeshProvider(WayofTime.bloodmagic.client.IMeshProvider) ItemLivingArmourPointsUpgrade(WayofTime.bloodmagic.item.alchemy.ItemLivingArmourPointsUpgrade) Int2ObjectOpenHashMap(it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap) ItemCuttingFluid(WayofTime.bloodmagic.item.alchemy.ItemCuttingFluid) ItemFluidRouterFilter(WayofTime.bloodmagic.item.routing.ItemFluidRouterFilter) ItemNodeRouter(WayofTime.bloodmagic.item.routing.ItemNodeRouter) Items(net.minecraft.init.Items) ItemPackSacrifice(WayofTime.bloodmagic.item.gear.ItemPackSacrifice) Set(java.util.Set) WayofTime.bloodmagic.item.sigil(WayofTime.bloodmagic.item.sigil) ShardType(WayofTime.bloodmagic.item.types.ShardType) Sets(com.google.common.collect.Sets) ItemSentientArmour(WayofTime.bloodmagic.item.armour.ItemSentientArmour) List(java.util.List) BloodMagic(WayofTime.bloodmagic.BloodMagic) Int2ObjectMap(it.unimi.dsi.fastutil.ints.Int2ObjectMap) ResourceLocation(net.minecraft.util.ResourceLocation) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) ItemRouterFilter(WayofTime.bloodmagic.item.routing.ItemRouterFilter) Int2ObjectOpenHashMap(it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) IMeshProvider(WayofTime.bloodmagic.client.IMeshProvider) IVariantProvider(WayofTime.bloodmagic.client.IVariantProvider) Int2ObjectMap(it.unimi.dsi.fastutil.ints.Int2ObjectMap) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

BloodMagic (WayofTime.bloodmagic.BloodMagic)1 IBMBlock (WayofTime.bloodmagic.block.IBMBlock)1 IMeshProvider (WayofTime.bloodmagic.client.IMeshProvider)1 IVariantProvider (WayofTime.bloodmagic.client.IVariantProvider)1 WayofTime.bloodmagic.item (WayofTime.bloodmagic.item)1 ItemCuttingFluid (WayofTime.bloodmagic.item.alchemy.ItemCuttingFluid)1 ItemLivingArmourPointsUpgrade (WayofTime.bloodmagic.item.alchemy.ItemLivingArmourPointsUpgrade)1 ItemLivingArmour (WayofTime.bloodmagic.item.armour.ItemLivingArmour)1 ItemSentientArmour (WayofTime.bloodmagic.item.armour.ItemSentientArmour)1 ItemPackSacrifice (WayofTime.bloodmagic.item.gear.ItemPackSacrifice)1 ItemPackSelfSacrifice (WayofTime.bloodmagic.item.gear.ItemPackSelfSacrifice)1 ItemFluidRouterFilter (WayofTime.bloodmagic.item.routing.ItemFluidRouterFilter)1 ItemNodeRouter (WayofTime.bloodmagic.item.routing.ItemNodeRouter)1 ItemRouterFilter (WayofTime.bloodmagic.item.routing.ItemRouterFilter)1 WayofTime.bloodmagic.item.sigil (WayofTime.bloodmagic.item.sigil)1 WayofTime.bloodmagic.item.soul (WayofTime.bloodmagic.item.soul)1 ComponentTypes (WayofTime.bloodmagic.item.types.ComponentTypes)1 ShardType (WayofTime.bloodmagic.item.types.ShardType)1 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1