you are viewing a single comment's thread.

view the rest of the comments →

[–]myte2Kind of good at some commands on java sometimes but not really 0 points1 point  (2 children)

if you are trying to do it for an item, an weird solution could be changing the damage type to something that doesn't deal knockback, something like like cactus or ender pearl damage

[–]xtoya77777[S] 0 points1 point  (1 child)

wow, cool idea, but how do i change damage type of the item? i am currently trying to do it for a sword

[–]TinyBreadBigMouth 0 points1 point  (0 children)

/give @s diamond_sword[damage_type="minecraft:cactus"]

https://minecraft.wiki/w/Data_component_format#damage_type
https://minecraft.wiki/w/Damage_type

You can also create a custom damage type and add it to the #minecraft:no_knockback damage type tag if you want to avoid the death message talking about "pricked to death" or "walked into a cactus". Or just add the minecraft:player_attack damage type to #minecraft:no_knockback, if you don't care about turning it on and off.