[1.12.2] NBT doesn't work for villager professions
Malarchist opened this issue ยท 8 comments
I'm trying to allow only nitwit villagers to spawn with the following:
[
{
"mob": "minecraft:villager",
"biome": "Plains",
"maxcount": 1,
"nbt": {
"Profession": 5,
"Career": 0
}
"result": "allow",
}
]
It's not working. All villager professions are still spawning.
Did I do something wrong or is this a bug or limitation? If so can this please be fixed?
Any help would be appreciated.
Why the maxcount? That makes it so this rule stops working as soon as there are more then 5 villagers.
Also result allow is default. Your rule essentiall does nothing. You need to deny villagers too. Otherwise this is useless
Sorry, there's more stuff around I forgot to mention.
I disabled structure spawning and added my own natural villager spawn in potential spawn:
{
"mob": "minecraft:villager",
"weight": 100,
"groupcountmin": 1,
"groupcountmax": 1
},
Then used the aforementioned to allow in spawn:
{
"mob": "minecraft:villager",
"biome": "Plains",
"maxcount": 1,
"nbt": {
"Profession": 5,
"Career": 0
},
"result": "allow"
},
Then used this to deny everything else:
{
"result": "deny"
}
I know that stops everything I don't allow. There's a bunch of unrelated allowances between those two segments for other mobs I'm not gonna bother you with. The goal is to make a sort of wandering villager system for my modpack, so that's why the low maxcount's there.
The spawning itself is fine. Villagers themselves are spawning at the rates I want, just not with the specific profession. I tried it out with other NBT tags like the attributes in the wiki example and it works just fine so I'm assuming it's only the profession tag that isn't working.
The problem is still that you are combining maxcount and the profession in one rule. Imagine this, in the beginning there are no villager. The first villager spawns. He has profession 5. His spawn will be allowed because the count is 0 which is lower then 1.
Then another villager with profession 5 spawns. His spawn will be denied because the count is now 1
But can I see your complete rule files?
So I isolated the test scripts to only things relevant to the problem, converted from json to txt for github:
Result: Nothing spawns except villagers, a lot of villagers. Still any profession though.
Ah your nbt syntax is wrong. Check the wiki. You must use keywords like 'contains'. i.e. it's a special syntax so that you can match part of the nbt. For example:
"nbt": [
{
"tag": "display",
"value": "My Clay"
}
]
This will match any nbt that has the tag 'display' with the given value. You need to do something similar for your profession
I thought nbt with entities was more like an application thing than a checker?
For instance, the following wiki example:
[
{
"mob": "minecraft:zombie",
"result": "default",
"healthmultiply": 2,
"nbt": {
"Attributes": [
{
"Base": 0.23,
"Modifiers": [
{
"Operation": 2,
"Amount": -0.5,
"Name": "effect.moveSlowdown 0"
}
],
"Name": "generic.movementSpeed"
}
]
}
}
]
It works and makes zombies slower even with default spawns. There are no slower zombies to pass a check, meaning that zombies that are allowed to spawn probably just have the nbt applied to them. Right?
Anyway, here's a dump of every permutation I tried to no avail:
spawn dump.txt
The only thing I can think of then is that professions are decided later and then there is nothing you can do about this I'm afraid