TransWikia.com

How to make a sword that when you hold it the mobs near it will die in 1 secs?

Arqade Asked on May 11, 2021

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.

2 Answers

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}]}

Answered by ViKyTricKy on May 11, 2021

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 of course be any item and name you want). You can rename a netherite sword in an anvil or obtain a renamed sword directly with 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)

Answered by Roasted Chicken on May 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP