當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。