當前位置: 首頁>>代碼示例>>Java>>正文


Java IProperty類代碼示例

本文整理匯總了Java中net.minecraft.block.properties.IProperty的典型用法代碼示例。如果您正苦於以下問題:Java IProperty類的具體用法?Java IProperty怎麽用?Java IProperty使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IProperty類屬於net.minecraft.block.properties包,在下文中一共展示了IProperty類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: matchState

import net.minecraft.block.properties.IProperty; //導入依賴的package包/類
public boolean matchState(IBlockState p_matchState_1_, Map<IProperty, List<Comparable>> p_matchState_2_)
{
    for (IProperty iproperty : p_matchState_2_.keySet())
    {
        List<Comparable> list = (List)p_matchState_2_.get(iproperty);
        Comparable comparable = p_matchState_1_.getValue(iproperty);

        if (comparable == null)
        {
            return false;
        }

        if (!list.contains(comparable))
        {
            return false;
        }
    }

    return true;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:21,代碼來源:ConnectedParser.java

示例2: canPlaceBlockOnSide

import net.minecraft.block.properties.IProperty; //導入依賴的package包/類
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack)
{
    BlockPos blockpos = pos;
    IProperty<?> iproperty = this.singleSlab.getVariantProperty();
    Comparable<?> comparable = this.singleSlab.getTypeForItem(stack);
    IBlockState iblockstate = worldIn.getBlockState(pos);

    if (iblockstate.getBlock() == this.singleSlab)
    {
        boolean flag = iblockstate.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP;

        if ((side == EnumFacing.UP && !flag || side == EnumFacing.DOWN && flag) && comparable == iblockstate.getValue(iproperty))
        {
            return true;
        }
    }

    pos = pos.offset(side);
    IBlockState iblockstate1 = worldIn.getBlockState(pos);
    return iblockstate1.getBlock() == this.singleSlab && comparable == iblockstate1.getValue(iproperty) ? true : super.canPlaceBlockOnSide(worldIn, blockpos, side, player, stack);
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:22,代碼來源:ItemSlab.java

示例3: getProperty

import net.minecraft.block.properties.IProperty; //導入依賴的package包/類
public IProperty<Boolean> getProperty(EnumFacing facing) {
	switch (facing) {
		case EAST:
			return EAST;
		case WEST:
			return WEST;
		case NORTH:
			return NORTH;
		case SOUTH:
			return SOUTH;
		case UP:
			return UP;
		case DOWN:
			return DOWN;
		default:
			return EAST;
	}
}
 
開發者ID:TechReborn,項目名稱:TechReborn3,代碼行數:19,代碼來源:BlockCable.java

示例4: getPropertyString

import net.minecraft.block.properties.IProperty; //導入依賴的package包/類
public String getPropertyString(Map<IProperty, Comparable> p_178131_1_)
{
    StringBuilder stringbuilder = new StringBuilder();

    for (Entry<IProperty, Comparable> entry : p_178131_1_.entrySet())
    {
        if (stringbuilder.length() != 0)
        {
            stringbuilder.append(",");
        }

        IProperty iproperty = (IProperty)entry.getKey();
        Comparable comparable = (Comparable)entry.getValue();
        stringbuilder.append(iproperty.getName());
        stringbuilder.append("=");
        stringbuilder.append(iproperty.getName(comparable));
    }

    if (stringbuilder.length() == 0)
    {
        stringbuilder.append("normal");
    }

    return stringbuilder.toString();
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:26,代碼來源:StateMapperBase.java

示例5: attemptToGetAsVariant

import net.minecraft.block.properties.IProperty; //導入依賴的package包/類
/** Attempt to parse string as a Variation, allowing for block properties having different names to the enum values<br>
 * (eg blue_orchid vs orchidBlue etc.)
 * @param part the string (potentially in the 'wrong' format, eg 'orchidBlue')
 * @param is the ItemStack from which this string came (eg from is.getUnlocalisedName)
 * @return a Variation, if one exists, that matches the part string passed in, or one of the ItemStacks current property values.
 */
public static Variation attemptToGetAsVariant(String part, ItemStack is)
{
    if (is.getItem() instanceof ItemBlock)
    {
        // Unlocalised name doesn't always match the names we use in types.xsd
        // (which are the names displayed by Minecraft when using the F3 debug etc.)
        ItemBlock ib = (ItemBlock)(is.getItem());
        IBlockState bs = ib.block.getStateFromMeta(is.getMetadata());
        for (IProperty prop : (java.util.Set<IProperty>)bs.getProperties().keySet())
        { 
            Comparable<?> comp = bs.getValue(prop);
            Variation var = attemptToGetAsVariant(comp.toString());
            if (var != null)
                return var;
        }
        return null;
    }
    else
        return attemptToGetAsVariant(part);
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:27,代碼來源:MinecraftTypeHelper.java

示例6: validateProperty

import net.minecraft.block.properties.IProperty; //導入依賴的package包/類
public static <T extends Comparable<T>> String validateProperty(Block block, IProperty<T> property)
{
    String s = property.getName();

    if (!NAME_PATTERN.matcher(s).matches())
    {
        throw new IllegalArgumentException("Block: " + block.getClass() + " has invalidly named property: " + s);
    }
    else
    {
        for (T t : property.getAllowedValues())
        {
            String s1 = property.getName(t);

            if (!NAME_PATTERN.matcher(s1).matches())
            {
                throw new IllegalArgumentException("Block: " + block.getClass() + " has property: " + s + " with invalidly named value: " + s1);
            }
        }

        return s;
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:24,代碼來源:BlockStateContainer.java

示例7: applyColour

import net.minecraft.block.properties.IProperty; //導入依賴的package包/類
/** Recolour the Minecraft block
 * @param state The block to be recoloured
 * @param colour The new colour
 * @return A new blockstate which is a recoloured version of the original
 */
static IBlockState applyColour(IBlockState state, Colour colour)
{
    for (IProperty prop : (java.util.Set<IProperty>)state.getProperties().keySet())
    {
        if (prop.getName().equals("color") && prop.getValueClass() == net.minecraft.item.EnumDyeColor.class)
        {
            net.minecraft.item.EnumDyeColor current = (net.minecraft.item.EnumDyeColor)state.getValue(prop);
            if (!current.getName().equalsIgnoreCase(colour.name()))
            {
                return state.withProperty(prop, EnumDyeColor.valueOf(colour.name()));
            }
        }
    }
    return state;
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:21,代碼來源:MinecraftTypeHelper.java

示例8: blockColourMatches

import net.minecraft.block.properties.IProperty; //導入依賴的package包/類
/** Test whether this block has a colour attribute which matches the list of allowed colours
 * @param bs blockstate to test
 * @param allowedColours list of allowed Colour enum values
 * @return true if the block matches.
 */
public static boolean blockColourMatches(IBlockState bs, List<Colour> allowedColours)
{
    for (IProperty prop : (java.util.Set<IProperty>) bs.getProperties().keySet())
    {
        if (prop.getName().equals("color") && prop.getValueClass() == net.minecraft.item.EnumDyeColor.class)
        {
            // The block in question has a colour, so check it is a specified one:
            net.minecraft.item.EnumDyeColor current = (net.minecraft.item.EnumDyeColor)bs.getValue(prop);
            for (Colour col : allowedColours)
            {
                if (current.getName().equalsIgnoreCase(col.name()))
                    return true;
            }
        }
    } 
    return false;
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:23,代碼來源:MinecraftTypeHelper.java

示例9: getModelResourceLocation

import net.minecraft.block.properties.IProperty; //導入依賴的package包/類
protected ModelResourceLocation getModelResourceLocation(IBlockState state)
{
    Map < IProperty<?>, Comparable<? >> map = Maps. < IProperty<?>, Comparable<? >> newLinkedHashMap(state.getProperties());
    String s;

    if (this.name == null)
    {
        s = ((ResourceLocation)Block.REGISTRY.getNameForObject(state.getBlock())).toString();
    }
    else
    {
        s = String.format("%s:%s", Block.REGISTRY.getNameForObject(state.getBlock()).getResourceDomain(), this.removeName(this.name, map));
    }

    if (this.suffix != null)
    {
        s = s + this.suffix;
    }

    for (IProperty<?> iproperty : this.ignored)
    {
        map.remove(iproperty);
    }

    return new ModelResourceLocation(s, this.getPropertyString(map));
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:27,代碼來源:StateMap.java

示例10: onItemUse

import net.minecraft.block.properties.IProperty; //導入依賴的package包/類
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (stack.stackSize == 0)
    {
        return false;
    }
    else if (!playerIn.canPlayerEdit(pos.offset(side), side, stack))
    {
        return false;
    }
    else
    {
        Object object = this.singleSlab.getVariant(stack);
        IBlockState iblockstate = worldIn.getBlockState(pos);

        if (iblockstate.getBlock() == this.singleSlab)
        {
            IProperty iproperty = this.singleSlab.getVariantProperty();
            Comparable comparable = iblockstate.getValue(iproperty);
            BlockSlab.EnumBlockHalf blockslab$enumblockhalf = (BlockSlab.EnumBlockHalf)iblockstate.getValue(BlockSlab.HALF);

            if ((side == EnumFacing.UP && blockslab$enumblockhalf == BlockSlab.EnumBlockHalf.BOTTOM || side == EnumFacing.DOWN && blockslab$enumblockhalf == BlockSlab.EnumBlockHalf.TOP) && comparable == object)
            {
                IBlockState iblockstate1 = this.doubleSlab.getDefaultState().withProperty(iproperty, comparable);

                if (worldIn.checkNoEntityCollision(this.doubleSlab.getCollisionBoundingBox(worldIn, pos, iblockstate1)) && worldIn.setBlockState(pos, iblockstate1, 3))
                {
                    worldIn.playSoundEffect((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), this.doubleSlab.stepSound.getPlaceSound(), (this.doubleSlab.stepSound.getVolume() + 1.0F) / 2.0F, this.doubleSlab.stepSound.getFrequency() * 0.8F);
                    --stack.stackSize;
                }

                return true;
            }
        }

        return this.tryPlace(stack, worldIn, pos.offset(side), object) ? true : super.onItemUse(stack, playerIn, worldIn, pos, side, hitX, hitY, hitZ);
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:42,代碼來源:ItemSlab.java

示例11: getTypeProperty

import net.minecraft.block.properties.IProperty; //導入依賴的package包/類
public IProperty<BlockFlower.EnumFlowerType> getTypeProperty()
{
    if (this.type == null)
    {
        this.type = PropertyEnum.<BlockFlower.EnumFlowerType>create("type", BlockFlower.EnumFlowerType.class, new Predicate<BlockFlower.EnumFlowerType>()
        {
            public boolean apply(@Nullable BlockFlower.EnumFlowerType p_apply_1_)
            {
                return p_apply_1_.getBlockType() == BlockFlower.this.getBlockType();
            }
        });
    }

    return this.type;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:16,代碼來源:BlockFlower.java

示例12: create

import net.minecraft.block.properties.IProperty; //導入依賴的package包/類
@SuppressWarnings("unchecked")
static <T extends Block> StateMetaMapper<T> create(Collection<IProperty<?>> properties)
{
    if (properties.size() == 0)
        return new EmptyStateMetaMapper<>();
    else if (properties.size() == 1)
        return new SimpleStateMetaMapper(properties.iterator().next());
    else
        return new BitStateMetaMapper<>(properties);
}
 
開發者ID:cubex2,項目名稱:customstuff4,代碼行數:11,代碼來源:StateMetaMapper.java

示例13: buildPropertyValueTable

import net.minecraft.block.properties.IProperty; //導入依賴的package包/類
public void buildPropertyValueTable(Map < Map < IProperty<?>, Comparable<? >> , BlockStateContainer.StateImplementation > map)
{
    if (this.propertyValueTable != null)
    {
        throw new IllegalStateException();
    }
    else
    {
        Table < IProperty<?>, Comparable<?>, IBlockState > table = HashBasedTable. < IProperty<?>, Comparable<?>, IBlockState > create();
        UnmodifiableIterator unmodifiableiterator = this.properties.entrySet().iterator();

        while (unmodifiableiterator.hasNext())
        {
            Entry < IProperty<?>, Comparable<? >> entry = (Entry)unmodifiableiterator.next();
            IProperty<?> iproperty = (IProperty)entry.getKey();

            for (Comparable<?> comparable : iproperty.getAllowedValues())
            {
                if (comparable != entry.getValue())
                {
                    table.put(iproperty, comparable, map.get(this.getPropertiesWithValue(iproperty, comparable)));
                }
            }
        }

        this.propertyValueTable = ImmutableTable. < IProperty<?>, Comparable<?>, IBlockState > copyOf(table);
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:29,代碼來源:BlockStateContainer.java

示例14: getAllowedValues

import net.minecraft.block.properties.IProperty; //導入依賴的package包/類
private List < Iterable < Comparable<? >>> getAllowedValues()
{
    List < Iterable < Comparable<? >>> list = Lists. < Iterable < Comparable<? >>> newArrayList();
    ImmutableCollection < IProperty<? >> immutablecollection = this.properties.values();
    UnmodifiableIterator unmodifiableiterator = immutablecollection.iterator();

    while (unmodifiableiterator.hasNext())
    {
        IProperty<?> iproperty = (IProperty)unmodifiableiterator.next();
        list.add(((IProperty)iproperty).getAllowedValues());
    }

    return list;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:15,代碼來源:BlockStateContainer.java

示例15: rotateBlock

import net.minecraft.block.properties.IProperty; //導入依賴的package包/類
/**
 * Rotate the block. For vanilla blocks this rotates around the axis passed in (generally, it should be the "face" that was hit).
 * Note: for mod blocks, this is up to the block and modder to decide. It is not mandated that it be a rotation around the
 * face, but could be a rotation to orient *to* that face, or a visiting of possible rotations.
 * The method should return true if the rotation was successful though.
 *
 * @param world The world
 * @param pos Block position in world
 * @param axis The axis to rotate around
 * @return True if the rotation was successful, False if the rotation failed, or is not possible
 */
public boolean rotateBlock(World world, BlockPos pos, EnumFacing axis)
{
    IBlockState state = world.getBlockState(pos);
    for (IProperty<?> prop : state.getProperties().keySet())
    {
        if (prop.getName().equals("facing") || prop.getName().equals("rotation"))
        {
            world.setBlockState(pos, state.cycleProperty(prop));
            return true;
        }
    }
    return false;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:25,代碼來源:Block.java


注:本文中的net.minecraft.block.properties.IProperty類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。