#Spawning entity variant with scripts

1 messages · Page 1 of 1 (latest)

flat flare
#

Is it possible to spawn an entity variant with scripts and not commands?

slate canopy
#

one of the properties is spawnEvent

#

you can put an event on the entity, and idk for sure but you might be able to get variant that way

wooden plover
# flat flare Is it possible to spawn an entity variant with scripts and not commands?

Yea
Use component groups to store ur variant data and put it in events
After that u can make a script and depending on how u want to execute ur event (player/world, for now i will tell u both)

  1. If u want to execute it as player:-
    player.runCommand('event entity @e[type=entity:identifier] your:event')

  2. If u want to execute it as world:- world.getDimension("overworld").runCommand('event entity @e[type=entity:identifier] your:event')

#

This is the most basic

#

And hybrid combo

slate canopy
#

hm so if you can do that

#
const myEntity = world.getDimension("overworld").spawnEntity("my:entity", { x: 0, y: 0, z: 0 }, { spawnEvent: "your:event" })
#

surely this would work too

wooden plover
#

Yea

slate canopy
#

oh so i guessed correctly

#

i was unsure what you could do with events

wooden plover
#

Idk what he really needs it for, so it's kinda difficult to suggest answers

slate canopy
#

trye

wooden plover
#

Mine is executed only if the entity alr exists

#

And urs spawns the entity variant