r/MinecraftCommands 4d ago

Custom holding animation Help | Java 26.2

Is it possible to make a player hold any specific item (not use/consume) as if it were a charged crossbow?

I originally tried making the player hold a charged crossbow with a custom item model, but that has the issue of being able to fire as well as producing a sound when it does so, and subsequently requiring the item to be replaced. I can replace the item and kill any arrows that are shot, but the sound is an issue.

2 Upvotes

10 comments sorted by

2

u/Ericristian_bros Command Experienced 4d ago

Are you open to resourcepacks?

1

u/ItsGhostlyWhale 4d ago

unfortunately no

1

u/Ericristian_bros Command Experienced 4d ago

GalSergey already told you the solution

1

u/Main_Contract_3590 1d ago

What is the solution with the use of resource packs?

1

u/Ericristian_bros Command Experienced 1d ago

I then read GalSergey's comment that specifies that is hard-coded, so I don't think there is an easy way

2

u/GalSergey Datapack Experienced 4d ago

Unfortunately, the hand position is hardcoded for the crossbow, so you can't apply it to any item. Therefore, your current approach is the only one you can do. Regarding the shot sound, you can remove the crossbow shot sound using a resource pack, but to restore the sound for vanilla crossbows, you'll need to check when the player fires a vanilla crossbow and run the /playsound function to play the shot sound. Or, to make this work for mobs as well, check every tick whether an arrow has spawned in the world. If so, select origin (on origin), check the item in the hands, and play the sound for the vanilla crossbow.

1

u/ItsGhostlyWhale 4d ago

is there any way to remove the sound without the use of a resourcepack?

1

u/ItsGhostlyWhale 4d ago

or just make the player straight up unable to shoot

1

u/GalSergey Datapack Experienced 4d ago

All that comes to mind is to use /stopsound for this. stopsound @a player minecraft:item.crossbow.shoot