Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweaking copper ore Crashes on world gen #55

Closed
Cracks777 opened this issue Apr 4, 2022 · 11 comments
Closed

Tweaking copper ore Crashes on world gen #55

Cracks777 opened this issue Apr 4, 2022 · 11 comments
Assignees
Labels
Bug Bug or issue

Comments

@Cracks777
Copy link

Cracks777 commented Apr 4, 2022

Minecraft Version

1.18.2

Forge Version

forge-1.18.2-40.0.36

Mod Version

OreTweaker-1.18.2-3.1.0

Describe the bug

When editing the config to lower copper ore gen it crashes the game when creating a new world

How to reproduce

change "maxVeinSize": 10 and"spawnRate": 8.0,, create new world and it will crash

**Link to [crashlog]

https://pastebin.com/SaT8k62L

@Cracks777 Cracks777 changed the title Tweaking copper ore Crashes on world gen[Bug] Relevant title here Tweaking copper ore Crashes on world gen Apr 4, 2022
@EwyBoy
Copy link
Owner

EwyBoy commented Apr 4, 2022

Can you send me a link to a pastbin of your copper json file?

@EwyBoy EwyBoy added Under Investigation Issue is being investigated.. Potential Bug Potential bug or issue labels Apr 4, 2022
@Cracks777
Copy link
Author

https://pastebin.com/CmyXeXj2

it only happens when changing the values for dripstone caves.

@EwyBoy
Copy link
Owner

EwyBoy commented Apr 4, 2022

I will look into it first thing after I get home from work.
But it looks like there could be an issue with TerraBlender.

OreTweaker does not really like mods that change to much things about world generation.

@Cracks777
Copy link
Author

it crashes without terrablender also

@EwyBoy
Copy link
Owner

EwyBoy commented Apr 4, 2022

Okey, good to know. Then its not Terrablenders fault.
I will do some testing once and get back to you.

@Cracks777
Copy link
Author

Ok did some more testing, if you change values for both entries it will crash, if you only change one or the other it does not crash, here the json that causes the crash

https://pastebin.com/0EK9MSYP

i removed bop and terrablender and still get the crash, thank you for looking into this.

@EwyBoy
Copy link
Owner

EwyBoy commented Apr 4, 2022

Found the issue @Cracks777.

Ore Tweaker uses the properties in the copper_ore.json 📃 to generate a unique name for the ore object being registered to the game.

The exact alogritem for creating a unique name I use is:

String registryName = String.format("%s_%s_%s_%s_%s_%s_feature",
                Objects.requireNonNull(ore.getRegistryName()).getPath(),
                fillerName,
                minY,
                maxY,
                spawnRate,
                maxVeinSize
        );

But since both your entries have the exact same values for these probs the second entry ends up with a duplicated name of the first one. I am releasing a simple fix to check if a name is available, if not it will auto append a number behind it to not collide with the name of the first entry. This was a design flaw when I designed this system.

Thanks for finding it.
Will prob have to backport this to 1.16, 1,17, and 1.18. Working on a fix now. Until then you can change one of these probs to make it magically work again 🥳🥳

@EwyBoy EwyBoy added Bug Bug or issue and removed Under Investigation Issue is being investigated.. Potential Bug Potential bug or issue labels Apr 4, 2022
@EwyBoy EwyBoy closed this as completed in 16a0949 Apr 4, 2022
@EwyBoy EwyBoy reopened this Apr 4, 2022
@EwyBoy
Copy link
Owner

EwyBoy commented Apr 4, 2022

Created a test build if you want to validate that it works for you now.
https://github.com/EwyBoy/OreTweaker/releases/tag/v1.18.2-Fix-Test

If its stable I will release it on CurseForge tomorrow for 1.16, 1.17 and 1.18.1/2

@EwyBoy
Copy link
Owner

EwyBoy commented Apr 4, 2022

New code should make it impossible to create duplicates.

private static String makeRegistryNameUnique(String name) {
        if (registryNames.contains(name)) {
            int i = 1;
            while (registryNames.contains(name + "_" +  i)) {
                i++;
            }
            return name + "_" +  i;
        }
        return name;
    }

    private static final List<String> registryNames = new ArrayList<>();

    private static String createUniqueRegistryName(Block block, String filler, int minY, int maxY, float spawnRate, int maxVeinSize, float discardChanceOnAirExposure, String distribution, boolean isDeepSlate, String featureType) {

        String registryName;

        if (isDeepSlate) {
            registryName = String.format("deepslate_%s_%s_%s_%s_%s_%s_%s_%s_%s_feature",
                    Objects.requireNonNull(block.getRegistryName()).getPath(),
                    filler,
                    minY,
                    maxY,
                    spawnRate,
                    maxVeinSize,
                    discardChanceOnAirExposure,
                    distribution,
                    featureType
            );
        } else {
            registryName = String.format("ore_%s_%s_%s_%s_%s_%s_%s_%s_%s_feature",
                    Objects.requireNonNull(block.getRegistryName()).getPath(),
                    filler,
                    minY,
                    maxY,
                    spawnRate,
                    maxVeinSize,
                    discardChanceOnAirExposure,
                    distribution,
                    featureType
            );
        }

        registryName = makeRegistryNameUnique(registryName);
        ModLogger.debug("Registry Name: " + registryName);
        registryNames.add(registryName);

        return registryName;
    }

@Cracks777
Copy link
Author

yes, It worked just fine. thank you for the fast response.

EwyBoy pushed a commit that referenced this issue Apr 7, 2022
EwyBoy pushed a commit that referenced this issue Apr 7, 2022
EwyBoy pushed a commit that referenced this issue Apr 7, 2022
@EwyBoy
Copy link
Owner

EwyBoy commented Apr 7, 2022

Fixed for 1.16, 1.18.1 and 1.18.2

https://www.curseforge.com/minecraft/mc-mods/ore-tweaker/files

@EwyBoy EwyBoy closed this as completed Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug or issue
Projects
None yet
Development

No branches or pull requests

2 participants