Patch rtp in already loaded chunks

This commit is contained in:
zontreck 2025-03-10 12:03:32 -07:00
parent cf7084c164
commit bda8e49ee1
2 changed files with 31 additions and 4 deletions

View file

@ -168,9 +168,36 @@ public class RTPFactory
// Log the request
ChunkChecks.Add(chunk);
// Check if the chunk's coordinates are loaded
var cxCheck = ServerUtilities.API.World.IsFullyLoadedChunk(position.GetBlockPos());
if (cxCheck)
{
// Process the check here, no need to load
var posX = GetSafePosition(rtp, position);
if (posX == null)
{
// Let this get checked again
ServerUtilities.API.Logger.Notification("position null: resume search");
}
else
{
// Found! Perform teleport and remove the RTP Check
RTPCache.Remove(rtp);
posX.Merge(rtp.player.Entity);
ServerUtilities.SendMessageTo(rtp.player, Lang.Get($"{ServerUtilities.MOD_ID}:rtp", GetDistance(new Vec2i(rtp.StartPosition.X, rtp.StartPosition.Z), new Vec2i(posX.X, posX.Z))));
ServerUtilities.API.Logger.Notification("position found");
}
ChunkChecks.Remove(chunk);
}
else
{
// Load the chunk
worldManager.LoadChunkColumnPriority(chunk.ChunkX, chunk.ChunkZ);
}
}
}

View file

@ -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 @ 11:52 AM MST",
"version": "1.0.6-dev.17",
"description": "A collection of server utilities\n\nBuild Date: 03-10-2025 @ 11:55 AM MST",
"version": "1.0.6-dev.18",
"dependencies": {
"game": ""
}