piegamesde / BlockMap

An out-of-game map renderer and viewer for Minecraft 1.13–1.18 worlds [unmaintained]
MIT License
91 stars 22 forks source link

Cannot read field "pins" because "helper" is null #61

Closed uncovery closed 3 years ago

uncovery commented 3 years ago

Environment info

Description

On one among several worlds, I am getting the following error:

ava.lang.NullPointerException: Cannot read field "pins" because "helper" is null
    at de.piegames.blockmap.world.RegionFolder$SavedRegionFolder.<init>(RegionFolder.java:293)
    at de.piegames.blockmap.world.RegionFolder$LocalRegionFolder.<init>(RegionFolder.java:355)
    at de.piegames.blockmap.world.RegionFolder$CachedRegionFolder.<init>(RegionFolder.java:442)
    at de.piegames.blockmap.world.RegionFolder$CachedRegionFolder.create(RegionFolder.java:551)
    at de.piegames.blockmap.standalone.CommandLineMain$CommandRender.call(CommandLineMain.java:236)
    at de.piegames.blockmap.standalone.CommandLineMain$CommandRender.call(CommandLineMain.java:113)
    at picocli.CommandLine.executeUserObject(CommandLine.java:1933)
    at picocli.CommandLine.access$1100(CommandLine.java:145)
    at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2332)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2326)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2291)
    at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2159)
    at picocli.CommandLine.execute(CommandLine.java:2058)
    at de.piegames.blockmap.standalone.CommandLineMain.mainWithoutQuit(CommandLineMain.java:399)
    at de.piegames.blockmap.standalone.CommandLineMain.main(CommandLineMain.java:403)

Steps to reproduce

I cannot instruct how to reproduce without uploading the whole world somewhere. Is there a chance to make a test for "helper" being null in the code and outputting which file is making trouble?

I tried to compile it myself but my Java skills are close to zero so I could not get it done. Compiling works but running throws this here:

java.lang.IllegalArgumentException: Did not find internal color map default
        at de.piegames.blockmap.color.BlockColorMap.loadInternal(BlockColorMap.java:348)
.....
saibotk commented 3 years ago

Did you compile it with our gradle tasks?

Because besides compiling the code, there is also a task that downloads and regenerates the colormaps from the minecraft files.

piegamesde commented 3 years ago

Yes, if you want to run it yourself see https://github.com/Minecraft-Technik-Wiki/BlockMap#run-it . Essentially, you should run ./gradlew regenerate and then it should work.

For reproduction, it'd be cool if you found a small example world that fails. But more importantly, please post the commands you are running that give you this result. Together with the stack trace, this should hopefully be enough for me to figure out what's going wrong.

uncovery commented 3 years ago

The command I am using is this:

/etc/alternatives/jre_16/bin/java -jar /folder/BlockMap-cli-2.2.1.jar render -f /folder/kingdom --create-big-image --min-X=-3264 --max-X=3264 --min-Z=-3264 --max-Z=3264 -o /folder/png --create-tile-html

uncovery commented 3 years ago

regenerate works. but then when I do the next one it fails.

gradlew :BlockMap-cli:run

> Configure project :BlockMap-gui
Project :BlockMap-gui => no module-info.java found

> Configure project :BlockMap-internal
Project :BlockMap-internal => no module-info.java found

> Task :BlockMap-cli:run FAILED
Missing required subcommand
Usage: blockmap [-hvV] COMMAND
  -h, --help      Print this help message and exit
  -v, --verbose   Be chatty
  -V, --version   Print version information and exit.
Commands:
  render       Render a folder containing region files to another folder
                 through the command line interface
  render-many  Render multiple worlds using a configuration file for usage in
                 servers

This is the command line interface of blockmap. To access the GUI (if
installed), run `blockmap-gui`.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':BlockMap-cli:run'.
> Process 'command 'C:\Program Files\Java\jdk-11\bin\java.exe'' finished with non-zero exit value 2

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1s
6 actionable tasks: 4 executed, 2 up-to-date
piegamesde commented 3 years ago

That already looks promising. You can now pass command line arguments to the application. Doing so through Gradle is a bit unweildy because of potential escaping issues: ./gradlew :BlockMap-cli:run --args="render -f /folder/kingdom --create-big-image --min-X=-3264 --max-X=3264 --min-Z=-3264 --max-Z=3264 -o /folder/png --create-tile-html"


Regarding the issue, there should be a rendered.json.gz file in your output folder. It seems to be broken, please send me its content. You may also try deleting it and see if it helps.

uncovery commented 3 years ago

There is no rendered.json.gz in the folders anywhere. I can't find any .gz files and no file called rendered.*

I cannot run the command since I have only managed to coax my local windows machine to run Java 12 to make the compiling possible, my CentOS production machine where the world is located does not have Java 12 and all the commands fail with either Java 11 or 16 and I cannot figure out how to install java 12 on the production machine only for the gradle commands without setting it as a default for everything and screwing with too many other things in return.

piegamesde commented 3 years ago

Things are starting to get really weird. The application should create a /folder/png output folder and a rendered.json.gz in it. If you already run the command previously, the one already existing should be used instead.

Please try running in a clean output directory, just to make sure no corrupt files are causing this. After that /folder/png/rendered.json.gz should definitely exist as the error happens later, and the unzipped content should be {regions:[]}.

uncovery commented 3 years ago

Ah ok, I thought that .gz is a part of the compile output, not the run. I'll check that and get back to you.

uncovery commented 3 years ago

ok so., problem solved....

under java 16, the rendered.json.gz from the initial error report was empty. I deleted it, and everything went fine.

What I finally suggest is to change the related function like this to tell what is wrong

        /**
         * Loads a json file that contains the information about all rendered files.
         *
         * @see #parseSaved(JsonElement)
         */
        protected SavedRegionFolder(T file) throws IOException {
            this.basePath = file;
            SavedRegionHelper helper = load(file);
                        if (helper == null) {
                            throw new IllegalArgumentException("invalid file " + file.toString() + ", please remove");
                        }
            pins = Optional.ofNullable(helper.pins);
            regions = Optional.ofNullable(helper.regions)
                    .stream().flatMap(Collection::stream)
                    .collect(Collectors.toMap(r -> new Vector2i(r.x, r.z), Function.identity()));
            timestamp = helper.timestamp;
            isNether = helper.isNether;
        }

This then points the user to the defect file and the problem is solved.

piegamesde commented 3 years ago

Yes, thank you. To be honest, I'm astonished that an empty file serializes to null instead of throwing a DeserializationException for invalid JSON.