Private
Public Access
1
0

fix GeneratePathForCurrentState exception, add catchup perf logging

This commit is contained in:
2026-03-17 10:56:33 +01:00
parent bff9251737
commit 6f3afd9cd8
3 changed files with 15 additions and 4 deletions

View File

@@ -286,11 +286,16 @@ public class BlockEntityBehaviorBeeSwarm(BlockEntity blockEntity) : BlockEntityB
activeBees.Add(bee);
if (catchup)
{
var totalDelta = Api.World.Calendar.ElapsedSeconds - packet.TimeElapsedSeconds;
var totalDelta = Math.Abs(Api.World.Calendar.ElapsedSeconds - packet.TimeElapsedSeconds);
if (modSystem?.Mod.Info.Version.Contains("dev") == true)
modSystem.Mod.Logger.Notification($"HandleBeeParticleSpawn catchup totalDelta: {totalDelta}s");
var stopwatch = Stopwatch.StartNew();
for (var i = 0; i < totalDelta / 0.1f; i++)
bee.Step(0.1f, 0.1f); // todo
stopwatch.Stop();
if (stopwatch.Elapsed.TotalSeconds > 0.02)
modSystem?.Mod?.Logger.Warning($"{nameof(BlockEntityBehaviorBeeSwarm)} {nameof(HandleBeeParticleSpawn)} catchup took {stopwatch.Elapsed.TotalSeconds:F2}s");
}
}
@@ -508,7 +513,7 @@ public class BlockEntityBehaviorBeeSwarm(BlockEntity blockEntity) : BlockEntityB
case SwarmState.BuildingSwarm:
{
var path = GenerateBuildingSwarmPath(blockAccessor, cfg);
var start = path is not null ? path[0].Position : hiddenAnchor;
var start = path is not null && path.Length > 0 ? path[0].Position : hiddenAnchor;
return (path, BeeRole.Traveling, start, hiddenAnchor);
}
case SwarmState.HangingOut:

View File

@@ -4,6 +4,7 @@ using RoamingBees.Particles.Catchup;
using RoamingBees.Utilities;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Numerics;
using Vintagestory.API.Client;
@@ -153,11 +154,16 @@ public class BlockEntityBehaviorRoamingBees(BlockEntity blockEntity) : BlockEnti
activeBees.Add(bee);
if (catchup)
{
var totalDelta = Api.World.Calendar.ElapsedSeconds - packet.TimeElapsedSeconds;
var totalDelta = Math.Abs(Api.World.Calendar.ElapsedSeconds - packet.TimeElapsedSeconds);
if (modSystem?.Mod.Info.Version.Contains("dev") == true)
modSystem.Mod.Logger.Notification($"HandleBeeParticleSpawn catchup totalDelta: {totalDelta}s");
var stopwatch = Stopwatch.StartNew();
for (var i = 0; i < totalDelta / 0.1f; i++)
bee.Step(0.1f, 0.1f); // todo
stopwatch.Stop();
if (stopwatch.Elapsed.TotalSeconds > 0.02)
modSystem?.Mod?.Logger.Warning($"{nameof(BlockEntityBehaviorRoamingBees)} {nameof(HandleBeeParticleSpawn)} catchup took {stopwatch.Elapsed.TotalSeconds:F2}s");
}
}

View File

@@ -7,7 +7,7 @@
"OrekiWoof"
],
"description": "Cute immersive roaming bees. Now on vanilla skeps and other mods' hives.",
"version": "2.0.0-dev.5",
"version": "2.0.0-dev.6",
"dependencies": {
"game": "1.21.0"
}