mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-03 14:38:53 +00:00
Random teleport will now place the player at the center of block, to help prevent players getting stuck in blocks and being pushed into lava
This commit is contained in:
1 parent
430528783a
commit
f7ce67ecff
1 file changed
+5
-1
@@ -36,6 +36,8 @@ public class RandomPoint extends TeleportationPoint {
|
|||||||
int x;
|
int x;
|
||||||
int y = 64;
|
int y = 64;
|
||||||
int z;
|
int z;
|
||||||
|
double blockCenterX = 0.5;
|
||||||
|
double blockCenterZ = 0.5;
|
||||||
int negativeX;
|
int negativeX;
|
||||||
int negativeZ;
|
int negativeZ;
|
||||||
|
|
||||||
@@ -51,13 +53,15 @@ public class RandomPoint extends TeleportationPoint {
|
|||||||
negativeZ = random.nextInt(2);
|
negativeZ = random.nextInt(2);
|
||||||
if (negativeX == 1) {
|
if (negativeX == 1) {
|
||||||
x = x * -1;
|
x = x * -1;
|
||||||
|
blockCenterX = blockCenterX * -1;
|
||||||
}
|
}
|
||||||
if (negativeZ == 1) {
|
if (negativeZ == 1) {
|
||||||
z = z * -1;
|
z = z * -1;
|
||||||
|
blockCenterZ = blockCenterZ * -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put together random location, get the highest block plus one to determine Y
|
// Put together random location, get the highest block plus one to determine Y
|
||||||
Location randomLocation = new Location(world, x, y, z);
|
Location randomLocation = new Location(world, (x + blockCenterX), y, (z + blockCenterZ));
|
||||||
y = world.getHighestBlockYAt(randomLocation) + 1;
|
y = world.getHighestBlockYAt(randomLocation) + 1;
|
||||||
randomLocation.setY(y);
|
randomLocation.setY(y);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user