Anıl Sayar

C++ & Qt Developer

Java & SQL Developer

C# & WPF Developer

Freelancer

Anıl Sayar
Anıl Sayar
Anıl Sayar
Anıl Sayar

C++ & Qt Developer

Java & SQL Developer

C# & WPF Developer

Freelancer

Blog Post

Schematic Rotation Manipulation

Schematic Rotation Approaches

This article is still in draft, but i still want to publish it because i do not want 0 articles in display :D. If you want to contribute, correct some mistakes, or give more easy/direct approaches, feel free to email, comment or even message on Discord. Thank you.


While I was developing a project that has schematic manipulations, I have encountered some common issues. Handling schematics for spigot servers can often be quite challenging, especially with rotation. If you want some schematic to face the player regardless of direction, there is no direct approach as far as i know. In order to face a certain direction to player, we must know the direction of player and the schematic itself and rotate accordingly.

In this article, we will be using WorldEdit API to make things a little bit simpler.

General approach and idea of this article is:

  • We can not get 4 way direction with original minecraft yaw directly, so we have to write basic conversion for player’s yaw to return a custom 4 direction class. This conversion will make things a lot easier in the long run.
  • We have to get the original direction of schematic. Unfortunately i have not been able to find a direct approach to this, but in this article, we will create custom command to create schematic with worldedit, and store the rotation in some configuration file while creating the schematic.
  • We need to create our own schematic manager to store all these rotation values and make our lives easier.
  • We will rotate the schematic with transform function in WorldEdit clipboard holder class.
  • [Extra] Block locations while pasting are not accurate, because it represents the old location. We will get all the block locations relative to origin.

Converting Player Direction

This approach should be easy. We have to create a basic direction enum to transform.

CustomDirection.class

For actually converting player yaw to custom direction, you can either put this function to custom direction class itself, or put this into our future custom schematic manager class which we will already have player, so we will not need to use player as parameter:

Starting Schematic Manager

Once custom direction is finished, we have to make custom schematic class before schematic manager to store our original direction or any other parameters.

CustomSchematic.class

To be continued..

Write a comment