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


Java IBlockState.cycleProperty方法代码示例

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


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

示例1: onBlockActivated

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (this.blockMaterial == Material.IRON)
    {
        return false; //Allow items to interact with the door
    }
    else
    {
        BlockPos blockpos = state.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER ? pos : pos.down();
        IBlockState iblockstate = pos.equals(blockpos) ? state : worldIn.getBlockState(blockpos);

        if (iblockstate.getBlock() != this)
        {
            return false;
        }
        else
        {
            state = iblockstate.cycleProperty(OPEN);
            worldIn.setBlockState(blockpos, state, 10);
            worldIn.markBlockRangeForRenderUpdate(blockpos, pos);
            worldIn.playEvent(playerIn, ((Boolean)state.getValue(OPEN)).booleanValue() ? this.getOpenSound() : this.getCloseSound(), pos, 0);
            return true;
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:26,代码来源:BlockDoor.java

示例2: 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 (this.blockMaterial == Material.iron)
    {
        return true;
    }
    else
    {
        BlockPos blockpos = state.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER ? pos : pos.down();
        IBlockState iblockstate = pos.equals(blockpos) ? state : worldIn.getBlockState(blockpos);

        if (iblockstate.getBlock() != this)
        {
            return false;
        }
        else
        {
            state = iblockstate.cycleProperty(OPEN);
            worldIn.setBlockState(blockpos, state, 2);
            worldIn.markBlockRangeForRenderUpdate(blockpos, pos);
            worldIn.playAuxSFXAtEntity(playerIn, ((Boolean)state.getValue(OPEN)).booleanValue() ? 1003 : 1006, pos, 0);
            return true;
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:26,代码来源:BlockDoor.java

示例3: 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 (worldIn.isRemote)
    {
        return true;
    }
    else
    {
        state = state.cycleProperty(POWERED);
        worldIn.setBlockState(pos, state, 3);
        worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, ((Boolean)state.getValue(POWERED)).booleanValue() ? 0.6F : 0.5F);
        worldIn.notifyNeighborsOfStateChange(pos, this);
        EnumFacing enumfacing = ((BlockLever.EnumOrientation)state.getValue(FACING)).getFacing();
        worldIn.notifyNeighborsOfStateChange(pos.offset(enumfacing.getOpposite()), this);
        return true;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:18,代码来源:BlockLever.java

示例4: onBlockActivated

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (!playerIn.capabilities.allowEdit)
    {
        return false;
    }
    else
    {
        state = state.cycleProperty(MODE);
        float f = state.getValue(MODE) == BlockRedstoneComparator.Mode.SUBTRACT ? 0.55F : 0.5F;
        worldIn.playSound(playerIn, pos, SoundEvents.BLOCK_COMPARATOR_CLICK, SoundCategory.BLOCKS, 0.3F, f);
        worldIn.setBlockState(pos, state, 2);
        this.onStateChange(worldIn, pos, state);
        return true;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:17,代码来源:BlockRedstoneComparator.java

示例5: onBlockActivated

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY)
{
    if (!playerIn.capabilities.allowEdit)
    {
        return false;
    }
    else
    {
        state = state.cycleProperty(MODE);
        float f = state.getValue(MODE) == BlockRedstoneComparator.Mode.SUBTRACT ? 0.55F : 0.5F;
        worldIn.playSound(playerIn, pos, SoundEvents.BLOCK_COMPARATOR_CLICK, SoundCategory.BLOCKS, 0.3F, f);
        worldIn.setBlockState(pos, state, 2);
        this.onStateChange(worldIn, pos, state);
        return true;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:17,代码来源:BlockRedstoneComparator.java

示例6: onBlockActivated

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
	BlockPos blockpos = state.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER ? pos : pos.down();
	IBlockState iblockstate = pos.equals(blockpos) ? state : worldIn.getBlockState(blockpos);
	if (iblockstate.getBlock() != this) {
		return false;
	}
	IBlockState checkstate = iblockstate.cycleProperty(OPEN);
	worldIn.setBlockState(blockpos, checkstate, 10);
	worldIn.markBlockRangeForRenderUpdate(blockpos, pos);
	worldIn.playEvent(playerIn, checkstate.getValue(OPEN) ? 1012 : 1006, pos, 0);
	return true;

}
 
开发者ID:MinecraftModDevelopmentMods,项目名称:Got-Wood,代码行数:15,代码来源:BlockWoodDoor.java

示例7: 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 (!playerIn.capabilities.allowEdit)
    {
        return false;
    }
    else
    {
        state = state.cycleProperty(MODE);
        worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, state.getValue(MODE) == BlockRedstoneComparator.Mode.SUBTRACT ? 0.55F : 0.5F);
        worldIn.setBlockState(pos, state, 2);
        this.onStateChange(worldIn, pos, state);
        return true;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:16,代码来源:BlockRedstoneComparator.java

示例8: 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 (this.blockMaterial == Material.iron)
    {
        return true;
    }
    else
    {
        state = state.cycleProperty(OPEN);
        worldIn.setBlockState(pos, state, 2);
        worldIn.playAuxSFXAtEntity(playerIn, ((Boolean)state.getValue(OPEN)).booleanValue() ? 1003 : 1006, pos, 0);
        return true;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:15,代码来源:BlockTrapDoor.java

示例9: onBlockActivated

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY)
{
    if (this.blockMaterial == Material.IRON)
    {
        return false;
    }
    else
    {
        state = state.cycleProperty(OPEN);
        worldIn.setBlockState(pos, state, 2);
        this.playSound(playerIn, worldIn, pos, ((Boolean)state.getValue(OPEN)).booleanValue());
        return true;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:15,代码来源:BlockTrapDoor.java

示例10: 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 (worldIn.isRemote) {
		return true;
	} else {
		state = state.cycleProperty(POWERED);
		worldIn.setBlockState(pos, state, 3);
		worldIn.playSoundEffect((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D,
				"random.click", 0.3F, ((Boolean) state.getValue(POWERED)).booleanValue() ? 0.6F : 0.5F);
		worldIn.notifyNeighborsOfStateChange(pos, this);
		EnumFacing enumfacing = ((BlockLever.EnumOrientation) state.getValue(FACING)).getFacing();
		worldIn.notifyNeighborsOfStateChange(pos.offset(enumfacing.getOpposite()), this);
		return true;
	}
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:16,代码来源:BlockLever.java


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