public void Resize(int x, int y, int z) { if (x < 16 || y < 16 || z < 16 || x > 32767 || y > 32767 || z > 32767) { return; } var mem1 = new byte[(x * y * z) * 4]; int copyX = Math.Min(MapSize.X, x); int copyY = Math.Min(MapSize.Y, y); int copyZ = Math.Min(MapSize.Z, z); // -- Copy in existing blocks as much as we can for (var ix = 0; ix < copyX - 1; ix++) { for (var iy = 0; iy < copyY - 1; iy++) { for (var iz = 0; iz < copyZ - 1; iz++) { int oldIndex = GetBlockIndex(ix, iy, iz); int newIndex = GetBlockIndex(ix, iy, iz, x, y); mem1[newIndex] = MapData[oldIndex]; // -- Copy existing block into new array. } } } // -- Adjust spawn location Vector3S current = MapSpawn.GetAsBlockCoords(); short newX = current.X; short newY = current.Y; if (current.X > x - 1) { newX = (short)(x - 1); } if (current.Y > y - 1) { newY = (short)(y - 1); } MapSpawn.SetAsBlockCoords(new Vector3S(newX, newY, current.Z)); MapSize = new Vector3S(x, y, z); MapData = mem1; }
public D3Map(string folder, string name, short sizeX, short sizeY, short sizeZ) { _mapPath = folder; _configFile = new PreferenceLoader(ConfigName, null, folder); _UUID = GenerateUuid(); _saveInterval = 10; _serverVersion = 1004; _overviewType = D3OverviewType.Iso; Name = name; MapSize = new Vector3S(sizeX, sizeY, sizeZ); MapSpawn = new MinecraftLocation(); MapSpawn.SetAsBlockCoords(new Vector3S(sizeX / 2, sizeY / 2, sizeZ / 2)); MapData = new byte[(sizeX * sizeY * sizeZ) * 4]; }