Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion CommonLib.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>bin/$(Configuration)/Mods/CommonLib</OutputPath>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
Expand All @@ -13,7 +15,35 @@
<NoWarn>CS1591</NoWarn>
</PropertyGroup>

<PropertyGroup>
<VintagestoryPath Condition="'$(VintagestoryPath)' == ''">$(VINTAGE_STORY)</VintagestoryPath>
</PropertyGroup>

<!-- Vintage Story 1.22 API references. Set VINTAGE_STORY or pass -p:VintagestoryPath=... -->
<ItemGroup>
<Reference Include="VintagestoryAPI" HintPath="$(VintagestoryPath)/VintagestoryAPI.dll" Private="false" />
<Reference Include="VintagestoryLib" HintPath="$(VintagestoryPath)/VintagestoryLib.dll" Private="false" />
<Reference Include="VSSurvivalMod" HintPath="$(VintagestoryPath)/Mods/VSSurvivalMod.dll" Private="false" />
<Reference Include="VSEssentials" HintPath="$(VintagestoryPath)/Mods/VSEssentials.dll" Private="false" />
<Reference Include="VSCreativeMod" HintPath="$(VintagestoryPath)/Mods/VSCreativeMod.dll" Private="false" />
<Reference Include="Newtonsoft.Json" HintPath="$(VintagestoryPath)/Lib/Newtonsoft.Json.dll" Private="false" />
<Reference Include="0Harmony" HintPath="$(VintagestoryPath)/Lib/0Harmony.dll" Private="false" />
<Reference Include="protobuf-net" HintPath="$(VintagestoryPath)/Lib/protobuf-net.dll" Private="false" />
</ItemGroup>

<Target Name="ValidateVintagestoryPath" BeforeTargets="ResolveAssemblyReferences">
<Error Condition="!Exists('$(VintagestoryPath)/VintagestoryAPI.dll')"
Text="Vintage Story API not found. Set VINTAGE_STORY or pass -p:VintagestoryPath=/path/to/VintageStory." />
</Target>

<ItemGroup>
<PackageReference Include="Nullable" Version="1.3.1" />
</ItemGroup>

<ItemGroup>
<Content Include="modinfo.json" CopyToOutputDirectory="PreserveNewest" />
<Content Include="modicon.png" CopyToOutputDirectory="PreserveNewest" />
<Content Include="LICENSE" CopyToOutputDirectory="PreserveNewest" />
<Content Include="README.md" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</Project>
6 changes: 3 additions & 3 deletions Config/ConfigUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ public static void ValidateConfig(ICoreAPI api, Type type, ref object config, IL
if (checkerAttr != null)
{
var value = prop.GetValue(config);
if (!checkerAttr.Check(api, (IComparable)value))
if (!checkerAttr.Check(api, (IComparable)value!))
{
if (checkerAttr is RangeAttribute rangeAttr)
{
var clampedValue = rangeAttr.ClampRange((IComparable)value);
var clampedValue = rangeAttr.ClampRange((IComparable)value!);
if (clampedValue != value)
{
logger.Warning($"{type.FullName}.{prop.Name} value {value} out of bounds, set to {clampedValue}");
Expand Down Expand Up @@ -188,7 +188,7 @@ public static object ConvertType(object value, Type type, object? defaultValue)
if (type.IsArray)
{
var list = (IList)value;
var elementType = type.GetElementType();
var elementType = type.GetElementType()!;
var convertedArray = Array.CreateInstance(elementType, list.Count);
for (int i = 0; i < list.Count; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion Extensions/ParsersExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public override string[] GetValidRange(CmdArgs args)
return api.World.AllPlayers.Select((IPlayer p) => p.PlayerName).ToArray();
}

public override object? GetValue()
public override object GetValue()
{
return player;
}
Expand Down
17 changes: 0 additions & 17 deletions Mod.xml

This file was deleted.

24 changes: 12 additions & 12 deletions Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
"profiles": {
"Client": {
"commandName": "Executable",
"executablePath": "%VINTAGE_STORY%/$(GameVersion)/Vintagestory.exe",
"commandLineArgs": "--addModPath $(ModsDir) --addOrigin $(AssetsDir) --tracelog",
"workingDirectory": "%VINTAGE_STORY%/$(GameVersion)"
"executablePath": "$(VINTAGE_STORY)/$(GameVersion)/Vintagestory.exe",
"commandLineArgs": "--addModPath \"$(MSBuildProjectDirectory)/bin/$(Configuration)/Mods\" --tracelog",
"workingDirectory": "$(VINTAGE_STORY)"
},
"Test World": {
"commandName": "Executable",
"executablePath": "%VINTAGE_STORY%/$(GameVersion)/Vintagestory.exe",
"commandLineArgs": "--playStyle \"preset-surviveandbuild\" --openWorld \"$(ProjectName) Test World\" --addModPath $(ModsDir) --addOrigin $(AssetsDir) --tracelog",
"workingDirectory": "%VINTAGE_STORY%/$(GameVersion)"
"executablePath": "$(VINTAGE_STORY)/$(GameVersion)/Vintagestory.exe",
"commandLineArgs": "--playStyle \"preset-surviveandbuild\" --openWorld \"$(MSBuildProjectName) Test World\" --addModPath \"$(MSBuildProjectDirectory)/bin/$(Configuration)/Mods\" --tracelog",
"workingDirectory": "$(VINTAGE_STORY)"
},
"Test World (Flat)": {
"commandName": "Executable",
"executablePath": "%VINTAGE_STORY%/$(GameVersion)/Vintagestory.exe",
"commandLineArgs": "--openWorld \"$(ProjectName) Test World\" --addModPath $(ModsDir) --addOrigin $(AssetsDir) --tracelog",
"workingDirectory": "%VINTAGE_STORY%/$(GameVersion)"
"executablePath": "$(VINTAGE_STORY)/$(GameVersion)/Vintagestory.exe",
"commandLineArgs": "--openWorld \"$(MSBuildProjectName) Test World\" --addModPath \"$(MSBuildProjectDirectory)/bin/$(Configuration)/Mods\" --tracelog",
"workingDirectory": "$(VINTAGE_STORY)"
},
"Server": {
"commandName": "Executable",
"executablePath": "%VINTAGE_STORY%/$(GameVersion)/VintagestoryServer.exe",
"commandLineArgs": "--addModPath $(ModsDir) --addOrigin $(AssetsDir) --tracelog",
"workingDirectory": "%VINTAGE_STORY%/$(GameVersion)"
"executablePath": "$(VINTAGE_STORY)/$(GameVersion)/VintagestoryServer.exe",
"commandLineArgs": "--addModPath \"$(MSBuildProjectDirectory)/bin/$(Configuration)/Mods\" --tracelog",
"workingDirectory": "$(VINTAGE_STORY)"
}
}
}
2 changes: 1 addition & 1 deletion Utils/WorldUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class WorldUtil
/// </summary>
public static CollectibleObject GetCollectibleObject(this IWorldAccessor world, AssetLocation code)
{
return (CollectibleObject)world.GetItem(code) ?? world.GetBlock(code);
return (CollectibleObject?)world.GetItem(code) ?? world.GetBlock(code)!;
}

/// <summary>
Expand Down
10 changes: 10 additions & 0 deletions modinfo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"type": "Code",
"name": "CommonLib",
"modid": "commonlib",
"version": "3.0.0",
"authors": ["DArkHekRoMaNT"],
"dependencies": {
"game": "1.22.0"
}
}