Realistic Terrain Generation

Realistic Terrain Generation

3M Downloads

EB-related crash: 'Exception getting block type in world'

whichonespink44 opened this issue ยท 29 comments

commented

When running RTG with EB, the game crashes when trying to enter the world for the first time.

Crash reports:
https://gist.github.com/whichonespink44/48b0d15d1a6b9d022080
https://gist.github.com/whichonespink44/83e7c9dc131c86661043
https://gist.github.com/whichonespink44/030e74a4d20864e839dc

It seems to be run into trouble when RTG tries to decorate the EB biome:

    public void rDecorate(World world, Random rand, int chunkX, int chunkY, OpenSimplexNoise simplex, CellNoise cell, float strength, float river) {

        if (strength > 0.3f) {
            baseBiome.decorate(world, rand, chunkX, chunkY);
        }
    }

https://github.com/Team-RTG/Realistic-Terrain-Generation/blob/master/src/main/java/rtg/world/biome/realistic/RealisticBiomeBase.java#L69

How to repeat the crash:
Install RTG (0.0.10) & EB (2.5) with no other mods and try to start a new world.

commented

I've been doing more testing, and the problem seems to happen only with biomes from the wasteland group. Both the wasteland.sandstone and wasteland.rock sub-categories have crashed during testing, and no other biomes that I've tested so far outside of that group have crashed.

commented

@SMEZ1234 - Sorry to trouble you... but is there anything from these crash reports that immediately jumps out at you as being the potential culprit? I'm hoping it's something really simple that we've overlooked when adding support for EB, but after several hours of debugging this over the last couple of days, I haven't made much progress unfortunately.

Other potentially useful information:

Any ideas?

commented

So I've been doing more testing, and I've managed to load up a world without crashing...

I spawned in a Mountains biome, and everything seemed to be working well, so I flew around for a while and the following biomes generated without crashing:

  • Mountains
  • Cold Boreal Forest
  • Snowy Ranges
  • Cold Fir Forest
  • Alpine Mountains
  • Red Desert
  • Rainforest Valley (including an EB-themed village ๐Ÿ˜„ )
  • Snowy Plateau
  • Alpine Mountains M
  • Glacier
  • Cypress Forest
  • Alpine Mountains Edge
  • Pine Forest Archipelago
  • Grassy Archipelago
  • Boreal Archipelago
  • Aspen Hills
  • Tundra
  • Boreal Plateau M
  • Mountains Edge
  • Mountainous Archipelago

And then it crashed with a different exception: https://gist.github.com/whichonespink44/a84a4467df7a468dc8e8

Not sure if this is related, but I did notice the biome.wasteland.sandstone group, which was present in the other reports, so maybe the issue is specific to that group?

commented

It's more than just the wasteland group. Through my own limited testing I've made a(n incomplete) list of biomes that cause Exception getting block type in world.

sand.BiomeGenScrub
snow.BiomeGenPolarDesert
wasteland.rock.BiomeGenRockHills
wasteland.sandstone.BiomeGenClayHills
wasteland.sandstone.BiomeGenCreekBed
wasteland.sandstone.BiomeGenSandStoneRanges
wetland.BiomeGenEphemeralLake

Later, if I'm feeling up to it, I might start generating test worlds with only a few EB biomes at a time to find out which ones crash and try to figure out a commonality.

IIRC, I had some similar crashes with chunks being decorated when running EB exclusively months ago, but the crashes were few and far between, and nothing of this scale, so I didn't think anything of it. So, not to point fingers without reason, but the problem could be on EB's side? (If it is, maybe this situation can be exploited to put pressure on @SMEZ1234 to step up his game and release the next version of EB already! :)

commented

@srs-bsns Also spent a lot of time on this today and managed to narrow it down to 21 incompatible biomes.

If you still plan on testing with only a handful of EB biomes enabled, be sure to download RTG-1.7.10-0.0.11, which has some new functionality to allow for that sort of thing. (Previously, the game would crash if you disabled too many biomes.)

Also, if you start referring back to the EB source code, just make sure you're always looking at the 2.5 branch version of whatever file you're looking at. I wasted about an hour scratching my head wondering why the game was crashing in the middle of a commented out line of code.

Oh, and thanks for helping to test the mod. Hopefully between us all we'll get to the bottom of this issue and be able to support all 90 EB biomes in RTG :)

commented

I'm not sure what's going on. I can put most of those biomes down to an issue with a certain file (WorldGenEnhancedBiomesMinable), except for these:
generateEBBasin=false
generateEBIceSheet=false
generateEBVolcano=false
generateEBVolcanoM=false

Also, 4 other biomes use that file and don't have errors:
Xeric Shrubland
Alpine Mountains M
Shield
Kakadu

Just looking at the coordinates of the blocks in the crash report (at the bottom), any idea why the locations are so varied? This was all on the creation of the world, if I understand correctly, and it shouldn't be checking blocks that are 3000 blocks away on both the x and z axes.

commented

Also, the locations of the blocks form a more or less straight diagonal line.

If it weren't for the fact that there aren't issues with those other 4 biomes, I'd say that you must be interfering with world.getBlock...

EDIT: For instance, if you created some kind of loop with world.getBlock leading to your generation, leading to my generation, leading to world.getBlock, this would be what I would expect to result, because of that nice, straight line.

Possibly when WGEBM extends into a new chunk it is triggering something like that?

EDIT 2: Yes, that seems to be the issue. If you go through the coordinates, they differ by around 16 each time, with some that don't when the error line crosses to the next chunk along a side, rather than a corner.

If I'm going off on a tangent tell me, but I think this explanation fits too nicely.

commented

@whichonespink44, welp, I've test all of the biomes now and I have some discrepancies with your list:

I had crashing with both Carr and Fens biomes which aren't in your list, and no crashing with the fallowing, which were in your list:
Basin
IceSheet
RiparianZone
RockyDesert
StoneCanyon
StoneCanyons
Volcano
VolcanoM

So that pretty much solves this:

@SMEZ1234 commented 13 hours ago
I'm not sure what's going on. I can put most of those biomes down to an issue with a certain file (WorldGenEnhancedBiomesMinable), except for these:
generateEBBasin=false
generateEBIceSheet=false
generateEBVolcano=false
generateEBVolcanoM=false

(I think you meant WorldGenMinableEnhancedBiomes.java :)

My final list of affected biomes is:
Carr
Fens
ClayHills
CreekBed
EphemeralLake
EphemeralLakeEdge
PolarDesert
RockyHills
SandstoneCanyon
SandstoneCanyons
SandstoneRanges
SandstoneRangesM
Scree
Scrub
SnowyWastelands
Wastelands

Which are all from:
enhancedbiomes.world.biome.wasteland.rock.*
enhancedbiomes.world.biome.wasteland.sandstone.*
enhancedbiomes.world.biome.snow.*
enhancedbiomes.world.biome.sand.*
enhancedbiomes.world.biome.wetland.*

Most of the time Exception getting block type in world is the thrown exception, but on occasion Exception while updating neighbours is thrown instead. Upon retesting those biomes that threw the 2nd exception they end up throwing the first, like the others.

Hope this info helps. Cheers.

commented

Thanks @SMEZ1234 - that's incredibly helpful information. I'm not sure if my Java/Forge skills are up to this challenge, but I'm going to create a feature branch now and see if I can try a few things.

If there's anything you would recommend trying first, I'm all ears. My only idea at the moment is to force RTG to bypass its custom decoration and just use EB's decoration for the incompatible biomes, but I'm not even sure that's possible.

commented

@srs-bsns With the Carr and Fens crashes, did the error log include WorldGenPools instead of WGMEB? That's probably another one that could extend outside the chunk, and those biomes don't have WGMEB. It could also occasionally be causing issues in Volcano biomes, which might explain why they were on @whichonespink44 's list.

I think the best method to solve this is to break the loop somehow. If it happens with EB there's always a chance it will happen with another biome. I'm not sure if there is somewhere you could put a check, but I do believe that the error is on your side. I think.
There's a possibility that it is caused by both mods trying to do biome generation individually, but that doesn't explain the 3000 coordinate shift.

Oh and good pickup on the file name. Probably a bad thing that I don't know the name of my own file... :)

EDIT: On the note of the type of exception, did the updating neighbours occur when the biomes were generated after the initial generation, with the getting block type occurring during, or was it just random?

commented

@SMEZ1234, yes, both Carr and Fens included WorldGenPools. Here's a stack trace (identical for both, with the '+' part looping):

-- Head --
Stacktrace:
    at java.security.AccessController.doPrivileged(Native Method)
    at java.lang.ClassLoader.checkPackageAccess(Unknown Source)
    at net.minecraft.world.World.func_147439_a(World.java:350)
    at enhancedbiomes.world.gen.WorldGenPool.func_76484_a(WorldGenPool.java:73)

-- Requested block coordinates --
Details:
    Found chunk: true
    Location: World: (2912,9,3190), Chunk: (at 0,0,6 in 182,199; contains blocks 2912,0,3184 to 2927,255,3199), Region: (5,6; contains chunks 160,192 to 191,223, blocks 2560,0,3072 to 3071,255,3583)

Stacktrace:
    at net.minecraft.world.World.func_147439_a(World.java:351)
    at enhancedbiomes.world.gen.WorldGenPool.func_76484_a(WorldGenPool.java:73)
    at enhancedbiomes.world.biome.wetland.BiomeGenCarr.func_76728_a(BiomeGenCarr.java:46)
    at rtg.world.biome.realistic.RealisticBiomeBase.rDecorate(RealisticBiomeBase.java:69)
    at rtg.world.gen.ChunkProviderRTG.func_73153_a(ChunkProviderRTG.java:776)
    at net.minecraft.world.gen.ChunkProviderServer.func_73153_a(ChunkProviderServer.java:279)
    at net.minecraft.world.chunk.Chunk.func_76624_a(Chunk.java:1050)
    at net.minecraft.world.gen.ChunkProviderServer.originalLoadChunk(ChunkProviderServer.java:190)
    at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:131)
    at net.minecraft.world.gen.ChunkProviderServer.func_73158_c(ChunkProviderServer.java:101)
    at net.minecraft.world.gen.ChunkProviderServer.func_73154_d(ChunkProviderServer.java:199)
    at net.minecraft.world.World.func_72964_e(World.java:419)
+   at net.minecraft.world.World.func_147439_a(World.java:345)
+   at enhancedbiomes.world.gen.WorldGenPool.func_76484_a(WorldGenPool.java:73)
+   at enhancedbiomes.world.biome.wetland.BiomeGenCarr.func_76728_a(BiomeGenCarr.java:46)
+   at rtg.world.biome.realistic.RealisticBiomeBase.rDecorate(RealisticBiomeBase.java:69)
+   at rtg.world.gen.ChunkProviderRTG.func_73153_a(ChunkProviderRTG.java:776)
+   at net.minecraft.world.gen.ChunkProviderServer.func_73153_a(ChunkProviderServer.java:279)
+   at net.minecraft.world.chunk.Chunk.func_76624_a(Chunk.java:1055)
+   at net.minecraft.world.gen.ChunkProviderServer.originalLoadChunk(ChunkProviderServer.java:190)
+   at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:131)
+   at net.minecraft.world.gen.ChunkProviderServer.func_73158_c(ChunkProviderServer.java:101)
+   at net.minecraft.world.gen.ChunkProviderServer.func_73154_d(ChunkProviderServer.java:199)
+   at net.minecraft.world.World.func_72964_e(World.java:419)

The coordinate shift is indeed odd. This crash happened at initial world generation before my client would even connect, so why it would be referencing blocks a few hundred chunks away from where the world spawn point would be doesn't make any sense unless there was some sort of endless loop.

As for the Updating Neighbours exception, IIRC all of those crashes were also at initial world gen before I could even get into the world. Here's a stack trace of one of those crashes (unfortunately this was when I also had other mods loaded, but I doubt there's any interference): http://pastebin.com/NqihFt4Z

The only time I was actually able to get into a world after initial generation at any time was when the world spawn was located in a biome that didn't cause a crash. In those cases a crash would only occur after travelling around until the moment I encountered a problematic biome, then the server would seem to lock up for a moment (looping) before crashing.

I'm not sure how related this might be, but I was using the ChunkGen mod to pregen areas of my test worlds 64x64 chunks at a time and using JourneyMap to create maps of those areas, and sometimes I had some strange results like this, where generation clearly went off on a tangent (obviously this is with biomes that didn't cause crashing):

commented

I've been doing a lot of testing (mainly adding FMLLog calls all over the code to gain more insight into what's going on) and I've got some stuff to share. In the meantime, I just thought I'd quickly mention that this seems to be very similar to the RailCraft issue (#195) and @scalda has narrowed down the culprits from that crash to be either Firestone and/or Quarried Stone. Just posting those in case anyone can spot some similarities between the RC worldgen and the crashing EB biomes.

commented

One other quick note potentially worth mentioning... I prevented this line from being executed for the crashing EB biomes, and they generated without crashing, and were even somewhat decorated, although they looked a bit odd which I'm assuming is because of the RTG noise/terrain.

commented

Ow btw the line under that one you can change 0.15 to 0.65 ๐Ÿ˜‰

commented

And finally... not sure if you guys are aware, but there's a config setting in ConfigRTG.cfg called "Enable Debugging" which logs a lot of stuff from the ChunkProvider... not sure how helpful that stuff would be, but just thought I'd mention it.

commented

When I used that a week ago it crashed because of that haha but I guess it works now ?

commented

"When I used that a week ago it crashed because of that haha but I guess it works now ?"

I think you might be referring to the "Show Debug Info in F3 Screen" option, which has been known to crash on occasion. The other option just logs info the FML log so it shouldn't be crashing. Let me know if that's not the case though and I'll look into it.

commented

Haha dunno what exactly it was :p

commented

Just wanted to post a quick update on this one... I still don't know what's causing this crash, but I think I might've found a way around it. Basically, these biomes are crashing when RTG is calling the EB biome's decorate() method. And for whatever reason, it's getting caught in an infinite loop somewhere along the way. So... I've been tweaking the aesthetics of the vanilla biomes for the 0.0.13 release, and part of that process has been to (sometimes) bypass the vanilla biome's decorate() method and let RTG decorate the biome completely. I'm not sure if that would actually work for EB's biomes, but it's worth a shot.

@SMEZ1234 - if RTG bypassed EB's decorate() method and decorated the biome as best it could based on knowing what the biome looks like and the world gen features it contains... is there anything you can think of that RTG would 'miss' or 'skip' if it used that approach?

commented

Another quick update... I've been experimenting with the approach I mentioned in my last post, and I'm happy to say that it's working great!! To be fair, I've only done the Carr biome, but bypassing EB's decorate() method and using RTG's rDecorate() has allowed me to load up the biome without crashing.

In terms of aesthetics, I managed to figure out how to reference some of EB's configs, methods and variables, despite not having access to an API, which has allowed me to do things like, if the user has chosen to use EB's grass, then the Carr biome will be decorated with Histisol and the underground will be Schist. I also figured out how to manually generate EB's trees, so the Carr biome has Alder trees as expected. And it's looking pretty sweet! ๐Ÿ˜„

This is all great news, because it means that we can have full EB compatibility, complete with the new RWG-esque biome aesthetics.

commented

@whichonespink44, This is great news! Not only solving the crashing issue with decoration, but being able to decorate with EB's custom stone and dirt is awesome. The custom stone and dirt is one of the things that I like about EB.

I can't wait until the next release so I can run it through a battery of test for you. :)

commented

@srs-bsns Here's a snapshot if you don't want to wait until the weekend for the full release:

https://goo.gl/sUuqEf

I've done 7 of the 21 biomes so far:

Carr
Fens
Clay Hills
Ephemeral Lake
Ephemeral Lake Edge
Polar Desert
Rocky Hills

I've tried to stay as true to the original EB biomes as possible, but deviated slightly in places where I thought it worked. Would be interested to hear what you think of what's been done so far.

Ok, best get back to the Matrix!!! ๐Ÿ’ป

commented

I've finished re-decorating all of the incompatible biomes from @srs-bsns's list above, so when 0.0.14 is released, we should be fully compatible with EB :)

Now it's time to tackle the other ones. There's no way I'll finish them all before the next release, but I'll do what I can and just keep updating them between releases.

Thanks to everyone who contributed to this issue - couldn't have gotten here without you!

commented

@whichonespink44, I haven't had much time to do testing with the snapshot you provided, but I did create a few test worlds and ran into a couple of issues that I thought I should let you know about before I continue.

The first issue is with Thaumcraft. I experienced multiple crashes, with the first happening at initial world gen. This first crash mentions RTG and EB in the stack trace: http://pastebin.com/eNYBgNkw
This happened before I discovered that you had reorganised the config directory and deleted it to start fresh, but I don't think this had any effect. After this crash I removed Thaumcraft to do some testing with out it, but readded it later and had several crashes. (none like this one though)

All of the crashes after the first one do not mention RTG or EB in the stack trace, but they're still OOB exceptions with Thaumcraft generation (same code). All of these crashes occured while flying around and generating new chunks, and caused either

  1. Ticking memory connection
  2. Exception in server tick loop
  3. Exception getting block type in world
    but they all had this in their stack traces:
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.LinkedList.checkElementIndex(Unknown Source)
    at java.util.LinkedList.get(Unknown Source)
    at net.minecraft.world.gen.structure.MapGenStructure.func_151545_a(MapGenStructure.java:181)
    at thaumcraft.common.lib.world.ThaumcraftWorldGenerator.generateSurface(ThaumcraftWorldGenerator.java:368)
    at thaumcraft.common.lib.world.ThaumcraftWorldGenerator.worldGeneration(ThaumcraftWorldGenerator.java:109)
    at thaumcraft.common.lib.world.ThaumcraftWorldGenerator.generate(ThaumcraftWorldGenerator.java:95)
    at cpw.mods.fml.common.registry.GameRegistry.generateWorld(GameRegistry.java:112)
...

What's strange is that there doesn't really seem to be much of a problem with Thaumcraft world gen (pic for proof)

This is a Thaumcraft taint biome overlapping an EB prairie biome, most of which generated fine, but if I try to move towards some chunks that haven't yet generated I'll crash every time with one of the 3 exceptions above. From the stack trace it looks like it's with some kind of structure gen, but I've see all the different types of Thaumcraft structures all over this world already that generated fine, so I have no idea what's going on here.

I was going to open up a new issue for this, but the initial crash that I had mentions RTG decoration and EB world gen, so I thought I'd post it here first in case it's related to this EB issue or to the changes you made to the decoration. If you find that Thaumcraft is likely the issue, then maybe @Azanor can help.

The second issue I had is, I assume, the same known issue with Railcraft. The world crashed at initial generation the first time I tried to generate a world with Railcraft. I didn't try a second time. I have a terrible feeling that this is somehow similar to this EB issue.
(+=looping to infinity)

java.lang.StackOverflowError: Exception in server tick loop
    at net.minecraft.crash.CrashReport.func_85055_a(CrashReport.java:373)
    at net.minecraft.world.World.func_147439_a(World.java:350)
    at net.minecraft.world.WorldServer.func_147454_a(WorldServer.java:428)
    at net.minecraft.world.WorldServer.func_147464_a(WorldServer.java:409)
+   at mods.railcraft.common.blocks.ore.BlockWorldLogic.func_149674_a(BlockWorldLogic.java:74)
+   at net.minecraft.world.WorldServer.func_147454_a(WorldServer.java:432)
+   at net.minecraft.world.WorldServer.func_147464_a(WorldServer.java:409)

On a lighter side, everything else is looking good. It's nice to see the EB stones and dirts again, though there are still a bunch of aesthetic issues that need tweaking, but that can all get fixed later. (I'll document as much as I can and post in the MCF thread when I have time.)
I tried to generate worlds with as many mods that add world generation as possible (trees, plants, ores, behives etc..) and everything, save a few rare exceptions, seems to be working fine.

Keep up the good work. :)

commented

@srs-bsns I've had a mini-breakthrough in pinpointing the causes of these crashes RTG has been experiencing lately, so if you carry on testing, be sure to use this snapshot:

https://goo.gl/f9Hohg

Long story short, RTG's chunk provider wasn't always doing things 'by the book', so I've just been going through and fine-tuning it a bit. What little I've done so far seems to have resolved the RailCraft crash (#195), and I haven't experienced the Thaumcraft crash (#249) in the minimal testing I've done so far with the latest snapshot above.

I'm still making tweaks to the chunk provider, though, so if you still experience these crashes that you've detailed above, you might be better off waiting until the next release this weekend, as I should have everything sorted(ish) by then.

Those crashes could also be down to the fact that I haven't manually re-decorated all of the EB biomes yet. The Prairie biome, for example, is still calling EB's decorate() method, which we know RTG doesn't handle very well, and maybe having Thaumcraft in the mix is triggering it somehow.

Either way, thanks for taking the time to test the snapshot. The detailed feedback you've been providing is very much appreciated. Hopefully by the weekend I will have resolved all of the major crash issues, and then I'd love to get into those aesthetic issues you mentioned.

commented

@whichonespink44 I'm sorry I haven't been contributing here - my computer has killed itself at the moment and can't remain on without crashing for more than a minute.
Well done for getting it working. I'll try to remember to keep checking this issue on my phone in case you want to ask me something.

commented

@SMEZ1234 No worries man, it's all good! Sorry to hear about your computer. Been there myself a few times - never a good time ๐Ÿ˜ž

commented

@srs-bsns Those OOB crashes with Thaumcraft structure gen are now fixed in master - took ages to figure out what was going on, but got there in the end.

commented

Closing this, but feel free to comment on here if you need to.