Allow only to strike with swords?

gl
7

How can you do it in Minecraft so that you can only hit with swords in adventure mode?

Be

Should go like this

/ execute as @a [nbt = {SelectedItem: {id: "minecraft: stone_sword}}] run effect clear @s weakness

/ execute as @a [nbt =! {SelectedItem: {id: "minecraft: stone_sword"}}] run effect clear @s weakness 1000000 255 true

For each sword you have to do the two commands again

gl

What is weakness for an effect?

Be

Weakness, the opposite of strength

gl

So you can't hit with weakness or only weakly?

gl

And it should go like this, right?

/ effect give @a [nbt =…] weakness 1000000 255 true

Be

Yes, as far as I know, it is more performant if you run execute in front of it, but no idea whether that is true.

Be

You need a sharpness enchantment on the weapon to do damage, otherwise it doesn't