本文整理匯總了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;
}
}
}
示例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;
}
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}