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

Started by Wolfgalaxy on

Topic category: Help with Minecraft modding (Java Edition)

Joined Dec 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do I make a structure spawned from an item spawn facing the player?

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.

Joined May 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • 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.

Joined May 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hey, can you please…
Wed, 08/18/2021 - 07:24

Hey, can you please screenshot your procedure for the item that lets you spawn the structure?