add 1.22 compat - use pin as tool in recipes

This commit is contained in:
2026-05-31 03:17:55 +02:00
parent eac0c23179
commit 2106e78ec8
5 changed files with 23 additions and 35 deletions

View File

@@ -1,5 +1,4 @@
using ButterflyPins.BlockEntities;
using System;
using Vintagestory.API.Common;
using Vintagestory.API.MathTools;
@@ -7,8 +6,6 @@ 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)
@@ -38,32 +35,4 @@ 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);
}
}