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


Java BlockStateContainer.getProperty方法代码示例

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


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

示例1: readBlockState

import net.minecraft.block.state.BlockStateContainer; //导入方法依赖的package包/类
/**
 * Reads a blockstate from the given tag.
 *  
 * @param tag The tag the blockstate is to be read from
 */
public static IBlockState readBlockState(NBTTagCompound tag)
{
    if (!tag.hasKey("Name", 8))
    {
        return Blocks.AIR.getDefaultState();
    }
    else
    {
        Block block = (Block)Block.REGISTRY.getObject(new ResourceLocation(tag.getString("Name")));
        IBlockState iblockstate = block.getDefaultState();

        if (tag.hasKey("Properties", 10))
        {
            NBTTagCompound nbttagcompound = tag.getCompoundTag("Properties");
            BlockStateContainer blockstatecontainer = block.getBlockState();

            for (String s : nbttagcompound.getKeySet())
            {
                IProperty<?> iproperty = blockstatecontainer.getProperty(s);

                if (iproperty != null)
                {
                    iblockstate = setValueHelper(iblockstate, iproperty, nbttagcompound.getString(s));
                }
            }
        }

        return iblockstate;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:36,代码来源:NBTUtil.java

示例2: getPredicate

import net.minecraft.block.state.BlockStateContainer; //导入方法依赖的package包/类
public Predicate<IBlockState> getPredicate(BlockStateContainer blockState)
{
    final IProperty<?> iproperty = blockState.getProperty(this.key);

    if (iproperty == null)
    {
        throw new RuntimeException(this.toString() + ": Definition: " + blockState + " has no property: " + this.key);
    }
    else
    {
        String s = this.value;
        boolean flag = !s.isEmpty() && s.charAt(0) == 33;

        if (flag)
        {
            s = s.substring(1);
        }

        List<String> list = SPLITTER.splitToList(s);

        if (list.isEmpty())
        {
            throw new RuntimeException(this.toString() + ": has an empty value: " + this.value);
        }
        else
        {
            Predicate<IBlockState> predicate;

            if (list.size() == 1)
            {
                predicate = this.makePredicate(iproperty, s);
            }
            else
            {
                predicate = Predicates.or(Iterables.transform(list, new Function<String, Predicate<IBlockState>>()
                {
                    @Nullable
                    public Predicate<IBlockState> apply(@Nullable String p_apply_1_)
                    {
                        return ConditionPropertyValue.this.makePredicate(iproperty, p_apply_1_);
                    }
                }));
            }

            return flag ? Predicates.not(predicate) : predicate;
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:49,代码来源:ConditionPropertyValue.java

示例3: func_190795_c

import net.minecraft.block.state.BlockStateContainer; //导入方法依赖的package包/类
private static Map < IProperty<?>, Comparable<? >> func_190795_c(Block p_190795_0_, String p_190795_1_) throws InvalidBlockStateException
{
    Map < IProperty<?>, Comparable<? >> map = Maps. < IProperty<?>, Comparable<? >> newHashMap();

    if ("default".equals(p_190795_1_))
    {
        return p_190795_0_.getDefaultState().getProperties();
    }
    else
    {
        BlockStateContainer blockstatecontainer = p_190795_0_.getBlockState();
        Iterator iterator = field_190796_b.split(p_190795_1_).iterator();

        while (true)
        {
            if (!iterator.hasNext())
            {
                return map;
            }

            String s = (String)iterator.next();
            Iterator<String> iterator1 = field_190797_c.split(s).iterator();

            if (!iterator1.hasNext())
            {
                break;
            }

            IProperty<?> iproperty = blockstatecontainer.getProperty((String)iterator1.next());

            if (iproperty == null || !iterator1.hasNext())
            {
                break;
            }

            Comparable<?> comparable = func_190792_a(iproperty, (String)iterator1.next());

            if (comparable == null)
            {
                break;
            }

            map.put(iproperty, comparable);
        }

        throw new InvalidBlockStateException("commands.generic.blockstate.invalid", new Object[] {p_190795_1_, Block.REGISTRY.getNameForObject(p_190795_0_)});
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:49,代码来源:CommandBase.java


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