1

I'm wondering how to make an item give a potion buff or generic boost when held ONLY in the off-hand.

Thanks!

4
  • Have you made any attempt to solve this yourself? Showing effort to solve your own problems means you get a better reception
    – Frank
    Commented Sep 9, 2016 at 22:38
  • This site is much more friendly than other sites. Plus, some articles aren't that explicit, such as Minecraft Wiki. Also, people that have a question like this can look here for information. Not only am I helping myself out, but others, too.
    – ReaLord
    Commented Sep 9, 2016 at 22:50
  • Yes. And for things like Minecraft, you get a much better reception when there's research behind your question. We want interesting questions, which require effort.
    – Frank
    Commented Sep 9, 2016 at 23:05
  • I'll keep that in mind next time. Sorry!
    – ReaLord
    Commented Sep 10, 2016 at 1:14

1 Answer 1

1

Easiest way to accomplish a "generic boost" is through attributes, which can be set to only apply on a specific slot. This is a generator that allows adding attributes to items for specific slots. Here's an example command that gives you 10 extra health (5 hearts) when held only in the offhand:

/give @p minecraft:diamond_sword 1 0 {AttributeModifiers:[{AttributeName:"generic.maxHealth",Name:"generic.maxHealth",Slot:"offhand",Amount:10,Operation:0,UUIDMost:91328,UUIDLeast:135212}]}

There's this wiki page if you want to learn more about all the things attributes can do, and what do different operations are for.

Though there's a few things attributes do better than potions effects, they're a bit limited and may not be able to do what you want.


Alternatively, you could do this by detecting when the player is holding the item in their offhand slot (-106)

/scoreboard players tag @a[tag=OffhandHoldingItem] remove OffhandHoldingItem
/scoreboard players tag @a add OffhandHoldingItem {Inventory:[{Slot:-106b,id:"minecraft:diamond_sword",tag:{display:{Name:"Example Sword"}}}]}

You can then do anything you want to the player, such as:

/effect @a[tag=OffhandHoldingItem] jump_boost 1

You must log in to answer this question.

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