当前位置: 首页>>代码示例>>Java>>正文


Java BlockStateMapper.getVariants方法代码示例

本文整理汇总了Java中net.minecraft.client.renderer.block.statemap.BlockStateMapper.getVariants方法的典型用法代码示例。如果您正苦于以下问题:Java BlockStateMapper.getVariants方法的具体用法?Java BlockStateMapper.getVariants怎么用?Java BlockStateMapper.getVariants使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.client.renderer.block.statemap.BlockStateMapper的用法示例。


在下文中一共展示了BlockStateMapper.getVariants方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTexture

import net.minecraft.client.renderer.block.statemap.BlockStateMapper; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
public static String getTexture(IBlockState state, String defaultTexture) {
	try {
		ModelLoader loader = ModelLoader.VanillaLoader.INSTANCE.getLoader();
		BlockStateMapper mapper = loader.blockModelShapes.getBlockStateMapper();
		Map<IBlockState, ModelResourceLocation> map = mapper.getVariants(state.getBlock());
		ModelResourceLocation stateLocation = map.get(state);
		ModelBlockDefinition definition = loader.getModelBlockDefinition(stateLocation);
		ResourceLocation modelLocation = definition.getVariant(stateLocation.getVariant()).getVariantList().get(0).getModelLocation();
		ModelBlock modelBlock = loader.loadModel(
				new ResourceLocation(modelLocation.getResourceDomain(), "models/" + modelLocation.getResourcePath()));
		String texture = getTexture(modelBlock);
		return ObjectUtils.firstNonNull(texture, defaultTexture);
	} catch (Exception e) {
		e.printStackTrace();
		return defaultTexture;
	}
}
 
开发者ID:NekoCaffeine,项目名称:Alchemy,代码行数:19,代码来源:WoodType.java

示例2: loadBlocks

import net.minecraft.client.renderer.block.statemap.BlockStateMapper; //导入方法依赖的package包/类
private void loadBlocks()
{
    BlockStateMapper blockstatemapper = this.blockModelShapes.getBlockStateMapper();

    for (Block block : Block.REGISTRY)
    {
        for (final ResourceLocation resourcelocation : blockstatemapper.getBlockstateLocations(block))
        {
            try
            {
                ModelBlockDefinition modelblockdefinition = this.getModelBlockDefinition(resourcelocation);
                Map<IBlockState, ModelResourceLocation> map = blockstatemapper.getVariants(block);

                if (modelblockdefinition.hasMultipartData())
                {
                    Collection<ModelResourceLocation> collection = Sets.newHashSet(map.values());
                    modelblockdefinition.getMultipartData().setStateContainer(block.getBlockState());
                    Collection<ModelResourceLocation> collection1 = (Collection)this.multipartVariantMap.get(modelblockdefinition);

                    if (collection1 == null)
                    {
                        collection1 = Lists.<ModelResourceLocation>newArrayList();
                        this.multipartVariantMap.put(modelblockdefinition, collection1);
                    }

                    collection1.addAll(Lists.newArrayList(Iterables.filter(collection, new Predicate<ModelResourceLocation>()
                    {
                        public boolean apply(@Nullable ModelResourceLocation p_apply_1_)
                        {
                            return resourcelocation.equals(p_apply_1_);
                        }
                    })));
                }

                for (Entry<IBlockState, ModelResourceLocation> entry : map.entrySet())
                {
                    ModelResourceLocation modelresourcelocation = (ModelResourceLocation)entry.getValue();

                    if (resourcelocation.equals(modelresourcelocation))
                    {
                        try
                        {
                            this.variants.put(modelresourcelocation, modelblockdefinition.getVariant(modelresourcelocation.getVariant()));
                        }
                        catch (RuntimeException var12)
                        {
                            if (!modelblockdefinition.hasMultipartData())
                            {
                                LOGGER.warn("Unable to load variant: {} from {}", new Object[] {modelresourcelocation.getVariant(), modelresourcelocation});
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                LOGGER.warn("Unable to load definition {}", new Object[] {resourcelocation, exception});
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:62,代码来源:ModelBakery.java

示例3: loadBlock

import net.minecraft.client.renderer.block.statemap.BlockStateMapper; //导入方法依赖的package包/类
protected void loadBlock(BlockStateMapper blockstatemapper, Block block, final ResourceLocation resourcelocation)
{
    {
        {
            {
                ModelBlockDefinition modelblockdefinition = this.getModelBlockDefinition(resourcelocation);
                Map<IBlockState, ModelResourceLocation> map = blockstatemapper.getVariants(block);

                if (modelblockdefinition.hasMultipartData())
                {
                    Collection<ModelResourceLocation> collection = Sets.newHashSet(map.values());
                    modelblockdefinition.getMultipartData().setStateContainer(block.getBlockState());
                    registerMultipartVariant(modelblockdefinition, Lists.newArrayList(Iterables.filter(collection, new Predicate<ModelResourceLocation>()
                    {
                        public boolean apply(@Nullable ModelResourceLocation p_apply_1_)
                        {
                            return resourcelocation.equals(p_apply_1_);
                        }
                    })));
                }

                for (Entry<IBlockState, ModelResourceLocation> entry : map.entrySet())
                {
                    ModelResourceLocation modelresourcelocation = (ModelResourceLocation)entry.getValue();

                    if (resourcelocation.equals(modelresourcelocation))
                    {
                        try
                        {
                            this.registerVariant(modelblockdefinition, modelresourcelocation);
                        }
                        catch (RuntimeException var12)
                        {
                            if (!modelblockdefinition.hasMultipartData())
                            {
                                LOGGER.warn("Unable to load variant: " + modelresourcelocation.getVariant() + " from " + modelresourcelocation, var12);
                            }
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:45,代码来源:ModelBakery.java


注:本文中的net.minecraft.client.renderer.block.statemap.BlockStateMapper.getVariants方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。