Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- internal fun processRegionFile(file: File) {
- val splitted = file.name.split('.')
- val regionX = splitted[1].toInt()
- val regionZ = splitted[2].toInt()
- if (locations.none { it.shouldSaveRegion(regionX, regionZ) }) {
- println("Skipping region $regionX $regionZ")
- return
- }
- for (x in 0..31) {
- for (z in 0..31) {
- val chunkX = regionX * 32 + x
- val chunkZ = regionZ * 32 + z
- val input = RegionFileCache.getChunkInputStream(oldWorld, chunkX, chunkZ)
- if (input != null) {
- val tag = CompressedStreamTools.read(input)
- input.close()
- processChunk(tag, chunkX, chunkZ)
- }
- }
- }
- }
- internal fun processChunk(tag: NBTTagCompound, x: Int, z: Int) {
- if (locations.none { it.shouldSaveChunk(x, z) }) {
- println("Skipping chunk $x $z")
- return;
- }
- val level = tag.getCompoundTag("Level")
- val entities = level.getTagList("Entities")
- if (setToTaiga) {
- level.setByteArray("Biomes", ByteArray(256, { 12 }))
- }
- if (!noRemove) {
- val numEntities = entities.tagCount()
- for (i in entities.tagCount() - 1 downTo 0) {
- val entity = entities.tagAt(i) as NBTTagCompound
- if (entity.getString("id").toLowerCase().startsWith("npc")) {
- val owner = entity.getString("owner")
- if (owner != "" && owner != "Helper" && owner != "Reiker") {
- entities.removeTag(i)
- }
- } else if (entity.getString("id") != "Painting") {
- entities.removeTag(i);
- }
- }
- val numRemoved = numEntities - entities.tagCount()
- if (numRemoved > 0) {
- println("Removed $numRemoved entities from chunk $x $z")
- }
- val tileEntities = level.getTagList("TileEntities")
- for (i in 0..tileEntities.tagCount() - 1) {
- val tileEntity = tileEntities.tagAt(i) as NBTTagCompound
- tileEntity.removeTag("Items")
- }
- }
- locations.filter { it.shouldSaveChunk(x, z) }.forEach { it.saveChunk(tag.copy() as NBTTagCompound, x, z) }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement