#[RESOLVED] make an item projectile without losing it.

1 messages · Page 1 of 1 (latest)

sleek matrix
#

So basically the current way of making items not go away when thrown is to /give right when projectile is thrown but i cant use it because of re-wielding animation.
I want an alternative to it, so when projectile is thrown its still in inventory not gone

sleek matrix
#

nvm i figured it out.
just stack to 2.

empty jackal
#

There is a way to do it and only have one item instead of 2
In case its too unsightly, but it uses scripting (in case you are against scripting)

sleek matrix
#

i dont hate scripting
i can do that effortlessly

empty jackal
#

You can just make a script to summon the entity and apply projectile Knockback to it

#

I have a script that does this if usually want, but it wouldn't be hard to do at all

sleek matrix
#

oh yeah we can do that with applyImpulse or applyKnockback

empty jackal
tropic jolt
empty jackal
empty jackal
empty jackal
sleek matrix
empty jackal
#

Here

#
import {world, system} from "@minecraft/server";

world.afterEvents.itemUse.subscribe(({ source, itemStack }) => {
    if (itemStack.typeId == 'item:name') {
        const player = source;
        const head = player.getHeadLocation();
        const view = player.getViewDirection();
        const bullet = player.dimension.spawnEntity('entity:name', head);
        const proj = bullet.getComponent('projectile');
        proj.owner = player;
        proj.shoot({ x: view.x * 1.5, y: view.y * 1.5, z: view.z * 1.5 });
    }
})```
sleek matrix
#

thanks

#

[RESOLVED] make an item projectile without losing it.