Advertisement
Rob5Underscores

Untitled

Aug 21st, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. try {
  2. RegionFile regionFile = new RegionFile(loadedInstance.getRegion().getTempFile());
  3. List<Chunk> chunkList = new ArrayList<>(), finalList = new ArrayList<>();
  4. int x = 0, z = 0;
  5. while (x < 32) {
  6. while (z < 32) {
  7. DataInputStream chunkIs = regionFile.getChunkDataInputStream(x, z);
  8. if (chunkIs != null) {
  9. Chunk chunk = new Chunk(x, z, TagIO.readInputStream(chunkIs));
  10. chunkList.add(chunk);
  11. }
  12. z++;
  13. }
  14. z=0;
  15. x++;
  16. }
  17.  
  18. for (Chunk chunks : chunkList) {
  19. CompoundTag data = chunks.getData();
  20. CompoundTag level = data.getCompound("Level");
  21. if (level != null) {
  22. level.remove("xPos");
  23. level.remove("zPos");
  24. level.put("xPos", new IntTag((loadedInstance.getRegion().getX()*32)+chunks.getX()));
  25. level.put("zPos", new IntTag((loadedInstance.getRegion().getZ()*32)+chunks.getZ()));
  26. data.remove("Level");
  27. data.put("Level", level);
  28. Chunk chunk = new Chunk(chunks.getX(), chunks.getZ(), data);
  29. finalList.add(chunk);
  30. } else {
  31. finalList.add(chunks);
  32. }
  33. }
  34.  
  35. for (Chunk chunks : finalList) {
  36. TagIO.writeOutputStream(chunks.getData(), regionFile.getChunkDataOutputStream(chunks.getX(), chunks.getZ()));
  37. }
  38.  
  39. Files.copy(new FileInputStream(loadedInstance.getRegion().getTempFile().getPath()), Paths.get(loadedInstance.getRegion().getFile().getPath()));
  40. pistonSponge.getPistonLogger().debug("Relocated Chunks");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement