Private
Public Access
1
0

reinit branch

This commit is contained in:
2026-03-11 01:46:34 +01:00
commit bff9251737
129 changed files with 16115 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
using Vintagestory.API.Common;
using Vintagestory.API.MathTools;
using Vintagestory.GameContent;
namespace OrekiWoofsBees.Common;
public static class PlantRecognitionUtilities
{
public static bool IsCrop(Block block)
{
return block is BlockCrop;
}
public static bool IsFlower(Block block, IBlockAccessor accessor, BlockPos pos)
{
if (block.FirstCodePart() == "flower")
return true;
if (block is BlockPlantContainer)
{
var plantContainer = block.GetBlockEntity<BlockEntityPlantContainer?>(pos);
if (plantContainer is null)
return false;
var contents = plantContainer.GetContents();
if (contents is null)
return false;
if (contents.Block?.FirstCodePart() == "flower")
return true;
}
if (block is BlockBerryBush && accessor.GetBlockEntity(pos) is BlockEntityBerryBush blockEntityBerryBush)
return blockEntityBerryBush.IsFlowering;
if (block is BlockFruitTreePart && accessor.GetBlockEntity(pos) is BlockEntityFruitTreeFoliage fruitTreeFoliage)
return fruitTreeFoliage.FoliageState == EnumFoliageState.Flowering;
return false;
}
public static bool IsPlant(Block block, IBlockAccessor accessor, BlockPos pos)
{
return IsCrop(block) || IsFlower(block, accessor, pos);
}
}