-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make players spawn in the center of a block when respawning on parkou…
…r checkpoints
- Loading branch information
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
common/src/main/java/net/endercube/common/utils/CoordinateUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package net.endercube.common.utils; | ||
|
||
import net.minestom.server.coordinate.Pos; | ||
|
||
public class CoordinateUtils { | ||
|
||
/** | ||
* Gets the center of a block from a block position | ||
* | ||
* @param blockPos The {@link Pos} with the integer block position | ||
* @return The {@link Pos} with the .5 position | ||
*/ | ||
public static Pos posFromBlockpos(Pos blockPos) { | ||
double x = blockPos.blockX(); | ||
double z = blockPos.blockZ(); | ||
|
||
if (x > 0) { | ||
x = x - 0.5; | ||
} else { | ||
x = x + 0.5; | ||
} | ||
|
||
if (z > 0) { | ||
z = z - 0.5; | ||
} else { | ||
z = z + 0.5; | ||
} | ||
|
||
return new Pos(x, blockPos.y(), z, blockPos.yaw(), blockPos.pitch()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters