#Is it possible to make an entity placeable in only 8 directions ?

1 messages · Page 1 of 1 (latest)

boreal mural
#

Custom armor stand is driving me insane. It never wants to point straight. Is it possible to make it where it can only be placed N, NE, E, SE, S, SW, W, NW?

Any help is appreciated

polar locust
#

Try adding this to your animation file:

    "loop": true,
    "bones": {
      "<put_root_bone_name_here>": {
        "rotation": [0, "-q.body_y_rotation + (Math.round(q.body_y_rotation / 45) * 45)", 0]
      }
    }
  }```
#

However, make sure that this animation is always running otherwise it will have no effect!

boreal mural
boreal mural
#

This is just a blank armor stand with armor stand behaviors from block bench.

No geometry change

boreal mural
warped ivy
# boreal mural

I made a script that rotates the custom armor stand everytime you use the "spawn egg"

function getblockFace(block,blockFace) {
    switch (blockFace) {
        case "Up":
            return block.above();
        case "Down":
            return block.below()
        case "South":
            return block.south()
        case "North":
            return block.north()
        case "East":
            return block.east()
        case "West":
            return block.west()
    }
}

world.beforeEvents.playerInteractWithBlock.subscribe(async({player, isFirstEvent, itemStack, block, blockFace})=>{
    if (itemStack?.typeId !== "myname:work_please_spawn_egg") return;
    await system.waitTicks(0);
    const entities = player.dimension.getEntities({
        location: getblockFace(block,blockFace).center(),
        closest: 1,
        type: "myname:work_please",
        excludeTags: ["rotated"]
    });
    if (!entities.length) return;
    const rot = player.getRotation().y + 180;
    let yRot = 0;
    if (rot >= 22.5 && rot < 67.5) yRot = 45
    else if (rot >= 67.5 && rot < 112.5) yRot = 90
    else if (rot >= 112.5 && rot < 157.5) yRot = 135
    else if (rot >= 157.5 && rot < 202.5) yRot = 180
    else if (rot >= 202.5 && rot < 247.5) yRot = 225
    else if (rot >= 247.5 && rot < 292.5) yRot = 270
    else if (rot >= 292.5 && rot < 337.5) yRot = 315
    else if (rot >= 292.5 && rot < 337.5) yRot = 315
    
    entities.forEach(entity=>{
        entity.setRotation({x:0,y:yRot});
        entity.addTag("rotated")
    })
})
#

I Removed minecraft:body_rotation_axis_aligned and minecraft:body_rotation_blocked component on my end while making these

#

The rotation wasn't instantaneous unfortunately

warped ivy
boreal mural
# warped ivy Do you want to use this approach instead?

So the axis aligned and blocked actually don't work at all because of the runtime identifier but removing stops it from acting like an armor stand completely.(Cant equip items, no poses, gets hurt animations, dies)

Ill hop on the PC now and check that out. Thank you so much for doing that.

im not sure how do the animation set up, and they never wrote back.

warped ivy
boreal mural
#

And doesn't actually snap at all

boreal mural
#

I would be fine with it only doing the 4 even if the component worked and the entity still acted like an armor stand

warped ivy
#

Well, an armor stand could still technically rotate outside its usual 8 directions if you use commands...

boreal mural
#

I've just got my PC loaded up. honestly, That's perfect, thank you! My biggest concern was to just get it to face forward and this achieves that and then some.

boreal mural
boreal mural
warped ivy
#

ye

boreal mural
#

Thank you!!!

boreal mural
#

[Scripting][error]-Unhandled promise rejection: ArgumentOutOfBoundsError: Unsupported or out of bounds value passed to function argument [0]. Value: 0, argument bounds: [1, 4294967295.00] at <anonymous> (new.js:50)

warped ivy
#

what's at line 50

boreal mural
#

await system.waitTicks(0);

#

oh i see

#

should be 1

warped ivy
#

oh, change 0 to 1

#

i was on beta api oop

#

the rest is stable

boreal mural
#

i thought it was saying i was placing it in some crazy location lmao

boreal mural
#

i never thought something as simple as an armor stand facing me would make me so happy. my hero. thank you again

polar locust
#

Sorry that I took a while to respond, but if you would like to use the animation method to avoid the jarring rotation alignment that the script method causes, make sure you have something like this in your client entity file:

"scripts": {
    "animate": [
      "45d_align"
    ]
},
"animations": {
    "45d_align": "animation.armor_stand.45d_align" // Change this to whatever you've named the animation
}```
#

(this is what I was referring to when I said to make sure that the animation is always running)