0

Today I had an incident on my 1.16.4 Minecraft server where a Player had his house unnecessarily grief'd by a cheater using fly hacks. Typically in the circumstance I would give the player some of his things back, however his main concern was that of a Savannah villager who had sharpness 5. Is there any way for me to spawn a Savannah Villager with sharpness 5 for this player, and if not, is there a good plugin for future cases to make griefing easier to deal with?

6
  • 1
    Possible duplicate of How do I create a villager with custom trade offers?
    – pppery
    Jan 2, 2021 at 3:18
  • @pppery that post is so outdated it's not really a duplicate...
    – jklw10
    Jan 2, 2021 at 11:55
  • I disagree categorically with the assertion that a question can be so outdated it ceases to be a valid duplicate target.
    – pppery
    Jan 2, 2021 at 14:54
  • Not sure why this was closed, yes someone answered it correctly, but it literally says, non-custom, I clearly wasnt asking for custom.
    – Topdogger-
    Jan 9, 2021 at 2:59
  • @pppery well the answer in the link IS so outdated it literally doesn't work in the newest version of minecraft.
    – jklw10
    Jan 12, 2021 at 2:15

1 Answer 1

0

I'd recommend summoning a villager and placing a lectern. Then, level the villager to max and take the highest level enchantment it has, and replacing it with the Sharpness V enchantment with the /data modify command.

You can get the entity data by typing /data get entity @e[type=minecraft:villager,limit=1,sort=nearest], or substituting the selector for the UUID provided by the autocomplete form when looking at the villager.

Then, find the spot in that huge data list that you want to replace.

Here is what the trades section usually looks like.

Offers: {
 Recipes: [
  {
   maxUses: 16, 
   buyB: {id: "minecraft:air", Count: 1b}, 
   buy: {id: "minecraft:paper", Count: 24b}, 
   sell: {id: "minecraft:emerald", Count: 1b},
   xp: 2, uses: 0, priceMultiplier: 0.05f, specialPrice: 0, demand: 0, rewardExp: 1b
  }, 
  {
   maxUses: 12, 
   buyB: {id: "minecraft:book", Count: 1b}, 
   buy: {id: "minecraft:emerald", Count: 22b}, 
   sell: {
     id: "minecraft:enchanted_book",
     Count: 1b,
     tag: {StoredEnchantments: [{lvl: 2s, id: "minecraft:projectile_protection"}]}
   }, 
   xp: 1, uses: 0, priceMultiplier: 0.2f, specialPrice: 0, demand: 0, rewardExp: 1b
  }
 ]
}

I've formatted this so that it's easier to look at but usually it's just in a big clump. you just need to know the keyword Offers is used when you want to edit the trades.

In the second trade there's an enchanted book with Projectile Protection II. In this example, I'm going to turn that projectile protection to Sharpness V with the commands above.

/data modify entity @e[type=minecraft:villager,limit=1,sort=nearest] Offers.Recipes[1].sell.tag.StoredEnchantments[0].lvl set value 5

Recipes[1] gets the second element in the Recipes list, then StoredEnchantments[0] gets the first element in the enchantment list (it's a list even though there's only one item). Then it sets the level to 5. Now, just do the same for the enchantment ID:

/data modify entity @e[type=minecraft:villager,limit=1,sort=nearest] Offers.Recipes[1].sell.tag.StoredEnchantments[0].id set value "minecraft:sharpness"

You could also just set both the ID and the level with just one command.

/data modify entity @e[type=minecraft:villager,limit=1,sort=nearest] Offers.Recipes[1].sell.tag.StoredEnchantments[0] set value {lvl:5, id:"minecraft:sharpness"}

Not the answer you're looking for? Browse other questions tagged .