J’ai un petit problème et j’aimerais le résoudre.
Pour commencer:
J’ai créé un plugin de limite de monde. j’ai définie un centre qui est en X:0 et Z:0. Je délimite un cercle de 2000 bloc de rayon. J’en profite pour afficher ma limite de monde sur dynmap.
Ensuite, je regarde chaque seconde si les joueurs sont dans le cercle ou à l’extérieur. Si le joueur est à l’extérieur, je lui enlève 2 cœurs de vie à chaque fois avec un petit message d’avertissement.
Plutôt que de tuer le joueur, j’aimerais que quand il lui reste par exemple 2 cœurs le téléporté quelques blocs en arrière dans la zone, mais je ne sais pas comment faire, car pour le tp en arrière il faut connaitre les coordonnées.
J’ai vu qu’avec ce code je pouvais déplacer le joueur de quelques blocs:
Vector3d rotation = player.getRotation();
Direction dir = cardinalDirectionFromPitch(rotation.getX());
Vector3d diff = dir.toVector3d().normalize().mul(3);
Location newLoc = player.getLocation().add(diff);
player.setLocationSafely(newLoc);
Donc je me dit: est ce qu’on peut créer une sorte de direction ou plutôt une position par exemple en X:0 et Z:0 et donc dès que le joueur sortirait du cercle on pourrait téléporter le joueur d’un nombre de bloc choisit vers cette position ou en arrière.
C’est possible ?
Google traduction:
I have a small problem and I would solve it.
To begin:
I created a world of limited plugin. I have a center which is defined by X 0 and Z 0. I delimits a circle of radius 2000 block. I take this opportunity to show the world my limit on Dynmap.
Then I look every second if players are in the circle or outside. If the player is outside, I take her life two hearts each time with a little warning.
Rather than kill the player, I would like that when he still has two
hearts eg teleported the few blocks back in the area, but I do not know
how to do, because right back tp must know the coordinates.
I saw that with this code I could move the player a few blocks:
Vector3D rotation player.getRotation = ();
Direction dir = cardinalDirectionFromPitch (rotation.getX ());
Vector3D = dir.toVector3d diff () normalize () mul (3)..;
NewLoc = player.getLocation Rentals () add (diff).
player.setLocationSafely (newLoc);
So
I said to myself, is what we can create a kind of management or rather a
position eg X: 0 and Z 0 and therefore when the player is beyond the
circle could teleport the player a number of block chooses to that position or backward.
It’s possible ?