Private
Public Access
1
0

8 Commits

23 changed files with 345 additions and 112 deletions

View File

@@ -1,5 +1,5 @@
{ {
"total": 625681, "total": 658541,
"sessions": [ "sessions": [
{ {
"begin": "2026-01-09T17:26:02+01:00", "begin": "2026-01-09T17:26:02+01:00",
@@ -1415,6 +1415,101 @@
"begin": "2026-03-29T08:19:40+02:00", "begin": "2026-03-29T08:19:40+02:00",
"end": "2026-03-29T09:38:35+02:00", "end": "2026-03-29T09:38:35+02:00",
"duration": 4734 "duration": 4734
},
{
"begin": "2026-03-30T00:33:23+02:00",
"end": "2026-03-30T01:23:09+02:00",
"duration": 2986
},
{
"begin": "2026-04-07T22:11:37+02:00",
"end": "2026-04-07T22:37:52+02:00",
"duration": 1575
},
{
"begin": "2026-05-22T16:05:00+02:00",
"end": "2026-05-22T16:20:11+02:00",
"duration": 911
},
{
"begin": "2026-05-22T16:20:15+02:00",
"end": "2026-05-22T16:43:59+02:00",
"duration": 1424
},
{
"begin": "2026-05-22T16:47:46+02:00",
"end": "2026-05-22T17:08:18+02:00",
"duration": 1231
},
{
"begin": "2026-05-22T17:36:43+02:00",
"end": "2026-05-22T17:36:52+02:00",
"duration": 8
},
{
"begin": "2026-05-23T02:43:28+02:00",
"end": "2026-05-23T03:08:51+02:00",
"duration": 1523
},
{
"begin": "2026-05-23T03:10:56+02:00",
"end": "2026-05-23T03:44:31+02:00",
"duration": 2015
},
{
"begin": "2026-05-24T04:17:33+02:00",
"end": "2026-05-24T04:42:36+02:00",
"duration": 1503
},
{
"begin": "2026-05-24T05:43:24+02:00",
"end": "2026-05-24T06:28:26+02:00",
"duration": 2702
},
{
"begin": "2026-05-24T06:28:37+02:00",
"end": "2026-05-24T06:48:38+02:00",
"duration": 1201
},
{
"begin": "2026-05-24T06:50:13+02:00",
"end": "2026-05-24T06:50:54+02:00",
"duration": 41
},
{
"begin": "2026-05-24T06:51:03+02:00",
"end": "2026-05-24T06:53:00+02:00",
"duration": 116
},
{
"begin": "2026-05-24T06:53:21+02:00",
"end": "2026-05-24T08:00:35+02:00",
"duration": 4033
},
{
"begin": "2026-05-24T08:00:36+02:00",
"end": "2026-05-24T08:36:26+02:00",
"duration": 2150
},
{
"begin": "2026-05-24T08:36:27+02:00",
"end": "2026-05-24T08:51:27+02:00",
"duration": 900
},
{
"begin": "2026-05-24T08:51:27+02:00",
"end": "2026-05-24T10:42:30+02:00",
"duration": 6662
},
{
"begin": "2026-05-24T10:42:30+02:00",
"end": "2026-05-24T10:45:32+02:00",
"duration": 181
},
{
"begin": "2026-05-24T10:45:43+02:00",
"end": "2026-05-24T11:14:02+02:00",
"duration": 1698
} }
] ]
} }

23
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,23 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Vintage Story Client (Beehives)",
"type": "dotnet",
"request": "launch",
"projectPath": "${workspaceFolder}/OrekiWoofsBeehives/OrekiWoofsBeehives.csproj"
},
{
"name": "Vintage Story Client (RoamingBees)",
"type": "dotnet",
"request": "launch",
"projectPath": "${workspaceFolder}/RoamingBees/RoamingBees/RoamingBees.csproj"
},
{
"name": "Vintage Story Client (Beehives + RoamingBees)",
"type": "dotnet",
"request": "launch",
"projectPath": "${workspaceFolder}/OrekiWoofsBees.Full/OrekiWoofsBees.Full.csproj"
}
]
}

50
.vscode/tasks.json vendored Normal file
View File

@@ -0,0 +1,50 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "check env",
"type": "shell",
"command": "if [ \"${input:buildConfig}\" = \"Version22\" ]; then [ -n \"$VINTAGE_STORY_22\" ] || { echo 'ERROR: VINTAGE_STORY_22 is not set'; exit 1; }; [ -n \"$VINTAGE_STORY_DATA_22\" ] || { echo 'ERROR: VINTAGE_STORY_DATA_22 is not set'; exit 1; }; else [ -n \"$VINTAGE_STORY_21\" ] || { echo 'ERROR: VINTAGE_STORY_21 is not set'; exit 1; }; [ -n \"$VINTAGE_STORY_DATA_21\" ] || { echo 'ERROR: VINTAGE_STORY_DATA_21 is not set'; exit 1; }; fi",
"windows": {
"command": "if ('${input:buildConfig}' -eq 'Version22') { if (-not $env:VINTAGE_STORY_22) { Write-Host 'ERROR: VINTAGE_STORY_22 is not set'; exit 1 }; if (-not $env:VINTAGE_STORY_DATA_22) { Write-Host 'ERROR: VINTAGE_STORY_DATA_22 is not set'; exit 1 } } else { if (-not $env:VINTAGE_STORY_21) { Write-Host 'ERROR: VINTAGE_STORY_21 is not set'; exit 1 }; if (-not $env:VINTAGE_STORY_DATA_21) { Write-Host 'ERROR: VINTAGE_STORY_DATA_21 is not set'; exit 1 } }"
},
"problemMatcher": []
},
{
"label": "build mod",
"command": "dotnet",
"type": "process",
"dependsOn": ["check env"],
"dependsOrder": "sequence",
"args": [
"build",
"${input:buildProject}",
"-c",
"${input:buildConfig}",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary;ForceNoAlign"
],
"problemMatcher": "$msCompile"
}
],
"inputs": [
{
"id": "buildConfig",
"type": "pickString",
"description": "Build configuration",
"options": ["Debug", "Release", "Version22"],
"default": "Debug"
},
{
"id": "buildProject",
"type": "pickString",
"description": "Project to build",
"options": [
"${workspaceFolder}/OrekiWoofsBeehives/OrekiWoofsBeehives.csproj",
"${workspaceFolder}/RoamingBees/RoamingBees/RoamingBees.csproj",
"${workspaceFolder}/OrekiWoofsBees.Full/OrekiWoofsBees.Full.csproj"
],
"default": "${workspaceFolder}/OrekiWoofsBees.Full/OrekiWoofsBees.Full.csproj"
}
]
}

View File

@@ -1,6 +1,6 @@
<Solution> <Solution>
<Configurations> <Configurations>
<BuildType Name="Debug22" /> <BuildType Name="Version22" />
<BuildType Name="Debug" /> <BuildType Name="Debug" />
<BuildType Name="Release" /> <BuildType Name="Release" />
</Configurations> </Configurations>
@@ -9,7 +9,7 @@
</Folder> </Folder>
<Project Path="OrekiWoofsBeehives/OrekiWoofsBeehives.csproj" /> <Project Path="OrekiWoofsBeehives/OrekiWoofsBeehives.csproj" />
<Project Path="OrekiWoofsBees.Common/OrekiWoofsBees.Common.csproj" Id="e53bd51a-4c0e-4482-9e20-1361d42e72ea"> <Project Path="OrekiWoofsBees.Common/OrekiWoofsBees.Common.csproj" Id="e53bd51a-4c0e-4482-9e20-1361d42e72ea">
<BuildType Solution="Debug22|*" Project="Release" /> <BuildType Solution="Version22|*" Project="Release" />
</Project> </Project>
<Project Path="RoamingBees/RoamingBees/RoamingBees.csproj" Id="7f545210-d3d4-4232-b6d6-7a10be19290c" /> <Project Path="RoamingBees/RoamingBees/RoamingBees.csproj" Id="7f545210-d3d4-4232-b6d6-7a10be19290c" />
<Project Path="RoamingBees/ZZCakeBuild/RoamingBeesCakeBuild.csproj" Id="742949f3-29ab-48ef-bb9a-903055795dfb" /> <Project Path="RoamingBees/ZZCakeBuild/RoamingBeesCakeBuild.csproj" Id="742949f3-29ab-48ef-bb9a-903055795dfb" />

View File

@@ -295,19 +295,19 @@ public class BlockEntityBeeSwarm : BlockEntity
Disperse(); Disperse();
} }
private void StartMigrating(double nowHours, BlockPos targetPos, bool targetIsVanillaSkep, string? targetPopulatedSkepCode) private void StartMigrating(double nowHours, StructVec3i targetPos, bool targetIsVanillaSkep, string? targetPopulatedSkepCode)
{ {
StopCandidateRefresh(); StopCandidateRefresh();
SwarmState = SwarmState.MigratingToNewHive; SwarmState = SwarmState.MigratingToNewHive;
stateStartTotalHours = nowHours; stateStartTotalHours = nowHours;
migrationStartPopulation = Population; migrationStartPopulation = Population;
transferredDuringMigration = 0; transferredDuringMigration = 0;
this.targetPos = targetPos.Copy(); this.targetPos = targetPos.ToBlockPos();
this.targetIsVanillaSkep = targetIsVanillaSkep; this.targetIsVanillaSkep = targetIsVanillaSkep;
this.targetPopulatedSkepCode = targetPopulatedSkepCode; this.targetPopulatedSkepCode = targetPopulatedSkepCode;
retryDay = -1; retryDay = -1;
if (!targetIsVanillaSkep && Api.World.BlockAccessor.GetBlockEntity(targetPos) is BlockEntityReusableBeehive targetHive) if (!targetIsVanillaSkep && Api.World.BlockAccessor.GetBlockEntity(this.targetPos) is BlockEntityReusableBeehive targetHive)
targetHive.SetIncomingSwarm(Pos); targetHive.SetIncomingSwarm(Pos);
MarkDirty(false); MarkDirty(false);
@@ -382,7 +382,7 @@ public class BlockEntityBeeSwarm : BlockEntity
continue; continue;
var score = CalculateBeehiveTargetScore(hive, targetPos, radius); var score = CalculateBeehiveTargetScore(hive, targetPos, radius);
candidates.Add(new SwarmTargetCandidate(targetPos, false, score, null)); candidates.Add(new SwarmTargetCandidate(StructVec3i.FromBlockPos(targetPos), false, score, null));
} }
} }
@@ -403,7 +403,7 @@ public class BlockEntityBeeSwarm : BlockEntity
continue; continue;
var score = CalculateSkepTargetScore(targetPos, radius); var score = CalculateSkepTargetScore(targetPos, radius);
candidates.Add(new SwarmTargetCandidate(targetPos, true, score, entry.Value)); candidates.Add(new SwarmTargetCandidate(StructVec3i.FromBlockPos(targetPos), true, score, entry.Value));
} }
} }
@@ -411,13 +411,13 @@ public class BlockEntityBeeSwarm : BlockEntity
return candidates; return candidates;
} }
private bool TryConvertSkepToPopulated(BlockPos pos, string populatedCode) private bool TryConvertSkepToPopulated(StructVec3i pos, string populatedCode)
{ {
var block = Api.World.GetBlock(new AssetLocation(populatedCode)); var block = Api.World.GetBlock(new AssetLocation(populatedCode));
if (block == null || block.Id == 0) if (block == null || block.Id == 0)
return false; return false;
Api.World.BlockAccessor.ExchangeBlock(block.BlockId, pos); Api.World.BlockAccessor.ExchangeBlock(block.BlockId, pos.ToBlockPos());
return true; return true;
} }
@@ -612,6 +612,7 @@ public class BlockEntityBeeSwarm : BlockEntity
tree.SetBlockPos("targetPos", targetPos); tree.SetBlockPos("targetPos", targetPos);
} }
private readonly BlockPos _tempBlockPos = new(0, 0, 0);
private TreeArrayAttribute BuildCandidateHivesTreeArray() private TreeArrayAttribute BuildCandidateHivesTreeArray()
{ {
if (targetHiveCandidates == null) if (targetHiveCandidates == null)
@@ -622,7 +623,8 @@ public class BlockEntityBeeSwarm : BlockEntity
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
var entry = new TreeAttribute(); var entry = new TreeAttribute();
entry.SetBlockPos("pos", targetHiveCandidates[i].Pos); _tempBlockPos.Set(targetHiveCandidates[i].Pos.X, targetHiveCandidates[i].Pos.Y, targetHiveCandidates[i].Pos.Z);
entry.SetBlockPos("pos", _tempBlockPos); // safe, as internally does 3x SetInt
entries[i] = entry; entries[i] = entry;
} }
return new TreeArrayAttribute(entries); return new TreeArrayAttribute(entries);
@@ -659,5 +661,5 @@ public class BlockEntityBeeSwarm : BlockEntity
Api.GetOrekiWoofsBeehives()?.BroadcastUnloadDebug(message); Api.GetOrekiWoofsBeehives()?.BroadcastUnloadDebug(message);
} }
private readonly record struct SwarmTargetCandidate(BlockPos Pos, bool IsVanillaSkep, double Score, string? PopulatedSkepCode); private readonly record struct SwarmTargetCandidate(StructVec3i Pos, bool IsVanillaSkep, double Score, string? PopulatedSkepCode);
} }

View File

@@ -5,14 +5,16 @@
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>bin\$(Configuration)\Mods\orekiwoofsbeehives</OutputPath> <OutputPath>bin\$(Configuration)\Mods\orekiwoofsbeehives</OutputPath>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<Configurations>Debug;Release;Debug22</Configurations> <Configurations>Debug;Release;Version22</Configurations>
<VINTAGE_STORY>$(VINTAGE_STORY_21)</VINTAGE_STORY>
<VINTAGE_STORY_DATA>$(VINTAGE_STORY_DATA_21)</VINTAGE_STORY_DATA>
<VintageStoryDataPathArgs></VintageStoryDataPathArgs> <VintageStoryDataPathArgs></VintageStoryDataPathArgs>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug22'"> <PropertyGroup Condition="'$(Configuration)' == 'Version22'">
<TargetFramework>net10.0</TargetFramework> <TargetFramework>net10.0</TargetFramework>
<VINTAGE_STORY>$(VINTAGE_STORY_22)</VINTAGE_STORY> <VINTAGE_STORY>$(VINTAGE_STORY_22)</VINTAGE_STORY>
<VINTAGE_STORY_DATA Condition="'$(VINTAGE_STORY_DATA_22)' != '' and Exists('$(VINTAGE_STORY_DATA_22)')">$(VINTAGE_STORY_DATA_22)</VINTAGE_STORY_DATA> <VINTAGE_STORY_DATA>$(VINTAGE_STORY_DATA_22)</VINTAGE_STORY_DATA>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(VINTAGE_STORY_DATA)' != '' and Exists('$(VINTAGE_STORY_DATA)')"> <PropertyGroup Condition="'$(VINTAGE_STORY_DATA)' != '' and Exists('$(VINTAGE_STORY_DATA)')">

View File

@@ -18,7 +18,7 @@ public static class BEFarmland_GetGrowthRate_Patch
} }
} }
#if DEBUG22 #if VERSION22
[HarmonyPatch(typeof(BlockEntitySoilNutrition), nameof(BlockEntitySoilNutrition.GetGrowthRate), [typeof(EnumSoilNutrient)])] [HarmonyPatch(typeof(BlockEntitySoilNutrition), nameof(BlockEntitySoilNutrition.GetGrowthRate), [typeof(EnumSoilNutrient)])]
[HarmonyPatchCategory("1.22")] [HarmonyPatchCategory("1.22")]
public static class BESoilNutrition_GetGrowthRate_Patch public static class BESoilNutrition_GetGrowthRate_Patch

View File

@@ -23,7 +23,9 @@
"beehiveframe-filled-feed": { "beehiveframe-filled-feed": {
"center": "game:block/food/grain/flax" "center": "game:block/food/grain/flax"
} }
} },
"collisionBox": { "x1": 0.125, "y1": 0, "z1": 0.125, "x2": 0.875, "y2": 0.0625, "z2": 0.875 },
"selectionBox": { "x1": 0.125, "y1": 0, "z1": 0.125, "x2": 0.875, "y2": 0.0625, "z2": 0.875 }
} }
}, },
{ "name": "Unplaceable" }, { "name": "Unplaceable" },

View File

@@ -0,0 +1,20 @@
[
{
"op": "addMerge",
"path": "/behaviors",
"value": [
{
"name": "Carryable",
"properties": {
"interactDelay": 0.8
}
}
],
"file": "orekiwoofsbeehives:blocktypes/beehive",
"dependsOn": [
{
"modid": "carryon"
}
]
}
]

View File

@@ -7,7 +7,7 @@
"OrekiWoof" "OrekiWoof"
], ],
"description": "Beehive with 8 slots for honey frames. Boosts your plants.", "description": "Beehive with 8 slots for honey frames. Boosts your plants.",
"version": "2.0.0-dev.7", "version": "2.0.0-rc.1",
"dependencies": { "dependencies": {
"game": "1.21.0" "game": "1.21.0"
} }

View File

@@ -5,7 +5,7 @@ namespace OrekiWoofsBees.Common;
public static class DiagnosticsUtil public static class DiagnosticsUtil
{ {
public static void StopAndLogTime<T>( public static bool StopAndLogTime<T>(
this Stopwatch stopwatch, this Stopwatch stopwatch,
T instance, T instance,
double totalSecondsThreshold, double totalSecondsThreshold,
@@ -14,7 +14,11 @@ public static class DiagnosticsUtil
{ {
stopwatch.Stop(); stopwatch.Stop();
if (stopwatch.Elapsed.TotalSeconds >= totalSecondsThreshold) if (stopwatch.Elapsed.TotalSeconds >= totalSecondsThreshold)
{
instance.Mod?.Logger.Warning($"{typeof(T).Name}.{callerName} ({note}) took {stopwatch.Elapsed.TotalSeconds:F2}s"); instance.Mod?.Logger.Warning($"{typeof(T).Name}.{callerName} ({note}) took {stopwatch.Elapsed.TotalSeconds:F2}s");
return true;
}
return false;
} }
public static void LogTime<T>( public static void LogTime<T>(

View File

@@ -4,13 +4,15 @@
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<Configurations>Debug;Release;Debug22</Configurations> <Configurations>Debug;Release;Version22</Configurations>
<VINTAGE_STORY>$(VINTAGE_STORY_21)</VINTAGE_STORY>
<VINTAGE_STORY_DATA>$(VINTAGE_STORY_DATA_21)</VINTAGE_STORY_DATA>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug22'"> <PropertyGroup Condition="'$(Configuration)' == 'Version22'">
<TargetFramework>net10.0</TargetFramework> <TargetFramework>net10.0</TargetFramework>
<VINTAGE_STORY>$(VINTAGE_STORY_22)</VINTAGE_STORY> <VINTAGE_STORY>$(VINTAGE_STORY_22)</VINTAGE_STORY>
<VINTAGE_STORY_DATA Condition="'$(VINTAGE_STORY_DATA_22)' != '' and Exists('$(VINTAGE_STORY_DATA_22)')">$(VINTAGE_STORY_DATA_22)</VINTAGE_STORY_DATA> <VINTAGE_STORY_DATA>$(VINTAGE_STORY_DATA_22)</VINTAGE_STORY_DATA>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@@ -55,7 +57,7 @@
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="configlib"> <Reference Include="configlib">
<HintPath>E:\Code\VintageStory\configlib_1.10.14\configlib.dll</HintPath> <HintPath>$(VS_CONFIGLIB)</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
</ItemGroup> </ItemGroup>

View File

@@ -5,4 +5,6 @@ namespace OrekiWoofsBees.Common;
public readonly record struct StructVec3i(int X, int Y, int Z) public readonly record struct StructVec3i(int X, int Y, int Z)
{ {
public static StructVec3i FromBlockPos(BlockPos pos) => new(pos.X, pos.Y, pos.Z); public static StructVec3i FromBlockPos(BlockPos pos) => new(pos.X, pos.Y, pos.Z);
public BlockPos ToBlockPos() => new(X, Y, Z);
} }

View File

@@ -1,15 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<Configurations>Debug;Release;Debug22</Configurations> <Configurations>Debug;Release;Version22</Configurations>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems> <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck> <DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
<VINTAGE_STORY>$(VINTAGE_STORY_21)</VINTAGE_STORY>
<VINTAGE_STORY_DATA>$(VINTAGE_STORY_DATA_21)</VINTAGE_STORY_DATA>
<VintageStoryDataPathArgs></VintageStoryDataPathArgs> <VintageStoryDataPathArgs></VintageStoryDataPathArgs>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug22'"> <PropertyGroup Condition="'$(Configuration)' == 'Version22'">
<TargetFramework>net10.0</TargetFramework> <TargetFramework>net10.0</TargetFramework>
<VintageStoryDataPathArgs> --dataPath "..\VintageStoryDataBeehives\Data22"</VintageStoryDataPathArgs> <VINTAGE_STORY>$(VINTAGE_STORY_22)</VINTAGE_STORY>
<VINTAGE_STORY_DATA>$(VINTAGE_STORY_DATA_22)</VINTAGE_STORY_DATA>
</PropertyGroup>
<PropertyGroup Condition="'$(VINTAGE_STORY_DATA)' != '' and Exists('$(VINTAGE_STORY_DATA)')">
<VintageStoryDataPathArgs> --dataPath "$(VINTAGE_STORY_DATA)"</VintageStoryDataPathArgs>
</PropertyGroup> </PropertyGroup>
<Target Name="BuildBothMods" BeforeTargets="Build"> <Target Name="BuildBothMods" BeforeTargets="Build">

View File

@@ -39,7 +39,12 @@ public class BlockEntityBehaviorRoamingBees(BlockEntity blockEntity) : BlockEnti
private ClimateCondition? climate; private ClimateCondition? climate;
private Vec3d? windVec; private Vec3d? windVec;
private readonly Stopwatch stopwatch = new(); private int onParticleTickStopwatchTriggerCount;
private int spawnStopwatchTriggerCount;
private readonly Stopwatch plantInfoStopwatch = new();
private readonly Stopwatch particleStopwatch = new();
private readonly Stopwatch serverSpawnStopwatch = new();
private readonly Stopwatch handleSpawnStopwatch = new();
private readonly List<StructVec3i> flowerPositions = []; private readonly List<StructVec3i> flowerPositions = [];
private readonly List<StructVec3i> cropPositions = []; private readonly List<StructVec3i> cropPositions = [];
private readonly List<Vector3> relativePlantPositions = []; private readonly List<Vector3> relativePlantPositions = [];
@@ -47,7 +52,6 @@ public class BlockEntityBehaviorRoamingBees(BlockEntity blockEntity) : BlockEnti
public const string TARGET_BEE_PARTICLE_COUNT_ATTRIBUTE = "roamingbees_targetBeeParticleCount"; public const string TARGET_BEE_PARTICLE_COUNT_ATTRIBUTE = "roamingbees_targetBeeParticleCount";
public const string RADIUS_ATTRIBUTE = "roamingbees_radius"; public const string RADIUS_ATTRIBUTE = "roamingbees_radius";
public const string NETWORK_CHANNEL_NAME = "bee particle spawns"; public const string NETWORK_CHANNEL_NAME = "bee particle spawns";
public const int SERVER_TICK_FREQUENCY_DECREASE = 50;
public int ActiveBeesCount => activeBees.Count; public int ActiveBeesCount => activeBees.Count;
public IEnumerable<BeeSpawnPacket> ActiveBeesPackets => activeBees.Select(x => x.SpawnPacket); public IEnumerable<BeeSpawnPacket> ActiveBeesPackets => activeBees.Select(x => x.SpawnPacket);
@@ -85,10 +89,25 @@ public class BlockEntityBehaviorRoamingBees(BlockEntity blockEntity) : BlockEnti
plantPositionRegistry?.RegisterBeehive(Blockentity.Pos, radius); plantPositionRegistry?.RegisterBeehive(Blockentity.Pos, radius);
var updateFrequency = 20; var updateFrequency = 20;
if (api.Side == EnumAppSide.Server)
updateFrequency *= SERVER_TICK_FREQUENCY_DECREASE;
Blockentity.RegisterGameTickListener(OnParticleTick, updateFrequency); Blockentity.RegisterGameTickListener(OnParticleTick, updateFrequency);
Blockentity.RegisterGameTickListener(UpdateClimateInfo, 10000); Blockentity.RegisterGameTickListener(UpdateClimateInfo, 10000);
Blockentity.RegisterGameTickListener(DecreaseStopwatchCounts, 60000);
if (api.Side.IsServer())
{
Blockentity.RegisterGameTickListener(OnSpawnTick, 500);
Blockentity.RegisterGameTickListener(OnUpdatePlantInfoTick, 5000);
}
}
private void DecreaseStopwatchCounts(float dt)
{
if (spawnStopwatchTriggerCount > 10)
modSystem?.Mod.Logger.Warning($"{nameof(spawnStopwatchTriggerCount)} is {spawnStopwatchTriggerCount}");
spawnStopwatchTriggerCount = Math.Max(0, spawnStopwatchTriggerCount - 1);
if (onParticleTickStopwatchTriggerCount > 10)
modSystem?.Mod.Logger.Warning($"{nameof(onParticleTickStopwatchTriggerCount)} is {onParticleTickStopwatchTriggerCount}");
onParticleTickStopwatchTriggerCount = Math.Max(0, onParticleTickStopwatchTriggerCount - 1);
} }
private void UpdateClimateInfo(float dt) private void UpdateClimateInfo(float dt)
@@ -150,7 +169,7 @@ public class BlockEntityBehaviorRoamingBees(BlockEntity blockEntity) : BlockEnti
public void HandleBeeParticleSpawn(BeeSpawnPacket packet, bool catchup = false) public void HandleBeeParticleSpawn(BeeSpawnPacket packet, bool catchup = false)
{ {
stopwatch.Restart(); handleSpawnStopwatch.Restart();
if (Blockentity.Pos != packet.HivePosition) if (Blockentity.Pos != packet.HivePosition)
return; return;
@@ -189,7 +208,7 @@ public class BlockEntityBehaviorRoamingBees(BlockEntity blockEntity) : BlockEnti
for (var i = 0; i < totalDelta / 0.1f; i++) for (var i = 0; i < totalDelta / 0.1f; i++)
bee.Step(0.1f, 0.1f); // todo bee.Step(0.1f, 0.1f); // todo
} }
stopwatch.StopAndLogTime(this, 0.05); handleSpawnStopwatch.StopAndLogTime(this, 0.05);
} }
public void Clear() public void Clear()
@@ -204,12 +223,22 @@ public class BlockEntityBehaviorRoamingBees(BlockEntity blockEntity) : BlockEnti
activeBees.Clear(); activeBees.Clear();
} }
private void OnParticleTick(float dt) private void OnUpdatePlantInfoTick(float dt)
{ {
if (Block is BlockSkep && !Config.Instance.EnableOnVanillaSkeps) if (!ShouldTick())
return; return;
stopwatch.Restart(); plantInfoStopwatch.Restart();
UpdatePlantInfo();
var note = $"global bees: {modSystem?.GlobalActiveBees}, registered hives: {modSystem?.BeeSpawnPacketDistributor?.SpawnHandlersCount}, radius: {Config.Instance.BeeRoamingRadius}";
plantInfoStopwatch.StopAndLogTime(this, 0.1, note);
}
private bool ShouldTick()
{
if (Block is BlockSkep && !Config.Instance.EnableOnVanillaSkeps)
return false;
var isFgc = Block?.Code?.Domain == "fromgoldencombs"; var isFgc = Block?.Code?.Domain == "fromgoldencombs";
var path = Block?.Code?.Path ?? string.Empty; var path = Block?.Code?.Path ?? string.Empty;
var isFgcLangstroth = isFgc && path.Contains("langstrothstack", StringComparison.OrdinalIgnoreCase); var isFgcLangstroth = isFgc && path.Contains("langstrothstack", StringComparison.OrdinalIgnoreCase);
@@ -218,22 +247,37 @@ public class BlockEntityBehaviorRoamingBees(BlockEntity blockEntity) : BlockEnti
if (isFgcLangstroth) if (isFgcLangstroth)
{ {
if (!Config.Instance.EnableOnFgcLangstroth) if (!Config.Instance.EnableOnFgcLangstroth)
return; return false;
if (!HasRequiredLangstrothBase()) if (!HasRequiredLangstrothBase())
return; return false;
} }
if (isFgcCeramic && !Config.Instance.EnableOnFgcCeramic) if (isFgcCeramic && !Config.Instance.EnableOnFgcCeramic)
return false;
return true;
}
private void OnParticleTick(float dt)
{
if (!ShouldTick())
return; return;
var isFgc = Block?.Code?.Domain == "fromgoldencombs";
var path = Block?.Code?.Path ?? string.Empty;
var isFgcLangstroth = isFgc && path.Contains("langstrothstack", StringComparison.OrdinalIgnoreCase);
var isFgcCeramic = isFgc && path.Contains("ceramicbroodpot", StringComparison.OrdinalIgnoreCase);
particleStopwatch.Restart();
entityAttributeSnapshot.Clear(); entityAttributeSnapshot.Clear();
Blockentity.ToTreeAttributes(entityAttributeSnapshot); Blockentity.ToTreeAttributes(entityAttributeSnapshot);
var targetBeeParticleCount = GetTargetBeeParticleCountFromBlockEntity(); var targetBeeParticleCount = GetTargetBeeParticleCountFromBlockEntity();
if (targetBeeParticleCount <= 0) TargetParticleCount = Math.Max(0, targetBeeParticleCount);
if (TargetParticleCount <= 0)
return; return;
TargetParticleCount = Math.Max(0, targetBeeParticleCount);
if (Block is BlockSkep) if (Block is BlockSkep)
TargetParticleCount = Config.Instance.RoamingBeesPerVanillaSkep; TargetParticleCount = Config.Instance.RoamingBeesPerVanillaSkep;
if (isFgcLangstroth) if (isFgcLangstroth)
@@ -241,14 +285,9 @@ public class BlockEntityBehaviorRoamingBees(BlockEntity blockEntity) : BlockEnti
if (isFgcCeramic) if (isFgcCeramic)
TargetParticleCount = Config.Instance.RoamingBeesPerFgcCeramic; TargetParticleCount = Config.Instance.RoamingBeesPerFgcCeramic;
if (Api.Side == EnumAppSide.Server)
{
UpdatePlantInfo();
stopwatch.LogTime(this, 0.05, "after UpdatePlantInfo");
}
Update(dt); Update(dt);
stopwatch.StopAndLogTime(this, 0.05); if (particleStopwatch.StopAndLogTime(this, 0.1, note: $"global bees: {modSystem?.GlobalActiveBees}, registered hives: {modSystem?.BeeSpawnPacketDistributor?.SpawnHandlersCount}"))
onParticleTickStopwatchTriggerCount++;
} }
private void Update(float dt) private void Update(float dt)
@@ -265,7 +304,10 @@ public class BlockEntityBehaviorRoamingBees(BlockEntity blockEntity) : BlockEnti
temperature = climate?.Temperature ?? 20f; temperature = climate?.Temperature ?? 20f;
// iterate from end to easily remove from list // iterate from end to easily remove from list
for (int i = activeBees.Count - 1; i >= 0; i--) var end = activeBees.Count - 1;
end -= onParticleTickStopwatchTriggerCount * 10;
for (int i = end; i >= 0; i--)
{ {
var bee = activeBees[i]; var bee = activeBees[i];
@@ -276,10 +318,7 @@ public class BlockEntityBehaviorRoamingBees(BlockEntity blockEntity) : BlockEnti
BeeVisualParticleRenderer.Spawn(clientWorld, Blockentity.Pos, bee); BeeVisualParticleRenderer.Spawn(clientWorld, Blockentity.Pos, bee);
} }
if (Api.Side == EnumAppSide.Server) if (Api.Side == EnumAppSide.Server)
{ bee.Step(dt, windSpeed);
for (var j = 0; j < SERVER_TICK_FREQUENCY_DECREASE; j++)
bee.Step(dt / SERVER_TICK_FREQUENCY_DECREASE, windSpeed);
}
if (bee.ShouldBeDespawned && modSystem != null) if (bee.ShouldBeDespawned && modSystem != null)
{ {
@@ -289,12 +328,28 @@ public class BlockEntityBehaviorRoamingBees(BlockEntity blockEntity) : BlockEnti
} }
TimeSinceLastSpawn += dt; TimeSinceLastSpawn += dt;
if (Api.Side == EnumAppSide.Server) }
TrySpawnNewBee(TargetParticleCount);
private void OnSpawnTick(float dt)
{
if (!ShouldTick())
return;
if (climate is null || windVec is null)
return;
serverSpawnStopwatch.Restart();
TrySpawnNewBee(TargetParticleCount);
if (serverSpawnStopwatch.StopAndLogTime(this, 0.1))
spawnStopwatchTriggerCount++;
} }
private void TrySpawnNewBee(int targetParticleCount) private void TrySpawnNewBee(int targetParticleCount)
{ {
int desiredParticleCount = targetParticleCount;
if (activeBees.Count >= desiredParticleCount)
return;
if (TimeSinceLastSpawn < spawn_cooldown_seconds) if (TimeSinceLastSpawn < spawn_cooldown_seconds)
return; return;
@@ -305,7 +360,7 @@ public class BlockEntityBehaviorRoamingBees(BlockEntity blockEntity) : BlockEnti
var sunPos = Api.World.Calendar.GetSunPosition(new Vec3d(Blockentity.Pos.X, Blockentity.Pos.Y, Blockentity.Pos.Z), Api.World.Calendar.TotalDays); var sunPos = Api.World.Calendar.GetSunPosition(new Vec3d(Blockentity.Pos.X, Blockentity.Pos.Y, Blockentity.Pos.Z), Api.World.Calendar.TotalDays);
float sunAltitudeDegrees = MathF.Asin(sunPos.Y) * 180f / GameMath.PI; float sunAltitudeDegrees = MathF.Asin(sunPos.Y) * 180f / GameMath.PI;
if (sunPos.Y <= cfg.SunAltitudeMinDegrees) if (sunAltitudeDegrees <= cfg.SunAltitudeMinDegrees)
return; return;
if (rainfall >= cfg.RainfallSpawnStopThreshold) if (rainfall >= cfg.RainfallSpawnStopThreshold)
@@ -318,10 +373,6 @@ public class BlockEntityBehaviorRoamingBees(BlockEntity blockEntity) : BlockEnti
if (modSystem.GlobalActiveBees >= maxGlobal) if (modSystem.GlobalActiveBees >= maxGlobal)
return; return;
int desiredParticleCount = targetParticleCount;
if (activeBees.Count >= desiredParticleCount)
return;
float sunAltitudeModifier = 1 - Math.Clamp((sunAltitudeDegrees - cfg.SunAltitudeMinDegrees) / cfg.SunAltitudeRangeDegrees, 0f, 1f); float sunAltitudeModifier = 1 - Math.Clamp((sunAltitudeDegrees - cfg.SunAltitudeMinDegrees) / cfg.SunAltitudeRangeDegrees, 0f, 1f);
float sunAltitudeCooldownPenalty = sunAltitudeModifier * cfg.MaxSunAltitudeCooldownPenalty; float sunAltitudeCooldownPenalty = sunAltitudeModifier * cfg.MaxSunAltitudeCooldownPenalty;

View File

@@ -17,6 +17,8 @@ internal class BeeSpawnPacketDistributor(RoamingBeesModSystem modSystem, EnumApp
private Dictionary<Vector3, IBeeSpawnHandler> spawnHandlers { get; } = []; private Dictionary<Vector3, IBeeSpawnHandler> spawnHandlers { get; } = [];
private Dictionary<Vector3, IBeeSpawnCatchup> catchupHandlers { get; } = []; private Dictionary<Vector3, IBeeSpawnCatchup> catchupHandlers { get; } = [];
public int SpawnHandlersCount => spawnHandlers.Count;
public void Register(BlockPos position, object manager) public void Register(BlockPos position, object manager)
{ {
if (manager is IBeeSpawnHandler spawnHandler) if (manager is IBeeSpawnHandler spawnHandler)

View File

@@ -5,14 +5,16 @@
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>bin\$(Configuration)\Mods\roamingbees</OutputPath> <OutputPath>bin\$(Configuration)\Mods\roamingbees</OutputPath>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<Configurations>Debug;Release;Debug22</Configurations> <Configurations>Debug;Release;Version22</Configurations>
<VINTAGE_STORY>$(VINTAGE_STORY_21)</VINTAGE_STORY>
<VINTAGE_STORY_DATA>$(VINTAGE_STORY_DATA_21)</VINTAGE_STORY_DATA>
<VintageStoryDataPathArgs></VintageStoryDataPathArgs> <VintageStoryDataPathArgs></VintageStoryDataPathArgs>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug22'"> <PropertyGroup Condition="'$(Configuration)' == 'Version22'">
<TargetFramework>net10.0</TargetFramework> <TargetFramework>net10.0</TargetFramework>
<VINTAGE_STORY>$(VINTAGE_STORY_22)</VINTAGE_STORY> <VINTAGE_STORY>$(VINTAGE_STORY_22)</VINTAGE_STORY>
<VINTAGE_STORY_DATA Condition="'$(VINTAGE_STORY_DATA_22)' != '' and Exists('$(VINTAGE_STORY_DATA_22)')">$(VINTAGE_STORY_DATA_22)</VINTAGE_STORY_DATA> <VINTAGE_STORY_DATA>$(VINTAGE_STORY_DATA_22)</VINTAGE_STORY_DATA>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(VINTAGE_STORY_DATA)' != '' and Exists('$(VINTAGE_STORY_DATA)')"> <PropertyGroup Condition="'$(VINTAGE_STORY_DATA)' != '' and Exists('$(VINTAGE_STORY_DATA)')">

View File

@@ -1,52 +1,4 @@
[ [
{
"op": "addMerge",
"path": "/entityBehaviors",
"value": [
{
"name": "BlockEntityBehaviorRoamingBees",
"properties": {
"facingVariantKey": "",
"entrancePositions": {
"north": [0.5, 0.1, 0.8],
"east": [0.2, 0.1, 0.5],
"south": [0.5, 0.1, 0.2],
"west": [0.8, 0.1, 0.5]
},
"frontDirections": {
"north": [0, 0, 1],
"east": [-1, 0, 0],
"south": [0, 0, -1],
"west": [1, 0, 0]
}
}
}
],
"file": "fromgoldencombs:blocktypes/ceramicpot/ceramicbroodpot",
"side": "Server",
"dependsOn": [
{
"modid": "fromgoldencombs"
}
]
},
{
"op": "addMerge",
"path": "/behaviorsByType/*",
"value": [
{
"name": "BlockBehaviorRoamingBees"
}
],
"file": "fromgoldencombs:blocktypes/ceramicpot/ceramicbroodpot",
"side": "Server",
"dependsOn": [
{
"modid": "fromgoldencombs"
}
]
},
{ {
"op": "addMerge", "op": "addMerge",
"path": "/entityBehaviors", "path": "/entityBehaviors",

View File

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

View File

@@ -3,7 +3,12 @@
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory> <RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
<Configurations>Debug;Release;Debug22</Configurations> <Configurations>Debug;Release;Version22</Configurations>
<VINTAGE_STORY>$(VINTAGE_STORY_21)</VINTAGE_STORY>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Version22'">
<VINTAGE_STORY>$(VINTAGE_STORY_22)</VINTAGE_STORY>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -3,7 +3,12 @@
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory> <RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
<Configurations>Debug;Release;Debug22</Configurations> <Configurations>Debug;Release;Version22</Configurations>
<VINTAGE_STORY>$(VINTAGE_STORY_21)</VINTAGE_STORY>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Version22'">
<VINTAGE_STORY>$(VINTAGE_STORY_22)</VINTAGE_STORY>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -1 +1,2 @@
dotnet run --project ./ZZCakeBuild/OrekiWoofsBeehivesCakeBuild.csproj -- "$@" dotnet run --project ./ZZCakeBuild/OrekiWoofsBeehivesCakeBuild.csproj -- "$@"
dotnet run --project ./RoamingBees/ZZCakeBuild/RoamingBeesCakeBuild.csproj -- "$@" && cp ./RoamingBees/Releases/* ./Releases

6
printLatestCommits.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/usr/bin/env bash
script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
count="${1:-10}"
git -C "$script_dir" log -n "$count" --pretty=format:%s | awk '{ lines[NR] = $0 } END { for (i = NR; i >= 1; i--) print lines[i] }'