BentoBoxWorld / Boxed

A game mode where you are boxed into a tiny space that only expands by completing advancements
Eclipse Public License 2.0
15 stars 4 forks source link

CraftChunkSnapshot.getBiome() called with y potentially out of range #45

Closed mtsr closed 1 year ago

mtsr commented 1 year ago

Expected behavior

Bukkit API docs for this method mention that y is minHeight inclusive, but maxHeight exclusive.

Observed/Actual behavior

https://github.com/BentoBoxWorld/Boxed/blob/54a559fc79367b151c19912f5df8b9af4e91ed0c/src/main/java/world/bentobox/boxed/generators/biomes/AbstractSeedBiomeProvider.java#L131 sets up y in a way that it can be maxHeight.

Changing this fixes some of the errors below (but I still get a few). That's probably just due to running 1.19.3, which I get, but the above seems to be an actual bug either way.

Steps/models to reproduce

crash-2023-01-06_20.11.11-server.txt

BentoBox version

BentoBox-1.22.0-SNAPSHOT-b2324.jar Boxed-2.0.2-SNAPSHOT-b133.jar

Plugin list

floodgate-spigot.jar BentoBox-1.22.0-SNAPSHOT-b2324.jar ViaBackwards-4.5.1.jar Vault.jar EssentialsX-2.20.0-dev+38-b323860.jar Multiverse-SignPortals-4.2.0.jar PlaceholderAPI-2.11.2.jar LuckPerms-Bukkit-5.4.55.jar Dynmap-3.5-beta-1-spigot.jar PaperTweaks.jar BoxedEyes-1.0.jar DragonFights-1.4.4.jar Multiverse-Inventories-4.2.3.jar Multiverse-NetherPortals-4.2.2.jar FastAsyncWorldEdit-Bukkit-2.5.1-SNAPSHOT-336.jar Multiverse-Portals-4.2.1.jar GeyserHacks.jar SleepFixer-2.0.2.jar Multiverse-Core-4.3.1.jar EssentialsXSpawn-2.20.0-dev+38-b323860.jar VoidGen-2.2.1.jar dynmap-mobs-1.3.jar PlayTime-3.5.jar Vivecraft_Spigot_Extensions.1.19.1.r1.zip worldborderapi-1.193.0.jar ViaVersion-4.5.1.jar

Other

No response

BONNe commented 1 year ago

Tastybento, why it is y * 4?

tastybento commented 1 year ago

This is a hack to overcome a bug in Spigot. I need to answer md5. https://hub.spigotmc.org/jira/plugins/servlet/mobile#issue/SPIGOT-7188

@mtsr Is correct with the exclusive limit and that must be fixed, but the mysterious *4 is there because biome copying doesn't work how you would expect without it right now.

mtsr commented 1 year ago

This is a hack to overcome a bug in Spigot. I need to answer md5. https://hub.spigotmc.org/jira/plugins/servlet/mobile#issue/SPIGOT-7188

Maybe add the link to the comment, so others can more easily find it? Although I realize Boxed probably doesn't see a lot of contributions.

@mtsr Is correct with the exclusive limit and that must be fixed, but the mysterious *4 is there because biome copying doesn't work how you would expect without it right now.

Yay.

In the meantime I realized that there's probably far more significant changes needed to make this work with 1.19.x. I'm running the other addons on 1.19.3, and since it's just for me and the kids, I don't feel like adding an extra server just for Boxed. Is the new version far enough along that there's things I could contribute?

I don't have enormous amounts of time, but I do have enough Java experience to be dangerous (it's not a language I use regularly, mainly).

tastybento commented 1 year ago

It mostly all works great with 1.19 right now so you can go ahead and play it. The reason I haven't done a release yet is that I was trying to find a way to do structures and have them detected by Advancements. Right now you can manually add structures to the seed world using /place and they will be copied to each player's Boxed area but they won't trigger an advancement when entering them. Where I ended up was that a data pack would be required. But that would be whole server affecting because you can't have world-specific data packs. I am still investigating all of this though. Right now what you could do is run and test the code and let me know if there are any weird things that happen with it.

mtsr commented 1 year ago

I'll try again with an even more minimal and completely clean server. But even after fixing the mentioned bug I was getting similar chunk system errors. I'll see if I can debug those as well.

Thanks!

tastybento commented 1 year ago

Yes, I've see those weird errors too. Make sure you're running on the latest build of Spigot (I use that as it's more up to date than Paper right now). I suspect some server issue, but you may find the bug in my code too!

mtsr commented 1 year ago

I get a slightly different error on a completely clean server, this is the full list of jars (all freshly downloaded from CI). Spigot is a completely fresh build using BuildTools latest.

Server started with aikar flags and with no flags at all give the same problem.

spigot-1.19.3.jar
plugins/BentoBox/addons/Likes-2.4.0-SNAPSHOT-b90.jar
plugins/BentoBox/addons/Warps-1.13.0-SNAPSHOT-b329.jar
plugins/BentoBox/addons/Chat-1.1.4.jar
plugins/BentoBox/addons/Boxed-2.0.2-SNAPSHOT-b136.jar
plugins/worldborderapi-1.193.0.jar
plugins/BentoBox-1.22.0-SNAPSHOT-b2327.jar
[17:45:00] [Server thread/INFO]: Preparing level "boxed_world"
[17:45:02] [Worker-Main-7/ERROR]: Failed to schedule load callback for chunk [27, -8]
java.util.concurrent.CompletionException: java.lang.NullPointerException: Cannot read field "snapshot" because the return value of "java.util.Map.get(Object)" is null
    at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315) ~[?:?]
    at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320) ~[?:?]
    at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1770) ~[?:?]
    at java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760) ~[?:?]
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) ~[?:?]
    at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) ~[?:?]
    at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) ~[?:?]
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) ~[?:?]
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) ~[?:?]
Caused by: java.lang.NullPointerException: Cannot read field "snapshot" because the return value of "java.util.Map.get(Object)" is null
    at world.bentobox.boxed.generators.chunks.AbstractBoxedChunkGenerator.getChunk(AbstractBoxedChunkGenerator.java:62) ~[?:?]
    at world.bentobox.boxed.generators.chunks.BoxedChunkGenerator.generateNoise(BoxedChunkGenerator.java:197) ~[?:?]
    at org.bukkit.craftbukkit.v1_19_R2.generator.CustomChunkGenerator.lambda$0(CustomChunkGenerator.java:269) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3638-Spigot-d90018e-7dcb59b]
    at org.bukkit.craftbukkit.v1_19_R2.generator.CustomChunkGenerator.lambda$1(CustomChunkGenerator.java:274) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3638-Spigot-d90018e-7dcb59b]
    at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
    ... 6 more
[17:45:02] [Server thread/ERROR]: Encountered an unexpected exception
net.minecraft.ReportedException: Exception initializing level
    at net.minecraft.server.MinecraftServer.initWorld(MinecraftServer.java:622) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3638-Spigot-d90018e-7dcb59b]
    at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:571) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3638-Spigot-d90018e-7dcb59b]
    at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:412) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3638-Spigot-d90018e-7dcb59b]
    at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:250) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3638-Spigot-d90018e-7dcb59b]
    at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:973) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3638-Spigot-d90018e-7dcb59b]
    at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:301) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3638-Spigot-d90018e-7dcb59b]
    at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.NullPointerException: Cannot read field "snapshot" because the return value of "java.util.Map.get(Object)" is null
    at world.bentobox.boxed.generators.chunks.AbstractBoxedChunkGenerator.getChunk(AbstractBoxedChunkGenerator.java:62) ~[?:?]
    at world.bentobox.boxed.generators.chunks.BoxedChunkGenerator.generateNoise(BoxedChunkGenerator.java:197) ~[?:?]
    at org.bukkit.craftbukkit.v1_19_R2.generator.CustomChunkGenerator.lambda$0(CustomChunkGenerator.java:269) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3638-Spigot-d90018e-7dcb59b]
    at org.bukkit.craftbukkit.v1_19_R2.generator.CustomChunkGenerator.lambda$1(CustomChunkGenerator.java:274) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3638-Spigot-d90018e-7dcb59b]
    at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
    at java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760) ~[?:?]
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) ~[?:?]
    at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) ~[?:?]
    at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) ~[?:?]
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) ~[?:?]
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) ~[?:?]
[17:45:02] [Server thread/ERROR]:   Cause of unexpected exception was
java.lang.NullPointerException: Cannot read field "snapshot" because the return value of "java.util.Map.get(Object)" is null
    at world.bentobox.boxed.generators.chunks.AbstractBoxedChunkGenerator.getChunk(AbstractBoxedChunkGenerator.java:62) ~[?:?]
    at world.bentobox.boxed.generators.chunks.BoxedChunkGenerator.generateNoise(BoxedChunkGenerator.java:197) ~[?:?]
    at org.bukkit.craftbukkit.v1_19_R2.generator.CustomChunkGenerator.lambda$0(CustomChunkGenerator.java:269) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3638-Spigot-d90018e-7dcb59b]
    at org.bukkit.craftbukkit.v1_19_R2.generator.CustomChunkGenerator.lambda$1(CustomChunkGenerator.java:274) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3638-Spigot-d90018e-7dcb59b]
    at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
    at java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760) ~[?:?]
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) ~[?:?]
    at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) ~[?:?]
    at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) ~[?:?]
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) ~[?:?]
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) ~[?:?]
tastybento commented 1 year ago

I revisited this today. I suspect, it may be caused by your JVM running out of memory and thus the weird errors because if I don't run it with appropriate flags, weird things do happen. Anyway, that's just a theory. Testing with the latest Paper or build of Spigot does work. That said, I did do some work on Boxed to improve the biomes. There is a known issue where changing the seed start coords does not work properly yet.

FWIW, here's my start script that allocates up to 12GB of RAM:

#!/bin/sh
java -Xms12G -Xmx12G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:InitiatingHeapOccupancyPercent=15 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true  -jar paper-1.19.3.jar nogui

Note that it takes about 3 minutes to initial boot as it builds the worlds. This is on a 16" MBP M1.

Hopefully, this works for you. Try the latest build from ci.bentobox.world.

haroldrc commented 1 year ago

same problem

tastybento commented 1 year ago

Same suggestion. If that doesn't work, share your setup.

haroldrc commented 1 year ago

https://pastebin.com/HWEVQ595

the server always crashes after i do the /boxed command.

steps to reproduce it: