Java Code Examples for net.minecraft.block.state.IBlockState#cycleProperty()

The following examples show how to use net.minecraft.block.state.IBlockState#cycleProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockSurgeryChamber.java    From Cyberware with MIT License 6 votes vote down vote up
public void toggleDoor(boolean top, IBlockState state, BlockPos pos, World worldIn)
{
	state = state.cycleProperty(OPEN);
	worldIn.setBlockState(pos, state, 2);
	
	BlockPos otherPos = pos.up();
	if (top)
	{
		otherPos = pos.down();
	}
	IBlockState otherState = worldIn.getBlockState(otherPos);

	if (otherState.getBlock() == this)
	{
		otherState = otherState.cycleProperty(OPEN);
		worldIn.setBlockState(otherPos, otherState, 2);
	}
}
 
Example 2
Source File: BlockMetalDoor.java    From BaseMetals with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
  public boolean onBlockActivated(final World world, final BlockPos coord, IBlockState blockstate, 
  		                        final EntityPlayer player,
                                  final EnumHand hand, ItemStack heldItem,
                                  final EnumFacing face,
  		                        final float partialX, final float partialY, final float partialZ) {
if (this.metal.getToolHarvestLevel() > 1) {
          return false;
      }
      final BlockPos pos = (blockstate.getValue(BlockDoor.HALF) == EnumDoorHalf.LOWER) ? coord : coord.down();
      final IBlockState bs = coord.equals(pos) ? blockstate : world.getBlockState(pos);
      if (bs.getBlock() != this) {
          return false;
      }
      blockstate = bs.cycleProperty(BlockDoor.OPEN);
      world.setBlockState(pos, blockstate, 2);
      world.markBlockRangeForRenderUpdate(pos, coord);
      world.playEvent(player, ((Boolean)blockstate.getValue(BlockDoor.OPEN)) ? 1003 : 1006, coord, 0);
      return true;
  }
 
Example 3
Source File: BlockShoji.java    From Sakura_mod with MIT License 5 votes vote down vote up
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    state = state.cycleProperty(OPEN);
    worldIn.setBlockState(pos, state, 10);
    worldIn.markBlockRangeForRenderUpdate(pos, pos);
    worldIn.playEvent(playerIn, state.getValue(OPEN) ? 1006 : 1012, pos, 0);
    TileEntityShoji te = (TileEntityShoji) worldIn.getTileEntity(pos);
    if (te != null) {
        te.setOpen(!te.isOpen());
        te.setAnimation(10);
    }
    return true;
}
 
Example 4
Source File: BlockTrapDoor.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    if (!content.opensWithHands)
        return true;

    state = state.cycleProperty(OPEN);
    worldIn.setBlockState(pos, state, 2);
    this.playSound(playerIn, worldIn, pos, ((Boolean) state.getValue(OPEN)).booleanValue());
    return true;
}
 
Example 5
Source File: BlockMetalTrapDoor.java    From BaseMetals with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public boolean onBlockActivated(final World world, final BlockPos coord, IBlockState state,
                                final EntityPlayer player, EnumHand hand, ItemStack heldItem, final EnumFacing facing,
                                final float partialX, final float partialY, final float partialZ) {
    if (this.metal.getToolHarvestLevel() > 1) {
        return true;
    }
    state = state.cycleProperty(BlockTrapDoor.OPEN);
    world.setBlockState(coord, state, 2);
    world.playEvent(player, ((Boolean)state.getValue(BlockTrapDoor.OPEN)) ? 1003 : 1006, coord, 0);
    return true;
}