Impelon / Disenchanter

A small Mod for MinecraftForge essentially adding a block to disenchant items.
https://minecraft.curseforge.com/projects/the-disenchanter-mod
BSD 2-Clause "Simplified" License
7 stars 13 forks source link

Custom StateMapper with UnlocalizedName #12

Closed Impelon closed 6 years ago

Impelon commented 7 years ago

As I've mentioned in this commit (https://github.com/Impelon/Disenchanter/commit/a35951b95d2667f3b083118092b227ce1dac6af8), I have registered the DisenchantmentTable with a custom StateMapper in 1.8.9+. This is because I do not want to (and I'm not supposed to) change the registry name, but I want all my files to be lowercase (as is enforced in 1.11).

So what I've done is that the UnlocalizedName is the RegistryName, but lowercase.

this.setRegistryName(DisenchanterMain.MODID, "disenchantmentTable");
this.setUnlocalizedName(this.getRegistryName().toString().toLowerCase());

This worked fine for the language files, and item models (that needed registering anyways). But for the Blockmodels I was forced to do the hacky stuff using substring/splits/etc. I did in the CombinedClientProxy.

new ModelResourceLocation(disenchantmentTable.getUnlocalizedName()
.substring(5), state.toString().split("[\\[\\]]")[1])

I'm wondering if my solution is considered bad practice and if there is a better solution... Anyone?

Impelon commented 6 years ago

I'm really struggling to think of a good solution here, to be honest... Does anyone have an idea how to get the name of your variants?

Impelon commented 6 years ago

So, from the bit of research that I have done, it seems that the custom state mapper/custom model location is the cause of all the above. Though: The issues only occur, if the respective mod also does something wrong when registering the textures/models. For example Buildcraft seems to have fixed this by using ModelBakeEvent and State Mappers together...

Impelon commented 6 years ago

Will be fixed in the 1.6 update.

Impelon commented 6 years ago

Fixed in all affected versions!