Jump to content

[1.12.2] Biome and Dimension tutorials


ttocskcaj

Recommended Posts

Hi modders,
I'm trying to create a custom dimension for a mod, but am struggling to find much information on how to do so.
I've already checked out mcjty's tutorials, but that doesn't explain much about using custom biomes, and glosses over the topic quite a bit: https://wiki.mcjty.eu/modding/index.php?title=Dimensions-1.12
The official docs for 1.12 don't seem to cover it, and I can't find older versions of the docs to see if there's anything covered in there.
I've tried going through the source of other mods, namely RFTools Dimensions and Plenty O' Biomes, but they're quite complicated (and don't have many comments :P)

The outcome I want, is four custom biomes, and a dimension similar to the vanilla overworld but only using those four biomes.

Cheers for any help, or links you can offer.

Link to comment
Share on other sites

16 hours ago, jabelar said:

Cheers @jabelar that was really helpful. I've got the hang (mostly) of WorldProvider, IChunkGenerator and Biomes with BiomeProviderSingle. I can't seem to get a custom BiomeProvider working though.

Following your tutorial for Multi-Biome Provider (Semi-Custom) I get a NullPointerException.

Log: https://pastebin.com/xYkbkTpH

public class BiomeProviderEP extends BiomeProvider {

    public BiomeProviderEP(World world) {
        super();
        allowedBiomes.clear();
        allowedBiomes.add(ModBiomes.BIOME_FIRE);
        allowedBiomes.add(ModBiomes.BIOME_EARTH);
    }

}

 

Link to comment
Share on other sites

If you look at the BiomeProvider class, and also look at the line where your log is showing the error, you'll see that it is failing when working with the genBiomes field which is a GenLayer type. I'm not entirely certain, but I think beyond adjusting the allowed biomes list you probably need to work through the other stuff that happens in the constructor to make sure it is all synced up particularly related to the genBiomes and the biomeIndexLayer.  I'd probably copy stuff from the BiomeProvider constructor and work through it to understand what it does and what is important.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

5 hours ago, jabelar said:

If you look at the BiomeProvider class, and also look at the line where your log is showing the error, you'll see that it is failing when working with the genBiomes field which is a GenLayer type. I'm not entirely certain, but I think beyond adjusting the allowed biomes list you probably need to work through the other stuff that happens in the constructor to make sure it is all synced up particularly related to the genBiomes and the biomeIndexLayer.  I'd probably copy stuff from the BiomeProvider constructor and work through it to understand what it does and what is important.

 Cheers, I got that :)

It seems weird that the constructor to create that field in BiomeProvider is private. There seems to be no easy way except override every method. I'll investigate further later .

Link to comment
Share on other sites

Finally got my dimension generating with 2 out of four biomes. Took a good few hours of messing around and trying to make sense of other code on github, and stepping through the debugger (yawn).

Firstly,  I was using the wrong constructor in my BiomeProvider, it needs to use the one that takes a WorldInfo object. Both twilightforest and biomes-o-plenty simply assign the genLayers and biomeIndexLayer fields directly, but they're both private variables, so I'm not sure how that works. Maybe it's my limited Java experience?

Secondly, I had to override the getModdedBiomeGenerators method and create my own GenLayers (These are what picks what biomes go where). This is what assigns the genLayers and biomIndexLayer fields in BiomeProvider.

Thirdly, the event listener for registering biomes wasn't working (Still don't know why this is. Maybe it's a bug?) I had to use ForgeRegistries.BIOMES.register(Biome) instead.

Here's my finished BiomeProvider.

public class BiomeProviderEP extends BiomeProvider {

    public BiomeProviderEP(World world) {
        super(world.getWorldInfo());
        allowedBiomes.clear();
        allowedBiomes.add(ModBiomes.BIOME_EARTH);
        allowedBiomes.add(ModBiomes.BIOME_FIRE);

        getBiomesToSpawnIn().clear();
        getBiomesToSpawnIn().add(ModBiomes.BIOME_EARTH);
    }

    @Override
    public GenLayer[] getModdedBiomeGenerators(WorldType worldType, long seed, GenLayer[] original) {
        GenLayer biomes = new GenLayerEP(1);

        biomes = new GenLayerEPBiomes(1000, biomes);
        biomes = new GenLayerZoom(1000, biomes);
        biomes = new GenLayerZoom(1001, biomes);
        biomes = new GenLayerZoom(1002, biomes);
        biomes = new GenLayerZoom(1003, biomes);
        biomes = new GenLayerZoom(1004, biomes);

        GenLayer biomeIndexLayer = new GenLayerVoronoiZoom(10L, biomes);
        biomeIndexLayer.initWorldGenSeed(seed);

        return new GenLayer[]{
                biomes,
                biomeIndexLayer
        };
    }
}

 

Link to comment
Share on other sites

5 hours ago, ttocskcaj said:

Firstly,  I was using the wrong constructor in my BiomeProvider, it needs to use the one that takes a WorldInfo object. Both twilightforest and biomes-o-plenty simply assign the genLayers and biomeIndexLayer fields directly, but they're both private variables, so I'm not sure how that works. Maybe it's my limited Java experience?

 

...

Thirdly, the event listener for registering biomes wasn't working (Still don't know why this is. Maybe it's a bug?) I had to use ForgeRegistries.BIOMES.register(Biome) instead.

 

Regarding the private variables, they may simply be creating their own replacement copy. If the private field is only used within the class and all inherited references to the field are overridden then you can simply have your own local field which acts the same. 

 

The event listener should definitely work though. Did you make sure your handling method was static? And that the class was properly annotated as a subscriber? Here is link to my biomes class: https://github.com/jabelar/ExampleMod-1.12/blob/master/src/main/java/com/blogspot/jabelarminecraft/examplemod/init/ModBiomes.java

 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

4 hours ago, jabelar said:

Regarding the private variables, they may simply be creating their own replacement copy. If the private field is only used within the class and all inherited references to the field are overridden then you can simply have your own local field which acts the same.

Not really sure what's going on. From what I can see, they just set and forget. The don't create their own copy or anything. Maybe it's only changed to private recently? Maybe I'm missing something small and obvious again haha.

https://github.com/TeamTwilight/twilightforest/blob/1.12.x/src/main/java/twilightforest/world/TFBiomeProvider.java

 

4 hours ago, jabelar said:

The event listener should definitely work though. Did you make sure your handling method was static? And that the class was properly annotated as a subscriber? Here is link to my biomes class: https://github.com/jabelar/ExampleMod-1.12/blob/master/src/main/java/com/blogspot/jabelarminecraft/examplemod/init/ModBiomes.java

I totally wouldn't do something silly like forget to make it static...
Cheers, it's working now :P

Last question:
The getModdedBiomeGenerators method that I'm overriding fires an event on the TERRAIN_GEN_BUS.

    public GenLayer[] getModdedBiomeGenerators(WorldType worldType, long seed, GenLayer[] original)
    {
        net.minecraftforge.event.terraingen.WorldTypeEvent.InitBiomeGens event = new net.minecraftforge.event.terraingen.WorldTypeEvent.InitBiomeGens(worldType, seed, original);
        net.minecraftforge.common.MinecraftForge.TERRAIN_GEN_BUS.post(event);
        return event.getNewBiomeGens();
    }


Would the preferred method be to use that event to override the genLayers instead?
Or am I fine overriding the whole method?
 

 

 

 

Link to comment
Share on other sites

The fact that TF is accessing those private fields is definitely odd. I couldn't find them using any reflection and I'm quite confident that a subclass can't access a private instance field from the parent. Very weird.

 

Regarding using events, technically events are intended for changing vanilla behavior. Since you're making your own BiomeProvider class it is not really clean to use events to intercept your own code. But it would technically work, and I guess might make sense in the context of the fact you have private fields you want to intercept. So yeah, maybe that is preferable.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

23 hours ago, ttocskcaj said:

Both twilightforest and biomes-o-plenty simply assign the genLayers and biomeIndexLayer fields directly, but they're both private variables, so I'm not sure how that works.

11 hours ago, jabelar said:

The fact that TF is accessing those private fields is definitely odd. I couldn't find them using any reflection and I'm quite confident that a subclass can't access a private instance field from the parent. Very weird.

 

The Twilight Forest and Biomes O' Plenty mod uses ATs to make those variables public in BiomeProviderTwilight Forest AT and Biomes O' Plenty AT.

 

 

  • Thanks 1

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

4 hours ago, larsgerrits said:

 

The Twilight Forest and Biomes O' Plenty mod uses ATs to make those variables public in BiomeProviderTwilight Forest AT and Biomes O' Plenty AT.

 

 

Ah, yeah that makes sense. I was searching for reflection but since they use it on a wholesale basis an AT would be worth it to them.

 

@ttocskcaj To get a similar effect I would use ReflectionHelper to create some reflection on those fields. 

Edited by jabelar

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

43 minutes ago, ttocskcaj said:

What exactly is an AT? Google doesn't seem to turn up anything.

Access Transformer. Basically, Java is kinda a funny language because it is possible to change the intended scope of the fields and methods. So Forge has provided a way to sort of open up accessibility in a bulk way with access transformer.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Don't use AT when you can use Reflection. Reflection is cleaner.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Please tell me that your dimension doesnt lag. I somehow got mine working for 1.11.2 but it lags horrible, even if i turn off the decoration. Im out of ideas, its not the cascading issue, not too many mobs, or stuff, it lags in eclipse and normal minecraft. Im not sure what i added that it started lagging so much.

 

picture

 

Could you somehow provide me your code, so i could take a look at it?

Link to comment
Share on other sites

3 minutes ago, Dragonisser said:

Please tell me that your dimension doesnt lag. I somehow got mine working for 1.11.2 but it lags horrible, even if i turn off the decoration. Im out of ideas, its not the cascading issue, not too many mobs, or stuff, it lags in eclipse and normal minecraft. Im not sure what i added that it started lagging so much.

 

picture

 

Could you somehow provide me your code, so i could take a look at it?

Mine is in 1.12. Not sure if there's any difference in world generation between the versions.
My chunk loading times are definitely longer that vanilla overworld, but I haven't spent any time optimizing it yet. Other than that, I don't get any lag playing, even running out of intellij.

Link to comment
Share on other sites

8 minutes ago, ttocskcaj said:

https://github.com/ttocskcaj/ElementalCraft/tree/b4931beb400823e81610d2d3854271204be8de57

 

After getting the dimension working with 2 biomes, we made the decision to split out "Elemental Plane" into 4 dimensions anyway (one for each element). There's link to an older commit, but it was working with 2 biomes at that point.

Thanks, hopefully i can figure it out now, why it isnt working. Still remember the good old 1.7.10 times were you could put up a dimension and it just works.

Link to comment
Share on other sites

1 minute ago, Dragonisser said:

Thanks, hopefully i can figure it out now, why it isnt working. Still remember the good old 1.7.10 times were you could put up a dimension and it just works.

Try profiling the code and see what's running slow?
Or step through in debugger, maybe you're getting stuck in a loop somewhere?

Link to comment
Share on other sites

3 minutes ago, ttocskcaj said:

Try profiling the code and see what's running slow?
Or step through in debugger, maybe you're getting stuck in a loop somewhere?

Theres this normal minecraft lag where everything runs fine but entities and world generation lags, "xxx ticks behind". But for me its a game lag, like running battlefield on a shitty laptop with 3 fps.

 

I wish i would knew where i should search to find the culprit for it.

Link to comment
Share on other sites

1 minute ago, Dragonisser said:

Theres this normal minecraft lag where everything runs fine but entities and world generation lags, "xxx ticks behind". But for me its a game lag, like running battlefield on a shitty laptop with 3 fps.

 

I wish i would knew where i should search to find the culprit for it.

Maybe the issue lies somewhere else. Blocks, Items or Entities?
From my understanding, your dimension, ChunkProvider, Biomes etc should only cause lag when chunks are being generated.

Link to comment
Share on other sites

20 minutes ago, ttocskcaj said:

Maybe the issue lies somewhere else. Blocks, Items or Entities?
From my understanding, your dimension, ChunkProvider, Biomes etc should only cause lag when chunks are being generated.

Since i dont have any entities or decorations(test, not the actual state) generating, just the chunks with topblock and fillerblock, its kinda weird why it lags.

Neither is it cascading chunk loading.

 

Sadly i cant check the code right now.

I bet if TGG, diesieben, jabelar or draco would take a look at it they would probably find it quite fast, but that is not their job.

Edited by Dragonisser
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.