Method local inner record decompiled into wrong location

Open
#131 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
java
Domain
devtools

Research direction

Start by reproducing the decompilation of net.minecraft.world.level.levelgen.WorldDimensions.bake from the vanilla Minecraft 1.19.3 example. Trace how ForgeFlower handles the method-local record Entry and compare the generated location with the source structure; done means the record is emitted in the correct scope and the example decompiles consistently.

Written by the indexing model from the issue text.

Description

In the vanilla minecraft server source (1.19.3), in net.minecraft.world.level.levelgen.WorldDimensions (mojang mappings) the following happens when decompiling
image

public WorldDimensions.Complete bake(Registry<LevelStem> existingRegistry) {
        Stream<ResourceKey<LevelStem>> stream = Stream.concat(existingRegistry.registryKeySet().stream(), this.dimensions.registryKeySet().stream()).distinct();
        List<Entry> list = new ArrayList<>();
        keysInOrder(stream).forEach((key) -> {
            existingRegistry.getOptional(key).or(() -> {
                return this.dimensions.getOptional(key);
            }).ifPresent((dimensionOptions) -> {
                record Entry(ResourceKey<LevelStem> key, LevelStem value) {
                    Lifecycle lifecycle() {
                        return WorldDimensions.checkStability(this.key, this.value);
                    }
                }

                list.add(new Entry(key, dimensionOptions));
            });
        });
        Lifecycle lifecycle = list.size() == VANILLA_DIMENSION_COUNT ? Lifecycle.stable() : Lifecycle.experimental();
        WritableRegistry<LevelStem> writableRegistry = new MappedRegistry<>(Registries.LEVEL_STEM, lifecycle);
        list.forEach((entry) -> {
            writableRegistry.register(entry.key, entry.value, entry.lifecycle());
        });
        Registry<LevelStem> registry = writableRegistry.freeze();
        PrimaryLevelData.SpecialWorldProperty specialWorldProperty = specialWorldProperty(registry);
        return new WorldDimensions.Complete(registry.freeze(), specialWorldProperty);
    }
Dominant language
No language data
Stars
110
Forks
49
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from MinecraftForge/ForgeFlower

All issues in MinecraftForge/ForgeFlower

Similar issues

More DevTools issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.