Java 类net.minecraft.client.renderer.block.statemap.BlockStateMapper 实例源码

项目:CustomWorldGen    文件:ModelBakery.java   
protected void loadBlocks()
{
    BlockStateMapper blockstatemapper = this.blockModelShapes.getBlockStateMapper();

    for (Block block : Block.REGISTRY)
    {
        for (final ResourceLocation resourcelocation : blockstatemapper.getBlockstateLocations(block))
        {
            try
            {
                loadBlock(blockstatemapper, block, resourcelocation);
            }
            catch (Exception exception)
            {
                LOGGER.warn((String)("Unable to load definition " + resourcelocation), (Throwable)exception);
            }
        }
    }
}
项目:Alchemy    文件:WoodType.java   
@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;
    }
}
项目:ExpandedRailsMod    文件:ModelBakery.java   
protected void loadBlocks()
{
    BlockStateMapper blockstatemapper = this.blockModelShapes.getBlockStateMapper();

    for (Block block : Block.REGISTRY)
    {
        for (final ResourceLocation resourcelocation : blockstatemapper.getBlockstateLocations(block))
        {
            try
            {
                loadBlock(blockstatemapper, block, resourcelocation);
            }
            catch (Exception exception)
            {
                LOGGER.warn((String)("Unable to load definition " + resourcelocation), (Throwable)exception);
            }
        }
    }
}
项目:CodeChickenLib    文件:DumpModelLocationsCommand.java   
@Override
public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender sender, @Nonnull String[] args) throws CommandException {
    ItemStack stack = Minecraft.getMinecraft().player.getHeldItemMainhand();
    if (!stack.isEmpty() && stack.getItem() instanceof ItemBlock) {
        Block block = Block.getBlockFromItem(stack.getItem());
        BlockStateMapper stateMapper = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getBlockStateMapper();
        for (Entry<IBlockState, ModelResourceLocation> entry : stateMapper.getVariants(block).entrySet()) {
            CCLLog.log(Level.INFO, entry.getKey().toString() + " | " + entry.getValue().toString());
        }
    }
}
项目:DecompiledMinecraft    文件:BlockModelShapes.java   
public BlockStateMapper getBlockStateMapper()
{
    return this.blockStateMapper;
}
项目:BaseClient    文件:BlockModelShapes.java   
public BlockStateMapper getBlockStateMapper()
{
    return this.blockStateMapper;
}
项目:BaseClient    文件:BlockModelShapes.java   
public BlockStateMapper getBlockStateMapper()
{
    return this.blockStateMapper;
}
项目:Backmemed    文件:BlockModelShapes.java   
public BlockStateMapper getBlockStateMapper()
{
    return this.blockStateMapper;
}
项目:Backmemed    文件:ModelBakery.java   
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});
            }
        }
    }
}
项目:CustomWorldGen    文件:BlockModelShapes.java   
public BlockStateMapper getBlockStateMapper()
{
    return this.blockStateMapper;
}
项目:CustomWorldGen    文件:ModelBakery.java   
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);
                            }
                        }
                    }
                }
            }
        }
    }
}
项目:ExpandedRailsMod    文件:BlockModelShapes.java   
public BlockStateMapper getBlockStateMapper()
{
    return this.blockStateMapper;
}
项目:ExpandedRailsMod    文件:ModelBakery.java   
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);
                            }
                        }
                    }
                }
            }
        }
    }
}