diff --git a/AriasServerUtils/RTPFactory.cs b/AriasServerUtils/RTPFactory.cs
index abddf7a..3f36d9f 100644
--- a/AriasServerUtils/RTPFactory.cs
+++ b/AriasServerUtils/RTPFactory.cs
@@ -49,53 +49,18 @@ public class RTPFactory
/// A safe position if able to be found
public static PlayerPosition GetSafePosition(RTPData data, RTPPosition position)
{
- Random rng = ServerUtilities.rng;
- IServerPlayer isp = data.player;
- EntityPos vPos = isp.Entity.Pos;
- BlockPos bPos = new BlockPos(isp.Entity.Pos.Dimension);
- IServerWorldAccessor iswa = isp.Entity.World as IServerWorldAccessor;
+ PlayerPosition PPos = PlayerPosition.from(data.player.Entity);
+ BlockPos check = new(
+ x: position.x,
+ y: 1,
+ z: position.z,
+ dim: position.dimension
+ );
- int tries = 10000;
- PlayerPosition PPos = PlayerPosition.from(isp.Entity);
- //PlayerPosition original = PlayerPosition.from(isp.Entity);
+ int height = ServerUtilities.API.World.BlockAccessor.GetTerrainMapheightAt(check);
-
- // Generate random X and Z within max RTP distance
- bPos.X = position.x;
- bPos.Z = position.z;
- bPos.Y = 255;
-
- Block lastAboveLast = null;
- Block lastBlock = null;
- Block curBlock;
-
- // Scan downwards to find a valid landing spot
- for (int i = 255; i > 0; i--)
- {
- bPos.Y = i;
- curBlock = iswa.BlockAccessor.GetBlock(bPos);
-
- if (curBlock.MatterState == EnumMatterState.Solid)
- {
- if (lastBlock != null && lastBlock.BlockMaterial == EnumBlockMaterial.Air &&
- lastAboveLast != null && lastAboveLast.BlockMaterial == EnumBlockMaterial.Air)
- {
- // Found a valid spot: curBlock is solid, lastBlock & lastAboveLast are gas (air)
- PPos.X = bPos.X;
- PPos.Y = bPos.Y + 1;
- PPos.Z = bPos.Z;
-
- ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:rtp-found", tries));
-
- return PPos;
- }
- }
-
- lastAboveLast = lastBlock;
- lastBlock = curBlock;
- }
-
- return null; // Return null if no valid position is found after retries
+ PPos.Y = height + 1;
+ return PPos;
}
///
@@ -179,13 +144,14 @@ public class RTPFactory
if (pos == null)
{
// Let this get checked again
- RTPCache.Remove(data);
}
else
{
// Found! Perform teleport and remove the RTP Check
RTPCache.Remove(data);
pos.Merge(data.player.Entity);
+
+ ServerUtilities.SendMessageTo(data.player, Lang.Get($"{ServerUtilities.MOD_ID}:rtp", GetDistance(new Vec2i(data.StartPosition.X, data.StartPosition.Z), new Vec2i(pos.X, pos.Z))));
}
// Remove this check
diff --git a/AriasServerUtils/assets/ariasserverutils/lang/en.json b/AriasServerUtils/assets/ariasserverutils/lang/en.json
index 2efe4df..6a19efb 100644
--- a/AriasServerUtils/assets/ariasserverutils/lang/en.json
+++ b/AriasServerUtils/assets/ariasserverutils/lang/en.json
@@ -34,7 +34,7 @@
"back": "You've been taken back to your last position",
"rtp-search": "Searching for a random position...",
- "rtp-progress": "Still searchinf for a random position...",
+ "rtp-progress": "Still searching for a random position...",
"rtp": "You have been teleported [{0}] blocks away!",
"rtp-found": "Found a valid landing position after {0} tries.",
"rtp-fail": "Giving up on RTP search. No valid position could be found. Try again later",
diff --git a/AriasServerUtils/modinfo.json b/AriasServerUtils/modinfo.json
index fbc64b5..cd1afab 100644
--- a/AriasServerUtils/modinfo.json
+++ b/AriasServerUtils/modinfo.json
@@ -3,8 +3,8 @@
"modid": "ariasserverutils",
"name": "Aria's Server Utilities",
"authors": ["zontreck"],
- "description": "A collection of server utilities\n\nBuild Date: 03-10-2025 @ 10:22 AM MST",
- "version": "1.0.6-dev.12",
+ "description": "A collection of server utilities\n\nBuild Date: 03-10-2025 @ 10:36 AM MST",
+ "version": "1.0.6-dev.13",
"dependencies": {
"game": ""
}