#Replicate spawn egg in script

1 messages · Page 1 of 1 (latest)

dense sage
#

I'm aware I could use block.location, but that would spawn it inside the block, and im also aware I could just set the y offeset, but im trying to get it spawned on the pointed location just like how spawn eggs work.

#

I've also tried getting blocks from the player's view direction, with FaceLocation, but it gives the same error. if what im trying to do is incorrect, can someone help me replicate a spawn egg?

#

I guess you could say im also trying to replicate minecraft:entity_placer aswell

grim raptor
#

block face is the distance from the northwest corner

#

so you are trying to spawn a creeper at 0,0,0

dense sage
#

how would I replicate entity_placer

grim raptor
#

const DirectionToVector = {
    [Direction.Down]: Vector.down,
    [Direction.Up]: Vector.up,
    [Direction.North]: Vector.forward,
    [Direction.South]: Vector.back,
    [Direction.West]: Vector.left,
    [Direction.East]: Vector.right,
};```
#

Just use blockFace

#

Vector.add(DirectionToVector[blockFace],block.location);

#

you might need to switch the vector value for north and south

dense sage
#

uhhh

#

so const blockFace = Vector.add(DirectionToVector[blockFace],block.location)?

grim raptor
#

Make sure the creeper spawns correctly in every direction

dense sage
#

oh so do I test for the direction in the if statement?

dense sage
#

also it says direction is undefined

grim raptor
#

Why would you test for direction

dense sage
#

oh, ill import Direction.

grim raptor
#

Ya and Vector

dense sage
#

DirectionToVector needs to be initaized

#

yeah idk what im doing, nothings working.

#

is this even helping me replicate entity_placer

#

does this even look right

#

I tried it in game and there's this error.

tough surge
#

const blockFace = data.blockFace

dense sage
#

oh, im stupid, thanks
its only spawning in 1 direction tho

#

oh nvm

#

this is awesome, thanks for the help

dense sage
#

actually, its not spawning correctly now, seemed like it was after I fixed foward and back

#

oh I see, its never spawning in the middle of the block like spawn eggs do...

#

how would I implement an offset to this...

#

ahhh, the block location 👀

#

nvm