Terra: [Bug] Chunk gen NPE when resources are reloaded before safe stronghold data creation

Pre-Issue Checklist

  • I have checked that I am on the latest version of Terra.
  • I have searched the github issue tracker for similar issues, including closed ones.
  • I have made sure that this is not a bug with another mod or plugin, and it is Terra that is causing the issue.
  • I have checked that this is an issue with Terra and not an issue with the pack I am using.
  • I have attached a copy of the latest.log file
  • I have filled out and provided all the appropriate information.

Environment

Name Value
Terra Version 6.1.2-BETA
Platform / Platform Version Current: git-Purpur-1684 (MC: 1.19)*
Any External Plugins or Mods AuctionHouse, BanItem, BetonQuest, Brewery, ChestSort, Chunky, Citizens, CitizensText, CommandAPI, ConditionalTextPlaceholders, CoreProtect, CraftBook, CrazyCrates, dynmap, Dynmap-Towny, Dynmap-WorldGuard, eco, EcoEnchants, Essentials, EssentialsChat, EssentialsSpawn, FarmControl, GemsEconomy, HeadDatabase, helper, helper-profiles, helper-sql, InventoryRollbackPlus, ItemsAdder, LangUtils, LevelledMobs, LocketteX, LoneLibs, LuckPerms, MMOExpansion, MMOItems, ModelEngine, MoeCore, MoeUtils, MultiChat*, Multiverse-Core, Multiverse-NetherPortals, MythicLib, MythicMobs, OpenInv, PlaceholderAPI, ProtocolLib, RandomTeleport (FUBSRandomTeleport), RPGInventory, ShowItem, SiegeWar, spark, TAB-Bridge, Terra, Towny, TownyChat, TownyFlight, Vault, VillagerMarket, VoidGen, WorldEdit, WorldGuard, WorldGuard-Towny
Terra Packs In Use OVERWORLD@1.1.1
Terra Addons In Use https://pastebin.com/942tMKdb

Issue Description

Hi, I’m new to Terra and I encountered some problem with Terra (really love this plugin). When generating terrain using the plugin Chunky or just moving around, the errors randomly appear. The config of Terra is all default. I searched in the discord and I found another user has the same issue as mine (https://discord.com/channels/715448651786485780/765260067812540416/990301360274669618)

Steps to reproduce

Create a new world using Terra and move around / use Chunky to generate the world. To better reproduce the error, restart the server and continue the chunk generation might help. Sometimes it does not appear but once appear the error is just so long…

Expected behavior

There should be no errors…

Actual behavior

When generating terrain using the plugin Chunky or just moving around, the errors randomly appear.

Updated 7/7/2022: Server crash log -> https://pastebin.com/6VHj33xq (sorry I forgot to put it here in the first place)

Full stacktrace

latest.log: https://pastebin.com/RRybGKv1

Exception Stacktrace
[17:35:15] [Worker-Main-1/ERROR]: Failed to schedule unload callback for chunk [-3, -17]
java.util.concurrent.CompletionException: net.minecraft.ReportedException: Exception generating new chunk
	at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315) ~[?:?]
	at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320) ~[?:?]
	at java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1159) ~[?:?]
	at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482) ~[?:?]
	at net.minecraft.server.level.ChunkTaskPriorityQueueSorter.lambda$message$1(ChunkTaskPriorityQueueSorter.java:51) ~[?:?]
	at net.minecraft.util.thread.ProcessorMailbox.pollTask(ProcessorMailbox.java:87) ~[?:?]
	at net.minecraft.util.thread.ProcessorMailbox.pollUntil(ProcessorMailbox.java:141) ~[?:?]
	at net.minecraft.util.thread.ProcessorMailbox.run(ProcessorMailbox.java:96) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
	at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: net.minecraft.ReportedException: Exception generating new chunk
	at net.minecraft.server.level.ChunkTracker.lambda$scheduleChunkGeneration$37(ChunkTracker.java:1305) ~[?:?]
	at com.mojang.datafixers.util.Either$Left.map(Either.java:38) ~[purpur-1.19.jar:?]
	at net.minecraft.server.level.ChunkTracker.lambda$scheduleChunkGeneration$39(ChunkTracker.java:1286) ~[?:?]
	at java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1150) ~[?:?]
	... 8 more
Caused by: java.lang.NullPointerException: Cannot invoke "com.dfsek.terra.api.util.generic.Lazy.value()" because the return value of "java.util.Map.get(Object)" is null
	at com.dfsek.terra.bukkit.nms.v1_19_R1.NMSChunkGeneratorDelegate.a(NMSChunkGeneratorDelegate.java:163) ~[Terra-bukkit-6.1.2-BETA.jar:?]
	at net.minecraft.world.level.levelgen.structure.placement.ConcentricRingsStructurePlacement.isPlacementChunk(ConcentricRingsStructurePlacement.java:62) ~[purpur-1.19.jar:git-Purpur-1684]
	at net.minecraft.world.level.levelgen.structure.placement.StructurePlacement.isStructureChunk(StructurePlacement.java:63) ~[purpur-1.19.jar:git-Purpur-1684]
	at net.minecraft.world.level.chunk.ChunkGenerator.lambda$createStructures$19(ChunkGenerator.java:771) ~[purpur-1.19.jar:git-Purpur-1684]
	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[?:?]
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[?:?]
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[?:?]
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[?:?]
	at java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(AbstractList.java:720) ~[?:?]
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[?:?]
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[?:?]
	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[?:?]
	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[?:?]
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]
	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[?:?]
	at net.minecraft.world.level.chunk.ChunkGenerator.createStructures(ChunkGenerator.java:756) ~[purpur-1.19.jar:git-Purpur-1684]
	at net.minecraft.world.level.chunk.ChunkStatus.lambda$static$2(ChunkStatus.java:51) ~[purpur-1.19.jar:git-Purpur-1684]
	at net.minecraft.world.level.chunk.ChunkStatus.generate(ChunkStatus.java:275) ~[purpur-1.19.jar:git-Purpur-1684]
	at net.minecraft.server.level.ChunkTracker.lambda$scheduleChunkGeneration$37(ChunkTracker.java:1288) ~[?:?]
	at com.mojang.datafixers.util.Either$Left.map(Either.java:38) ~[purpur-1.19.jar:?]
	at net.minecraft.server.level.ChunkTracker.lambda$scheduleChunkGeneration$39(ChunkTracker.java:1286) ~[?:?]
	at java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1150) ~[?:?]
	... 8 more
[17:35:15] [Worker-Main-1/ERROR]: Failed to schedule load callback for chunk [-3, -17]
java.util.concurrent.CompletionException: net.minecraft.ReportedException: Exception generating new chunk
	at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315) ~[?:?]
	at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320) ~[?:?]
	at java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1159) ~[?:?]
	at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482) ~[?:?]
	at net.minecraft.server.level.ChunkTaskPriorityQueueSorter.lambda$message$1(ChunkTaskPriorityQueueSorter.java:51) ~[?:?]
	at net.minecraft.util.thread.ProcessorMailbox.pollTask(ProcessorMailbox.java:87) ~[?:?]
	at net.minecraft.util.thread.ProcessorMailbox.pollUntil(ProcessorMailbox.java:141) ~[?:?]
	at net.minecraft.util.thread.ProcessorMailbox.run(ProcessorMailbox.java:96) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
	at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: net.minecraft.ReportedException: Exception generating new chunk
	at net.minecraft.server.level.ChunkTracker.lambda$scheduleChunkGeneration$37(ChunkTracker.java:1305) ~[?:?]
	at com.mojang.datafixers.util.Either$Left.map(Either.java:38) ~[purpur-1.19.jar:?]
	at net.minecraft.server.level.ChunkTracker.lambda$scheduleChunkGeneration$39(ChunkTracker.java:1286) ~[?:?]
	at java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1150) ~[?:?]
	... 8 more
Caused by: java.lang.NullPointerException: Cannot invoke "com.dfsek.terra.api.util.generic.Lazy.value()" because the return value of "java.util.Map.get(Object)" is null
	at com.dfsek.terra.bukkit.nms.v1_19_R1.NMSChunkGeneratorDelegate.a(NMSChunkGeneratorDelegate.java:163) ~[Terra-bukkit-6.1.2-BETA.jar:?]
	at net.minecraft.world.level.levelgen.structure.placement.ConcentricRingsStructurePlacement.isPlacementChunk(ConcentricRingsStructurePlacement.java:62) ~[purpur-1.19.jar:git-Purpur-1684]
	at net.minecraft.world.level.levelgen.structure.placement.StructurePlacement.isStructureChunk(StructurePlacement.java:63) ~[purpur-1.19.jar:git-Purpur-1684]
	at net.minecraft.world.level.chunk.ChunkGenerator.lambda$createStructures$19(ChunkGenerator.java:771) ~[purpur-1.19.jar:git-Purpur-1684]
	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[?:?]
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[?:?]
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[?:?]
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[?:?]
	at java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(AbstractList.java:720) ~[?:?]
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[?:?]
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[?:?]
	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[?:?]
	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[?:?]
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]
	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[?:?]
	at net.minecraft.world.level.chunk.ChunkGenerator.createStructures(ChunkGenerator.java:756) ~[purpur-1.19.jar:git-Purpur-1684]
	at net.minecraft.world.level.chunk.ChunkStatus.lambda$static$2(ChunkStatus.java:51) ~[purpur-1.19.jar:git-Purpur-1684]
	at net.minecraft.world.level.chunk.ChunkStatus.generate(ChunkStatus.java:275) ~[purpur-1.19.jar:git-Purpur-1684]
	at net.minecraft.server.level.ChunkTracker.lambda$scheduleChunkGeneration$37(ChunkTracker.java:1288) ~[?:?]
	at com.mojang.datafixers.util.Either$Left.map(Either.java:38) ~[purpur-1.19.jar:?]
	at net.minecraft.server.level.ChunkTracker.lambda$scheduleChunkGeneration$39(ChunkTracker.java:1286) ~[?:?]
	at java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1150) ~[?:?]
	... 8 more

Additional details

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 31 (10 by maintainers)

Most upvoted comments

Oh, I think that may be the culprit

Of course, as mentioned above, this doesn’t explain other plugins (might be worth looking into ProtocolLib? Both logs above that didn’t have the CommandAPI did have ProtocolLib). This also leads to whether Terra naturally supports regular /minecraft:reload or not - might be worth trying without the CommandAPI and using /minecraft:reload.

This may be completely irrelevant, but I thought I’d mention it anyway: the CommandAPI performs a post-server load resources reload. That is, after the server has finished loading, the CommandAPI triggers a modified internal /minecraft:reload, which will reload all resources. I’m not sure if this also reloads world generators, but that’s a possibility.

More info can be found here: https://github.com/JorelAli/CommandAPI/blob/master/commandapi-nms/commandapi-1.19-common/src/main/java/dev/jorel/commandapi/nms/NMS_1_19_Common.java#L634

This doesn’t explain the cases where this issue can arise without the CommandAPI, but it might help point things in the right direction?

(I’m currently on holiday, so I haven’t investigated this issue personally, but this may help!)

@willkroboth have you told Terra/Bukkit to override the regular worldgen in the ‘Bukkit.yml’ file?

You need to add

worlds:
  world:
    generator: Terra:OVERWORLD

for it to work as the generator.

@Akiranya Temporary fix is disable CommandAPI.