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


Java IBlockState.withProperty方法代码示例

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


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

示例1: withRotation

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
/**
 * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed
 * blockstate.
 */
public IBlockState withRotation(IBlockState state, Rotation rot)
{
    switch (rot)
    {
        case COUNTERCLOCKWISE_90:
        case CLOCKWISE_90:

            switch ((EnumFacing.Axis)state.getValue(AXIS))
            {
                case X:
                    return state.withProperty(AXIS, EnumFacing.Axis.Z);
                case Z:
                    return state.withProperty(AXIS, EnumFacing.Axis.X);
                default:
                    return state;
            }

        default:
            return state;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:26,代码来源:BlockRotatedPillar.java

示例2: getStateFromMeta

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
/**
 * Convert the given metadata into a BlockState for this Block
 */
public IBlockState getStateFromMeta(int meta)
{
    IBlockState iblockstate = this.getDefaultState().withProperty(VARIANT, BlockStoneSlab.EnumType.byMetadata(meta & 7));

    if (this.isDouble())
    {
        iblockstate = iblockstate.withProperty(SEAMLESS, Boolean.valueOf((meta & 8) != 0));
    }
    else
    {
        iblockstate = iblockstate.withProperty(HALF, (meta & 8) == 0 ? BlockSlab.EnumBlockHalf.BOTTOM : BlockSlab.EnumBlockHalf.TOP);
    }

    return iblockstate;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:19,代码来源:BlockStoneSlab.java

示例3: getStateFromMeta

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
/**
 * Convert the given metadata into a BlockState for this Block
 */
public IBlockState getStateFromMeta(int meta)
{
    IBlockState iblockstate = this.getDefaultState().withProperty(VARIANT, BlockPlanks.EnumType.byMetadata((meta & 3) % 4));

    switch (meta & 12)
    {
        case 0:
            iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y);
            break;

        case 4:
            iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X);
            break;

        case 8:
            iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z);
            break;

        default:
            iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE);
    }

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

示例4: onBlockActivated

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (((Boolean)state.getValue(OPEN)).booleanValue())
    {
        state = state.withProperty(OPEN, Boolean.valueOf(false));
        worldIn.setBlockState(pos, state, 2);
    }
    else
    {
        EnumFacing enumfacing = EnumFacing.fromAngle((double)playerIn.rotationYaw);

        if (state.getValue(FACING) == enumfacing.getOpposite())
        {
            state = state.withProperty(FACING, enumfacing);
        }

        state = state.withProperty(OPEN, Boolean.valueOf(true));
        worldIn.setBlockState(pos, state, 2);
    }

    worldIn.playAuxSFXAtEntity(playerIn, ((Boolean)state.getValue(OPEN)).booleanValue() ? 1003 : 1006, pos, 0);
    return true;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:24,代码来源:BlockFenceGate.java

示例5: getActualState

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
    TileEntity te = world instanceof ChunkCache ? ((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos);
    boolean working = false;
    if (te instanceof PurifierTileEntity) {
        working = ((PurifierTileEntity)te).isWorking();
    }
    return state.withProperty(WORKING, working);
}
 
开发者ID:McJty,项目名称:needtobreath,代码行数:10,代码来源:PurifierBlock.java

示例6: getStateFromMeta

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public IBlockState getStateFromMeta(int meta) {
	IBlockState iblockstate = this.getDefaultState().withProperty(VARIANT, BlockRubberSlab.Variant.DEFAULT);

	if (!this.isDouble()) {
		iblockstate = iblockstate.withProperty(HALF, (meta & 8) == 0 ? BlockSlab.EnumBlockHalf.BOTTOM : BlockSlab.EnumBlockHalf.TOP);
	}

	return iblockstate;
}
 
开发者ID:TechReborn,项目名称:TechReborn3,代码行数:10,代码来源:BlockRubberSlab.java

示例7: onBlockHarvested

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
{
    if (player.capabilities.isCreativeMode)
    {
        state = state.withProperty(NODROP, Boolean.valueOf(true));
        worldIn.setBlockState(pos, state, 4);
    }
    this.dropBlockAsItem(worldIn, pos, state, 0);

    super.onBlockHarvested(worldIn, pos, state, player);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:12,代码来源:BlockSkull.java

示例8: getActualState

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
/**
 * Get the actual Block state of this Block at the given position. This applies properties not visible in the
 * metadata, such as fence connections.
 */
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
{
    if (this.func_176306_h(worldIn, pos))
    {
        switch (this.func_176305_g(worldIn, pos))
        {
            case 0:
                state = state.withProperty(SHAPE, BlockStairs.EnumShape.STRAIGHT);
                break;

            case 1:
                state = state.withProperty(SHAPE, BlockStairs.EnumShape.INNER_RIGHT);
                break;

            case 2:
                state = state.withProperty(SHAPE, BlockStairs.EnumShape.INNER_LEFT);
        }
    }
    else
    {
        switch (this.func_176307_f(worldIn, pos))
        {
            case 0:
                state = state.withProperty(SHAPE, BlockStairs.EnumShape.STRAIGHT);
                break;

            case 1:
                state = state.withProperty(SHAPE, BlockStairs.EnumShape.OUTER_RIGHT);
                break;

            case 2:
                state = state.withProperty(SHAPE, BlockStairs.EnumShape.OUTER_LEFT);
        }
    }

    return state;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:42,代码来源:BlockStairs.java

示例9: onBlockActivated

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {

	if (!world.isRemote) {

		ItemStack held = player.getHeldItem(hand);

		if (player.isSneaking()) {

			if (state.getValue(FILTER) && ((TileDisplacer) world.getTileEntity(pos)).hasFilter()) {
				state = state.withProperty(FILTER, false);
				world.setBlockState(pos, state);

				if (world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof TileDisplacer) {
					((TileDisplacer) world.getTileEntity(pos)).setHasFilter(false);
					((TileDisplacer) world.getTileEntity(pos)).markDirty();

					PacketHandler.sendToAll(new PacketDisplacerSync(((TileDisplacer) world.getTileEntity(pos)), false));
					if (!player.isCreative())
						InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(SimpleTubes.proxy.itemUpgrade, 1, 0));
				}
			}
			return true;
		} else {
			if (!(held.getItem() instanceof ItemUpgrade) || held == ItemStack.EMPTY) {
				if (((TileDisplacer) world.getTileEntity(pos)).hasFilter()) {
					player.openGui(SimpleTubes.instance, 0, world, pos.getX(), pos.getY(), pos.getZ());
					return true;
				}
			}
		}
	}

	return true;
}
 
开发者ID:oMilkyy,项目名称:SimpleTubes,代码行数:36,代码来源:BlockDisplacer.java

示例10: getStateFromMeta

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
/**
 * Convert the given metadata into a BlockState for this Block
 */
public IBlockState getStateFromMeta(int meta)
{
    IBlockState iblockstate = this.getDefaultState();

    for (int i = 0; i < 3; ++i)
    {
        iblockstate = iblockstate.withProperty(HAS_BOTTLE[i], Boolean.valueOf((meta & 1 << i) > 0));
    }

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

示例11: updateTick

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    BlockPos blockpos = pos.up();

    if (worldIn.isAirBlock(blockpos))
    {
        int i;

        for (i = 1; worldIn.getBlockState(pos.down(i)).getBlock() == this; ++i)
        {
            ;
        }

        if (i < 3)
        {
            int j = ((Integer)state.getValue(AGE)).intValue();

            if (j == 15)
            {
                worldIn.setBlockState(blockpos, this.getDefaultState());
                IBlockState iblockstate = state.withProperty(AGE, Integer.valueOf(0));
                worldIn.setBlockState(pos, iblockstate, 4);
                this.onNeighborBlockChange(worldIn, blockpos, iblockstate, this);
            }
            else
            {
                worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(j + 1)), 4);
            }
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:32,代码来源:BlockCactus.java

示例12: onBlockPlaced

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
/**
 * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
 * IBlockstate
 */
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
    IBlockState iblockstate = this.getDefaultState().withProperty(POWERED, Boolean.valueOf(false)).withProperty(ATTACHED, Boolean.valueOf(false));

    if (facing.getAxis().isHorizontal())
    {
        iblockstate = iblockstate.withProperty(FACING, facing);
    }

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

示例13: withRotation

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public IBlockState withRotation(IBlockState state, Rotation rot)
{
    return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING)));
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:5,代码来源:BlockBanner.java

示例14: onItemUse

import net.minecraft.block.state.IBlockState; //导入方法依赖的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 (worldIn.isRemote)
    {
        return true;
    }
    else if (side != EnumFacing.UP)
    {
        return false;
    }
    else
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        Block block = iblockstate.getBlock();
        boolean flag = block.isReplaceable(worldIn, pos);

        if (!flag)
        {
            pos = pos.up();
        }

        int i = MathHelper.floor_double((double)(playerIn.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
        EnumFacing enumfacing = EnumFacing.getHorizontal(i);
        BlockPos blockpos = pos.offset(enumfacing);

        if (playerIn.canPlayerEdit(pos, side, stack) && playerIn.canPlayerEdit(blockpos, side, stack))
        {
            boolean flag1 = worldIn.getBlockState(blockpos).getBlock().isReplaceable(worldIn, blockpos);
            boolean flag2 = flag || worldIn.isAirBlock(pos);
            boolean flag3 = flag1 || worldIn.isAirBlock(blockpos);

            if (flag2 && flag3 && World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && World.doesBlockHaveSolidTopSurface(worldIn, blockpos.down()))
            {
                IBlockState iblockstate1 = Blocks.bed.getDefaultState().withProperty(BlockBed.OCCUPIED, Boolean.valueOf(false)).withProperty(BlockBed.FACING, enumfacing).withProperty(BlockBed.PART, BlockBed.EnumPartType.FOOT);

                if (worldIn.setBlockState(pos, iblockstate1, 3))
                {
                    IBlockState iblockstate2 = iblockstate1.withProperty(BlockBed.PART, BlockBed.EnumPartType.HEAD);
                    worldIn.setBlockState(blockpos, iblockstate2, 3);
                }

                --stack.stackSize;
                return true;
            }
            else
            {
                return false;
            }
        }
        else
        {
            return false;
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:59,代码来源:ItemBed.java

示例15: getActualState

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
/**
 * Get the actual Block state of this Block at the given position. This applies properties not visible in the
 * metadata, such as fence connections.
 */
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
{
    return state.withProperty(UP, Boolean.valueOf(worldIn.getBlockState(pos.up()).isBlockNormalCube()));
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:9,代码来源:BlockVine.java


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