flatten folder structure, fix collision boxes and gui/fp/tp transforms
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using ButterflyPins.BlockEntities;
|
||||
using System;
|
||||
using Vintagestory.API.Common;
|
||||
using Vintagestory.API.MathTools;
|
||||
|
||||
@@ -6,6 +7,8 @@ namespace ButterflyPins.Blocks;
|
||||
|
||||
public class BlockButterflyPinBoard : Block
|
||||
{
|
||||
private const string ButterflyPinPrefix = "clothes-butterflypin-";
|
||||
|
||||
public override bool OnBlockInteractStart(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel)
|
||||
{
|
||||
if (blockSel == null)
|
||||
@@ -35,4 +38,32 @@ public class BlockButterflyPinBoard : Block
|
||||
|
||||
base.OnBlockBroken(world, pos, byPlayer, dropQuantityMultiplier);
|
||||
}
|
||||
|
||||
public override bool ConsumeCraftingIngredients(ItemSlot[] slots, ItemSlot outputSlot, GridRecipe matchingRecipe)
|
||||
{
|
||||
bool preservedPin = false;
|
||||
|
||||
foreach (ItemSlot slot in slots)
|
||||
{
|
||||
if (slot.Empty)
|
||||
continue;
|
||||
|
||||
if (!preservedPin && IsButterflyPin(slot.Itemstack))
|
||||
{
|
||||
preservedPin = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
slot.TakeOut(1);
|
||||
slot.MarkDirty();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool IsButterflyPin(ItemStack stack)
|
||||
{
|
||||
AssetLocation? code = stack.Collectible?.Code;
|
||||
return code != null && code.Path.StartsWith(ButterflyPinPrefix, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"ingredientPattern": "PPP\tS_S\tPPP",
|
||||
"ingredients": {
|
||||
"P": { "type": "item", "code": "plank-*" },
|
||||
"S": { "type": "item", "code": "stick" }
|
||||
},
|
||||
"width": 3,
|
||||
"height": 3,
|
||||
"output": { "type": "block", "code": "pinboard2x2-south" }
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"ingredientPattern": "PPP\tPSP\tPPP",
|
||||
"ingredients": {
|
||||
"P": { "type": "item", "code": "plank-*" },
|
||||
"S": { "type": "item", "code": "stick" }
|
||||
},
|
||||
"width": 3,
|
||||
"height": 3,
|
||||
"output": { "type": "block", "code": "pinboard3x3-south" }
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
<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>
|
||||
@@ -1,122 +0,0 @@
|
||||
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
|
||||
{
|
||||
}
|
||||
@@ -42,7 +42,7 @@
|
||||
"collisionbox": {
|
||||
"x1": 0.0625,
|
||||
"y1": 0.0625,
|
||||
"z1": 0.9375,
|
||||
"z1": 0.90625,
|
||||
"x2": 0.9375,
|
||||
"y2": 0.9375,
|
||||
"z2": 1.0,
|
||||
@@ -56,7 +56,7 @@
|
||||
"selectionbox": {
|
||||
"x1": 0.0625,
|
||||
"y1": 0.0625,
|
||||
"z1": 0.9375,
|
||||
"z1": 0.90625,
|
||||
"x2": 0.9375,
|
||||
"y2": 0.9375,
|
||||
"z2": 1.0,
|
||||
@@ -80,7 +80,7 @@
|
||||
"guiTransform": {
|
||||
"rotation": { "x": -19, "y": 136, "z": 0 },
|
||||
"origin": { "x": 0.5, "y": 0.5, "z": 0.5 },
|
||||
"scale": 1.9
|
||||
"scale": 1.0
|
||||
},
|
||||
"groundTransform": {
|
||||
"translation": { "x": 0, "y": 0, "z": 0 },
|
||||
@@ -90,7 +90,13 @@
|
||||
},
|
||||
"tpHandTransform": {
|
||||
"translation": { "x": -0.45, "y": -0.8, "z": 0.04 },
|
||||
"rotation": { "x": 0, "y": 0, "z": -10 },
|
||||
"rotation": { "x": 0, "y": 180, "z": -10 },
|
||||
"origin": { "x": 0.5, "y": 0.5, "z": 0.5 },
|
||||
"scale": 0.95
|
||||
},
|
||||
"fpHandTransform": {
|
||||
"translation": { "x": -0.45, "y": -0.8, "z": 0.04 },
|
||||
"rotation": { "x": 0, "y": 180, "z": -10 },
|
||||
"origin": { "x": 0.5, "y": 0.5, "z": 0.5 },
|
||||
"scale": 0.95
|
||||
}
|
||||
@@ -42,7 +42,7 @@
|
||||
"collisionbox": {
|
||||
"x1": 0.0625,
|
||||
"y1": 0.0625,
|
||||
"z1": 0.9375,
|
||||
"z1": 0.90625,
|
||||
"x2": 0.9375,
|
||||
"y2": 0.9375,
|
||||
"z2": 1.0,
|
||||
@@ -56,7 +56,7 @@
|
||||
"selectionbox": {
|
||||
"x1": 0.0625,
|
||||
"y1": 0.0625,
|
||||
"z1": 0.9375,
|
||||
"z1": 0.90625,
|
||||
"x2": 0.9375,
|
||||
"y2": 0.9375,
|
||||
"z2": 1.0,
|
||||
@@ -80,7 +80,7 @@
|
||||
"guiTransform": {
|
||||
"rotation": { "x": -19, "y": 136, "z": 0 },
|
||||
"origin": { "x": 0.5, "y": 0.5, "z": 0.5 },
|
||||
"scale": 1.9
|
||||
"scale": 1.0
|
||||
},
|
||||
"groundTransform": {
|
||||
"translation": { "x": 0, "y": 0, "z": 0 },
|
||||
@@ -90,7 +90,13 @@
|
||||
},
|
||||
"tpHandTransform": {
|
||||
"translation": { "x": -0.45, "y": -0.8, "z": 0.04 },
|
||||
"rotation": { "x": 0, "y": 0, "z": -10 },
|
||||
"rotation": { "x": 0, "y": 180, "z": -10 },
|
||||
"origin": { "x": 0.5, "y": 0.5, "z": 0.5 },
|
||||
"scale": 0.95
|
||||
},
|
||||
"fpHandTransform": {
|
||||
"translation": { "x": -0.45, "y": -0.8, "z": 0.04 },
|
||||
"rotation": { "x": 0, "y": 180, "z": -10 },
|
||||
"origin": { "x": 0.5, "y": 0.5, "z": 0.5 },
|
||||
"scale": 0.95
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"ingredientPattern": "_S_\tSBS\t_S_",
|
||||
"ingredients": {
|
||||
"S": { "type": "item", "code": "game:stick" },
|
||||
"B": {
|
||||
"type": "item",
|
||||
"code": "game:*-butterflypin-*"
|
||||
}
|
||||
},
|
||||
"width": 3,
|
||||
"height": 3,
|
||||
"output": { "type": "block", "code": "pinboard2x2-north" }
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"ingredientPattern": "S_S\t_B_\tS_S",
|
||||
"ingredients": {
|
||||
"S": { "type": "item", "code": "game:stick" },
|
||||
"B": {
|
||||
"type": "item",
|
||||
"code": "game:*-butterflypin-*"
|
||||
}
|
||||
},
|
||||
"width": 3,
|
||||
"height": 3,
|
||||
"output": { "type": "block", "code": "pinboard3x3-north" }
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
dotnet run --project ZZCakeBuild/CakeBuild.csproj -- $args
|
||||
exit $LASTEXITCODE;
|
||||
@@ -1 +0,0 @@
|
||||
dotnet run --project ./ZZCakeBuild/CakeBuild.csproj -- "$@"
|
||||
Reference in New Issue
Block a user