add 1.22 compat - use pin as tool in recipes
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user