Compare commits

..

2 Commits

Author SHA1 Message Date
2ad99a9d3b VS_CONFIGLIB for CakeBuild 2026-03-16 00:37:10 +01:00
074b34dd24 crash prevention when failing to GetContents in CardRenderer 2026-03-16 00:36:49 +01:00
3 changed files with 27 additions and 1 deletions

View File

@@ -117,8 +117,20 @@ internal class CardRenderer(ICoreClientAPI api, Config config) : IDisposable
if (heldBag == null)
continue;
ItemStack[]? bagContents;
try
{
bagContents = heldBag.GetContents(bagStack, api.World);
}
catch
{
continue;
}
if (bagContents == null)
continue;
contents = [];
ItemStack[] bagContents = heldBag.GetContents(bagStack, api.World);
foreach (ItemStack contentStack in bagContents)
{
if (contentStack == null || contentStack.StackSize <= 0)

View File

@@ -4,6 +4,9 @@
<TargetFramework>net8.0</TargetFramework>
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
<Configurations>Debug;Release;Version22</Configurations>
<VS_CONFIGLIB Condition="'$(VS_CONFIGLIB)' == ''">$([System.Environment]::GetEnvironmentVariable('VS_CONFIGLIB'))</VS_CONFIGLIB>
<ConfigLibAvailable Condition="'$(VS_CONFIGLIB)' != '' and Exists('$(VS_CONFIGLIB)')">true</ConfigLibAvailable>
<DefineConstants Condition="'$(ConfigLibAvailable)' == 'true'">$(DefineConstants);CONFIGLIB</DefineConstants>
</PropertyGroup>
<ItemGroup>
@@ -17,4 +20,15 @@
<HintPath>$(VINTAGE_STORY)/VintagestoryAPI.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Include="configlib" Condition="'$(ConfigLibAvailable)' == 'true'">
<HintPath>$(VS_CONFIGLIB)</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<Target Name="WarnWithoutConfigLib" BeforeTargets="CoreCompile" Condition="'$(ConfigLibAvailable)' != 'true'">
<Warning Text="No VS_CONFIGLIB - will compile without supporting ConfigLib. Set VS_CONFIGLIB env var to a path that contains the configlib's dlls." />
</Target>
</Project>

0
ChestPreview/build.sh Normal file → Executable file
View File