2

Villager Picks Up Emerald Block?

Drake__archer's Avatar Drake__archer2/23/24 10:30 pm
2 emeralds 148 8
2/26/2024 12:08 pm
Drake__archer's Avatar Drake__archer
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!
Posted by Drake__archer's Avatar
Drake__archer
Level 10 : Journeyman Modder
9

Create an account or sign in to comment.

8

HoboMaggot
02/24/2024 9:05 pm
Level 52 : Grandmaster Blob
HoboMaggot's Avatar
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
1
Drake__archer
02/25/2024 9:14 am
Level 10 : Journeyman Modder
Drake__archer's Avatar
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
Drake__archer
02/25/2024 9:30 am
Level 10 : Journeyman Modder
history
Drake__archer's Avatar
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?
1
HoboMaggot
02/25/2024 6:40 pm
Level 52 : Grandmaster Blob
history
HoboMaggot's Avatar
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
<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.
1
Drake__archer
02/25/2024 7:42 pm
Level 10 : Journeyman Modder
history
Drake__archer's Avatar
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
2
HoboMaggot
02/25/2024 8:16 pm
Level 52 : Grandmaster Blob
HoboMaggot's Avatar
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:
[tag=!alreadyHasTrade]
1
Drake__archer
02/25/2024 7:56 pm
Level 10 : Journeyman Modder
Drake__archer's Avatar
I also have 1 more question. How would I check if the villager doesn't have the alreadyHasTrade tag?
1
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome