I saw a video on YouTube where someone made a sword that using repeating command blocks, causes the mobs nearby to die. The sword in the video was created in Minecraft Bedrock Edition but I want it in Java Edition and in 1.16.


Hio there! First time here so excuse me if I do anything wrong. It in fact is possible using scoreboards and /execute commands, I'll try to explain everything as thoroughly as possible.

First off all, I'm assuming the sword has been renamed to "Spaghetti" and is a netherite sword, as this will be what the command block will be checking for (these are just examples and can ofcourse be any item and name you want). Done either through renaming in an anvil or the following give command: /give @p netherite_sword{display:{Name:'{"text":"Spaghetti"}'}} 1

If you don't want a lot of text and just want the commands here they are:

/scoreboard objectives add os_timer dummy is first needed to create the scoreboard we need

Then the following 3 commands all need to be in 3 separate always active repeating command blocks 1

execute at @a[nbt={SelectedItem:{id:"minecraft:netherite_sword",tag:{display:{Name:'{"text":"Spaghetti"}'}}}}] run scoreboard players add @e[nbt=!{SelectedItem:{id:"minecraft:netherite_sword",tag:{display:{Name:'{"text":"Spaghetti"}'}}}},distance=..3] os_timer 1

kill @e[scores={os_timer=20}]

execute at @a run scoreboard players reset @e[distance=3..] os_timer

Explanations below:

/scoreboard objectives add os_timer dummy The scoreboard "os_timer" is needed as this is the countdown until a mob is killed, the name can be whatever you want, as long as you edit them in every other command as well.

The first command in a command block:

The first part of the command /execute at @a[nbt={SelectedItem:{id:"minecraft:netherite_sword",tag:{display:{Name:'{"text":"Spaghetti"}'}}}}] in short looks for a player that wields a netherite sword that is called "Spaghetti" and takes that player's location as its location where it runs.

The second part of the command run scoreboard players add @e[nbt=!{SelectedItem:{id:"minecraft:netherite_sword",tag:{display:{Name:'{"text":"Spaghetti"}'}}}},distance=..3] os_timer 1 in short adds 1 score to the "os_timer" scoreboard for every entity in a 3 block radius that is NOT wielding the sword (as to not kill yourself in the process).

Second command block:

kill @e[scores={os_timer=20}] simply kills all entities whose "os_timer" score is 20, 20 being chosen as a repeating command block runs 20 ticks per second.

Third command block:

execute at @a run scoreboard players reset @e[distance=3..] os_timer this one is not needed, however what it does is, it resets every entity's score when they go outside the 3 block range (of every player)

New contributor
Roasted Chicken is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

I'd like to say that this is probably not possible. But you can try making a sword that is ONE SHOT Kill sword by adding 32k sharpness enchantment This is what you have to type in to get a **One Shot ** kill sword The video you saw the person might be using some mods which might be helping him.

/give @p netherite_sword{Enchantments:[{id:sharpness,lvl:32767},{id:knockback,lvl:10},{id:fire_aspect,lvl:32767},{id:looting,lvl:10},{id:sweeping,lvl:3},{id:unbreaking,lvl:32767},{id:mending,lvl:1}]}
New contributor
ViKyTricKy is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 1
    Why would this be not possible? – ExpertCoder14 Feb 22 at 18:40
  • Welp, thanks VikyTricKy but i already have a sword like that and also ExpertCoder14 if you say this is not possible than how do you do it? – yypl Feb 23 at 0:43
  • @yypl he never said it wasnt possible – Penguin Feb 23 at 3:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.