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

Ores registered with non-unique ID's #4

Open
mallrat208 opened this issue Mar 5, 2017 · 0 comments
Open

Ores registered with non-unique ID's #4

mallrat208 opened this issue Mar 5, 2017 · 0 comments

Comments

@mallrat208
Copy link

mallrat208 commented Mar 5, 2017

UBC Version:
UndergroundBiomesConstructs-1.10-0.9-beta.16

I've run into a small problem while porting UBC Ore Registrar to 1.10.2.

Currently when an Ore is registered if it has no meta value or has a value of 0 the resulting blocks id is going to be based off of the original blocks registry name.

For example "thermalfoundation:ore" would result in "ubcores:sedimentary_stone_ore" .. which is fine.
The problem is that "immersiveengineering:ore" also results in "ubcores:sedimentary_stone_ore" which will cause a crash since we're attempting to register a new block to the same existing id.

This is from Lines 20-27 in OreEntry.java

    private static String name(Block baseStone, Block baseOre, int meta) {
        if (meta == UBOre.NO_METADATA|| meta == 0) {
            return baseStone.getRegistryName().getResourcePath() + "_" + baseOre.getRegistryName().getResourcePath();
        }
        ItemStack stack = new ItemStack(baseOre,1,meta);
        String name = stack.getUnlocalizedName();
        return baseStone.getRegistryName().getResourcePath() + "_" + name;
    }

There are a few ways to fix this. The easiest option would be to use the same naming scheme for Meta = 0 as you do for Meta >0. This will however break vanilla ores in existing worlds as their name will change as well as any registered modded ores. While not ideal, an exception can be made if the Resource Domain is equal to "minecraft" to prevent any breakage to vanilla stuff atleast. Something like this...

    private static String name(Block baseStone, Block baseOre, int meta) {
        if (baseOre.getRegisteryName().getDomain().equals("minecraft")) {
            return baseStone.getRegistryName().getResourcePath() + "_" + baseOre.getRegistryName().getResourcePath();
        }
        ItemStack stack = new ItemStack(baseOre,1,meta);
        String name = stack.getUnlocalizedName();
        return baseStone.getRegistryName().getResourcePath() + "_" + name;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant