#Armor stand entity does not face straight when placed *resolved*

1 messages · Page 1 of 1 (latest)

median shuttle
#

help would be greatly appreciated : )

median shuttle
#

?

dusky hill
#
import { world, system } from "@minecraft/server";

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 !== "replace:this") return;
    await system.waitTicks(1);
    const entities = player.dimension.getEntities({
        location: getblockFace(block,blockFace).center(),
        closest: 1,
        type: "replace:this",
        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")
    })
})
#

Scripts like this exist everywhere on the discord

median shuttle
dusky hill
#

No problem

median shuttle
#

dont understand scripts that much but i can hopefully figure it out when i get home

#

also is there like a script forum or something you can find scripts at?

#

like that one

median shuttle
#

hm do i need to replace anything other than the two "replace:this"? or do i need to like add anything else somewhere loll

dusky hill
median shuttle
#

yeah i did that but it wasnt working😭

#

the item name and entity name and identifiers are the same but i changed them to be different too and that didnt work either

median shuttle
#

else if (rot >= 292.5 && rot < 337.5) yRot = 315
else if (rot >= 292.5 && rot < 337.5) yRot = 315

#

are there supposed to be 2 ?

#

and would i need to change the rotation numbers at all?

dusky hill
median shuttle
#

idkk fr ive tried everything i could think of

#

import { world, system } from "@minecraft/server";

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 !== "tap:armor_case_item") return;
await system.waitTicks(1);
const entities = player.dimension.getEntities({
location: getblockFace(block,blockFace).center(),
closest: 1,
type: "tap:armor_case",
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")
})

})

#

idk why it doesnt let me do the js text thing lol

dusky hill
#

Did you add it to the main.js file

#

Or import it there

median shuttle
dusky hill
dusky hill
median shuttle
#

but i might have found what i need to do maybe lolll

dusky hill
#

So what do you think it is

median shuttle
#

index?

dusky hill
#

Yes

median shuttle
#

bet thank you

dusky hill
#

That's what I meant when I said import

median shuttle
#

yeah i figured, i was just looking for something named “main” or something the whole time so i ignored the index lmao

#

but thank you bro

#

so i have a bigger armor case too, would i be able to add them both in the same file or should i just make a new one

median shuttle
#

okay bett

dusky hill
#

Before you go, do you know how to import it

median shuttle
#

import ‘./armor_case.js’;

dusky hill
#

Yeah

#

You could also do it without the .js on the end

median shuttle
#

oh okay bet, thanks bro

dusky hill
#

No problem

median shuttle
#

Armor stand entity does not face straight when placed resolved

shadow needle
#

Does the problem like this?

dusky hill
shadow needle
#

Do you still have the entity template on how it is fixed?

shadow needle
#

Ohh, I finally fixed it sorry to bother

lean acorn