#throw splash potion
1 messages · Page 1 of 1 (latest)
You want to make Custom Splash Potion, and you want to throw it, right?
First, do spawnEntity at player.getHeadLocation().
Then do applyImpulse at player.getViewDirection() to make it throw.
Then check for nearby entities using world.getEntities({}), then apply effect to them.
there's an official method to throw/shoot projectiles.
you spawn the entity, get the projectile component from the entity, then use the shoot method.
there's properties you can set too, I recommend making a function for it.
yeah your right, i just live in the dinosaur age, so i didnt know about the shoot method
well actually im looking if they're any convenient way
Do I need to create my own custom particle with it? I just need to throw vanilla potion and iirc they dont have projectile component in it
they have the projectile component.
all things thrown are projectiles
- use
Mapand save the splash potion's custom data after being thrown (detected byentitySpawn) - Use either
projectileHitEntityorprojectileHitBlockevent listeners. - Retrieve the data from the
Mapand use the providedlocationfrom the eventprojectileHitlistener. (The splash potion entity becomes invalid at this point except its.id) - Do all fancy visual effects code and stuff
oh really, so i can use onEntitySpawn then??
are you looking to throw it or detect when its thrown...
you are confusing me now
because I gave you a solution already.
well the thing is that I can't get the projectile component if I take the entity reference from the return value of dimension.spawnEntity(). However, that projectile component is available if I take the entity reference from entitySpawn.subscribe
you can.
unless you mean when it splashes, then do what gega says
Have you tried that yourself? I'm sure it wont work cuz I've just tried that by the time I sent my previous reply
Yes, I have.
multiple times.
maybe you are doing incorrectly? share your code.
const e = dimension.spawnEntity("splash_potion", location)
if (e.getComponent("projectile") instanceof EntityProjectileComponent) console.warn("projectile component")
else console.warn("component is not present")
you do not need to do instanceof
what is the scripting version du you use? is it beta version or stable?
that doesnt matter, getting the projectile component is doable in stable.
well if that getComponent('projectile_component') doesnt return EntityProjectileComponent, how would I call shoot() method
...
you got the projectile component correctly last time
idk why you did 'projectile_component' this time
getComponent('projectile')
oh, sorry I mean getComponent("projectile")
You got the point, right?
oh nvm, I got it typo :D