Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-6553

New alt worlds after save/load get corrupted.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • None
    • None
    • Linux

    • 3137-Spigot-66f9d3c-85b8c1f (MC: 1.17)
    • custom
    • Yes

      When creating a new world. It creates fine, you can go there and see the blocks placed by the generator. But after you save, unload then reload the world, either manually by API or server reboot, the world always gets corrupted.

      Things noticed:

      If you do not populate any blocks in the generator and return an empty createChunkData() in the generateChunkData() method, and place blocks manually in game, there is no issue.

      If you load an old map created in 1.16 there is no issue.

      If you create a new map in 1.17, and you set blocks in the generateChunkData() method such as chunk.setBlock(x, y, z, Material.Dirt) then you will have an issue. You can visit the world after its been created, you can see the blocks placed by the generator, but after you unload and reload the world all of the blocks placed by the generator or by player in game will be gone. The chunks will be recreated using the current generator when the world is reloaded.

      // Class for Generator
      
      import java.util.Random;
      import org.bukkit.Material;
      import org.bukkit.World;
      import org.bukkit.block.Biome;
      import org.bukkit.generator.ChunkGenerator;
      
      public class WorldGen_Flat extends ChunkGenerator {
      	
      	public ChunkData generateChunkData(World world, Random rand, int ChunkX, int ChunkZ, BiomeGrid biome) {
      		ChunkData chunk =  createChunkData(world);
      		int chunkSize = 16;
      		int seaLevel = 62;
      		for (int x = 0; x < chunkSize; x++) {
      			for (int z = 0; z < chunkSize; z++) {
      				for (int y = 0; y < world.getMaxHeight(); y++) {
      					Material blockType = null;
      					if (y == seaLevel) blockType = Material.GRASS_BLOCK;
      					if (y < seaLevel) blockType = Material.DIRT;
      					if (y <= 1) blockType = Material.BEDROCK;
      					if (blockType != null) chunk.setBlock(x, y, z, blockType);
      					biome.setBiome(x, y, z, Biome.PLAINS);
      				}
      			}
      		}
      		return chunk;
      	}
      
      }
      

      // Creating the World
      
      WorldCreator wc = new WorldCreator("test_map");
      wc.hardcore(false);
      wc.environment(Environment.NORMAL);
      wc.type(WorldType.FLAT);
      wc.generateStructures(false);
      wc.generator(new WorldGen_Flat());
      World newWorld = wc.createWorld();
      newWorld.setGameRule(GameRule.DO_MOB_SPAWNING, false);
      newWorld.getBlockAt(0, 62, 0).setType(Material.SEA_LANTERN);
      newWorld.setSpawnLocation(0, 63, 0);
      

      // Loading the World called from onEnable()
      
      this.getServer().createWorld(new WorldCreator("test_map"));
      

      And when loading the world, this is the error in the console:

      // In this case i placed a chest in the world by hand in game before saving, unloading and reloading.
      
      [21:13:18] [Server thread/INFO]: Attempted to place a tile entity (net.minecraft.world.level.block.entity.TileEntityChest@58adad7a) at 0,63,0 (Block{minecraft:air}) where there was no entity tile!
      [21:13:18] [Server thread/INFO]: Chunk coordinates: 0,0
      [21:13:18] [Server thread/WARN]: java.lang.Exception
      [21:13:18] [Server thread/WARN]:        at net.minecraft.world.level.chunk.Chunk.setTileEntity(Chunk.java:496)
      [21:13:18] [Server thread/WARN]:        at net.minecraft.world.level.chunk.storage.ChunkRegionLoader.loadEntities(ChunkRegionLoader.java:459)
      [21:13:18] [Server thread/WARN]:        at net.minecraft.world.level.chunk.storage.ChunkRegionLoader.lambda$6(ChunkRegionLoader.java:165)
      [21:13:18] [Server thread/WARN]:        at net.minecraft.world.level.chunk.Chunk.addEntities(Chunk.java:573)
      [21:13:18] [Server thread/WARN]:        at net.minecraft.server.level.PlayerChunkMap.lambda$33(PlayerChunkMap.java:698)
      [21:13:18] [Server thread/WARN]:        at com.mojang.datafixers.util.Either.lambda$mapLeft$0(Either.java:162)
      [21:13:18] [Server thread/WARN]:        at com.mojang.datafixers.util.Either$Left.map(Either.java:38)
      [21:13:18] [Server thread/WARN]:        at com.mojang.datafixers.util.Either.mapLeft(Either.java:162)
      [21:13:18] [Server thread/WARN]:        at net.minecraft.server.level.PlayerChunkMap.lambda$31(PlayerChunkMap.java:681)
      [21:13:19] [Server thread/WARN]:        at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)
      [21:13:19] [Server thread/WARN]:        at java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:478)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.server.level.ChunkTaskQueueSorter.b(SourceFile:58)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.util.thread.IAsyncTaskHandler.executeTask(SourceFile:151)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.server.level.ChunkProviderServer$a.executeTask(ChunkProviderServer.java:603)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.util.thread.IAsyncTaskHandler.executeNext(SourceFile:125)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.server.level.ChunkProviderServer$a.executeNext(ChunkProviderServer.java:614)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.server.level.ChunkProviderServer.runTasks(ChunkProviderServer.java:322)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.server.MinecraftServer.bg(MinecraftServer.java:1134)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.server.MinecraftServer.executeNext(MinecraftServer.java:1118)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.util.thread.IAsyncTaskHandler.executeAll(SourceFile:110)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.server.MinecraftServer.executeModerately(MinecraftServer.java:1095)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.server.MinecraftServer.loadSpawn(MinecraftServer.java:774)
      [21:13:19] [Server thread/WARN]:        at org.bukkit.craftbukkit.v1_17_R1.CraftServer.createWorld(CraftServer.java:1082)
      [21:13:19] [Server thread/WARN]:        at something.myplugin.g.loadAllWorlds(g.java:778)
      [21:13:19] [Server thread/WARN]:        at something.myplugin.Command_Listener.CommandHook(Command_Listener.java:122)
      [21:13:19] [Server thread/WARN]:        at something.myplugin.VillageMod.onCommand(VillageMod.java:74)
      [21:13:19] [Server thread/WARN]:        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45)
      [21:13:19] [Server thread/WARN]:        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149)
      [21:13:19] [Server thread/WARN]:        at org.bukkit.craftbukkit.v1_17_R1.CraftServer.dispatchCommand(CraftServer.java:764)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.server.network.PlayerConnection.handleCommand(PlayerConnection.java:1944)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1783)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1764)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.network.protocol.game.PacketPlayInChat.a(PacketPlayInChat.java:46)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.network.protocol.game.PacketPlayInChat.a(PacketPlayInChat.java:1)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.network.protocol.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:30)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.server.TickTask.run(SourceFile:18)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.util.thread.IAsyncTaskHandler.executeTask(SourceFile:151)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.util.thread.IAsyncTaskHandler.executeNext(SourceFile:125)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.server.MinecraftServer.bg(MinecraftServer.java:1125)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.server.MinecraftServer.executeNext(MinecraftServer.java:1118)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.util.thread.IAsyncTaskHandler.awaitTasks(SourceFile:134)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.server.MinecraftServer.sleepForTick(MinecraftServer.java:1102)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1031)
      [21:13:19] [Server thread/WARN]:        at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:307)
      [21:13:19] [Server thread/WARN]:        at java.base/java.lang.Thread.run(Thread.java:831)

       

            Unassigned Unassigned
            MCV Village_Admin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: