public bool CanPlace(NbtWorld World) { int averageHeight = 0; int maxHeight = 0; BlockManager bm = (BlockManager)World.GetBlockManager (); for (int x = 0; x < _fp.X; ++x) { for (int z = 0; z < _fp.Z; ++z) { int h = bm.GetHeight (x + _x, z + _z); averageHeight += h; if (maxHeight < h) maxHeight = h; } } averageHeight /= _fp.X * _fp.Z; if (averageHeight > 120) return false; for (int x = 0; x < _fp.X; ++x) { for (int z = 0; z < _fp.Z; ++z) { if (Abs (bm.GetHeight (x + _x, z + _z) - averageHeight) > 3) return false; } } //Build the house! BuildHouse (_x, _z, averageHeight, bm); return true; }
public bool CanPlace(int X, int Z, NbtWorld World) { if (X - _radius < 0 || X + _radius >= _xMax || Z - _radius < 0 || Z + _radius >= _zMax) return false; BlockManager bm = (BlockManager)World.GetBlockManager (); bool tr = true; foreach (IBuilding b in _buildings) { tr = tr && b.CanPlace (World); } if (tr) { foreach (IBuilding b in _buildings) { b.Build (World); } for (int x = 0; x < 2 * _radius; ++x) { for (int z = 0; z < 2 * _radius; ++z) { int xp = x + X - _radius; int zp = z + Z - _radius; bool isEdge = x == 0 || z == 0 || x == 2 * _radius - 1 || z == 2 * _radius - 1; if (isEdge) { bm.SetID (xp, bm.GetHeight (xp, zp) - 1, zp, BlockInfo.Wool.ID); bm.SetData (xp, bm.GetHeight (xp, zp) - 1, zp, (int)WoolColor.PURPLE); } } } } return tr; }
/// <summary> /// Create an obsidian podium under the player's current location /// </summary> /// <param name="world">The world to be modified</param> /// <returns name="world">The world to be modified</returns> public static NbtWorld MakePodium(NbtWorld world) { BlockManager bm = (BlockManager)world.GetBlockManager(); Player player = world.Level.Player; MakeArena(bm, player.Position, 2, 2); return world; }
public void Build(NbtWorld World) { int averageHeight = 0; BlockManager bm = (BlockManager)World.GetBlockManager (); for (int x = 0; x < _fp.X; ++x) { for (int z = 0; z < _fp.Z; ++z) { averageHeight += bm.GetHeight (x + _x, z + _z); } } averageHeight /= _fp.X * _fp.Z; BuildHouse (_x, _z, averageHeight, bm); }
public WorldStamp(NbtWorld world) { _world = world; _blockManager = _world.GetBlockManager(); }