#Armor stand entity does not face straight when placed *resolved*
1 messages · Page 1 of 1 (latest)
?
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
holy okay thank you
No problem
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
hm do i need to replace anything other than the two "replace:this"? or do i need to like add anything else somewhere loll
No, just the "replace:this" for the item name and the "replace:this" for the entity name
Just make sure you don't mix them up
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
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?
You are doing the identifier for the item, not the display name, right?
yeah
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
no i have no idea how to do that😭😂
Sorry, I didn't notice this message
Kinda, but not really
What you can do is search up your problem in script resources, Script API or in the regular search using keywords and find related posts
And u can either find resolved posts or try to fix unresolved ones (or you can learn to write scripts on your own)
ahhh okay okay
Did you make a new file for the script or did you try to add it to an already existing one
made a new one
but i might have found what i need to do maybe lolll
So what do you think it is
Yes
bet thank you
That's what I meant when I said import
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
Add them both to the same file
okay bett
Before you go, do you know how to import it
i would just copy one of them right?
import ‘./armor_case.js’;
oh okay bet, thanks bro
No problem
Armor stand entity does not face straight when placed resolved
Yes, you have the same problem
Do you still have the entity template on how it is fixed?
Ohh, I finally fixed it sorry to bother
U are life saver bro, try to kiss on screen thousand time to u 🗣️