feat: filter buffer data sent to visualizer clients by view distance
This commit is contained in:
@@ -66,10 +66,17 @@ internal static class ClaimLinkVisualizerNetwork
|
|||||||
{
|
{
|
||||||
ClaimLinkBufferResponse response = new();
|
ClaimLinkBufferResponse response = new();
|
||||||
|
|
||||||
|
BlockPos playerPos = toPlayer.Entity.Pos.AsBlockPos;
|
||||||
|
int radius = toPlayer.WorldData.LastApprovedViewDistance;
|
||||||
|
|
||||||
foreach (int groupId in ClaimLinkModSystem.Registry.All)
|
foreach (int groupId in ClaimLinkModSystem.Registry.All)
|
||||||
{
|
{
|
||||||
ClaimLinkBufferEntryDto entry = new() { GroupId = groupId };
|
ClaimLinkBufferEntryDto entry = new() { GroupId = groupId };
|
||||||
foreach (Cuboidi cuboid in ClaimLinkBuffer.GetBuffer(groupId))
|
foreach (Cuboidi cuboid in ClaimLinkBuffer.GetBuffer(groupId))
|
||||||
|
{
|
||||||
|
if (!IsNearby(cuboid, playerPos, radius))
|
||||||
|
continue;
|
||||||
|
|
||||||
entry.Cuboids.Add(
|
entry.Cuboids.Add(
|
||||||
new ClaimLinkBufferCuboidDto
|
new ClaimLinkBufferCuboidDto
|
||||||
{
|
{
|
||||||
@@ -81,9 +88,20 @@ internal static class ClaimLinkVisualizerNetwork
|
|||||||
MaxZ = cuboid.MaxZ,
|
MaxZ = cuboid.MaxZ,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
response.Entries.Add(entry);
|
}
|
||||||
|
|
||||||
|
if (entry.Cuboids.Count > 0)
|
||||||
|
response.Entries.Add(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
api.Network.GetChannel(ChannelName).SendPacket(response, toPlayer);
|
api.Network.GetChannel(ChannelName).SendPacket(response, toPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool IsNearby(Cuboidi cuboid, BlockPos playerPos, int radius) =>
|
||||||
|
cuboid.MinX <= playerPos.X + radius
|
||||||
|
&& cuboid.MaxX >= playerPos.X - radius
|
||||||
|
&& cuboid.MinY <= playerPos.Y + radius
|
||||||
|
&& cuboid.MaxY >= playerPos.Y - radius
|
||||||
|
&& cuboid.MinZ <= playerPos.Z + radius
|
||||||
|
&& cuboid.MaxZ >= playerPos.Z - radius;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
"anth64"
|
"anth64"
|
||||||
],
|
],
|
||||||
"description": "Link claims together with groups.",
|
"description": "Link claims together with groups.",
|
||||||
"version": "0.2.0",
|
"version": "0.3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"game": "1.22.5",
|
"game": "1.22.5",
|
||||||
"commandhook": "2.1.0"
|
"commandhook": "2.1.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user