Mystical World

Mystical World

24M Downloads

Crash with Chunk Pregenerator while pre-genning

BugmanBugman opened this issue · 4 comments

commented

https://paste.dimdev.org/uvacoqumoc.mccrash

Pregenning also causes any spawners in the structures to become structure blocks, and the chests won't work

commented

This is an issue with Chunk Pregenerator, although the author refuses to admit fault and instead blames it on me for causing cascading chunk generation(?).

The root problem is that I have placed & created a spawner or chest, but the tile entity has not been instantiated for it by the time it gets to the point at which I want to set the mob to be spawned/the loot table for the chest to use.

This is despite the fact that world.setBlockState is returning true, despite the fact that I am attempting 10 times (as noted in the crash) to properly set the state of the object. As far as I am aware, despite Speiger telling me that "this is a problem everyone causes and you see it even in Vanilla", there are no circumstances under which my chest/spawner should be created and a tile entity not also created for them. Indeed, I turned the generation rates up as high as they would go and sprinted across the world as quickly as I could, and I was unable to cause the issue using vanilla generation.

My assumption (and I have no desire to dig into Chunk Pregenerator's code) is that considerable "hackiness" is involved and the creation of tile entities is deferred until a later point -- after block states have already been set, but not before our code for interacting with those tile entities are called.

The only solution here is to somehow defer the set-up of chests/spawners until that point, but as far as I'm aware there is no way to do this in Forge, especially with the IWorldGenerator, and Speiger has yet to provide any information on how best to do this.

In summary: don't use Chunk Pregenerator. It might be fast, but the moment something tries to do something the author hasn't accounted for, it just gets discarded and chunk generation continues as though it were a steam-roller.

Instead, try the Forge pregeneration commands, although they are poorly documented and not as fast the issue you describe never occurred for me in all my testing attempts.

commented
commented

Yep your issue. I am not even touching how worldgen is done itself. I am just asking the world to generate chunks. A bit different then forge does yes, but not different enough to actually cause this issue.
Your issue is:

  • Placing a Chest.
  • BlockAdded in Chest is called. (After block is placed but before the TileEntity actually exists)
  • BlockAdded request nearby blocks without checking if the chunks exist.
  • BlockAdded loads a new chunk and triggers worldgen.
  • BlockAdded causes the chest to be replaced.
  • Your TileEntity not checking if it actually is itself. And game crashes
commented

Thanks for a much more succinct summary of what you believe the issue. I believe I can actually work with this.

BlockAdded causes the chest to be replaced.
Your TileEntity not checking if it actually is itself. And game crashes

It actually is checking if it is actually itself, not to mention the fact that the chest is inside of an already-placed (previously in the code) NBT template. I still fail to understand how Minecraft's template placement doesn't call a cascade, but when I change a blockstate inside the template, I do. I fail to understand the issue.

I can easily change the generation code's checks for tile entity placement to check the blockstate to see if it has actually changed, and remove the forced crash instead just silently letting things happen.

However, if it were something that happened in regular chunk generation, then I am sure I would get a lot more reports on this issue. Every single report on this issue I've had, has to do with Chunk Pregenerator.

Forgive me for seeing a link between your mod and this issue, but there is something about the nature of how your mod works that seems to cause this to happen frequently in comparison to the Forge standard generator or standard world generation.