Zeno410 / UndergroundBiomesConstructs1.10

Underground Biomes Constructs for Minecraft 10.2
7 stars 28 forks source link

Ores registered with non-unique ID's #4

Open mallrat208 opened 7 years ago

mallrat208 commented 7 years ago

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;
    }