当前位置: 首页>>代码示例>>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;未经允许,请勿转载。