How do I make a structure spawned from an item spawn facing the player?

Started by Wolfgalaxy on Mon, 05/31/2021 - 00:43

Topic category: Help with modding (Java Edition)

Last seen on 23:55, 10. Jul 2021
Joined Dec 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
How do I make a structure spawned from an item spawn facing the player?
Mon, 05/31/2021 - 00:43

I have an item that spawns a structure when it's right clicked on the ground, but the structure always spawns facing the same direction. I want it to spawn facing the player. Is there any way to do this? I also tried switching it to spawning the structure when the item is right clicked in the air and that didn't work either.

Last seen on 18:15, 28. Jul 2021
Joined May 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
I will tell you how you…
Fri, 06/25/2021 - 19:15

I will tell you how you could do this by giving you an example:

Let's say that you built your structure facing north, for simplicity's sake. In your procedure, you could simply make an if statement for every possible direction the structure can be placed in and rotate it accordingly.

So, for north, the if statement would be something like:

(if <Direction of Event/target entity> = NORTH) then place the structure with no rotation

For another direction, like east, it would look something like this:

(if <Direction of Event/target entity> = EAST) then place the structure with rotation "CLOCKWISE_90"

Do this for all 4 cardinal directions (N/S/E/W), and it should work as you want. You might have to play around with rotations to get exactly what you want. If you want rotations for UP and DOWN as well, you will unfortunately have to make custom structures for those two as Minecraft does not have support for rotating on that axis.