mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 22:16:22 +00:00
Merge pull request #46 from Log1x/rtp-respect-wb
enhance(rtp): Ensure that random teleport respects the vanilla worldborder
This commit is contained in:
1 file changed
+8
-1
@@ -47,7 +47,10 @@ public class RandomPoint extends TeleportationPoint {
|
|||||||
double blockCenterZ = 0.5;
|
double blockCenterZ = 0.5;
|
||||||
|
|
||||||
// The furthest distance at which a player can be teleported to
|
// The furthest distance at which a player can be teleported to
|
||||||
int rtpRange = HuskHomes.getSettings().getRtpRange();
|
int rtpRange = Math.min(
|
||||||
|
HuskHomes.getSettings().getRtpRange(),
|
||||||
|
(int) world.getWorldBorder().getSize() - 1
|
||||||
|
);
|
||||||
|
|
||||||
// Calculate random X and Z coords
|
// Calculate random X and Z coords
|
||||||
x = random.nextInt(rtpRange);
|
x = random.nextInt(rtpRange);
|
||||||
@@ -81,6 +84,10 @@ public class RandomPoint extends TeleportationPoint {
|
|||||||
|
|
||||||
// Failsafe check in case the world is null
|
// Failsafe check in case the world is null
|
||||||
if (world != null) {
|
if (world != null) {
|
||||||
|
// Ensure we are inside of the world border.
|
||||||
|
if (!world.getWorldBorder().isInside(location)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Get instances of the blocks around where the player would teleport
|
// Get instances of the blocks around where the player would teleport
|
||||||
Block block = world.getBlockAt(x, y, z);
|
Block block = world.getBlockAt(x, y, z);
|
||||||
|
|||||||
Reference in new issue
Block a user