Restore the original RTP search method

This commit is contained in:
zontreck 2025-03-10 11:04:23 -07:00
parent 3712399a03
commit 5f99672a9b
2 changed files with 37 additions and 4 deletions

View file

@ -4,6 +4,7 @@ using System.Data;
using System.Linq;
using System.Numerics;
using AriasServerUtils;
using Microsoft.Win32.SafeHandles;
using Vintagestory.API.Common;
using Vintagestory.API.Common.Entities;
using Vintagestory.API.Config;
@ -53,9 +54,41 @@ public class RTPFactory
BlockPos check = data.LastPosition.GetBlockPos();
check.Y = 1;
int height = ServerUtilities.API.World.BlockAccessor.GetTerrainMapheightAt(check);
int Y = 255;
bool lastBlockAir = true;
bool lastLastBlockAir = true;
bool curBlockAir = true;
bool safe = false;
for (Y = 255; Y > 1; Y--)
{
// Manually scan downwards
var BA = ServerUtilities.API.World.BlockAccessor;
check.Y = Y;
var current = BA.GetBlock(check);
PPos.Y = height + 1;
if (current.BlockMaterial != EnumBlockMaterial.Air)
{
curBlockAir = false;
}
lastLastBlockAir = lastBlockAir;
lastBlockAir = curBlockAir;
if (!curBlockAir && lastBlockAir && lastLastBlockAir)
{
// We found a safe spot to land
check.Y++;
safe = true;
break;
}
}
if (!safe) return null;
PPos.Y = check.Y;
return PPos;
}

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