diff --git a/Common/Collectible/Block/Block.cs b/Common/Collectible/Block/Block.cs index a600a371..ec1fd4c7 100644 --- a/Common/Collectible/Block/Block.cs +++ b/Common/Collectible/Block/Block.cs @@ -2168,6 +2168,45 @@ public BlockBehavior GetBehavior(Type type, bool withInheritance) return null; } + /// + /// Returns the CropProps for the Block. + /// + /// + public virtual BlockCropProperties GetCropProps() { + return CropProps; + } + + /// + /// Returns the CropProps for a specific in-world instance of the Block at a specific in-world position. Without overrides, this returns the same result as + /// + /// + /// The position of the block in-world. + /// + public virtual BlockCropProperties GetCropProps(IWorldAccessor world, BlockPos pos) { + return GetCropProps(); + } + + /// + /// Returns the Block's crop growth stage, if it is indeed a crop. + /// + /// 0, if it is not a crop or the stage cannot be determined. + public virtual int GetCurrentCropStage() { + if (GetCropProps() == null) return 0; + + int.TryParse(LastCodePart(), out int stage); + return stage; + } + + /// + /// Returns the crop growth stage for a specific in-world instance of the block at a specific in-world position. Without overrides, this returns the same result as + /// + /// + /// + /// + public virtual int GetCurrentCropStage(IWorldAccessor world, BlockPos pos) { + return GetCurrentCropStage(); + } + /// /// Called by the block info HUD for display the interaction help besides the crosshair