#throw splash potion

1 messages · Page 1 of 1 (latest)

lean marten
#

Looking for a way to throw splash potion that will give the actual effect to the nearby entities

rough nexus
#

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.

sour pond
#

there's properties you can set too, I recommend making a function for it.

rough nexus
lean marten
#

well actually im looking if they're any convenient way

lean marten
sour pond
#

all things thrown are projectiles

random tide
#
  1. use Map and save the splash potion's custom data after being thrown (detected by entitySpawn)
  2. Use either projectileHitEntity or projectileHitBlock event listeners.
  3. Retrieve the data from the Map and use the provided location from the event projectileHit listener. (The splash potion entity becomes invalid at this point except its .id)
  4. Do all fancy visual effects code and stuff
lean marten
sour pond
#

you are confusing me now

#

because I gave you a solution already.

lean marten
sour pond
#

unless you mean when it splashes, then do what gega says

lean marten
# sour pond you can.

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

sour pond
#

multiple times.

#

maybe you are doing incorrectly? share your code.

lean marten
#
const e = dimension.spawnEntity("splash_potion", location)
if (e.getComponent("projectile") instanceof EntityProjectileComponent) console.warn("projectile component")
else console.warn("component is not present")
sour pond
#

you do not need to do instanceof

lean marten
#

what is the scripting version du you use? is it beta version or stable?

sour pond
#

that doesnt matter, getting the projectile component is doable in stable.

lean marten
#

well if that getComponent('projectile_component') doesnt return EntityProjectileComponent, how would I call shoot() method

sour pond
#

you got the projectile component correctly last time

#

idk why you did 'projectile_component' this time

#

getComponent('projectile')

lean marten
#

You got the point, right?

lean marten