public void ClosePiston(int x, int y, PistonFlags direction)
 {
     int xMove = 0;
     int yMove = 0;
     switch (direction)
     {
         case PistonFlags.Left:
             xMove = -1;
             break;
         case PistonFlags.Right:
             xMove = 1;
             break;
         case PistonFlags.Down:
             yMove = 1;
             break;
         case PistonFlags.Up:
             yMove = -1;
             break;
     }
     BlockData block = GameServer.GetBlockAt(x + xMove, y + yMove);
     if (block.ID == 21)
     {
         GameServer.SetBlock(x + xMove, y + yMove, 0);
     }
 }
 public bool OpenPiston(int x, int y, PistonFlags direction)
 {
     int xMove = 0;
     int yMove = 0;
     switch (direction)
     {
         case PistonFlags.Left:
             xMove = -1;
             break;
         case PistonFlags.Right:
             xMove = 1;
             break;
         case PistonFlags.Down:
             yMove = 1;
             break;
         case PistonFlags.Up:
             yMove = -1;
             break;
     }
     int closestEmpty = -1;
     bool isBlocked = false;
     for (int i = 1; i <= 6; i++)
     {
         BlockData b = GameServer.GetBlockAt(x + (xMove * i), y + (yMove * i));
         if (b.ID == 0)
         {
             closestEmpty = i;
             break;
         }
         if (!b.Block.GetBlockPistonable())
         {
             isBlocked = true;
             break;
         }
     }
     if (!isBlocked && closestEmpty != -1)
     {
         for (int i = closestEmpty; i > 1; i--)
         {
             int curX = x + xMove * i;
             int curY = y + yMove * i;
             int nextX = curX - xMove;
             int nextY = curY - yMove;
             BlockData next = GameServer.GetBlockAt(nextX, nextY);
             GameServer.SetBlock(curX, curY, next.ID, true, next.MetaData);
             GameServer.SetBlock(nextX, nextY, 0, false, 0);
         }
     }
     if (closestEmpty != -1)
     {
         int xM = x + xMove;
         int yM = y + yMove;
         GameServer.SetBlock(xM, yM, 21, true, (byte)direction);
         return true;
     }
     return false;
 }