This commit is contained in:
2026-03-18 00:07:23 +01:00
commit 897c5a80e1
13 changed files with 372 additions and 0 deletions

View File

@@ -0,0 +1,90 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>bin\$(Configuration)\Mods\mod</OutputPath>
<Nullable>enable</Nullable>
<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>
<PropertyGroup Condition="'$(Configuration)' == 'Version22'">
<TargetFramework>net10.0</TargetFramework>
<VINTAGE_STORY>$(VINTAGE_STORY_22)</VINTAGE_STORY>
<VINTAGE_STORY_DATA>$(VINTAGE_STORY_DATA_22)</VINTAGE_STORY_DATA>
</PropertyGroup>
<PropertyGroup>
<VintageStoryDataPathArgs> --dataPath "$(VINTAGE_STORY_DATA)"</VintageStoryDataPathArgs>
</PropertyGroup>
<ItemGroup>
<Reference Include="VintagestoryAPI">
<HintPath>$(VINTAGE_STORY)/VintagestoryAPI.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="VSSurvivalMod">
<HintPath>$(VINTAGE_STORY)/Mods/VSSurvivalMod.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="VSEssentials">
<HintPath>$(VINTAGE_STORY)/Mods/VSEssentials.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="VSCreativeMod">
<HintPath>$(VINTAGE_STORY)/Mods/VSCreativeMod.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>$(VINTAGE_STORY)/Lib/Newtonsoft.Json.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="0Harmony">
<HintPath>$(VINTAGE_STORY)/Lib/0Harmony.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="VintagestoryLib">
<HintPath>$(VINTAGE_STORY)/VintagestoryLib.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="protobuf-net">
<HintPath>$(VINTAGE_STORY)/Lib/protobuf-net.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="cairo-sharp">
<HintPath>$(VINTAGE_STORY)/Lib/cairo-sharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Data.Sqlite">
<HintPath>$(VINTAGE_STORY)/Lib/Microsoft.Data.Sqlite.dll</HintPath>
<Private>False</Private>
</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>
<ItemGroup>
<Content Include="modinfo.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="modicon.png" Condition="Exists('modicon.png')">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,11 @@
using Vintagestory.API.Common;
namespace ButterflyPins.Core;
public class ButterflyPinsModSystem : ModSystem
{
public override void Start(ICoreAPI api)
{
api.Logger.Notification("ButterflyPins loaded");
}
}

View File

@@ -0,0 +1,10 @@
{
"profiles": {
"Client": {
"commandName": "Executable",
"executablePath": "dotnet",
"commandLineArgs": "\"$(VINTAGE_STORY)/Vintagestory.dll\" --tracelog --addModPath \"$(ProjectDir)/bin/$(Configuration)/Mods\" --addOrigin \"$(ProjectDir)/assets\"$(VintageStoryDataPathArgs)",
"workingDirectory": "$(VINTAGE_STORY)"
}
}
}

View File

@@ -0,0 +1,15 @@
{
"$schema": "https://moddbcdn.vintagestory.at/schema/modinfo.latest.json",
"type": "Code",
"modid": "butterflypins",
"name": "Butterfly Pins",
"authors": [
"OrekiWoof"
],
"description": "ButterflyPins mod.",
"version": "1.0.0",
"dependencies": {
"game": "1.21.0"
},
"side": "Universal"
}

View File

@@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<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>
<PackageReference Include="Cake.Frosting" Version="5.0.0" />
<PackageReference Include="Cake.Json" Version="7.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<Reference Include="VintagestoryAPI">
<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>

View File

@@ -0,0 +1,122 @@
using Cake.Common;
using Cake.Common.IO;
using Cake.Common.Tools.DotNet;
using Cake.Common.Tools.DotNet.Clean;
using Cake.Common.Tools.DotNet.Publish;
using Cake.Core;
using Cake.Frosting;
using Cake.Json;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.IO;
using System.Linq;
using Vintagestory.API.Common;
namespace CakeBuild;
public static class Program
{
public static int Main(string[] args)
{
return new CakeHost()
.UseContext<BuildContext>()
.Run(args);
}
}
public class BuildContext : FrostingContext
{
public const string PROJECT_NAME = "ButterflyPins";
public string BuildConfiguration { get; }
public string Version { get; }
public string Name { get; }
public bool SkipJsonValidation { get; }
public string GameVersion { get; }
public BuildContext(ICakeContext context)
: base(context)
{
BuildConfiguration = context.Argument("configuration", "Release");
SkipJsonValidation = context.Argument("skipJsonValidation", false);
var modInfo = context.DeserializeJsonFromFile<ModInfo>($"../{PROJECT_NAME}/modinfo.json");
Version = modInfo.Version;
Name = modInfo.ModID;
GameVersion = modInfo.Dependencies.First(x => x.ModID == "game").Version;
}
}
[TaskName("ValidateJson")]
public sealed class ValidateJsonTask : FrostingTask<BuildContext>
{
public override void Run(BuildContext context)
{
if (context.SkipJsonValidation)
{
return;
}
var jsonFiles = context.GetFiles($"../{BuildContext.PROJECT_NAME}/assets/**/*.json");
foreach (var file in jsonFiles)
{
try
{
var json = File.ReadAllText(file.FullPath);
JToken.Parse(json);
}
catch (JsonException ex)
{
throw new Exception($"Validation failed for JSON file: {file.FullPath}{Environment.NewLine}{ex.Message}", ex);
}
}
}
}
[TaskName("Build")]
[IsDependentOn(typeof(ValidateJsonTask))]
public sealed class BuildTask : FrostingTask<BuildContext>
{
public override void Run(BuildContext context)
{
context.DotNetClean($"../{BuildContext.PROJECT_NAME}/{BuildContext.PROJECT_NAME}.csproj",
new DotNetCleanSettings
{
Configuration = context.BuildConfiguration
});
context.DotNetPublish($"../{BuildContext.PROJECT_NAME}/{BuildContext.PROJECT_NAME}.csproj",
new DotNetPublishSettings
{
Configuration = context.BuildConfiguration
});
}
}
[TaskName("Package")]
[IsDependentOn(typeof(BuildTask))]
public sealed class PackageTask : FrostingTask<BuildContext>
{
public override void Run(BuildContext context)
{
context.EnsureDirectoryExists("../Releases");
context.CleanDirectory("../Releases");
context.EnsureDirectoryExists($"../Releases/{context.Name}");
context.CopyFiles($"../{BuildContext.PROJECT_NAME}/bin/{context.BuildConfiguration}/Mods/mod/publish/*", $"../Releases/{context.Name}");
if (context.DirectoryExists($"../{BuildContext.PROJECT_NAME}/assets"))
{
context.CopyDirectory($"../{BuildContext.PROJECT_NAME}/assets", $"../Releases/{context.Name}/assets");
}
context.CopyFile($"../{BuildContext.PROJECT_NAME}/modinfo.json", $"../Releases/{context.Name}/modinfo.json");
if (context.FileExists($"../{BuildContext.PROJECT_NAME}/modicon.png"))
{
context.CopyFile($"../{BuildContext.PROJECT_NAME}/modicon.png", $"../Releases/{context.Name}/modicon.png");
}
context.Zip($"../Releases/{context.Name}", $"../Releases/{context.Name}_v{context.Version}-v{context.GameVersion}.zip");
}
}
[TaskName("Default")]
[IsDependentOn(typeof(PackageTask))]
public class DefaultTask : FrostingTask
{
}

2
ButterflyPins/build.ps1 Normal file
View File

@@ -0,0 +1,2 @@
dotnet run --project ZZCakeBuild/CakeBuild.csproj -- $args
exit $LASTEXITCODE;

1
ButterflyPins/build.sh Normal file
View File

@@ -0,0 +1 @@
dotnet run --project ./ZZCakeBuild/CakeBuild.csproj -- "$@"