[Solved] modifyWorldGenerator not called

I’ve been playing around with modifying world generators and after looking at the Skylands Template in the cookbook, the one thread that somewhat touches upon it in the forums, and of course the Sponge API docs (scroll to the bottom for modifyWorldGenerator), I can’t for the life of me get the modifyWorldGenerator function to be called.

As a first iteration to doing other things, I first want to make a hill defined by Ae^(ax^2 + az^2) centered around spawn. I do this by making a Generator Populator:

public class TestGeneratorPopulator implements GeneratorPopulator
{

	public void populate(World arg0, MutableBlockBuffer blocks, BiomeBuffer arg2) {
		// TODO Auto-generated method stub
		Vector3i vec = blocks.getBlockMin();
		int x = vec.getX();
		int z = vec.getZ();
		//define surface?
		int height = (int) (64.0 + 50.0*Math.exp(-.01*x*x + -.01*z*z));
		blocks.setHorizontalLayer(1,height,BlockTypes.STONE.getDefaultState());
	}

}

This Generator Populator is then added to the worldGenerator by the MainGenParser:

public class MainGenParser implements WorldGeneratorModifier {

	@Inject private Logger logger;
	
	
	public String getName() {
		// TODO Auto-generated method stub
		return "GeoCraftBaseTerrainGen";
	}
	
	
	public String getId() {
		// TODO Auto-generated method stub
		return "GCBaseGen";
	}

	
	public void modifyWorldGenerator(WorldCreationSettings settings,
			DataContainer container, WorldGenerator worldGenerator) {
		logger.info("setting base populator");
		worldGenerator.setBaseGeneratorPopulator(new TestGeneratorPopulator());
		worldGenerator.setBiomeGenerator(new TestBiomeGen());
		List<GeneratorPopulator> pops = worldGenerator.getGeneratorPopulators();
		pops.clear();
		List<Populator> popst = worldGenerator.getPopulators();
		popst.clear();
	}

}

Which is registered and called by a subscribed method in the main class:

@Plugin(id = "GeoCraft", name = "The Minecraft Geology Project", version = "1.0a")
public class GeoCraftMain {
	
	@Inject private Logger logger;
    @Inject private Game game;
    @Inject @DefaultConfig(sharedRoot = false) private File defaultConfig;
    
    
	@Subscribe
    public void onServerAboutToStart(ServerAboutToStartEvent event) 
	{
       final MainGenParser testGen = new MainGenParser();
		this.logger.info("trying to add parser");
		this.game.getRegistry().registerWorldGeneratorModifier(testGen);
		this.logger.info("Parser Added");
		this.game.getRegistry().getWorldBuilder()
				.name("overworld")
                .enabled(true)
                .loadsOnStartup(true)
                .keepsSpawnLoaded(true)
                .dimensionType(DimensionTypes.OVERWORLD)
                .generator(GeneratorTypes.OVERWORLD)
                .generatorModifiers(testGen);
    }
}

Also potentially important are my TestBiomeGen class:

public class TestBiomeGen implements BiomeGenerator {

	public void generateBiomes(MutableBiomeBuffer arg0) {
		// TODO Auto-generated method stub

	}

}

and the server logs:

[08:57:16] [Server thread/INFO] [STDOUT]: [org.spongepowered.common.world.DimensionManager:init:52]: Proxying to Forge DimensionManager Init!
[08:57:16] [Server thread/INFO] [GeoCraft]: trying to add parser
[08:57:16] [Server thread/INFO] [GeoCraft]: Parser Added
[08:57:16] [Server thread/INFO]: Preparing level "world"
[08:57:17] [Server thread/INFO] [FML]: Loading dimension 0 (world) (net.minecraft.server.dedicated.DedicatedServer@4c5f3bf7)
[08:57:18] [Server thread/INFO] [FML]: Loading dimension 1 (DIM1) (net.minecraft.server.dedicated.DedicatedServer@4c5f3bf7)
[08:57:18] [Server thread/INFO] [FML]: Loading dimension -1 (DIM-1) (net.minecraft.server.dedicated.DedicatedServer@4c5f3bf7)
[08:57:18] [Server thread/INFO]: Preparing start region for level -1
[08:57:19] [Server thread/INFO]: Preparing spawn area: 6%
...just gonna fast foreward a bit...
[08:57:49] [Server thread/INFO]: Preparing spawn area: 97%
[08:57:50] [Server thread/INFO]: Done (33.916s)! For help, type "help" or "?"

As you can see, nothing failed and methods in the main class were called, but not the modifyWorldGenerator method in the MainGenParser. There was no “setting base parser” logged o-o.

So tell me spongemen and spongewomen, What the heck am I missing?

Edit: Formatting

You’re not using @Override on the implemented method modifyWorldGenerator.

Or on getName and getId, for that matter.

You’re not calling build() at the end of the WorldBuilder.

Also none of your links work. You might want to check your Markdown syntax.

Sorry bout that. Links should work now.

I tried adding @Override notations on the three methods in the MainGenParser, but Eclipse gets upset and tells me there are multiple markers at each @Override method, that each method must override a superclass method. hm. Here’s a screenshot of the error in case I explained that poorly:

That’s odd, your method signatures look fine, you seem to be implementing them correctly. Anyways, the @Override annotations are optional (but highly recommended). They’re not the source of the problem.

Did adding build() to the end of the builder fix it? It is necessary to create the world.

Yeah. Adding the @Override annotation with the .build() command in the main plugin class caused it to freak out and end the server when it hit the @Override annotation. When I leave out the @Override annotation, but with a .build() command i get:

 onServerAboutToStart]
java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_65]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[?:1.6.0_65]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[?:1.6.0_65]
	at java.lang.reflect.Method.invoke(Method.java:597) ~[?:1.6.0_65]
	at org.spongepowered.mod.plugin.SpongeModPluginContainer.handleModStateEvent(SpongeModPluginContainer.java:126) [SpongeModPluginContainer.class:1.8-1446-2.1DEV-508+unknown-b508.git-unknown]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_65]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[?:1.6.0_65]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[?:1.6.0_65]
	at java.lang.reflect.Method.invoke(Method.java:597) ~[?:1.6.0_65]
	at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) [minecraft_server.1.8.jar:?]
	at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) [minecraft_server.1.8.jar:?]
	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) [minecraft_server.1.8.jar:?]
	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) [minecraft_server.1.8.jar:?]
	at com.google.common.eventbus.EventBus.post(EventBus.java:275) [minecraft_server.1.8.jar:?]
	at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) [LoadController.class:?]
	at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190) [LoadController.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_65]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[?:1.6.0_65]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[?:1.6.0_65]
	at java.lang.reflect.Method.invoke(Method.java:597) ~[?:1.6.0_65]
	at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) [minecraft_server.1.8.jar:?]
	at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) [minecraft_server.1.8.jar:?]
	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) [minecraft_server.1.8.jar:?]
	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) [minecraft_server.1.8.jar:?]
	at com.google.common.eventbus.EventBus.post(EventBus.java:275) [minecraft_server.1.8.jar:?]
	at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119) [LoadController.class:?]
	at net.minecraftforge.fml.common.Loader.serverAboutToStart(Loader.java:851) [Loader.class:?]
	at net.minecraftforge.fml.common.FMLCommonHandler.handleServerAboutToStart(FMLCommonHandler.java:314) [FMLCommonHandler.class:?]
	at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:257) [po.class:?]
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:438) [MinecraftServer.class:?]
	at java.lang.Thread.run(Thread.java:695) [?:1.6.0_65]
Caused by: java.lang.NullPointerException
	at org.spongepowered.common.world.gen.WorldGeneratorRegistry.checkId(WorldGeneratorRegistry.java:75) ~[WorldGeneratorRegistry.class:1.8-1446-2.1DEV-508+unknown-b508.git-unknown]
	at org.spongepowered.common.world.gen.WorldGeneratorRegistry.registerModifier(WorldGeneratorRegistry.java:68) ~[WorldGeneratorRegistry.class:1.8-1446-2.1DEV-508+unknown-b508.git-unknown]
	at org.spongepowered.common.registry.SpongeGameRegistry.registerWorldGeneratorModifier(SpongeGameRegistry.java:817) ~[SpongeGameRegistry.class:1.8-1446-2.1DEV-508+unknown-b508.git-unknown]
	at com.GeoCraft.GeoCraftMain.onServerAboutToStart(GeoCraftMain.java:37) ~[GeoCraftMain.class:?]
	... 31 more

Implement the methods to respect the nullable contracts. getId() should never return null…

Mybad. Don’t know why those are null in the screenshot. After fixing that, still get an error. Heres the error:

    [Plugin Class: com.GeoCraft.GeoCraftMain][Handler: onServerAboutToStart]
java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_65]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[?:1.6.0_65]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[?:1.6.0_65]
	at java.lang.reflect.Method.invoke(Method.java:597) ~[?:1.6.0_65]
	at org.spongepowered.mod.plugin.SpongeModPluginContainer.handleModStateEvent(SpongeModPluginContainer.java:126) [SpongeModPluginContainer.class:1.8-1446-2.1DEV-508+unknown-b508.git-unknown]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_65]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[?:1.6.0_65]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[?:1.6.0_65]
	at java.lang.reflect.Method.invoke(Method.java:597) ~[?:1.6.0_65]
	at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) [minecraft_server.1.8.jar:?]
	at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) [minecraft_server.1.8.jar:?]
	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) [minecraft_server.1.8.jar:?]
	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) [minecraft_server.1.8.jar:?]
	at com.google.common.eventbus.EventBus.post(EventBus.java:275) [minecraft_server.1.8.jar:?]
	at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) [LoadController.class:?]
	at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190) [LoadController.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_65]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[?:1.6.0_65]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[?:1.6.0_65]
	at java.lang.reflect.Method.invoke(Method.java:597) ~[?:1.6.0_65]
	at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) [minecraft_server.1.8.jar:?]
	at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) [minecraft_server.1.8.jar:?]
	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) [minecraft_server.1.8.jar:?]
	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) [minecraft_server.1.8.jar:?]
	at com.google.common.eventbus.EventBus.post(EventBus.java:275) [minecraft_server.1.8.jar:?]
	at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119) [LoadController.class:?]
	at net.minecraftforge.fml.common.Loader.serverAboutToStart(Loader.java:851) [Loader.class:?]
	at net.minecraftforge.fml.common.FMLCommonHandler.handleServerAboutToStart(FMLCommonHandler.java:314) [FMLCommonHandler.class:?]
	at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:257) [po.class:?]
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:438) [MinecraftServer.class:?]
	at java.lang.Thread.run(Thread.java:695) [?:1.6.0_65]
Caused by: java.lang.NullPointerException
	at com.GeoWorldGenerators.MainGenParser.modifyWorldGenerator(MainGenParser.java:35) ~[MainGenParser.class:?]
	at net.minecraft.world.World.updateWorldGenerator(World.java:596) ~[aqu.class:?]
	at net.minecraft.world.WorldServer.onPostInit(WorldServer.java:76) ~[qt.class:?]
	at net.minecraft.world.WorldServer.func_175643_b(WorldServer.java:170) ~[qt.class:?]
	at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:460) ~[MinecraftServer.class:?]
	at org.spongepowered.common.world.SpongeWorldBuilder.build(SpongeWorldBuilder.java:211) ~[SpongeWorldBuilder.class:1.8-1446-2.1DEV-508+unknown-b508.git-unknown]
	at com.GeoCraft.GeoCraftMain.onServerAboutToStart(GeoCraftMain.java:46) ~[GeoCraftMain.class:?]
	... 31 more

and to reiterate, I have the build() command as so:

@Subscribe
    public void onServerAboutToStart(ServerAboutToStartEvent event) 
	{
       final MainGenParser testGen = new MainGenParser();
		this.logger.info("trying to add parser");
		this.game.getRegistry().registerWorldGeneratorModifier(testGen);
		this.logger.info("Parser Added");
		this.game.getRegistry().getWorldBuilder()
				.name("overworld")
                .enabled(true)
                .loadsOnStartup(true)
                .keepsSpawnLoaded(true)
                .dimensionType(DimensionTypes.OVERWORLD)
                .generator(GeneratorTypes.OVERWORLD)
                .generatorModifiers(testGen).build();
    }

and the nulls taken out of the modifyGen Class:

public String getName() {
		// TODO Auto-generated method stub
		return "GeoCraftBaseTerrainGen";
	}
	
	
	public String getId() {
		// TODO Auto-generated method stub
		return "GCBaseGen";
	}

	
	public void modifyWorldGenerator(WorldCreationSettings settings,
			DataContainer container, WorldGenerator worldGenerator) {
		logger.info("setting base populator");
		worldGenerator.setBaseGeneratorPopulator(new TestGeneratorPopulator());
		worldGenerator.setBiomeGenerator(new TestBiomeGen());
		List<GeneratorPopulator> pops = worldGenerator.getGeneratorPopulators();
		pops.clear();
		List<Populator> popst = worldGenerator.getPopulators();
		popst.clear();
	}

The stack trace has all you need to know. Something is null in your world generator modifier at line 35.

Ah yes, singletons I remember you. Well… thats embarrassing.

Well, thats fixed now, no errors as far as I can tell, but it still seems as though any logger statements I add to the modifyWorldGenerator method never get called. I am getting logger messages from other classes however.

Predictably, nothing is changing with the terrain either. Hm.

Did you teleport to the custom world? Can you post all of your code online somewhere?

I did not. I was under the impression that the modifyWorldGen would be applied to the default world? I’ll pastebin the relevant classes as they stand so far:
Main:

@Plugin(id = "GeoCraft", name = "The Minecraft Geology Project", version = "1.0a")
public class GeoCraftMain {
	
    @Inject private Logger logger;
    @Inject private Game game;
    @Inject 
    @DefaultConfig(sharedRoot = false) private File defaultConfig;
    
    
    @Subscribe
    public void onServerAboutToStart(ServerAboutToStartEvent event) 
	{
        MainGenParser testGen = new MainGenParser();
        Debug.set(this);
		this.logger.info("trying to add parser");
		this.game.getRegistry().registerWorldGeneratorModifier(testGen);
		this.logger.info("Parser Added");
		this.game.getRegistry().getWorldBuilder()
		.name("overworld")
                .enabled(true)
                .loadsOnStartup(true)
                .keepsSpawnLoaded(true)
                .dimensionType(DimensionTypes.OVERWORLD)
                .generator(GeneratorTypes.OVERWORLD)
                .generatorModifiers(testGen).build();
    }
	
	@Subscribe
	public void onServerStop(ServerStoppingEvent event)
	{
		//LoadSaveClass.saveRegionMap();
		
	}
	public Logger getLogger() {
		return logger;
	}
	

}

Logger:

public class Debug
{
	private static GeoCraftMain instance;

	public static GeoCraftMain get()
	{
	  return instance;
	}
    static void set(GeoCraftMain inst)
	{
	 instance = inst;
	}
    public static void log(String string)
    {
    	instance.getLogger().debug(string);
    }

}

modifyWorldGen:

public class MainGenParser implements WorldGeneratorModifier {

	
	
	
	public String getName() {
		// TODO Auto-generated method stub
		return "GeoCraftBaseTerrainGen";
	}
	
	
	public String getId() {
		// TODO Auto-generated method stub
		return "GCBaseGen";
	}

	
	public void modifyWorldGenerator(WorldCreationSettings settings,
			DataContainer container, WorldGenerator worldGenerator) {
		Debug.log("in modify");
	    worldGenerator.setBaseGeneratorPopulator(new TestGeneratorPopulator());
		List<GeneratorPopulator> pops = worldGenerator.getGeneratorPopulators();
		pops.clear();
		pops.add(new TestGeneratorPopulator());
		List<Populator> popst = worldGenerator.getPopulators();
		popst.clear();
	}
	
	

}

Test Populator:

public class TestGeneratorPopulator implements GeneratorPopulator
{

	public void populate(World arg0, MutableBlockBuffer blocks, BiomeBuffer arg2) {
		// TODO Auto-generated method stub
		Vector3i vec = blocks.getBlockMin();
		int x = vec.getX();
		int z = vec.getZ();
		//define surface?
		int height = (int) (64.0 + 50.0);//*Math.exp(-.001*x*x-.001*z*z));
		blocks.setHorizontalLayer(1,height,BlockTypes.STONE.getDefaultState());
		Debug.log("populating");
	}

}

This looks fine, it should be working. If you want to get some code for a teleport command, just borrow what’s in WorldsTest. If you want to modify the generator or the main world, apply the generator modifier in WorldLoadEvent. To do that, get the generator from the world, apply the modifier and set it back in the world. Example. The name for the main world should be “world” IIRC.

MK I looked at your example, applied it, changed the modifier applier check to “world” as so:

@Subscribe
    public void onWorldLoadEvent(WorldLoadEvent event)
    {
        final World world = event.getWorld();
        if(world.getName().equals("world"))
        {
        	logger.info("GeoCraft Attempting to Mod WorldGen");
        	final MainGenParser testGen = new MainGenParser();
        	logger.info("GeoCraft WorldGen Modification 1");
        	final WorldGenerator normGen = world.getWorldGenerator();
        	logger.info("GeoCraft WorldGen Modification 2");
        	testGen.modifyWorldGenerator(null,null, normGen);
        	logger.info("GeoCraft WorldGen Modification 3");
        	world.setWorldGenerator(normGen);
        	logger.info("GeoCraft WorldGen Modification Complete");
        }
    }
    
    @Subscribe
    public void onServerAboutToStart(ServerAboutToStartEvent event) 
    {
    	Debug.set(this);
    	game.getRegistry().getWorldBuilder()
        .name("world")
        .enabled(true)
        .loadsOnStartup(true)
        .keepsSpawnLoaded(true)
        .dimensionType(DimensionTypes.OVERWORLD)
        .generator(GeneratorTypes.OVERWORLD)
        .gameMode(GameModes.CREATIVE)
        .build();
    }

In the plugin’s main class. If I’m thinking this right, the onServerAboutToStart() method just tells the server to build the overworld like normal. If it works well, we should see all the loggers from the onWorldLoad() method fire, as well as the “in Modify” logger info. And I do see that:

[12:45:48] [Server thread/INFO] [FML]: Loading dimension 2 (world) (net.minecraft.server.dedicated.DedicatedServer@4fa3c06e)
[12:45:49] [Server thread/INFO] [GeoCraft]: GeoCraft Attempting to Mod WorldGen
[12:45:49] [Server thread/INFO] [GeoCraft]: GeoCraft WorldGen Modification 1
[12:45:49] [Server thread/INFO] [GeoCraft]: GeoCraft WorldGen Modification 2
[12:45:49] [Server thread/INFO] [GeoCraft]: in modify
[12:45:49] [Server thread/INFO] [GeoCraft]: GeoCraft WorldGen Modification 3
[12:45:49] [Server thread/INFO] [GeoCraft]: GeoCraft WorldGen Modification Complete
[12:45:49] [Server thread/INFO]: Preparing start region for level 2
[12:45:50] [Server thread/INFO]: Preparing spawn area: 13%
[12:45:51] [Server thread/INFO]: Preparing spawn area: 30%
[12:45:52] [Server thread/INFO]: Preparing spawn area: 47%
[12:45:53] [Server thread/INFO]: Preparing spawn area: 59%
[12:45:54] [Server thread/INFO]: Preparing spawn area: 78%
[12:45:55] [Server thread/INFO]: Preparing spawn area: 96%
[12:45:55] [Server thread/INFO]: Preparing level “world”

However after this, it looks like it tries to build the real ‘world’ and fails because the
final WorldGenerator normGen = world.getWorldGenerator();
line in the main class retrieves a null value?

    [12:45:55] [Server thread/INFO]: Preparing level "world"
    [12:45:55] [Server thread/INFO] [FML]: Loading dimension 0 (world) (net.minecraft.server.dedicated.DedicatedServer@4fa3c06e)
    [12:45:56] [Server thread/INFO] [GeoCraft]: GeoCraft Attempting to Mod WorldGen
    [12:45:56] [Server thread/INFO] [GeoCraft]: GeoCraft WorldGen Modification 1
    [12:45:56] [Server thread/ERROR] [Sponge]: Could not pass Load to SpongePlugin:The Minecraft Geology Project{1.0a}
    java.lang.NullPointerException
    	at com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:258) ~[minecraft_server.1.8.jar:?]
    	at org.spongepowered.common.world.gen.SpongeWorldGenerator.<init>(SpongeWorldGenerator.java:66) ~[SpongeWorldGenerator.class:1.8-1446-2.1DEV-508+unknown-b508.git-unknown]
    	at net.minecraft.world.World.getWorldGenerator(World.java:769) ~[aqu.class:?]
    	at com.GeoCraft.GeoCraftMain.onWorldLoadEvent(GeoCraftMain.java:43) ~[GeoCraftMain.class:?]

and then proceeds to (I assume) leave out the modifyWorldGenerator and just build the server like normal:

[12:45:56] [Server thread/INFO] [FML]: Loading dimension 1 (DIM1) (net.minecraft.server.dedicated.DedicatedServer@4fa3c06e)
[12:45:56] [Server thread/INFO] [FML]: Loading dimension -1 (DIM-1) (net.minecraft.server.dedicated.DedicatedServer@4fa3c06e)
[12:45:56] [Server thread/INFO]: Preparing start region for level 2
[12:45:56] [Server thread/INFO]: Preparing start region for level -1
[12:45:57] [Server thread/INFO]: Preparing spawn area: 5%
[12:45:58] [Server thread/INFO]: Preparing spawn area: 13%
...etc;
[12:46:29] [Server thread/INFO]: Done (42.084s)!  For help, type "help" or "?"

Leaving out the .build() sequence in the onServerAboutToStart() method returns

[12:57:40] [Server thread/ERROR] [Sponge]: Could not pass Load to SpongePlugin:The Minecraft Geology Project{1.0a}
java.lang.NullPointerException
	at com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:258) ~[minecraft_server.1.8.jar:?]
	at org.spongepowered.common.world.gen.SpongeWorldGenerator.<init>(SpongeWorldGenerator.java:66) ~[SpongeWorldGenerator.class:1.8-1446-2.1DEV-508+unknown-b508.git-unknown]
	at net.minecraft.world.World.getWorldGenerator(World.java:769) ~[aqu.class:?]
	at com.GeoCraft.GeoCraftMain.onWorldLoadEvent(GeoCraftMain.java:43) ~[GeoCraftMain.class:?]

which looks suspiciously like the first error.

EDIT: I should probably clarify that line 43 is the
final WorldGenerator normGen..
declaration/

You want to use either methods, not both. Right now you’re creating a second world called “world”. Either create a new world and set your generator using the world builder in server start, or modify an existing world in world load.

You’ll have to update to the latest version on Sponge (or SpongeVanilla) for me to debug this. The latest version of the API changes the signatures of some world generator interfaces, you’ll have to replace ImmutableBiomeBuffer to ImmutableBiomeArea, MutableBlockBuffer to MutableBlockVolume and etc. The filling methods are being moved and will be re-added later in a more versatile API.

So update your code to the latest version (should only take a few minutes), keep only the world load modifier and try again.

Is there a tutorial/resource out there that shows one how to update the dependencies in a maven project?

I found a good one here.

In case anyone else would like to know how I updated my project, heres how you do it in eclipse:

right click on project>maven>update project> make sure force update of snapshot/releases is clicked.
Then of course download the latest dev build and place it in your mod folder in whatever test server you’re running.

It is done. I updated the populator class definitions, exported the project, ran the server, and bam:

[10:45:19] [Server thread/INFO] [GeoCraft]: GeoCraft Attempting to Mod WorldGen
[10:45:19] [Server thread/INFO] [GeoCraft]: GeoCraft WorldGen Modification 1
[10:45:19] [Server thread/ERROR] [Sponge]: Could not pass Load to SpongePlugin:The Minecraft Geology Project{1.0a}
java.lang.NullPointerException
	at com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:258) ~[minecraft_server.1.8.jar:?]
	at org.spongepowered.common.world.gen.SpongeWorldGenerator.<init>(SpongeWorldGenerator.java:66) ~[SpongeWorldGenerator.class:1.8-1487-2.1DEV-517+unknown-b517.git-unknown]
	at net.minecraft.world.World.getWorldGenerator(World.java:788) ~[aqu.class:?]
	at com.GeoCraft.GeoCraftMain.onWorldLoadEvent(GeoCraftMain.java:43) ~[GeoCraftMain.class:?]

Line 43 happens to be where the default generator is retrieved in the main class:

@Subscribe
public void onWorldLoadEvent(WorldLoadEvent event)
{
    final World world = event.getWorld();
    if(world.getName().equals("world"))
    {
    	logger.info("GeoCraft Attempting to Mod WorldGen");
    	final MainGenParser testGen = new MainGenParser();
    	logger.info("GeoCraft WorldGen Modification 1");
    	final WorldGenerator normGen = world.getWorldGenerator();//line 43****
    	logger.info("GeoCraft WorldGen Modification 2");
    	testGen.modifyWorldGenerator(null,null, normGen);
    	logger.info("GeoCraft WorldGen Modification 3");
    	world.setWorldGenerator(normGen);
    	logger.info("GeoCraft WorldGen Modification Complete");
    }
}

So it seems by using getGenerator() its breaking something?

1 Like

That’s still not the latest version. The stack trace says the error is at line 66 of the class SpongeWorldGenerator. Latest version of the source code shows a comment at that line.

Obviously the error originates from one of these two lines, but I can’t tell which.

[16:41:31] [Server thread/ERROR] [Sponge]: Could not pass Load to SpongePlugin:The Minecraft Geology Project{1.0a}
java.lang.NullPointerException
	at com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:258) ~[minecraft_server.1.8.jar:?]
	at org.spongepowered.common.world.gen.SpongeWorldGenerator.<init>(SpongeWorldGenerator.java:68) ~[SpongeWorldGenerator.class:1.8-1487-2.1DEV-519+unknown-b519.git-unknown]
	at net.minecraft.world.World.getWorldGenerator(World.java:790) ~[aqu.class:?]
	at com.GeoCraft.GeoCraftMain.onWorldLoadEvent(GeoCraftMain.java:43) ~[GeoCraftMain.class:?]

Looks like a dev build came out sometime in the last day. Anyways the new error shows the nullPointerException arising on line 68 in SpongeWorldGenerator