Real-Gecko / BornToBe

GNU General Public License v3.0
0 stars 0 forks source link

[Request] Option to disable villager renaming #1

Open Luke616 opened 6 years ago

Luke616 commented 6 years ago

See title, the feature where a villager's name is replaced with its profession raises conflicts with the Village Names mod (it overwrites VN's custom villager names) and also causes some weirdness with VTT (a custom villager type with an improper name will cause the villager to be names something like entity.Villager.name)

Attached is an image of this second issue. Thanks again for this mod, its absolutely required for servers running VTT.

2018-03-13_19 10 35

Real-Gecko commented 6 years ago

If you point me to Forge API event that happens only once when villager joins the world for the first time, I'll gladly remove this "feature". But I found only one event where you can somehow control villagers profession, which is EntityJoinWorldEvent that is fired everytime chunk with this entity loaded. So to prevent all farmers from shifting their profession I came up with this trick: give every villager that has been already processed once a custom name

villager.setCustomNameTag(name.getUnformattedComponentText());

Next time event is fired on the same villager once again we already know that this villager had a chance for shift and skip:

if (e.getEntity().hasCustomName()) return;

As for custom professions names, here's good article in VTT wiki that describes how to give your custom professions nice looking career names.

Luke616 commented 6 years ago

Thank you very much for the article link! Admittedly I know very little about the way forge handles these things. Is there some way you could assign every villager the first time it is "processed" some sort of NBT tag, which is checked for instead of the custom name?

Real-Gecko commented 6 years ago

I tried it, but it did not work, some digging through Forge source codes showed that it's pretty tricky, so I decided to go easy way.

Luke616 commented 6 years ago

I see. Well, thanks for the explanation - wish I could help more but I'm certainly not a modder. A bit of reading in the forge documentation pointed me to these pages, which might have more information on how to implement this type of feature. You've probably already read this stuff though, ah well. https://mcforge.readthedocs.io/en/latest/datastorage/extendedentityproperties/ https://mcforge.readthedocs.io/en/latest/datastorage/capabilities/

Real-Gecko commented 6 years ago

OK, I'll see what can be done, but no promises.