hollow-cube / minestom-ce

1.20.4 Lightweight Minecraft server
https://minestom.net
Apache License 2.0
107 stars 35 forks source link

[1.20.4] AnvilLoader crashes on minecraft:grass #93

Closed MelonHell closed 10 months ago

MelonHell commented 10 months ago

AnvilLoader crashes on minecraft:grass

java.lang.NullPointerException
    at java.base/java.util.Objects.requireNonNull(Objects.java:233)
    at net.minestom.server.instance.AnvilLoader.loadSections(AnvilLoader.java:228)
    at net.minestom.server.instance.AnvilLoader.loadMCA(AnvilLoader.java:125)
    at net.minestom.server.instance.AnvilLoader.loadChunk(AnvilLoader.java:86)
    at ru.melonhell.dmndsrc.impl.cstrike.WorldModule$CustomLoader.loadChunk(WorldModule.kt:30)
    at net.minestom.server.instance.InstanceContainer.lambda$retrieveChunk$6(InstanceContainer.java:294)

I think you can add something like this to AnvilLoader

if (blockName.equals("minecraft:grass")) {
    blockName = "minecraft:short_grass";
}
MelonHell commented 10 months ago

https://github.com/DiamondSrc/Minestom/commit/19c45a5269b8602f1beb4eef047e0406bdc3ab16

davidmayr commented 10 months ago

I personally don't think this is a good idea. The exception should be replaced with a warning, but minestom should not be responsible for adding minecraft data converters to the loaders. They did this sort of change in 1.17 (I think? With pathblocks) and they are going to do it again.

Minestom should not implement world raw patches like minecraft does, imo. What you could do however is make a PR for a DataFixer API where it is possible to hook into the anvil loaders loading mechanism to patch worlds.

Then everyone can implement these patches themselves or use libraries like my https://github.com/cafestube/ExternalDataConverter/ to patch the worlds

mworzala commented 10 months ago

I am in agreement that Minestom should not be responsible for converting old worlds. It should work on the version Minestom is currently on and any behavior from other versions is undefined.