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()));
});
}
Aggregations