public boolean onItemUse(
      ItemStack par1ItemStack,
      EntityPlayer par2EntityPlayer,
      World par3World,
      int par4,
      int par5,
      int par6,
      int par7,
      float par8,
      float par9,
      float par10) {
    if (par7 != 1) {
      return false;
    } else {
      ++par5;
      Block block = this.doorBlock;

      if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)
          && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack)) {
        if (!block.canPlaceBlockAt(par3World, par4, par5, par6)) {
          return false;
        } else {
          int i1 =
              MathHelper.floor_double(
                      (double) ((par2EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D)
                  & 3;
          ItemDoor.placeDoorBlock(par3World, par4, par5, par6, i1, block);
          --par1ItemStack.stackSize;
          return true;
        }
      } else {
        return false;
      }
    }
  }
  @Override
  public boolean canBePlantedHere(World world, int x, int y, int z, ItemStack stack) {
    if (!world.isAirBlock(x, y, z)) return false;

    Block groundId = world.getBlock(x, y - 1, z);
    return (_block.canPlaceBlockAt(world, x, y, z) && _block.canBlockStay(world, x, y, z))
        || (_block instanceof IPlantable
            && groundId != null
            && groundId.canSustainPlant(world, x, y, z, ForgeDirection.UP, (IPlantable) _block));
  }
 private boolean func_179474_a(World worldIn, BlockPos p_179474_2_, Block p_179474_3_, Block p_179474_4_, Block p_179474_5_)
 {
     return !p_179474_3_.canPlaceBlockAt(worldIn, p_179474_2_) ? false : (p_179474_4_.getMaterial() != Material.air ? false : (p_179474_5_.getMaterial() == Material.air ? false : p_179474_5_.isFullCube()));
 }
  public void updateEntity() {

    // Check for ghost TEs
    if (dead) return;
    // Make sure the relays haven't been broken
    verifyRelay();
    // Bounce
    if (linked
        && worldObj.getTotalWorldTime() % 100 == 0
        && !worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) {
      // Target coordinates to check
      int targetX = xCoord + movementDirection.offsetX;
      int targetZ = zCoord + movementDirection.offsetZ;
      // Switch direction if at end of track
      if (worldObj.getBlock(targetX, yCoord, targetZ) != Block.getBlockFromName("air")
          || worldObj.getBlock(targetX, yCoord + 1, targetZ) != Block.getBlockFromName("air")) {
        movementDirection = movementDirection.getOpposite();
      }
    }
    // Move
    if (linked
        && worldObj.getTotalWorldTime() % 100 == 1
        && !worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) {
      // Cache coordinated
      int targetX = xCoord + movementDirection.offsetX;
      int targetZ = zCoord + movementDirection.offsetZ;
      // Check for abandoned TEs
      if (worldObj.getBlock(xCoord, yCoord, zCoord)
          != ThaumicTinkerer.registry.getFirstBlockFromClass(BlockMobilizer.class)) {
        return;
      }
      // Check if the space the mobilizer will move into is empty
      if ((worldObj.isAirBlock(targetX, yCoord, targetZ)
          || worldObj.getBlock(targetX, yCoord, targetZ).isAir(worldObj, targetX, yCoord, targetZ)
              && (worldObj.isAirBlock(xCoord, yCoord + 1, zCoord)
                  || worldObj.isAirBlock(targetX, yCoord + 1, targetZ)
                  || worldObj
                      .getBlock(targetX, yCoord + 1, targetZ)
                      .isAir(worldObj, targetX, yCoord + 1, targetZ)))) {

        // Move Entities
        // List<Entity> entities = worldObj.getEntitiesWithinAABB(Entity.class,
        // AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord+1, yCoord+3, zCoord+1));
        // System.out.print(entities);
        // for(Entity e: entities){
        //	e.setPosition(e.posX+movementDirection.offsetX, e.posY,
        // e.posZ+movementDirection.offsetZ);
        // }

        // Move the block on top of the mobilizer
        if (!worldObj.isRemote) {

          TileEntity passenger = worldObj.getTileEntity(xCoord, yCoord + 1, zCoord);
          IAppEngApi api = AEApi.instance();

          // Prevent the passenger from popping off. Not sent to clients.
          worldObj.setBlock(targetX, yCoord, targetZ, Block.getBlockFromName("stone"), 0, 0);
          // Move non-TE blocks
          Block passengerId = worldObj.getBlock(xCoord, yCoord + 1, zCoord);

          if (worldObj.isAirBlock(xCoord, yCoord + 1, zCoord)
              || passengerId.canPlaceBlockAt(worldObj, targetX, yCoord + 1, targetZ)) {

            if (passenger == null) {
              if (passengerId != Block.getBlockFromName("bedrock")
                  && passengerId != Block.getBlockFromName("")) {
                worldObj.setBlock(
                    targetX,
                    yCoord + 1,
                    targetZ,
                    passengerId,
                    worldObj.getBlockMetadata(xCoord, yCoord + 1, zCoord),
                    3);
                if (passengerId != Block.getBlockFromName("air")
                    && passengerId != Block.getBlockFromName("piston_head")) {
                  worldObj.setBlock(
                      xCoord, yCoord + 1, zCoord, Block.getBlockFromName("air"), 0, 2);
                }
              }
              // If AE is installed, use its handler
            } else if (api != null) {
              if (api.registries().moveable().askToMove(passenger)) {
                worldObj.setBlock(
                    targetX,
                    yCoord + 1,
                    targetZ,
                    worldObj.getBlock(xCoord, yCoord + 1, zCoord),
                    worldObj.getBlockMetadata(xCoord, yCoord + 1, zCoord),
                    3);
                passenger.invalidate();
                worldObj.setBlockToAir(xCoord, yCoord + 1, zCoord);
                api.registries()
                    .moveable()
                    .getHandler(passenger)
                    .moveTile(passenger, worldObj, targetX, yCoord + 1, targetZ);
                api.registries().moveable().doneMoving(passenger);
                passenger.validate();
              }

              // Handler IMovableTiles and vanilla TEs without AE
            } else if (passenger instanceof IMovableTile
                || passenger.getClass().getName().startsWith("net.minecraft.tileentity")) {
              boolean imovable = passenger instanceof IMovableTile;
              if (imovable) ((IMovableTile) passenger).prepareToMove();
              worldObj.setBlock(
                  targetX,
                  yCoord + 1,
                  targetZ,
                  worldObj.getBlock(xCoord, yCoord + 1, zCoord),
                  worldObj.getBlockMetadata(xCoord, yCoord + 1, zCoord),
                  3);
              passenger.invalidate();
              worldObj.setBlockToAir(xCoord, yCoord + 1, zCoord);

              // IMovableHandler default code
              Chunk c = worldObj.getChunkFromBlockCoords(targetX, targetZ);

              c.func_150812_a(targetX & 0xF, yCoord + 1, targetZ & 0xF, passenger);

              if (c.isChunkLoaded) {
                worldObj.addTileEntity(passenger);
                worldObj.markBlockForUpdate(targetX, yCoord + 1, targetZ);
              }
              if (imovable) ((IMovableTile) passenger).doneMoving();
              passenger.validate();
            }
          }
          // Move self
          this.invalidate();
          worldObj.removeTileEntity(xCoord, yCoord, zCoord);
          worldObj.setBlock(xCoord, yCoord, zCoord, Block.getBlockFromName("air"), 0, 2);
          worldObj.setBlock(
              targetX,
              yCoord,
              targetZ,
              ThaumicTinkerer.registry.getFirstBlockFromClass(BlockMobilizer.class));

          int oldX = xCoord;
          int oldZ = zCoord;

          this.xCoord = targetX;
          this.zCoord = targetZ;
          this.validate();
          worldObj.addTileEntity(this);
          worldObj.removeTileEntity(oldX, yCoord, oldZ);

          worldObj.notifyBlockChange(oldX, yCoord, oldZ, Block.getBlockFromName("air"));
        }
      }
    }
  }