コード例 #1
0
 public static List<Level.ReflectionLinePos> GetReflectionLine(Player p, Level l)
 {
     for (int i = 0; i < l.reflectionLines.Keys.Count; i++)
         if (p.name.ToLower() == l.reflectionLines.Keys.ToList<string>()[i])
             return l.reflectionLines.Values.ToList<List<Level.ReflectionLinePos>>()[i];
     return new List<Level.ReflectionLinePos>();
 }
コード例 #2
0
 public static void placeBlock(Level l, Player p, ushort x, ushort y, ushort z, byte type)
 {
     if (p == null)
         l.Blockchange(x, y, z, type);
     else
         l.Blockchange(p, x, y, z, type);
 }
コード例 #3
0
ファイル: MapViewer.cs プロジェクト: blha303/MCDawn
 public static void Meep(Level l)
 {
     /**
      * @str1 = Unused .-. I'll delete it later.
      * @str2 = Tileset
      * @str3 = Savename
      * @blocks = Level blocks
      */
     IsoCraft.height = l.height;
     IsoCraft.length = l.depth;
     IsoCraft.width = l.width;
     IsoCraft.Main("", "tileset.png", "test.png", l.blocks);
 }
コード例 #4
0
ファイル: PlayerBot.cs プロジェクト: sillyboyization/MCDawn
        public PlayerBot(string n, Level l)
        {
            Server.s.Log("adding " + n + " bot");
            name = n;
            color = "&1";
            id = FreeId();

            level = l;
            ushort x = (ushort)((0.5 + level.spawnx) * 32);
            ushort y = (ushort)((1 + level.spawny) * 32);
            ushort z = (ushort)((0.5 + level.spawnz) * 32);
            pos = new ushort[3] { x, y, z }; rot = new byte[2] { level.rotx, level.roty };
            GlobalSpawn();
            Server.s.PlayerBotListUpdate();
        }
コード例 #5
0
ファイル: MapGenerator.cs プロジェクト: jonnyli1125/MCDawn
        //Averages over 9 points
        float GetAverage9(ushort x, ushort y, Level Lvl)
        {
            divide = 0.0f;
            float temp = GetPixel(x, y, Lvl);
            temp += GetPixel((ushort)(x + 1), y, Lvl);
            temp += GetPixel((ushort)(x - 1), y, Lvl);
            temp += GetPixel(x, (ushort)(y + 1), Lvl);
            temp += GetPixel(x, (ushort)(y - 1), Lvl);

            temp += GetPixel((ushort)(x + 1), (ushort)(y + 1), Lvl);
            temp += GetPixel((ushort)(x - 1), (ushort)(y + 1), Lvl);
            temp += GetPixel((ushort)(x + 1), (ushort)(y - 1), Lvl);
            temp += GetPixel((ushort)(x - 1), (ushort)(y - 1), Lvl);

            return temp / divide;
        }
コード例 #6
0
        public static ushort writeLetter(Level l, Player p, char c, ushort x, ushort y, ushort z, byte b, int directionToGo)
        {
            switch (c)
            {
                case 'A':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    break;
                case 'B':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    break;
                case 'C':
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'D':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    break;
                case 'E':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'F':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'G':
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'H':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'I':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'J':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'K':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'L':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    break;
                case 'M':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'N':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'O':
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    break;
                case 'P':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    break;
                case 'Q':
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    break;
                case 'R':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    break;
                case 'S':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'T':
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'U':
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'V':
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'W':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'X':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'Y':
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'Z':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;

                case '0':
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    break;
                case '1':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    break;
                case '2':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case '3':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case '4':
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    break;
                case '5':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case '6':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case '7':
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case '8':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case '9':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;

                case ':':
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    break;
                case '\\':
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    break;
                case '/':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case '.':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    break;
                case '!':
                    placeBlock(l, p, x, y, z, b);
                    for (int i = 2; i <= 4; i++) { placeBlock(l, p, x, (ushort)(y + i), z, b); }
                    break;
                case ',':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    break;
                case '\'':
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    break;
                case '"':
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    break;
                case ' ':
                    break;

                case '+':
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    break;
                case '-':
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    break;
                case '_':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    break;
                case '=':
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    break;
                case '[':
                    for (int i = -1; i < 6; i++) { placeBlock(l, p, x, (ushort)(y + i), z, b); }
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y - 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 5), z, b);
                    break;
                case ']':
                    placeBlock(l, p, x, (ushort)(y - 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 5), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    for (int i = -1; i < 6; i++) { placeBlock(l, p, x, (ushort)(y + i), z, b); }
                    break;
                case '?':
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 5), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y - 1), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case '(':
                    for (int i = 0; i < 5; i++) { placeBlock(l, p, x, (ushort)(y + i), z, b); }
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y - 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 5), z, b);
                    break;
                case ')':
                    placeBlock(l, p, x, (ushort)(y - 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 5), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    for (int i = 0; i < 5; i++) { placeBlock(l, p, x, (ushort)(y + i), z, b); }
                    break;
                case '{':
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 5), z, b);
                    placeBlock(l, p, x, (ushort)(y - 1), z, b);
                    break;
                case '}':
                    placeBlock(l, p, x, (ushort)(y + 5), z, b);
                    placeBlock(l, p, x, (ushort)(y - 1), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    break;
                case '|':
                    for (int i = -1; i < 5; i++) { placeBlock(l, p, x, (ushort)(y + i), z, b); }
                    break;

                default:
                    Player.SendMessage(p, "\"" + c + "\" is currently not supported. Space left");
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    break;
            }

            if (directionToGo == 0) return (ushort)(x + 2);
            else if (directionToGo == 1) return (ushort)(x - 2);
            else if (directionToGo == 2) return (ushort)(z + 2);
            else return (ushort)(z - 2);
        }
コード例 #7
0
ファイル: MapGenerator.cs プロジェクト: jonnyli1125/MCDawn
        public bool GenerateMap(Level Lvl, string type)
        {
            Server.s.Log("Attempting map gen");
            if (Inuse) { Server.s.Log("Generator in use"); return false; }
            Random rand = new System.Random();
            try
            {
                Inuse = true;
                terrain = new float[Lvl.width * Lvl.height];
                overlay = new float[Lvl.width * Lvl.height];

                if (!type.Equals("ocean"))
                { overlay2 = new float[Lvl.width * Lvl.height]; }

                //float dispAux, pd;
                ushort WaterLevel = (ushort)(Lvl.depth / 2 + 2);
                ushort LavaLevel = 5;

                if (type.Equals("ocean"))
                {
                    WaterLevel = (ushort)(Lvl.depth * 0.85f);
                }

                //Generate the level
                GenerateFault(terrain, Lvl, type, rand);

                //APPLY FILTER to terrain
                FilterAverage(Lvl);

                //CREATE OVERLAY
                //GenerateFault(overlay, Lvl, "overlay", rand);
                Server.s.Log("Creating overlay");
                GeneratePerlinNoise(overlay, Lvl, "", rand);

                if (!type.Equals("ocean") && type != "desert")
                {
                    Server.s.Log("Planning trees");
                    GeneratePerlinNoise(overlay2, Lvl, "", rand);
                }

                Server.s.Log("Converting height map");
                Server.s.Log("And applying overlays");
                float RangeLow = 0.2f;
                float RangeHigh = 0.8f;
                float TreeDens = 0.35f;
                short TreeDist = 3;
                //changes the terrain range based on type, also tree threshold
                switch (type)
                {
                    case "island":
                        RangeLow = 0.4f;
                        RangeHigh = 0.75f;
                        break;
                    case "forest":
                        RangeLow = 0.45f;
                        RangeHigh = 0.8f;
                        TreeDens = 0.7f;
                        TreeDist = 2;
                        break;
                    case "mountains":
                        RangeLow = 0.3f;
                        RangeHigh = 0.9f;
                        TreeDist = 4;
                        break;
                    case "ocean":
                        RangeLow = 0.1f;
                        RangeHigh = 0.6f;
                        break;
                    case "desert":
                        RangeLow = 0.5f;
                        RangeHigh = 0.85f;
                        WaterLevel = 0;
                        TreeDist = 24;
                        break;
                    case "nether":
                    case "hell":
                        RangeLow = .3f;
                        RangeHigh = 1.3f;
                        break;
                    case "arctic":
                        RangeLow = 0.4f;
                        RangeHigh = 0.70f;
                        break;
                    case "sphere":
                    case "dome":
                        RangeLow = 0; // It don't matter, its a ball...
                        RangeHigh = 0; // It don't matter, its a ball...
                        break;
                    default:
                        break;
                }

                //loops though evey X/Z coordinate
                for (int bb = 0; bb < terrain.Length; bb++)
                {
                    ushort x = (ushort)(bb % Lvl.width);
                    ushort y = (ushort)(bb / Lvl.width);
                    ushort z;
                    if (type.Equals("island"))
                    {
                        z = Evaluate(Lvl, Range(terrain[bb], RangeLow - NegateEdge(x, y, Lvl), RangeHigh - NegateEdge(x, y, Lvl)));
                    }
                    else if (type.Equals("arctic"))
                    {
                        z = Evaluate(Lvl, Range(terrain[bb], RangeLow - NegateEdge(x, y, Lvl), RangeHigh - NegateEdge(x, y, Lvl)));
                    }
                    else
                    {
                        z = Evaluate(Lvl, Range(terrain[bb], RangeLow, RangeHigh));
                    }
                    if (type != "hell" && type != "nether")
                    {
                        if (z > WaterLevel)
                        {
                            for (ushort zz = 0; z - zz >= 0; zz++)
                            {
                                if (type == "desert")
                                {
                                    Lvl.skipChange(x, (ushort)(z - zz), y, Block.sand);
                                }
                                else if (overlay[bb] < 0.72f)    //If not zoned for rocks or gravel
                                {
                                    if (type.Equals("island"))      //increase sand height for island
                                    {
                                        if (z > WaterLevel + 2)
                                        {
                                            if (zz == 0) { Lvl.skipChange(x, (ushort)(z - zz), y, Block.grass); }      //top layer
                                            else if (zz < 3) { Lvl.skipChange(x, (ushort)(z - zz), y, Block.dirt); }   //next few
                                            else { Lvl.skipChange(x, (ushort)(z - zz), y, Block.rock); }               //ten rock it
                                        }
                                        else
                                        {
                                            Lvl.skipChange(x, (ushort)(z - zz), y, Block.sand);                        //SAAAND extra for islands
                                        }
                                    }
                                    else if (type.Equals("arctic"))
                                    {
                                        if (z > WaterLevel + 2)
                                        {
                                            if (zz == 0) { Lvl.skipChange(x, (ushort)(z - zz), y, Block.white); }      //top layer
                                            else if (zz < 3) { Lvl.skipChange(x, (ushort)(z - zz), y, Block.white); }   //next few
                                            else { Lvl.skipChange(x, (ushort)(z - zz), y, Block.white); }               //ten rock it
                                        }
                                        else
                                        {
                                            Lvl.skipChange(x, (ushort)(z - zz), y, Block.white);
                                        }
                                    }
                                    else if (type == "desert")
                                    {
                                        Lvl.skipChange(x, (ushort)(z - zz), y, Block.sand);
                                    }
                                    else
                                    {
                                        if (zz == 0) { Lvl.skipChange(x, (ushort)(z - zz), y, Block.grass); }
                                        else if (zz < 3) { Lvl.skipChange(x, (ushort)(z - zz), y, Block.dirt); }
                                        else { Lvl.skipChange(x, (ushort)(z - zz), y, Block.rock); }
                                    }
                                }
                                else
                                {
                                    Lvl.skipChange(x, (ushort)(z - zz), y, Block.rock);    //zoned for above sea level rock floor
                                }
                            }

                            if (overlay[bb] < 0.25f && type != "desert" && type != "arctic")    //Zoned for flowers
                            {
                                int temprand = rand.Next(12);

                                switch (temprand)
                                {
                                    case 10:
                                        Lvl.skipChange(x, (ushort)(z + 1), y, Block.redflower);
                                        break;
                                    case 11:
                                        Lvl.skipChange(x, (ushort)(z + 1), y, Block.yellowflower);
                                        break;
                                    default:
                                        break;
                                }
                            }

                            if (!type.Equals("ocean"))
                            {
                                if (overlay[bb] < 0.65f && overlay2[bb] < TreeDens)
                                {
                                    if (Lvl.GetTile(x, (ushort)(z + 1), y) == Block.air)
                                    {
                                        if (Lvl.GetTile(x, z, y) == Block.grass || type == "desert")
                                        {
                                            if (rand.Next(13) == 0)
                                            {
                                                if (!TreeCheck(Lvl, x, z, y, TreeDist))
                                                {
                                                    if (type == "desert")
                                                        AddCactus(Lvl, x, (ushort)(z + 1), y, rand);
                                                    else
                                                        AddTree(Lvl, x, (ushort)(z + 1), y, rand);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else    //Must be on/under the water line then
                        {
                            for (ushort zz = 0; WaterLevel - zz >= 0; zz++)
                            {
                                if (WaterLevel - zz > z)
                                { Lvl.skipChange(x, (ushort)(WaterLevel - zz), y, Block.water); }    //better fill the water aboce me
                                else if (WaterLevel - zz > z - 3)
                                {
                                    if (!type.Equals("arctic"))
                                    {
                                        if (overlay[bb] < 0.75f)
                                        {
                                            Lvl.skipChange(x, (ushort)(WaterLevel - zz), y, Block.sand);   //sand top
                                        }
                                        else
                                        {
                                            Lvl.skipChange(x, (ushort)(WaterLevel - zz), y, Block.gravel);  //zoned for gravel
                                        }
                                    }
                                    else
                                    {
                                        Lvl.skipChange(x, (ushort)(WaterLevel - zz), y, Block.white);
                                    }
                                }
                                else
                                {
                                    if (!type.Equals("arctic")) { Lvl.skipChange(x, (ushort)(WaterLevel - zz), y, Block.rock); }
                                    else { Lvl.skipChange(x, (ushort)(WaterLevel - zz), y, Block.white); }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (z > LavaLevel)
                        {
                            for (ushort zz = 0; z - zz >= 0; zz++)
                            {
                                if (z > (LavaLevel - 1))
                                {
                                    if (zz == 0) { Lvl.skipChange(x, (ushort)(z - zz), y, Block.rock); }      //top layer
                                    else if (zz < 3) { Lvl.skipChange(x, (ushort)(z - zz), y, Block.rock); }
                                    else if (zz < 2) { Lvl.skipChange(x, (ushort)(z - zz), y, Block.lava); }//next few
                                    else { Lvl.skipChange(x, (ushort)(z - zz), y, Block.obsidian); }
                                }
                                else
                                {
                                    Lvl.skipChange(x, (ushort)(z - zz), y, Block.lava);
                                }
                                if (overlay[bb] < 0.3f)
                                {
                                    switch (rand.Next(13))
                                    {
                                        case 9:
                                        case 10:
                                        case 11:
                                        case 12:
                                            Lvl.skipChange(x, (ushort)(z + 1), y, Block.lava); //change to lava when time
                                            break;
                                        default:
                                            break;
                                    }
                                }
                                // if (zz == z) Lvl.skipChange(x, (ushort)(z - zz), y, Block.opsidian);
                                Lvl.skipChange(x, (ushort)(z), y, (rand.Next(100) % 3 == 1 ? Block.darkgrey : Block.obsidian));
                            }
                        }
                        else
                        {
                            for (ushort zz = 0; LavaLevel - zz >= 0; zz++)
                            {

                                if (LavaLevel - zz > z - 1)
                                { /*if (Lvl.GetTile(x, z, y) == Block.air)*/ Lvl.skipChange(x, (ushort)(LavaLevel - zz), y, Block.lava); }    //better fill the water aboce me
                                else if (LavaLevel - zz > z - 3)
                                {
                                    if (overlay[bb] < .9f)
                                    {
                                        if (zz < z) Lvl.skipChange(x, (ushort)(z - zz), (ushort)(y), Block.lava);
                                        else Lvl.skipChange(x, (ushort)(z - zz), y, Block.rock);
                                    }
                                    else
                                    {
                                        Lvl.skipChange(x, (ushort)(LavaLevel - zz), (ushort)(y - 5), Block.lava);  //killer lava
                                    }
                                }
                                else
                                {
                                    Lvl.skipChange(x, (ushort)(LavaLevel - zz), y, Block.stone); //and just make the rest cobblestone
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Server.ErrorLog(e);
                Server.s.Log("Gen Fail");
                Inuse = false;
                return false;
            }

            terrain = new float[0]; //Derp
            overlay = new float[0]; //Derp
            overlay2 = new float[0]; //Derp

            Inuse = false;

            return true;
        }
コード例 #8
0
ファイル: CmdMuseum.cs プロジェクト: sillyboyization/MCDawn
        public override void Use(Player p, string message)
        {
            string path;

            if (message.Split(' ').Length == 1) path = "levels/" + message + ".lvl";
            else if (message.Split(' ').Length == 2) try { path = @Server.backupLocation + "/" + message.Split(' ')[0] + "/" + int.Parse(message.Split(' ')[1]) + "/" + message.Split(' ')[0] + ".lvl"; }
                catch { Help(p); return; }
            else { Help(p); return; }

            if (File.Exists(path))
            {
                FileStream fs = File.OpenRead(path);
                try
                {

                    GZipStream gs = new GZipStream(fs, CompressionMode.Decompress);
                    byte[] ver = new byte[2];
                    gs.Read(ver, 0, ver.Length);
                    ushort version = BitConverter.ToUInt16(ver, 0);
                    Level level;
                    if (version == 1874)
                    {
                        byte[] header = new byte[16]; gs.Read(header, 0, header.Length);
                        ushort width = BitConverter.ToUInt16(header, 0);
                        ushort height = BitConverter.ToUInt16(header, 2);
                        ushort depth = BitConverter.ToUInt16(header, 4);
                        level = new Level(name, width, depth, height, "empty");
                        level.spawnx = BitConverter.ToUInt16(header, 6);
                        level.spawnz = BitConverter.ToUInt16(header, 8);
                        level.spawny = BitConverter.ToUInt16(header, 10);
                        level.rotx = header[12]; level.roty = header[13];
                    }
                    else
                    {
                        byte[] header = new byte[12]; gs.Read(header, 0, header.Length);
                        ushort width = version;
                        ushort height = BitConverter.ToUInt16(header, 0);
                        ushort depth = BitConverter.ToUInt16(header, 2);
                        level = new Level(name, width, depth, height, "grass");
                        level.spawnx = BitConverter.ToUInt16(header, 4);
                        level.spawnz = BitConverter.ToUInt16(header, 6);
                        level.spawny = BitConverter.ToUInt16(header, 8);
                        level.rotx = header[10]; level.roty = header[11];
                    }

                    level.setPhysics(0);

                    byte[] blocks = new byte[level.width * level.height * level.depth];
                    gs.Read(blocks, 0, blocks.Length);
                    level.blocks = blocks;
                    gs.Close();

                    level.backedup = true;
                    level.permissionbuild = LevelPermission.Admin;

                    level.jailx = (ushort)(level.spawnx * 32); level.jaily = (ushort)(level.spawny * 32); level.jailz = (ushort)(level.spawnz * 32);
                    level.jailrotx = level.rotx; level.jailroty = level.roty;

                    p.Loading = true;
                    foreach (Player pl in Player.players) if (p.level == pl.level && p != pl) p.SendDie(pl.id);
                    foreach (PlayerBot b in PlayerBot.playerbots) if (p.level == b.level) p.SendDie(b.id);

                    Player.GlobalDie(p, true);

                    p.level = level;
                    p.SendMotd();

                    p.SendRaw(2);
                    byte[] buffer = new byte[level.blocks.Length + 4];
                    BitConverter.GetBytes(IPAddress.HostToNetworkOrder(level.blocks.Length)).CopyTo(buffer, 0);
                    //ushort xx; ushort yy; ushort zz;

                    for (int i = 0; i < level.blocks.Length; ++i)
                        buffer[4 + i] = Block.Convert(level.blocks[i]);

                    buffer = Player.GZip(buffer);
                    int number = (int)Math.Ceiling(((double)buffer.Length) / 1024);
                    for (int i = 1; buffer.Length > 0; ++i)
                    {
                        short length = (short)Math.Min(buffer.Length, 1024);
                        byte[] send = new byte[1027];
                        Player.HTNO(length).CopyTo(send, 0);
                        Buffer.BlockCopy(buffer, 0, send, 2, length);
                        byte[] tempbuffer = new byte[buffer.Length - length];
                        Buffer.BlockCopy(buffer, length, tempbuffer, 0, buffer.Length - length);
                        buffer = tempbuffer;
                        send[1026] = (byte)(i * 100 / number);
                        p.SendRaw(3, send);
                        Thread.Sleep(10);
                    } buffer = new byte[6];
                    Player.HTNO((short)level.width).CopyTo(buffer, 0);
                    Player.HTNO((short)level.depth).CopyTo(buffer, 2);
                    Player.HTNO((short)level.height).CopyTo(buffer, 4);
                    p.SendRaw(4, buffer);

                    ushort x = (ushort)((0.5 + level.spawnx) * 32);
                    ushort y = (ushort)((1 + level.spawny) * 32);
                    ushort z = (ushort)((0.5 + level.spawnz) * 32);

                    p.aiming = false;
                    Player.GlobalSpawn(p, x, y, z, level.rotx, level.roty, true);
                    p.ClearBlockchange();
                    p.Loading = false;

                    if (message.IndexOf(' ') == -1)
                        level.name = "&cMuseum " + Server.DefaultColor + "(" + message.Split(' ')[0] + ")";
                    else
                        level.name = "&cMuseum " + Server.DefaultColor + "(" + message.Split(' ')[0] + " " + message.Split(' ')[1] + ")";

                    if (!p.hidden)
                    {
                        Player.GlobalChat(null, p.color + p.prefix + p.name + Server.DefaultColor + " went to the " + level.name, false);
                    }

                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                }
                catch (Exception ex) { Player.SendMessage(p, "Error loading level."); Server.ErrorLog(ex); return; }
                finally { fs.Close(); }
            }
            else { Player.SendMessage(p, "Level or backup could not be found."); return; }
        }
コード例 #9
0
ファイル: CmdNewLvl.cs プロジェクト: ddeckys/MCDawn
        public override void Use(Player p, string message)
        {
            if (message == "") { Help(p); return; }

            string[] parameters = message.Split(' '); // Grab the parameters from the player's message
            if (parameters.Length >= 5 && parameters.Length <= 6) // make sure there are 5 params, or 6, if type is sphere.
            {
                switch (parameters[4])
                {
                    case "flat":
                    case "pixel":
                    case "island":
                    case "mountains":
                    case "ocean":
                    case "forest":
                    case "desert":
                    case "nether":
                    case "hell":
                    case "arctic":
                    case "dome":
                    case "sphere":
                        break;

                    default:
                        Player.SendMessage(p, "Valid types: island, mountains, forest, ocean, flat, pixel, desert, nether, arctic, sphere [block]"); return;
                }

                string name = parameters[0].ToLower();
                ushort x = 1, y = 1, z = 1;
                try
                {
                    x = Convert.ToUInt16(parameters[1]);
                    y = Convert.ToUInt16(parameters[2]);
                    z = Convert.ToUInt16(parameters[3]);
                }
                catch { Player.SendMessage(p, "Invalid dimensions."); return; }
                if (!isGood(x)) { Player.SendMessage(p, x + " is not a good dimension! Use a power of 2 next time."); }
                if (!isGood(y)) { Player.SendMessage(p, y + " is not a good dimension! Use a power of 2 next time."); }
                if (!isGood(z)) { Player.SendMessage(p, z + " is not a good dimension! Use a power of 2 next time."); }

                if (!Player.ValidName(name)) { Player.SendMessage(p, "Invalid name!"); return; }

                try
                {
                    if (p != null)
                    if (p.group.Permission < LevelPermission.Admin)
                    {
                        if (x * y * z > 30000000) { Player.SendMessage(p, "Cannot create a map with over 30 million blocks"); return; }
                    }
                    else
                    {
                        if (x * y * z > 225000000) { Player.SendMessage(p, "You cannot make a map with over 225 million blocks"); return; }
                    }
                }
                catch
                {
                    Player.SendMessage(p, "An error occured");
                }

                // create a new level...
                try
                {
                    if (parameters.Length == 5) { Level lvl = new Level(name, x, y, z, parameters[4]); lvl.Save(true); }
                    else
                    {
                        byte blockChosen = 20;
                        try { blockChosen = Block.Byte(parameters[5]); }
                        catch { Player.SendMessage(p, "Invalid Block Chosen"); return; }
                        Level lvl = new Level(name, x, y, z, parameters[4], blockChosen);
                        lvl.Save(true);
                    }
                }
                finally
                {
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                }
                Player.GlobalMessage("Level " + name + " created"); // The player needs some form of confirmation.
            }
            else
                Help(p);
        }
コード例 #10
0
ファイル: MapGenerator.cs プロジェクト: jonnyli1125/MCDawn
 //return true if tree is near
 private bool TreeCheck(Level Lvl, ushort x, ushort z, ushort y, short dist)
 {
     for (short xx = (short)-dist; xx <= +dist; ++xx)
     {
         for (short yy = (short)-dist; yy <= +dist; ++yy)
         {
             for (short zz = (short)-dist; zz <= +dist; ++zz)
             {
                 byte foundTile = Lvl.GetTile((ushort)(x + xx), (ushort)(z + zz), (ushort)(y + yy));
                 if (foundTile == Block.trunk || foundTile == Block.green)
                 {
                     return true;
                 }
             }
         }
     }
     return false;
 }
コード例 #11
0
ファイル: CmdC4.cs プロジェクト: sillyboyization/OpenNet
 public void Explode(Player user, Level level, ushort x, ushort y, ushort z, int size)
 {
     level = user.level;
     level.MakeExplosion(x, y, z, size);
 }
コード例 #12
0
ファイル: ConvertDAT.cs プロジェクト: jonnyli1125/MCDawn
        public static Level Load(Stream lvlStream, string fileName)
        {
            byte[] temp = new byte[8];
            Level lvl = new Level(fileName, 0, 0, 0, "empty");
            byte[] data;
            int length;
            try {
                lvlStream.Seek( -4, SeekOrigin.End );
                lvlStream.Read( temp, 0, sizeof( int ) );
                lvlStream.Seek( 0, SeekOrigin.Begin );
                length = BitConverter.ToInt32( temp, 0 );
                data = new byte[length];
                using( GZipStream reader = new GZipStream( lvlStream, CompressionMode.Decompress, true ) ) {
                    reader.Read( data, 0, length );
                }

                for( int i = 0; i < length - 1; i++ ) {
                    if( data[i] == 0xAC && data[i + 1] == 0xED ) {

                        // bypassing the header crap
                        int pointer = i + 6;
                        Array.Copy( data, pointer, temp, 0, sizeof( short ) );
                        pointer += IPAddress.HostToNetworkOrder( BitConverter.ToInt16( temp, 0 ) );
                        pointer += 13;

                        int headerEnd = 0;
                        // find the end of serialization listing
                        for( headerEnd = pointer; headerEnd < data.Length - 1; headerEnd++ ) {
                            if( data[headerEnd] == 0x78 && data[headerEnd + 1] == 0x70 ) {
                                headerEnd += 2;
                                break;
                            }
                        }

                        // start parsing serialization listing
                        int offset = 0;
                        while( pointer < headerEnd ) {
                            if( data[pointer] == 'Z' ) offset++;
                            else if( data[pointer] == 'I' || data[pointer] == 'F' ) offset += 4;
                            else if( data[pointer] == 'J' ) offset += 8;

                            pointer += 1;
                            Array.Copy( data, pointer, temp, 0, sizeof( short ) );
                            short skip = IPAddress.HostToNetworkOrder( BitConverter.ToInt16( temp, 0 ) );
                            pointer += 2;

                            // look for relevant variables
                            Array.Copy( data, headerEnd + offset - 4, temp, 0, sizeof( int ) );
                            if( MemCmp( data, pointer, "width" ) ) {
                                lvl.width = (ushort)IPAddress.HostToNetworkOrder( BitConverter.ToInt32( temp, 0 ) );
                            } else if( MemCmp( data, pointer, "depth" ) ) {
                                lvl.depth = (ushort)IPAddress.HostToNetworkOrder( BitConverter.ToInt32( temp, 0 ) );
                            } else if( MemCmp( data, pointer, "height" ) ) {
                                lvl.height = (ushort)IPAddress.HostToNetworkOrder( BitConverter.ToInt32( temp, 0 ) );
                            }

                            pointer += skip;
                        }

                        lvl.spawnx = (ushort)(lvl.width / 1.3);
                        lvl.spawny = (ushort)(lvl.depth / 1.3);
                        lvl.spawnz = (ushort)(lvl.height / 1.3);

                        // find the start of the block array
                        bool foundBlockArray = false;
                        offset = Array.IndexOf<byte>( data, 0x00, headerEnd );
                        while( offset != -1 && offset < data.Length - 2 ) {
                            if( data[offset] == 0x00 && data[offset + 1] == 0x78 && data[offset + 2] == 0x70 ) {
                                foundBlockArray = true;
                                pointer = offset + 7;
                            }
                            offset = Array.IndexOf<byte>( data, 0x00, offset + 1 );
                        }

                        // copy the block array... or fail
                        if( foundBlockArray ) {
                            lvl.CopyBlocks( data, pointer );
                            lvl.Save(true);
                        } else {
                            throw new Exception( "Could not locate block array." );
                        }
                        break;
                    }
                }

            } catch( Exception ex ) {
                Server.s.Log("Conversion failed");
                Server.ErrorLog(ex);
                return null;
            }

            return lvl;
        }
コード例 #13
0
ファイル: PlayerBot.cs プロジェクト: sillyboyization/MCDawn
        public PlayerBot(string n, Level l, ushort x, ushort y, ushort z, byte rotx, byte roty)
        {
            name = n;
            color = "&1";
            id = FreeId();

            level = l;
            pos = new ushort[3] { x, y, z }; rot = new byte[2] { rotx, roty };
            GlobalSpawn();

            foreach (Player p in Player.players)
            {
                if (p.level == level)
                {
                    Player.SendMessage(p, color + name + Server.DefaultColor + ", the bot, has been added.");
                }
            }

            botTimer.Elapsed += delegate
            {
                int currentNum, foundNum = (32 * 75);
                Random rand = new Random();

                x = (ushort)Math.Round((decimal)pos[0] / (decimal)32);
                y = (ushort)((pos[1] - 33) / 32);
                z = (ushort)Math.Round((decimal)pos[2] / (decimal)32);

                if (kill)
                {
                    foreach (Player p in Player.players)
                    {
                        if ((ushort)(p.pos[0] / 32) == x)
                        {
                            if (Math.Abs((ushort)(p.pos[1] / 32) - y) < 2)
                            {
                                if ((ushort)(p.pos[2] / 32) == z)
                                {
                                    p.HandleDeath(Block.Zero);
                                }
                            }
                        }
                    }
                }

                if (Waypoints.Count < 1)
                {
                    if (hunt)
                        Player.players.ForEach(delegate(Player p)
                        {
                            if (p.level == level && !p.invincible)
                            {
                                currentNum = Math.Abs(p.pos[0] - pos[0]) + Math.Abs(p.pos[1] - pos[1]) + Math.Abs(p.pos[2] - pos[2]);
                                if (currentNum < foundNum)
                                {
                                    foundNum = currentNum;
                                    foundPos = p.pos;
                                    foundRot = p.rot;
                                    movement = true;
                                    rot[1] = (byte)(255 - foundRot[1]);
                                    if (foundRot[0] < 128) rot[0] = (byte)(foundRot[0] + 128);
                                    else rot[0] = (byte)(foundRot[0] - 128);
                                }
                            }
                        });
                }
                else
                {
                    bool skip = false;
                    movement = false;

                retry: switch (Waypoints[currentPoint].type)
                    {
                        case "walk":
                            foundPos[0] = Waypoints[currentPoint].x;
                            foundPos[1] = Waypoints[currentPoint].y;
                            foundPos[2] = Waypoints[currentPoint].z;
                            movement = true;

                            if ((ushort)(pos[0] / 32) == (ushort)(Waypoints[currentPoint].x / 32))
                            {
                                if ((ushort)(pos[2] / 32) == (ushort)(Waypoints[currentPoint].z / 32))
                                {
                                    rot[0] = Waypoints[currentPoint].rotx;
                                    rot[1] = Waypoints[currentPoint].roty;
                                    currentPoint++;
                                    movement = false;

                                    if (currentPoint == Waypoints.Count) currentPoint = 0;
                                    if (!skip) { skip = true; goto retry; }
                                }
                            }
                            break;
                        case "teleport":
                            pos[0] = Waypoints[currentPoint].x;
                            pos[1] = Waypoints[currentPoint].y;
                            pos[2] = Waypoints[currentPoint].z;
                            rot[0] = Waypoints[currentPoint].rotx;
                            rot[1] = Waypoints[currentPoint].roty;
                            currentPoint++;
                            if (currentPoint == Waypoints.Count) currentPoint = 0;
                            return;
                        case "wait":
                            if (countdown != 0)
                            {
                                countdown--;
                                if (countdown == 0)
                                {
                                    currentPoint++;
                                    if (currentPoint == Waypoints.Count) currentPoint = 0;
                                    if (!skip) { skip = true; goto retry; }
                                }
                            }
                            else
                            {
                                countdown = Waypoints[currentPoint].seconds;
                            }
                            return;
                        case "nod":
                            if (countdown != 0)
                            {
                                countdown--;

                                if (nodUp)
                                {
                                    if (rot[1] > 32 && rot[1] < 128) nodUp = !nodUp;
                                    else
                                    {
                                        if (rot[1] + (byte)Waypoints[currentPoint].rotspeed > 255) rot[1] = 0;
                                        else rot[1] += (byte)Waypoints[currentPoint].rotspeed;
                                    }
                                }
                                else
                                {
                                    if (rot[1] > 128 && rot[1] < 224) nodUp = !nodUp;
                                    else
                                    {
                                        if (rot[1] - (byte)Waypoints[currentPoint].rotspeed < 0) rot[1] = 255;
                                        else rot[1] -= (byte)Waypoints[currentPoint].rotspeed;
                                    }
                                }

                                if (countdown == 0)
                                {
                                    currentPoint++;
                                    if (currentPoint == Waypoints.Count) currentPoint = 0;
                                    if (!skip) { skip = true; goto retry; }
                                }
                            }
                            else
                            {
                                countdown = Waypoints[currentPoint].seconds;
                            }
                            return;
                        case "spin":
                            if (countdown != 0)
                            {
                                countdown--;

                                if (rot[0] + (byte)Waypoints[currentPoint].rotspeed > 255) rot[0] = 0;
                                else if (rot[0] + (byte)Waypoints[currentPoint].rotspeed < 0) rot[0] = 255;
                                else rot[0] += (byte)Waypoints[currentPoint].rotspeed;

                                if (countdown == 0)
                                {
                                    currentPoint++;
                                    if (currentPoint == Waypoints.Count) currentPoint = 0;
                                    if (!skip) { skip = true; goto retry; }
                                }
                            }
                            else
                            {
                                countdown = Waypoints[currentPoint].seconds;
                            }
                            return;
                        case "speed":
                            movementSpeed = (int)Math.Round((decimal)((decimal)24 / (decimal)100 * (decimal)Waypoints[currentPoint].seconds));
                            if (movementSpeed == 0) movementSpeed = 1;

                            currentPoint++;
                            if (currentPoint == Waypoints.Count) currentPoint = 0;
                            if (!skip) { skip = true; goto retry; }
                            return;
                        case "reset":
                            currentPoint = 0;
                            return;
                        case "remove":
                            removeBot();
                            return;
                        case "linkscript":
                            if (File.Exists("bots/" + Waypoints[currentPoint].newscript))
                            {
                                Command.all.Find("botset").Use(null, this.name + " " + Waypoints[currentPoint].newscript);
                                return;
                            }

                            currentPoint++;
                            if (currentPoint == Waypoints.Count) currentPoint = 0;
                            if (!skip) { skip = true; goto retry; }
                            return;
                        case "jump":
                            jumpTimer.Elapsed += delegate
                            {
                                currentjump++;
                                switch (currentjump)
                                {
                                    case 1:
                                    case 2: pos[1] += 24; break;
                                    case 3: break;
                                    case 4: pos[1] -= 24; break;
                                    case 5: pos[1] -= 24; jumping = false; currentjump = 0; jumpTimer.Stop(); break;
                                }
                            };
                            jumpTimer.Start();

                            currentPoint++;
                            if (currentPoint == Waypoints.Count) currentPoint = 0;
                            if (!skip) { skip = true; goto retry; }
                            break;
                    }

                    if (currentPoint == Waypoints.Count) currentPoint = 0;
                }

                if (!movement)
                {
                    if (rot[0] < 245) rot[0] += 8;
                    else rot[0] = 0;

                    if (rot[1] > 32 && rot[1] < 64) rot[1] = 224;
                    else if (rot[1] > 250) rot[1] = 0;
                    else rot[1] += 4;
                }
            };

            botTimer.Start();

            moveTimer.Elapsed += delegate
            {
                moveTimer.Interval = Server.updateTimer.Interval / movementSpeed;
                if (!movement) return;
                int newNum; Random rand = new Random();

                if ((pos[1] - 19) % 32 != 0 && !jumping)
                {
                    pos[1] = (ushort)((pos[1] + 19) - (pos[1] % 32));
                }

                x = (ushort)Math.Round((decimal)(pos[0] - 16) / (decimal)32);
                y = (ushort)((pos[1] - 64) / 32);
                z = (ushort)Math.Round((decimal)(pos[2] - 16) / (decimal)32);

                byte b = Block.Convert(level.GetTile(x, y, z));
                byte b1, b2, b3;//, b4;

                if (Block.Walkthrough(b) && !jumping)
                {
                    pos[1] = (ushort)(pos[1] - 32);
                }

                y = (ushort)((pos[1] - 64) / 32);   //Block below feet

                newNum = level.PosToInt((ushort)(x + Math.Sign(foundPos[0] - pos[0])), y, (ushort)(z + Math.Sign(foundPos[2] - pos[2])));
                b = Block.Convert(level.GetTile(newNum));
                b1 = Block.Convert(level.GetTile(level.IntOffset(newNum, 0, 1, 0)));
                b2 = Block.Convert(level.GetTile(level.IntOffset(newNum, 0, 2, 0)));
                b3 = Block.Convert(level.GetTile(level.IntOffset(newNum, 0, 3, 0)));

                if (Block.Walkthrough(b2) && Block.Walkthrough(b3) && !Block.Walkthrough(b1))
                {     //Get ready to go up step
                    pos[0] += (ushort)Math.Sign(foundPos[0] - pos[0]);
                    pos[1] += (ushort)32;
                    pos[2] += (ushort)Math.Sign(foundPos[2] - pos[2]);
                }
                else if (Block.Walkthrough(b1) && Block.Walkthrough(b2))
                {                        //Stay on current level
                    pos[0] += (ushort)Math.Sign(foundPos[0] - pos[0]);
                    pos[2] += (ushort)Math.Sign(foundPos[2] - pos[2]);
                }
                else if (Block.Walkthrough(b) && Block.Walkthrough(b1))
                {                         //Drop a level
                    pos[0] += (ushort)Math.Sign(foundPos[0] - pos[0]);
                    pos[1] -= (ushort)32;
                    pos[2] += (ushort)Math.Sign(foundPos[2] - pos[2]);
                }

                x = (ushort)Math.Round((decimal)(pos[0] - 16) / (decimal)32);
                y = (ushort)((pos[1] - 64) / 32);
                z = (ushort)Math.Round((decimal)(pos[2] - 16) / (decimal)32);

                b1 = Block.Convert(level.GetTile(x, (ushort)(y + 1), z));
                b2 = Block.Convert(level.GetTile(x, (ushort)(y + 2), z));
                b3 = Block.Convert(level.GetTile(x, y, z));

                /*
                if ((ushort)(foundPos[1] / 32) > y) {
                    if (b1 == Block.water || b1 == Block.waterstill || b1 == Block.lava || b1 == Block.lavastill) {
                        if (Block.Walkthrough(b2)) {
                            pos[1] = (ushort)(pos[1] + (Math.Sign(foundPos[1] - pos[1])));
                        }
                    } else if (b2 == Block.water || b2 == Block.waterstill || b2 == Block.lava || b2 == Block.lavastill) {
                        pos[1] = (ushort)(pos[1] + (Math.Sign(foundPos[1] - pos[1])));
                    }
                } else if ((ushort)(foundPos[1] / 32) < y) {
                    if (b3 == Block.water || b3 == Block.waterstill || b3 == Block.lava || b3 == Block.lavastill) {
                        pos[1] = (ushort)(pos[1] + (Math.Sign(foundPos[1] - pos[1])));
                    }
                }*/
            };
            moveTimer.Start();
            Server.s.PlayerBotListUpdate();
        }
コード例 #14
0
ファイル: MapGenerator.cs プロジェクト: jonnyli1125/MCDawn
 void GeneratePerlinNoise(float[] array, Level Lvl, string type, Random rand)
 {
     GenerateNormalized(array, 0.7f, 8, Lvl.width, Lvl.height, rand.Next(), 64);
 }
コード例 #15
0
ファイル: MapGenerator.cs プロジェクト: jonnyli1125/MCDawn
        void AddCactus(Level Lvl, ushort x, ushort y, ushort z, Random Rand)
        {
            byte height = (byte)Rand.Next(3, 6);
            ushort yy;

            for (yy = 0; yy <= height; yy++) Lvl.skipChange(x, (ushort)(y + yy), z, Block.green);

            int inX = 0, inZ = 0;

            switch (Rand.Next(1, 3))
            {
                case 1: inX = -1; break;
                case 2:
                default: inZ = -1; break;
            }

            for (yy = height; yy <= Rand.Next(height + 2, height + 5); yy++) Lvl.skipChange((ushort)(x + inX), (ushort)(y + yy), (ushort)(z + inZ), Block.green);
            for (yy = height; yy <= Rand.Next(height + 2, height + 5); yy++) Lvl.skipChange((ushort)(x - inX), (ushort)(y + yy), (ushort)(z - inZ), Block.green);
        }
コード例 #16
0
ファイル: MapGenerator.cs プロジェクト: jonnyli1125/MCDawn
        public void CreateSphere(Level l, byte blockChosen)
        {
            ushort x = 1; ushort y = 1; ushort z = 1;
            CatchPos cpos;
            cpos.x = (ushort)(l.width - 1); cpos.y = (ushort)(l.height - 1); cpos.z = (ushort)(l.depth - 1);
            cpos.type = blockChosen;

            // find start/end coordinates
            int sx = Math.Min(cpos.x, x);
            int ex = Math.Max(cpos.x, x);
            int sy = Math.Min(cpos.y, y);
            int ey = Math.Max(cpos.y, y);
            int sz = Math.Min(cpos.z, z);
            int ez = Math.Max(cpos.z, z);

            // find axis lengths
            double rx = (ex - sx + 1) / 2d;
            double ry = (ey - sy + 1) / 2d;
            double rz = (ez - sz + 1) / 2d;

            double rx2 = 1 / (rx * rx);
            double ry2 = 1 / (ry * ry);
            double rz2 = 1 / (rz * rz);

            // find center points
            double cx = (ex + sx) / 2d;
            double cy = (ey + sy) / 2d;
            double cz = (ez + sz) / 2d;

            // rougher estimation than the non-hollow form, a voxelized surface is a bit funky
            int totalBlocks = (int)(4 / 3d * Math.PI * ((rx + .5) * (ry + .5) * (rz + .5) - (rx - .5) * (ry - .5) * (rz - .5)) * 0.85);

            for (int xx = sx; xx <= ex; xx++)
            {
                for (int yy = sy; yy <= ey; yy++)
                {
                    for (int zz = sz; zz <= ez; zz++)
                    {
                        // get relative coordinates
                        double dx = (xx - cx);
                        double dy = (yy - cy);
                        double dz = (zz - cz);

                        if ((dx * dx) * rx2 + (dy * dy) * ry2 + (dz * dz) * rz2 <= 1)
                        {
                            // we touched the surface
                            // keep drilling until we hit an internal block
                            do
                            {
                                l.SetTile((ushort)xx, (ushort)yy, (ushort)zz, blockChosen);
                                l.SetTile((ushort)xx, (ushort)yy, (ushort)(cz - dz), blockChosen);
                                dz = (++zz - cz);
                            } while (zz <= (int)cz &&
                                    ((dx + 1) * (dx + 1) * rx2 + (dy * dy) * ry2 + (dz * dz) * rz2 > 1 ||
                                     (dx - 1) * (dx - 1) * rx2 + (dy * dy) * ry2 + (dz * dz) * rz2 > 1 ||
                                     (dx * dx) * rx2 + (dy + 1) * (dy + 1) * ry2 + (dz * dz) * rz2 > 1 ||
                                     (dx * dx) * rx2 + (dy - 1) * (dy - 1) * ry2 + (dz * dz) * rz2 > 1 ||
                                     (dx * dx) * rx2 + (dy * dy) * ry2 + (dz + 1) * (dz + 1) * rz2 > 1 ||
                                     (dx * dx) * rx2 + (dy * dy) * ry2 + (dz - 1) * (dz - 1) * rz2 > 1));
                            break;
                        }
                    }
                }
            }
        }
コード例 #17
0
ファイル: MapGenerator.cs プロジェクト: jonnyli1125/MCDawn
        void GenerateFault(float[] array, Level Lvl, string type, Random rand)
        {
            float startheight = 0.5f;
            float dispAux;
            ushort i, j, k, halfX, halfZ;
            float a, b, c, w, d;

            float DispMax, DispMin, DispChange;
            DispMax = 0.01f;
            DispChange = -0.0025f;
            if (type.Equals("mountains"))
            {
                DispMax = 0.02f;
                startheight = 0.6f;
            }
            else if (type.Equals("overlay"))
            {
                DispMax = 0.02f;
                DispChange = -0.01f;
            }
            else if (type.Equals("hell") || type.Equals("nether"))
            {
                DispMax = 0.02f;
                startheight = 0.04f;
            }

            for (int x = 0; x < array.Length; x++)
            {
                array[x] = startheight;
                //overlay[x] = 0.5f;
            }
            DispMin = -DispMax;
            float disp = DispMax;
            //if (terrainHeights == NULL)
            //    return (TERRAIN_ERROR_NOT_INITIALISED);

            halfX = (ushort)(Lvl.width / 2);
            halfZ = (ushort)(Lvl.height / 2);
            int numIterations = (int)((Lvl.width + Lvl.height));
            Server.s.Log("Iterations = " + numIterations.ToString());
            for (k = 0; k < numIterations; k++)
            {
                //s.Log("itteration " + k.ToString());
                d = (float)Math.Sqrt(halfX * halfX + halfZ * halfZ);
                w = (float)(rand.NextDouble() * 360);
                //w = (float)(rand.NextDouble()*90);
                a = (float)Math.Cos(w);
                b = (float)Math.Sin(w);

                c = ((float)rand.NextDouble()) * 2 * d - d;
                //c = ((float)rand.NextDouble() / 1) * 2 * d - d;
                //float disp = (float)(rand.NextDouble()* 0.02f - 0.01f);
                //iterationsDone++;
                //if (iterationsDone < itMinDisp)
                //    disp = maxDisp + (iterationsDone / (itMinDisp + 0.0)) * (minDisp - maxDisp);
                //else
                //    disp = minDisp;
                for (i = 0; i < Lvl.height; i++)
                {
                    for (j = 0; j < Lvl.width; j++)
                    {
                        //switch (terrainFunction)
                        //{
                        //case STEP:
                        if ((i - halfZ) * a + (j - halfX) * b + c > 0)
                            dispAux = disp;
                        else
                            dispAux = -disp;
                        //    break;
                        /*case SIN:
                            pd = ((i - halfZ) * a + (j - halfX) * b + c) / terrainWaveSize;
                            if (pd > 1.57) pd = 1.57;
                            else if (pd < 0) pd = 0;
                            dispAux = -disp / 2 + sin(pd) * disp;
                            break;
                        case COS:
                            pd = ((i - halfZ) * a + (j - halfX) * b + c) / terrainWaveSize;
                            if (pd > 3.14) pd = 3.14;
                            else if (pd < -3.14) pd = -3.14;
                            dispAux = disp - (terrainWaveSize / (terrainGridWidth + 0.0)) + cos(pd) * disp;
                            break;
                    }*/
                        //s.Log("adding " + dispAux.ToString());
                        AddTerrainHeight(array, j, i, Lvl.width, dispAux);
                        //terrainHeights[i * terrainGridWidth + j] += dispAux;
                    }
                }

                disp += DispChange;
                if (disp < DispMin) { disp = DispMax; }
            }
        }
コード例 #18
0
ファイル: MapGenerator.cs プロジェクト: jonnyli1125/MCDawn
        //applys the average filter
        void FilterAverage(Level Lvl)
        {
            Server.s.Log("Applying average filtering");

            float[] filtered = new float[terrain.Length];

            for (int bb = 0; bb < terrain.Length; bb++)
            {
                ushort x = (ushort)(bb % Lvl.width);
                ushort y = (ushort)(bb / Lvl.width);
                filtered[bb] = GetAverage9(x, y, Lvl);
            }

            for (int bb = 0; bb < terrain.Length; bb++)
            {
                terrain[bb] = filtered[bb];
            }
        }
コード例 #19
0
ファイル: MapGenerator.cs プロジェクト: jonnyli1125/MCDawn
 //converts the float into a ushort for map height
 ushort Evaluate(Level lvl, float height)
 {
     ushort temp = (ushort)(height * lvl.depth);
     if (temp < 0) return 0;
     if (temp > lvl.depth - 1) return (ushort)(lvl.depth - 1);
     return temp;
 }
コード例 #20
0
ファイル: MapGenerator.cs プロジェクト: jonnyli1125/MCDawn
        //
        void AddTree(Level Lvl, ushort x, ushort y, ushort z, Random Rand)
        {
            byte height = (byte)Rand.Next(5, 8);
            for (ushort yy = 0; yy < height; yy++) Lvl.skipChange(x, (ushort)(y + yy), z, Block.trunk);

            short top = (short)(height - Rand.Next(2, 4));

            for (short xx = (short)-top; xx <= top; ++xx)
            {
                for (short yy = (short)-top; yy <= top; ++yy)
                {
                    for (short zz = (short)-top; zz <= top; ++zz)
                    {
                        short Dist = (short)(Math.Sqrt(xx * xx + yy * yy + zz * zz));
                        if (Dist < top + 1)
                        {
                            if (Rand.Next((int)(Dist)) < 2)
                            {
                                try
                                {
                                    Lvl.skipChange((ushort)(x + xx), (ushort)(y + yy + height), (ushort)(z + zz), Block.leaf);
                                }
                                catch { }
                            }
                        }
                    }
                }
            }
        }
コード例 #21
0
ファイル: IsoCat.cs プロジェクト: jonnyli1125/MCDawn
        public IsoCat(Level level, IsoCatMode mode, int rot)
        {
            Rot = rot;
            Mode = mode;
            Level = level;

            dimX = Level.width;
            dimY = Level.height;
            offsetY = Math.Max(0, Level.width - Level.height);
            offsetX = Math.Max(0, Level.height - Level.width);
            dimX2 = dimX / 2 - 1;
            dimY2 = dimY / 2 - 1;
            dimX1 = dimX - 1;
            dimY1 = dimY - 1;

            blendDivisor = 255 * Level.depth;

            imageWidth = TileX * Math.Max(dimX, dimY) + TileY / 2 * Level.depth + TileX * 2;
            imageHeight = TileY / 2 * Level.depth + MaxTileDim / 2 * Math.Max(Math.Max(dimX, dimY), Level.depth) + TileY * 2;

            imageBmp = new Bitmap(imageWidth, imageHeight, PixelFormat.Format32bppArgb);
            imageData = imageBmp.LockBits(new Rectangle(0, 0, imageBmp.Width, imageBmp.Height),
                                           ImageLockMode.ReadWrite,
                                           PixelFormat.Format32bppArgb);

            image = (byte*)imageData.Scan0;
            imageStride = imageData.Stride;

            isoOffset = (Level.depth * TileY / 2 * imageStride + imageStride / 2 + TileX * 2);
            isoX = (TileX / 4 * imageStride + TileX * 2);
            isoY = (TileY / 4 * imageStride - TileY * 2);
            isoH = (-TileY / 2 * imageStride);

            mh34 = Level.depth * 3 / 4;
        }
コード例 #22
0
ファイル: MapGenerator.cs プロジェクト: jonnyli1125/MCDawn
 //returns the valve of a x,y terrain coordinate
 float GetPixel(ushort x, ushort y, Level Lvl)
 {
     if (x < 0) { return 0.0f; }
     if (x >= Lvl.width) { return 0.0f; }
     if (y < 0) { return 0.0f; }
     if (y >= Lvl.height) { return 0.0f; }
     divide += 1.0f;
     return terrain[x + y * Lvl.width];
 }
コード例 #23
0
ファイル: CmdFill.cs プロジェクト: blha303/MCDawn
 public byte GetTile(ushort x, ushort y, ushort z, Level l, byte[] blocks)
 {
     //if (PosToInt(x, y, z) >= blocks.Length) { return null; }
     //Avoid internal overflow
     if (x < 0) { return Block.Zero; }
     if (x >= l.width) { return Block.Zero; }
     if (y < 0) { return Block.Zero; }
     if (y >= l.depth) { return Block.Zero; }
     if (z < 0) { return Block.Zero; }
     if (z >= l.height) { return Block.Zero; }
     try
     {
         return blocks[l.PosToInt(x, y, z)];
     }
     catch (Exception e) { Server.ErrorLog(e); return Block.Zero; }
 }
コード例 #24
0
ファイル: MapGenerator.cs プロジェクト: jonnyli1125/MCDawn
        //Forces the edge of a map to slope lower for island map types
        float NegateEdge(ushort x, ushort y, Level Lvl)
        {
            float tempx = 0.0f, tempy = 0.0f;
            float temp;
            if (x != 0) { tempx = ((float)x / (float)Lvl.width) * 0.5f; }
            if (y != 0) { tempy = ((float)y / (float)Lvl.height) * 0.5f; }
            tempx = Math.Abs(tempx - 0.25f);
            tempy = Math.Abs(tempy - 0.25f);
            if (tempx > tempy)
            {
                temp = tempx - 0.15f;
            }
            else
            {
                temp = tempy - 0.15f;
            }

            //s.Log("temp = " + temp.ToString());
            if (temp > 0.0f) { return temp; }
            return 0.0f;
        }