content: package thebetweenlands.common.block.structure;
  
  import java.util.Random;
  
  import javax.annotation.Nullable;
  
  import net.minecraft.block.ITileEntityProvider;
  import net.minecraft.block.SoundType;
  import net.minecraft.block.material.Material;
  import net.minecraft.block.properties.IProperty;
  import net.minecraft.block.properties.PropertyDirection;
  import net.minecraft.block.state.BlockFaceShape;
  import net.minecraft.block.state.BlockStateContainer;
  import net.minecraft.block.state.IBlockState;
  import net.minecraft.entity.EntityLivingBase;
  import net.minecraft.entity.player.EntityPlayer;
  import net.minecraft.init.SoundEvents;
  import net.minecraft.tileentity.TileEntity;
  import net.minecraft.util.EnumBlockRenderType;
  import net.minecraft.util.EnumFacing;
  import net.minecraft.util.EnumHand;
  import net.minecraft.util.Mirror;
  import net.minecraft.util.Rotation;
  import net.minecraft.util.SoundCategory;
  import net.minecraft.util.math.BlockPos;
  import net.minecraft.world.IBlockAccess;
  import net.minecraft.world.World;
  import thebetweenlands.common.block.BasicBlock;
  import thebetweenlands.common.tile.TileEntityDungeonDoorCombination;
  
  public class BlockDungeonDoorCombination extends BasicBlock implements ITileEntityProvider {
  	public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
  
  	public BlockDungeonDoorCombination() {
  		this(Material.ROCK);
  	}
  
  	public BlockDungeonDoorCombination(Material material) {
  		super(material);
  		setHardness(0.4F);
  		setSoundType(SoundType.STONE);
  		setHarvestLevel("pickaxe", 0);
  		setDefaultState(blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
  	}
  	
  	@Nullable
  	public static TileEntityDungeonDoorCombination getTileEntity(IBlockAccess world, BlockPos pos) {
  		TileEntity tile = world.getTileEntity(pos);
  		if(tile instanceof TileEntityDungeonDoorCombination) {
  			return (TileEntityDungeonDoorCombination) tile;
  		}
  		return null;
  	}
  
      @Override
      public EnumBlockRenderType getRenderType(IBlockState state) {
          return EnumBlockRenderType.MODEL;
      }
  
  	@Override
  	public boolean isOpaqueCube(IBlockState state) {
  		return false;
  	}
  
  	@Override
  	public TileEntity createNewTileEntity(World world, int meta) {
  		return new TileEntityDungeonDoorCombination();
  	}
  
  	@Override
  	public IBlockState getStateFromMeta(int meta) {
  		EnumFacing facing = EnumFacing.byIndex(meta); // Using this instead of 'byHorizontalIndex' because the ids don't match and previous was release
  		return getDefaultState().withProperty(FACING, facing.getAxis().isHorizontal() ? facing: EnumFacing.NORTH);
  	}
  
  	@Override
  	public int getMetaFromState(IBlockState state) {
  		int meta = 0;
  		meta = meta | state.getValue(FACING).getIndex();
  		return meta;
  	}
  
  	@Override
  	 public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
  		return getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
  	}
  
  	@Override
  	public IBlockState withRotation(IBlockState state, Rotation rot) {
  		return state.withProperty(FACING, rot.rotate((EnumFacing) state.getValue(FACING)));
  	}
  
  	@Override
  	public IBlockState withMirror(IBlockState state, Mirror mirrorIn) {
  		return state.withRotation(mirrorIn.toRotation((EnumFacing) state.getValue(FACING)));
  	}
  
  	@Override
  	protected BlockStateContainer createBlockState() {
  		return new BlockStateContainer(this, new IProperty[] {FACING});
  	}
  
  	@Override
  	public int quantityDropped(Random random) {
  		return 0;
  	}
  
  	@Override
  	public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
  		world.notifyBlockUpdate(pos, state, state, 3);
  	}
  
  	@Override
      public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face) {
      	return BlockFaceShape.UNDEFINED;
      }
  	
  	@Override
  	public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
  		if (player.capabilities.isCreativeMode && hand == EnumHand.MAIN_HAND) {
  			if(!world.isRemote) {
  				TileEntityDungeonDoorCombination tile = getTileEntity(world, pos);
  				if (tile != null && facing == state.getValue(FACING)) {
  					if(hitY >= 0.0625F && hitY < 0.375F)
  						tile.cycleBottomState();
  					if(hitY >= 0.375F && hitY < 0.625F)
  						tile.cycleMidState();
  					if(hitY >= 0.625F && hitY <= 0.9375F)
  						tile.cycleTopState();
  					world.playSound(null, pos, SoundEvents.UI_BUTTON_CLICK, SoundCategory.BLOCKS, 1F, 1.0F);
  					world.notifyBlockUpdate(pos, state, state, 3);
  					return true;
  				}
  			} else {
  				return true;
  			}
  		}
  		return false;
  	}
  }
  