1.13 ChunkManager

Discussion in 'Spigot Plugin Development' started by Alex0589, Jul 30, 2018.

  1. I'm trying to update a plugin called IslandCraft to 1.13, but after some changes, I get this error:
    Code (Text):
    org.bukkit.event.EventException: null
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:308) ~[spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:500) ~[spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:485) ~[spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at net.minecraft.server.v1_13_R1.ChunkMap.a(ChunkMap.java:41) ~[spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at net.minecraft.server.v1_13_R1.ChunkMap.put(ChunkMap.java:134) ~[spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at net.minecraft.server.v1_13_R1.ChunkMap.put(ChunkMap.java:1) ~[spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.longs.Long2ObjectMaps$SynchronizedMap.put(Long2ObjectMaps.java:371) ~[spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at net.minecraft.server.v1_13_R1.ChunkProviderServer.a(ChunkProviderServer.java:207) ~[spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at java.util.concurrent.CompletableFuture.uniApply(Unknown Source) [?:1.8.0_171]
        at java.util.concurrent.CompletableFuture.uniApplyStage(Unknown Source) [?:1.8.0_171]
        at java.util.concurrent.CompletableFuture.thenApply(Unknown Source) [?:1.8.0_171]
        at net.minecraft.server.v1_13_R1.ChunkProviderServer.generateChunk(ChunkProviderServer.java:169) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at net.minecraft.server.v1_13_R1.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:127) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at net.minecraft.server.v1_13_R1.World.getChunkAt(World.java:268) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at net.minecraft.server.v1_13_R1.WorldProviderNormal.a(SourceFile:209) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at net.minecraft.server.v1_13_R1.WorldProviderNormal.a(SourceFile:186) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at net.minecraft.server.v1_13_R1.WorldServer.b(WorldServer.java:821) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at net.minecraft.server.v1_13_R1.WorldServer.a(WorldServer.java:731) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at org.bukkit.craftbukkit.v1_13_R1.CraftServer.createWorld(CraftServer.java:942) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at org.bukkit.Bukkit.createWorld(Bukkit.java:456) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at org.bukkit.WorldCreator.createWorld(WorldCreator.java:261) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at com.onarandombox.MultiverseCore.utils.WorldManager.doLoad(WorldManager.java:466) [Multiverse-Core-2.5%20(1).jar:?]
        at com.onarandombox.MultiverseCore.utils.WorldManager.doLoad(WorldManager.java:447) [Multiverse-Core-2.5%20(1).jar:?]
        at com.onarandombox.MultiverseCore.utils.WorldManager.doLoad(WorldManager.java:422) [Multiverse-Core-2.5%20(1).jar:?]
        at com.onarandombox.MultiverseCore.utils.WorldManager.loadWorlds(WorldManager.java:725) [Multiverse-Core-2.5%20(1).jar:?]
        at com.onarandombox.MultiverseCore.MultiverseCore.onEnable(MultiverseCore.java:309) [Multiverse-Core-2.5%20(1).jar:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:339) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:403) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at org.bukkit.craftbukkit.v1_13_R1.CraftServer.enablePlugin(CraftServer.java:424) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at org.bukkit.craftbukkit.v1_13_R1.CraftServer.enablePlugins(CraftServer.java:338) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at net.minecraft.server.v1_13_R1.MinecraftServer.m(MinecraftServer.java:562) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at net.minecraft.server.v1_13_R1.MinecraftServer.g_(MinecraftServer.java:524) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at net.minecraft.server.v1_13_R1.MinecraftServer.a(MinecraftServer.java:423) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at net.minecraft.server.v1_13_R1.DedicatedServer.init(DedicatedServer.java:288) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at net.minecraft.server.v1_13_R1.MinecraftServer.run(MinecraftServer.java:686) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_171]
    Caused by: java.lang.ClassCastException: current.NmsHandler$1 cannot be cast to net.minecraft.server.v1_13_R1.ChunkProviderServer
        at net.minecraft.server.v1_13_R1.WorldServer.getChunkProviderServer(WorldServer.java:1049) ~[spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at org.bukkit.craftbukkit.v1_13_R1.CraftWorld.unloadChunk0(CraftWorld.java:204) ~[spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at org.bukkit.craftbukkit.v1_13_R1.CraftWorld.regenerateChunk(CraftWorld.java:214) ~[spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        at bukkit.plugin.BiomeGeneratorListener.onChunkLoad(BiomeGeneratorListener.java:96) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_171]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_171]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:304) ~[spigot.jar:git-Spigot-ed1cec9-1c7adf7]
        ... 37 more
    [22:00:05] [Server thread/WARN]: net.minecraft.server.v1_13_R1.ReportedException: Exception initializing level
    [22:00:05] [Server thread/WARN]:     at net.minecraft.server.v1_13_R1.WorldServer.a(WorldServer.java:746)
    [22:00:05] [Server thread/WARN]:     at org.bukkit.craftbukkit.v1_13_R1.CraftServer.createWorld(CraftServer.java:942)
    [22:00:05] [Server thread/WARN]:     at org.bukkit.Bukkit.createWorld(Bukkit.java:456)
    [22:00:05] [Server thread/WARN]:     at org.bukkit.WorldCreator.createWorld(WorldCreator.java:261)
    [22:00:05] [Server thread/WARN]:     at com.onarandombox.MultiverseCore.utils.WorldManager.doLoad(WorldManager.java:466)
    [22:00:05] [Server thread/WARN]:     at com.onarandombox.MultiverseCore.utils.WorldManager.doLoad(WorldManager.java:447)
    [22:00:05] [Server thread/WARN]:     at com.onarandombox.MultiverseCore.utils.WorldManager.doLoad(WorldManager.java:422)
    [22:00:05] [Server thread/WARN]:     at com.onarandombox.MultiverseCore.utils.WorldManager.loadWorlds(WorldManager.java:725)
    [22:00:05] [Server thread/WARN]:     at com.onarandombox.MultiverseCore.MultiverseCore.onEnable(MultiverseCore.java:309)
    [22:00:05] [Server thread/WARN]:     at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264)
    [22:00:05] [Server thread/WARN]:     at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:339)
    [22:00:05] [Server thread/WARN]:     at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:403)
    [22:00:05] [Server thread/WARN]:     at org.bukkit.craftbukkit.v1_13_R1.CraftServer.enablePlugin(CraftServer.java:424)
    [22:00:05] [Server thread/WARN]:     at org.bukkit.craftbukkit.v1_13_R1.CraftServer.enablePlugins(CraftServer.java:338)
    [22:00:05] [Server thread/WARN]:     at net.minecraft.server.v1_13_R1.MinecraftServer.m(MinecraftServer.java:562)
    [22:00:05] [Server thread/WARN]:     at net.minecraft.server.v1_13_R1.MinecraftServer.g_(MinecraftServer.java:524)
    [22:00:05] [Server thread/WARN]:     at net.minecraft.server.v1_13_R1.MinecraftServer.a(MinecraftServer.java:423)
    [22:00:05] [Server thread/WARN]:     at net.minecraft.server.v1_13_R1.DedicatedServer.init(DedicatedServer.java:288)
    [22:00:05] [Server thread/WARN]:     at net.minecraft.server.v1_13_R1.MinecraftServer.run(MinecraftServer.java:686)
    [22:00:05] [Server thread/WARN]:     at java.lang.Thread.run(Unknown Source)
    [22:00:05] [Server thread/WARN]: Caused by: java.lang.ClassCastException: current.NmsHandler$1 cannot be cast to net.minecraft.server.v1_13_R1.ChunkProviderServer
    [22:00:05] [Server thread/WARN]:     at net.minecraft.server.v1_13_R1.WorldServer.getChunkProviderServer(WorldServer.java:1049)
    [22:00:05] [Server thread/WARN]:     at net.minecraft.server.v1_13_R1.WorldServer.getChunkProvider(WorldServer.java:1260)
    [22:00:05] [Server thread/WARN]:     at current.NmsHandler$1.getChunkAt(NmsHandler.java:60)
    [22:00:05] [Server thread/WARN]:     at net.minecraft.server.v1_13_R1.World.getChunkAt(World.java:268)
    [22:00:05] [Server thread/WARN]:     at net.minecraft.server.v1_13_R1.World.getChunkAtWorldCoords(World.java:264)
    [22:00:05] [Server thread/WARN]:     at net.minecraft.server.v1_13_R1.World.getType(World.java:636)
    [22:00:05] [Server thread/WARN]:     at net.minecraft.server.v1_13_R1.WorldProviderNormal.a(SourceFile:224)
    [22:00:05] [Server thread/WARN]:     at net.minecraft.server.v1_13_R1.WorldProviderNormal.a(SourceFile:186)
    [22:00:05] [Server thread/WARN]:     at net.minecraft.server.v1_13_R1.WorldServer.b(WorldServer.java:821)
    [22:00:05] [Server thread/WARN]:     at net.minecraft.server.v1_13_R1.WorldServer.a(WorldServer.java:731)
    [22:00:05] [Server thread/WARN]:     ... 19 more

    And here's the class where I do my reflection stuff( I'm almost sure that it works):
    Code (Text):
    package current;

    import java.lang.reflect.Field;
    import java.util.List;

    import net.minecraft.server.v1_13_R1.*;
    import nms.BiomeGenerator;
    import nms.NmsWrapper;
    import org.apache.commons.lang.reflect.FieldUtils;
    import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.longs.Long2ObjectMap;
    import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.longs.LongSet;
    import org.bukkit.craftbukkit.v1_13_R1.CraftWorld;

    import javax.annotation.Nullable;


    public class NmsHandler extends NmsWrapper {

        @Override
        public boolean installBiomeGenerator(final org.bukkit.World world, final BiomeGenerator biomeGenerator) {
            final World nmsWorld;

            try {
                nmsWorld = ((CraftWorld) world).getHandle();
                register(nmsWorld, biomeGenerator);
            } catch (IllegalArgumentException e) {
                for(int x = 0; x < 1000; x++)System.out.println("4");
                e.printStackTrace();
                return false;
            }
            return true;
        }

        private static void register(World world, final BiomeGenerator generator)  {
            Class<?> clazz = world.getClass();

            WorldDataSaver data = new WorldDataSaver(world);

            IChunkProvider provider = new IChunkProvider() {
                @Nullable
                @Override
                public Chunk getLoadedChunkAt(int i, int i1) {
                    return data.getWorld().getChunkProvider().getLoadedChunkAt(i, i1);
                }

                @Override
                public Chunk getChunkAt(int i, int i1) {
                    return data.getWorld().getChunkProvider().getChunkAt(i, i1);
                }

                @Override
                public IChunkAccess d(int i, int i1) {
                    return data.getWorld().getChunkProvider().d(i, i1);
                }

                @Override
                public boolean unloadChunks() {
                    return data.getWorld().getChunkProvider().unloadChunks();
                }

                @Override
                public String getName() {
                    return data.getWorld().getChunkProvider().getName();
                }

                @Override
                public ChunkGenerator<?> getChunkGenerator() {
                    return new ChunkGenerator<GeneratorSettings>() {
                        @Override
                        public void createChunk(IChunkAccess iChunkAccess) {
                            for(int x = 0; x < 1000; x++)System.out.println("Chunk");
                            data.getWorld().getChunkProvider().getChunkGenerator().createChunk(iChunkAccess);
                        }

                        @Override
                        public void addFeatures(RegionLimitedWorldAccess regionLimitedWorldAccess, WorldGenStage.Features features) {
                            data.getWorld().getChunkProvider().getChunkGenerator().addFeatures(regionLimitedWorldAccess, features);
                        }

                        @Override
                        public void addDecorations(RegionLimitedWorldAccess regionLimitedWorldAccess) {
                            data.getWorld().getChunkProvider().getChunkGenerator().addDecorations(regionLimitedWorldAccess);
                        }

                        @Override
                        public void addMobs(RegionLimitedWorldAccess regionLimitedWorldAccess) {
                            data.getWorld().getChunkProvider().getChunkGenerator().addMobs(regionLimitedWorldAccess);
                        }

                        @Override
                        public List<BiomeBase.BiomeMeta> getMobsFor(EnumCreatureType enumCreatureType, BlockPosition blockPosition) {
                            return  data.getWorld().getChunkProvider().getChunkGenerator().getMobsFor(enumCreatureType, blockPosition);
                        }

                        @Nullable
                        @Override
                        public BlockPosition findNearestMapFeature(net.minecraft.server.v1_13_R1.World world, String s, BlockPosition blockPosition, int i) {
                            return  data.getWorld().getChunkProvider().getChunkGenerator().findNearestMapFeature(world, s, blockPosition, i);
                        }

                        @Override
                        public GeneratorSettings getSettings() {
                            return data.getWorld().getChunkProvider().getChunkGenerator().getSettings();
                        }

                        @Override
                        public int a(net.minecraft.server.v1_13_R1.World world, boolean b, boolean b1) {
                            return  data.getWorld().getChunkProvider().getChunkGenerator().a(world,b,b1);
                        }

                        @Override
                        public boolean canSpawnStructure(BiomeBase biomeBase, StructureGenerator<? extends WorldGenFeatureConfiguration> structureGenerator) {
                            return  data.getWorld().getChunkProvider().getChunkGenerator().canSpawnStructure(biomeBase, structureGenerator);
                        }

                        @Nullable
                        @Override
                        public WorldGenFeatureConfiguration getFeatureConfiguration(BiomeBase biomeBase, StructureGenerator<? extends WorldGenFeatureConfiguration> structureGenerator) {
                            return  data.getWorld().getChunkProvider().getChunkGenerator().getFeatureConfiguration(biomeBase, structureGenerator);
                        }

                        @Override
                        public Long2ObjectMap<StructureStart> getStructureStartCache(StructureGenerator<? extends WorldGenFeatureConfiguration> structureGenerator) {
                            return  data.getWorld().getChunkProvider().getChunkGenerator().getStructureStartCache(structureGenerator);
                        }

                        @Override
                        public Long2ObjectMap<LongSet> getStructureCache(StructureGenerator<? extends WorldGenFeatureConfiguration> structureGenerator) {
                            return  data.getWorld().getChunkProvider().getChunkGenerator().getStructureCache(structureGenerator);
                        }

                        @Override
                        public WorldChunkManager getWorldChunkManager() {
                            return new CustomWorldChunkManager(generator);
                        }

                        @Override
                        public long getSeed() {
                            return  data.getWorld().getChunkProvider().getChunkGenerator().getSeed();
                        }

                        @Override
                        public int getSpawnHeight() {
                            return  data.getWorld().getChunkProvider().getChunkGenerator().getSpawnHeight();
                        }

                        @Override
                        public int e() {
                            return  data.getWorld().getChunkProvider().getChunkGenerator().e();
                        }

                        @Override
                        public net.minecraft.server.v1_13_R1.World getWorld() {
                            return data.getWorld();
                        }
                    };
                }

                @Override
                public boolean f(int i, int i1) {
                    return data.getWorld().getChunkProvider().f(i, i1);
                }
            };

            try {
                FieldUtils.writeField(world, "chunkProvider", provider, true);
            } catch (IllegalAccessException e) {
                for(int x = 0; x < 1000; x++)System.out.println("5");
                e.printStackTrace();
            }

        }
    }
    In few words in that class I get a field called "chunkProvider" that you can find in the nms world class. The reflection works and the new IChunkProvider is setted, but for some reason I get a ClassCastException which is strange as I don't cast anything. Can someone help me?
     
  2. What is line 60 on NmsHandler class?
     
  3. A blank line lol
     
  4. Anyways I found out that in my listener class I'm using this method:
    Code (Text):

      public boolean regenerateChunk(int x, int z)
      {
        if (!unloadChunk0(x, z, false)) {
          return false;
        }
        long chunkKey = ChunkCoordIntPair.a(x, z);
        this.world.getChunkProviderServer().unloadQueue.remove(chunkKey);
       
        net.minecraft.server.v1_13_R1.Chunk chunk = null;
       
        chunk = (net.minecraft.server.v1_13_R1.Chunk)Futures.getUnchecked(this.world.getChunkProviderServer().generateChunk(x, z));
        PlayerChunk playerChunk = this.world.getPlayerChunkMap().getChunk(x, z);
        if (playerChunk != null) {
          playerChunk.chunk = chunk;
        }
        if (chunk != null)
        {
          this.world.getChunkProviderServer().chunks.put(chunkKey, chunk);
         
          chunk.addEntities();
         
          refreshChunk(x, z);
        }
        return chunk != null;
      }
    (nms world class) which then calls this one:
    Code (Text):
    private boolean unloadChunk0(int x, int z, boolean save)
      {
        net.minecraft.server.v1_13_R1.Chunk chunk = this.world.getChunkProviderServer().getChunkIfLoaded(x, z);
        if (chunk == null) {
          return true;
        }
        return this.world.getChunkProviderServer().unloadChunk(chunk, (chunk.mustSave) || (save));
      }
    which then class a method in the WorldServer class (nms):
    Code (Text):
    public ChunkProviderServer getChunkProviderServer() {
        return (ChunkProviderServer)super.getChunkProvider();
    }
    and boom I found the cast exception
     
  5. You need to create a CPS not an IChunkProvider
     
  6. I'll try maybe it works
     
  7. Sorry for the question but where do I find the args that a ChunkProviderServer asks?
     
  8. I just discovered that I can get it from the world now I just need to edit it in some way
     
  9. @xTrollxDudex I now have the ChunkProviderServer and I'm also able to change it's chunk generator, but now I have no idea on how to replace the WorldServer ChunkProviderServer with mine. Can you help me?
     
  10.  
  11. I can't as in the WorldSever or World Class there's no variable for the CPS, but only a method that returns the CPS casting to IChunkProvider. What Should I do?
     
    #11 Alex0589, Jul 31, 2018
    Last edited: Jul 31, 2018
  12. Code that I'm using:
    Code (Text):
    package current;

    import com.google.common.util.concurrent.ListenableFuture;
    import net.minecraft.server.v1_13_R1.*;
    import nms.BiomeGenerator;
    import org.apache.commons.lang.reflect.FieldUtils;
    import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.longs.Long2ObjectMap;
    import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.longs.LongSet;

    import javax.annotation.Nullable;
    import java.util.List;

    public class Utils {
        public void register(World world, final BiomeGenerator biome)  {
            WorldDataSaver data = new WorldDataSaver(world);
            IChunkProvider provider = getProvider(data, biome);

            try {
                FieldUtils.writeField(world, "chunkProvider",provider,true);
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }

        private IChunkProvider getProvider(WorldDataSaver data, BiomeGenerator biomeGenerator) {
            return new IChunkProvider() {
                @Nullable
                @Override
                public Chunk getLoadedChunkAt(int i, int i1) {
                    return data.getWorld().getChunkProvider().getLoadedChunkAt(i, i1);
                }

                @Override
                public Chunk getChunkAt(int i, int i1) {
                    return data.getWorld().getChunkProvider().getChunkAt(i, i1);
                }

                @Override
                public IChunkAccess d(int i, int i1) {
                    return data.getWorld().getChunkProvider().d(i, i1);
                }

                @Override
                public boolean unloadChunks() {
                    return data.getWorld().getChunkProvider().unloadChunks();
                }

                @Override
                public String getName() {
                    return data.getWorld().getChunkProvider().getName();
                }

                @Override
                public ChunkGenerator<?> getChunkGenerator() {
                    return getChunkGeneratorCustom(data,biomeGenerator);
                }

                @Override
                public boolean f(int i, int i1) {
                    return data.getWorld().getChunkProvider().f(i, i1);
                }
            };
        }
        private ChunkGenerator<?> getChunkGeneratorCustom(WorldDataSaver data,  BiomeGenerator biomeGenerator) {
            return new ChunkGenerator<GeneratorSettings>() {
                @Override
                public void createChunk(IChunkAccess iChunkAccess) {
                    data.getWorld().getChunkProvider().getChunkGenerator().createChunk(iChunkAccess);
                }

                @Override
                public void addFeatures(RegionLimitedWorldAccess regionLimitedWorldAccess, WorldGenStage.Features features) {
                    data.getWorld().getChunkProvider().getChunkGenerator().addFeatures(regionLimitedWorldAccess, features);
                }

                @Override
                public void addDecorations(RegionLimitedWorldAccess regionLimitedWorldAccess) {
                    data.getWorld().getChunkProvider().getChunkGenerator().addDecorations(regionLimitedWorldAccess);
                }

                @Override
                public void addMobs(RegionLimitedWorldAccess regionLimitedWorldAccess) {
                    data.getWorld().getChunkProvider().getChunkGenerator().addMobs(regionLimitedWorldAccess);
                }

                @Override
                public List<BiomeBase.BiomeMeta> getMobsFor(EnumCreatureType enumCreatureType, BlockPosition blockPosition) {
                    return data.getWorld().getChunkProvider().getChunkGenerator().getMobsFor(enumCreatureType, blockPosition);
                }

                @Nullable
                @Override
                public BlockPosition findNearestMapFeature(net.minecraft.server.v1_13_R1.World world, String s, BlockPosition blockPosition, int i) {
                    return data.getWorld().getChunkProvider().getChunkGenerator().findNearestMapFeature(world, s, blockPosition, i);
                }

                @Override
                public GeneratorSettings getSettings() {
                    return data.getWorld().getChunkProvider().getChunkGenerator().getSettings();
                }

                @Override
                public int a(net.minecraft.server.v1_13_R1.World world, boolean b, boolean b1) {
                    return data.getWorld().getChunkProvider().getChunkGenerator().a(world, b, b1);
                }

                @Override
                public boolean canSpawnStructure(BiomeBase biomeBase, StructureGenerator<? extends WorldGenFeatureConfiguration> structureGenerator) {
                    return data.getWorld().getChunkProvider().getChunkGenerator().canSpawnStructure(biomeBase, structureGenerator);
                }

                @Nullable
                @Override
                public WorldGenFeatureConfiguration getFeatureConfiguration(BiomeBase biomeBase, StructureGenerator<? extends WorldGenFeatureConfiguration> structureGenerator) {
                    return data.getWorld().getChunkProvider().getChunkGenerator().getFeatureConfiguration(biomeBase, structureGenerator);
                }

                @Override
                public Long2ObjectMap<StructureStart> getStructureStartCache(StructureGenerator<? extends WorldGenFeatureConfiguration> structureGenerator) {
                    return data.getWorld().getChunkProvider().getChunkGenerator().getStructureStartCache(structureGenerator);
                }

                @Override
                public Long2ObjectMap<LongSet> getStructureCache(StructureGenerator<? extends WorldGenFeatureConfiguration> structureGenerator) {
                    return data.getWorld().getChunkProvider().getChunkGenerator().getStructureCache(structureGenerator);
                }

                @Override
                public WorldChunkManager getWorldChunkManager() {
                    return new CustomWorldChunkManager(biomeGenerator);
                }

                @Override
                public long getSeed() {
                    return data.getWorld().getChunkProvider().getChunkGenerator().getSeed();
                }

                @Override
                public int getSpawnHeight() {
                    return data.getWorld().getChunkProvider().getChunkGenerator().getSpawnHeight();
                }

                @Override
                public int e() {
                    return data.getWorld().getChunkProvider().getChunkGenerator().e();
                }

                @Override
                public net.minecraft.server.v1_13_R1.World getWorld() {
                    return data.getWorld();
                }
            };
        }
    }
     
    Code (Text):
    package current;

    import net.minecraft.server.v1_13_R1.*;
    import nms.BiomeGenerator;
    import nms.NmsWrapper;
    import org.bukkit.craftbukkit.v1_13_R1.CraftWorld;

    public class NmsHandler extends NmsWrapper {

        @Override
        public boolean installBiomeGenerator(final org.bukkit.World world, final BiomeGenerator biomeGenerator) {
            final World nmsWorld;
            try {
                nmsWorld = ((CraftWorld) world).getHandle();
                new Utils().register(nmsWorld, biomeGenerator);
            } catch (IllegalArgumentException e) {
                for(int x = 0; x < 1000; x++)System.out.println("4");
                e.printStackTrace();
                return false;
            }
            return true;
        }
    }

    Error:
    Code (Text):
    org.bukkit.event.EventException: null
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:308) ~[spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:500) ~[spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:485) ~[spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at net.minecraft.server.v1_13_R1.ChunkMap.a(ChunkMap.java:41) ~[spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at net.minecraft.server.v1_13_R1.ChunkMap.put(ChunkMap.java:134) ~[spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at net.minecraft.server.v1_13_R1.ChunkMap.put(ChunkMap.java:1) ~[spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.longs.Long2ObjectMaps$SynchronizedMap.put(Long2ObjectMaps.java:371) ~[spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at net.minecraft.server.v1_13_R1.ChunkProviderServer.a(ChunkProviderServer.java:207) ~[spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at java.util.concurrent.CompletableFuture.uniApply(Unknown Source) [?:1.8.0_171]
            at java.util.concurrent.CompletableFuture.uniApplyStage(Unknown Source) [?:1.8.0_171]
            at java.util.concurrent.CompletableFuture.thenApply(Unknown Source) [?:1.8.0_171]
            at net.minecraft.server.v1_13_R1.ChunkProviderServer.generateChunk(ChunkProviderServer.java:169) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at net.minecraft.server.v1_13_R1.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:127) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at net.minecraft.server.v1_13_R1.World.getChunkAt(World.java:268) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at net.minecraft.server.v1_13_R1.WorldProviderNormal.a(SourceFile:209) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at net.minecraft.server.v1_13_R1.WorldProviderNormal.a(SourceFile:186) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at net.minecraft.server.v1_13_R1.WorldServer.b(WorldServer.java:821) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at net.minecraft.server.v1_13_R1.WorldServer.a(WorldServer.java:731) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at org.bukkit.craftbukkit.v1_13_R1.CraftServer.createWorld(CraftServer.java:942) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at org.bukkit.Bukkit.createWorld(Bukkit.java:456) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at org.bukkit.WorldCreator.createWorld(WorldCreator.java:261) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at com.onarandombox.MultiverseCore.utils.WorldManager.doLoad(WorldManager.java:466) [Multiverse-Core-2.5%20(1).jar:?]
            at com.onarandombox.MultiverseCore.utils.WorldManager.addWorld(WorldManager.java:268) [Multiverse-Core-2.5%20(1).jar:?]
            at com.onarandombox.MultiverseCore.commands.CreateCommand.runCommand(CreateCommand.java:114) [Multiverse-Core-2.5%20(1).jar:?]
            at com.pneumaticraft.commandhandler.multiverse.CommandHandler.checkAndRunCommand(CommandHandler.java:279) [Multiverse-Core-2.5%20(1).jar:?]
            at com.pneumaticraft.commandhandler.multiverse.CommandHandler.processFoundCommands(CommandHandler.java:143) [Multiverse-Core-2.5%20(1).jar:?]
            at com.pneumaticraft.commandhandler.multiverse.CommandHandler.locateAndRunCommand(CommandHandler.java:93) [Multiverse-Core-2.5%20(1).jar:?]
            at com.onarandombox.MultiverseCore.MultiverseCore.onCommand(MultiverseCore.java:916) [Multiverse-Core-2.5%20(1).jar:?]
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at org.bukkit.craftbukkit.v1_13_R1.CraftServer.dispatchCommand(CraftServer.java:692) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at org.bukkit.craftbukkit.v1_13_R1.CraftServer.dispatchServerCommand(CraftServer.java:677) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at net.minecraft.server.v1_13_R1.DedicatedServer.aW(DedicatedServer.java:453) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at net.minecraft.server.v1_13_R1.DedicatedServer.w(DedicatedServer.java:412) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at net.minecraft.server.v1_13_R1.MinecraftServer.v(MinecraftServer.java:819) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at net.minecraft.server.v1_13_R1.MinecraftServer.run(MinecraftServer.java:717) [spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_171]
    Caused by: java.lang.ClassCastException: current.Utils$1 cannot be cast to net.minecraft.server.v1_13_R1.ChunkProviderServer
            at net.minecraft.server.v1_13_R1.WorldServer.getChunkProviderServer(WorldServer.java:1049) ~[spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at org.bukkit.craftbukkit.v1_13_R1.CraftWorld.unloadChunk0(CraftWorld.java:204) ~[spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at org.bukkit.craftbukkit.v1_13_R1.CraftWorld.regenerateChunk(CraftWorld.java:214) ~[spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            at bukkit.plugin.BiomeGeneratorListener.onChunkLoad(BiomeGeneratorListener.java:97) ~[?:?]
            at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source) ~[?:?]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_171]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_171]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:304) ~[spigot.jar:git-Spigot-ed1cec9-1c7adf7]
            ... 37 more
    [11:50:44 WARN]: net.minecraft.server.v1_13_R1.ReportedException: Exception initializing level
    [11:50:44 WARN]:        at net.minecraft.server.v1_13_R1.WorldServer.a(WorldServer.java:746)
    [11:50:44 WARN]:        at org.bukkit.craftbukkit.v1_13_R1.CraftServer.createWorld(CraftServer.java:942)
    [11:50:44 WARN]:        at org.bukkit.Bukkit.createWorld(Bukkit.java:456)
    [11:50:44 WARN]:        at org.bukkit.WorldCreator.createWorld(WorldCreator.java:261)
    [11:50:44 WARN]:        at com.onarandombox.MultiverseCore.utils.WorldManager.doLoad(WorldManager.java:466)
    [11:50:44 WARN]:        at com.onarandombox.MultiverseCore.utils.WorldManager.addWorld(WorldManager.java:268)
    [11:50:44 WARN]:        at com.onarandombox.MultiverseCore.commands.CreateCommand.runCommand(CreateCommand.java:114)
    [11:50:44 WARN]:        at com.pneumaticraft.commandhandler.multiverse.CommandHandler.checkAndRunCommand(CommandHandler.java:279)
    [11:50:44 WARN]:        at com.pneumaticraft.commandhandler.multiverse.CommandHandler.processFoundCommands(CommandHandler.java:143)
    [11:50:44 WARN]:        at com.pneumaticraft.commandhandler.multiverse.CommandHandler.locateAndRunCommand(CommandHandler.java:93)
    [11:50:44 WARN]:        at com.onarandombox.MultiverseCore.MultiverseCore.onCommand(MultiverseCore.java:916)
    [11:50:44 WARN]:        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
    [11:50:44 WARN]:        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141)
    [11:50:44 WARN]:        at org.bukkit.craftbukkit.v1_13_R1.CraftServer.dispatchCommand(CraftServer.java:692)
    [11:50:44 WARN]:        at org.bukkit.craftbukkit.v1_13_R1.CraftServer.dispatchServerCommand(CraftServer.java:677)
    [11:50:44 WARN]:        at net.minecraft.server.v1_13_R1.DedicatedServer.aW(DedicatedServer.java:453)
    [11:50:44 WARN]:        at net.minecraft.server.v1_13_R1.DedicatedServer.w(DedicatedServer.java:412)
    [11:50:44 WARN]:        at net.minecraft.server.v1_13_R1.MinecraftServer.v(MinecraftServer.java:819)
    [11:50:44 WARN]:        at net.minecraft.server.v1_13_R1.MinecraftServer.run(MinecraftServer.java:717)
    [11:50:44 WARN]:        at java.lang.Thread.run(Unknown Source)
    [11:50:44 WARN]: Caused by: java.lang.ClassCastException: current.Utils$1 cannot be cast to net.minecraft.server.v1_13_R1.ChunkProviderServer
    [11:50:44 WARN]:        at net.minecraft.server.v1_13_R1.WorldServer.getChunkProviderServer(WorldServer.java:1049)
    [11:50:44 WARN]:        at net.minecraft.server.v1_13_R1.WorldServer.getChunkProvider(WorldServer.java:1260)
    [11:50:44 WARN]:        at current.Utils$1.getChunkAt(Utils.java:35)
    [11:50:44 WARN]:        at net.minecraft.server.v1_13_R1.World.getChunkAt(World.java:268)
    [11:50:44 WARN]:        at net.minecraft.server.v1_13_R1.World.getChunkAtWorldCoords(World.java:264)
    [11:50:44 WARN]:        at net.minecraft.server.v1_13_R1.World.getType(World.java:636)
    [11:50:44 WARN]:        at net.minecraft.server.v1_13_R1.WorldProviderNormal.a(SourceFile:224)
    [11:50:44 WARN]:        at net.minecraft.server.v1_13_R1.WorldProviderNormal.a(SourceFile:186)
    [11:50:44 WARN]:        at net.minecraft.server.v1_13_R1.WorldServer.b(WorldServer.java:821)
    [11:50:44 WARN]:        at net.minecraft.server.v1_13_R1.WorldServer.a(WorldServer.java:731)
     
  13. I Continued to search and I found out that I can just modify the WorldChunkManager now found in the ChunkGenerator class (it's an interface) Than there's another class called ChunkGeneratorAbstact which extends ChunkGenerator and inside of there's a varaible ("c") which is what I was looking for. The only problem is that I have no idea on how to get there
     
  14. can you not spam messages
     
    • Funny Funny x 1
  15. LOl I'm having a problem so I'm trying to find someone able to help me.