2
Villager Picks Up Emerald Block?
In my Data Pack, I want to make it so if an Emerald Block is within a 16-block radius of an employed Villager, the Villager will go to the Emerald Block, pick it up and its level will go up by 1.
But I have zero idea as to how to make Data Packs, so some extra help would be great!
I want it to be all contained within 1 function, without any other functions or anything else.
Any help would be greatly appreciated!
But I have zero idea as to how to make Data Packs, so some extra help would be great!
I want it to be all contained within 1 function, without any other functions or anything else.
Any help would be greatly appreciated!
Create an account or sign in to comment.
8
Datapack making guide by legitmoose
Imo, you'll need to implement a new system where villagers pathfind their way to the emerald block. Once they're on the item entity, they "pick it up", and you change the villager's nbt data as well as deleting that item
Make sure you go to the r/MinecraftCommands discord if you need help
Imo, you'll need to implement a new system where villagers pathfind their way to the emerald block. Once they're on the item entity, they "pick it up", and you change the villager's nbt data as well as deleting that item
Make sure you go to the r/MinecraftCommands discord if you need help
I just found something for the pathfinding, where you give every villager with a specific tag certain coordinates to walk towards, but I now have 2 questions:
1. How would I get the X, Y, and Z of the closest Emerald Block item to the villager with the specific tag?
2. How would I delete the item?
1. How would I get the X, Y, and Z of the closest Emerald Block item to the villager with the specific tag?
2. How would I delete the item?
I figured out the pathfinding, item deleting, and leveling up bits. But I actually forgot to mention that I wanted it to add a new trade to the villager, and now I have a problem where every time the villager picks up an emerald block, levels up, and gains the trade, if I give it multiple emerald blocks, it has multiple of the same trade.
I am adding the trade with a /data merge command, so how would I prevent this "trade stacking?"
EDIT: I also want to make it so the trade can only be used 64 times per day, but with MaxUses tag, if I make it be 64, the trade can only be used 64 times, and then it can never be used again. How can I fix this?
I am adding the trade with a /data merge command, so how would I prevent this "trade stacking?"
EDIT: I also want to make it so the trade can only be used 64 times per day, but with MaxUses tag, if I make it be 64, the trade can only be used 64 times, and then it can never be used again. How can I fix this?
the first time you give them a trade, also give them a tag. Check for the absence of that tag when you give the villager a trade
Also the trade limit nbt also resets every time they go to a workstation and "work" there.
<execute command /location specifier> data merge entity @e[type=villager,tag=alreadyHasTrade] {nbt}
Also the trade limit nbt also resets every time they go to a workstation and "work" there.
I have 2 questions:
1. What does the {nbt} mean?
2. What do you mean by the trade limit nbt "resetting"? does that mean the MaxUses tag goes to 0, or does that mean it starts to work again?
EDIT: I now realize that the {nbt} means the custom trade
1. What does the {nbt} mean?
2. What do you mean by the trade limit nbt "resetting"? does that mean the MaxUses tag goes to 0, or does that mean it starts to work again?
EDIT: I now realize that the {nbt} means the custom trade
It means the "uses" nbt that dictates how many trades the villager has done goes to 0. So yes, it'll start to work with it.
To answer your question below:
To answer your question below:
[tag=!alreadyHasTrade]
view more replies ( 1 )
I also have 1 more question. How would I check if the villager doesn't have the alreadyHasTrade tag?