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); }
public void AddCactus(Level Lvl, ushort x, ushort y, ushort z, Random Rand, bool blockChange = false, bool overwrite = true, Player p = null) { byte height = (byte)Rand.Next(3, 6); ushort yy; for (yy = 0; yy <= height; yy++) { if (overwrite || Lvl.GetTile(z, (ushort)(y + yy), z) == Block.air) if (blockChange) if (p == null) Lvl.Blockchange(x, (ushort)(y + yy), z, Block.green); else Lvl.Blockchange(p, x, (ushort)(y + yy), z, Block.green); else 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++) { if (overwrite || Lvl.GetTile((ushort)(x + inX), (ushort)(y + yy), (ushort)(z + inZ)) == Block.air) if (blockChange) if (p == null) Lvl.Blockchange((ushort)(x + inX), (ushort)(y + yy), (ushort)(z + inZ), Block.green); else Lvl.Blockchange(p, (ushort)(x + inX), (ushort)(y + yy), (ushort)(z + inZ), Block.green); else Lvl.skipChange((ushort)(x + inX), (ushort)(y + yy), (ushort)(z + inZ), Block.green); } for (yy = height; yy <= Rand.Next(height + 2, height + 5); yy++) { if (overwrite || Lvl.GetTile((ushort)(x + inX), (ushort)(y + yy), (ushort)(z + inZ)) == Block.air) if (blockChange) if (p == null) Lvl.Blockchange((ushort)(x - inX), (ushort)(y + yy), (ushort)(z - inZ), Block.green); else Lvl.Blockchange(p, (ushort)(x - inX), (ushort)(y + yy), (ushort)(z - inZ), Block.green); else Lvl.skipChange((ushort)(x - inX), (ushort)(y + yy), (ushort)(z - inZ), Block.green); } }
public void AddNotchSwampTree(Level Lvl, ushort x, ushort y, ushort z, Random Rand, bool blockChange = false, bool overwrite = true, Player p = null) { byte dist, tile; byte height = (byte)Rand.Next(4, 8); byte top = (byte)(height - 2); short xx, yy, zz; ushort xxx, yyy, zzz; for (yy = 0; yy <= height; yy++) { yyy = (ushort)(y + yy); tile = Lvl.GetTile(x, yyy, z); if (overwrite || tile == Block.air || (yyy == y && tile == Block.shrub)) if (blockChange) if (p == null) Lvl.Blockchange(x, yyy, z, Block.trunk); else Lvl.Blockchange(p, x, yyy, z, Block.trunk); else Lvl.SetTile(x, yyy, z, Block.trunk); } for (yy = top; yy <= height + 1; yy++) { dist = yy > height - 1 ? (byte)2 : (byte)3; for (xx = (short)-dist; xx <= dist; xx++) { for (zz = (short)-dist; zz <= dist; zz++) { xxx = (ushort)(x + xx); yyy = (ushort)(y + yy); zzz = (ushort)(z + zz); tile = Lvl.GetTile(xxx, yyy, zzz); //Server.s.Log(String.Format("{0} {1} {2}", xxx, yyy, zzz)); if ((xxx == x && zzz == z && yy <= height) || (!overwrite && tile != Block.air)) continue; if (Math.Abs(xx) == dist && Math.Abs(zz) == dist) { if (yy > height) continue; if (Rand.Next(2) == 0) { if (blockChange) if (p == null) Lvl.Blockchange(xxx, yyy, zzz, Block.leaf); else Lvl.Blockchange(p, xxx, yyy, zzz, Block.leaf); else Lvl.SetTile(xxx, yyy, zzz, Block.leaf); } } else { if (blockChange) if (p == null) Lvl.Blockchange(xxx, yyy, zzz, Block.leaf); else Lvl.Blockchange(p, xxx, yyy, zzz, Block.leaf); else Lvl.SetTile(xxx, yyy, zzz, Block.leaf); } } } } }
// public void AddTree(Level Lvl, ushort x, ushort y, ushort z, Random Rand, bool blockChange = false, bool overwrite = true, Player p = null) { byte height = (byte)Rand.Next(5, 8); short top = (short)(height - Rand.Next(2, 4)); ushort xxx, yyy, zzz; for (ushort yy = 0; yy < top + height - 1; yy++) { if (overwrite || Lvl.GetTile(x, (ushort)(y + yy), z) == Block.air || (y + yy == y && Lvl.GetTile(x, (ushort)(y + yy), z) == Block.shrub)) if (blockChange) if (p == null) Lvl.Blockchange(x, (ushort)(y + yy), z, Block.trunk); else Lvl.Blockchange(p, x, (ushort)(y + yy), z, Block.trunk); else Lvl.SetTile(x, (ushort)(y + yy), z, Block.trunk); } 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 { xxx = (ushort)(x + xx); yyy = (ushort)(y + yy + height); zzz = (ushort)(z + zz); if ((xxx != x || zzz != z || yy >= top - 1) && (overwrite || Lvl.GetTile(xxx, yyy, zzz) == Block.air)) if (blockChange) if (p == null) Lvl.Blockchange(xxx, yyy, zzz, Block.leaf); else Lvl.Blockchange(p, xxx, yyy, zzz, Block.leaf); else Lvl.SetTile(xxx, yyy, zzz, Block.leaf); } catch { } } } } } } }