#How to enchant any throwable projectile? Such as knockback

1 messages · Page 1 of 1 (latest)

faint fog
#

Hello,

I found out recently that you can enchant any throwable projectile with any enchant such as knockback. So I do wonder how to do that because I want throwed snowball to be able to hit player then they'd get knockback.

I did try experiment many time but couldn't figure it out. /enchant didn't work. I also tried /give @s snowball[enchantments=]

But these both didn't work.

neat tuskBOT
#

<@&1201956957406109788>

Someone will come and help soon!

💬 While you wait, take this time to provide more context and details.

🙇 If nobody has answered you by <t:1735853730:t>, feel free to use the Summon Helpers button to ping our helper team.

✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve

terse folio
#

im pretty sure that doesnt work?

faint fog
#

Yeah but I often told by other people that it is possible in this server. I never found out how it work

#

Custom enchantment thing

winged karma
#

You have to make a custom enchantment

faint fog
#

How does that work?

#

That's new to me

#

I assume

#

its functions similar to json?

#

In that case, I'd need to add Enchantments folder then add snowball_knockback.json?

winged karma
#

You can use this generator to help. You'll put the output of this in a JSON file in your data pack under data/<namespace>/enchantment
https://misode.github.io/enchantment/

I don't think just the straight up knockback effect works here, so you'll probably need to do a post_attack effect that does some other stuff. Possibly run a function and then use a player motion library

faint fog
#

thought player motion dont work?

#

or is there different command/method for it?

winged karma
#

A "library" is another data pack that others can use to help perform more complicated tasks. Regular player motion like we can do for mobs is impossible, but there are some tricks that can be done using negative explosions or entity hotboxes to simulate player motion, which these libraries can help with so you don't need to make it from scratch each time

faint fog
#

I see, thanks

faint fog
winged karma
#

If you put it in the minecraft namespace, yes. But I recommend putting it in your own namespace

#

Though I think you want to use ", not '

faint fog
#

For some reasons it doesn't enchant

#

What I got so far

#
    "description": "Snowball Knockback",
    "supported_items": "minecraft:snowball",
    "weight": 1,
    "max_level": 1,
    "min_cost": {
      "base": 0,
      "per_level_above_first": 0
    },
    "max_cost": {
      "base": 0,
      "per_level_above_first": 0
    },
    "anvil_cost": 0,
    "slots": [],
    "effects": {
      "minecraft:post_attack": [
        {
          "effect": {
            "type": "minecraft:run_function",
            "function": "potions:snowball_knockback"
          },
          "enchanted": "attacker",
          "affected": "attacker"
        }
      ]
    }
  }```
#

and this one I used

#

/give @s snowball[minecraft:enchantments={levels:{"potions:snowball_knockback":1}}]

tender edge
#

but the effects aren't guaranteed as the item is converted into entity upon throwing meaning it won't contain any information of enchantment whatsoever

#

you could make a datapack that gives the snowball tag i think?

#

and maybe you could detect if the player gets hit by a certain throwable or anything that has custom tag it should be able to trigger some function

tender edge
#

the throwable gets thrown it doesn't contain any enchantment tags

#

we can test it in the game with /data

winged karma
#

Projectiles generally, and snowballs specifically, keep the enchantments of the item that was thrown to spawn it

#

They get put in the item data of the entity as components

#

Partly so that custom enchantments like this can work as expected

winged karma
winged karma
#

Clearly

tender edge
#

that looks like a useful information

#

hha

winged karma
#

Mhm

tender edge
#

soo

winged karma
#

So stop spamming

tender edge
#

the enchantments still doesn't work

#

right?

winged karma
#

Yes, it has one or more syntax errors

faint fog
tender edge
#

i mean for example can we detect player getting hitted by the snowball we threw with the enchants on?

faint fog
#

Hmm, it still doesn't work. I did added slot: mainhand

winged karma
faint fog
#

gotcha

winged karma
faint fog
#

But when I did command

#

It says

#

Malformed 'minecraft:enchantments' component: 'Failed to get element potions:snowball_knockback missed input: {"potions:snowball_knockback":1}'

#

I am very confused by that

winged karma
#

So it's an issue with your command

#

Try just doing /enchant

faint fog
#

seems enchant didn't work too

#

I looked all possible choices

winged karma
#

In what way doesn't it work?

faint fog
#

it doesn't exists basically

winged karma
#

So then you're either missing the errors that are showing up in logs, or the enchantment is not in data/potions/enchantment in your data pack

faint fog
#

odd, it is data/potions/enchantment/snowball_knockback.json

winged karma
#

Then check logs for errors again

#

Cause you must be missing some

faint fog
#

My apologies for late response but I did check latest log and date log, nothing is there

#

Is it really weird?

winged karma
#

Yeah. If the enchantment isn't showing up on the autofill when you try to use /enchant then you must be mistaken about something

#

It's either not where you think it is or there are errors that you're missing

faint fog
#

Darn, I'll try find it, I'll let you know by tomorrow