Json block behaviors Harvestable

From Vintage Story Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Purpose

Enables right click to harvest the block. After the block is harvested, it is replaced with the one specified by the harvestedBlockCode property.

Used by blocks

  • bigberrybush
  • saguarocactus
  • smallberrybush
  • log-resin

Usage

The player begins harvesting the block by holding right click. The player can be holding any tool while harvesting the block (the behavior ignores what the player is holding). harvestingSound is played when the harvesting starts and again randomly during the harvest. During the harvest, particles are randomly spawned and the attack animation is shown.

After harvestTime seconds have elapsed, the block is replaced with harvestedBlockCode. harvestedStack is placed in the player inventory if they have room, otherwise it is dropped on the ground. If the block has the forageStatAffected attribute, then the dropped stack size is affected by the player's forageDropRate trait (comes from their class).

Example:

    {
        name: "Harvestable", properties: {
            harvestTime: 1, 
            harvestedStack: { type: "item", code: "resin", quantity: { avg: 1 }  },
            harvestedBlockCode: "log-resinharvested-{wood}-ud"
        }
    }

The "onitemcollected" event is fired after the block is harvested. Nothing in vanilla VS listens to the event, but a mod could be created to listen to it. It is not possible for such an event handler to block the item from getting dropped.

Alone this behavior does not support making the block harvestable again after a fixed time period. So the Transient block entity class is often assigned to the harvested block type, which does replace the harvested block after a configurable time period.

Properties

harvestTime (float, seconds, default: 0)
The number of seconds it takes to harvest the block.
harvestedStack (BlockDropItemStack)
The item stack to drop when the block is harvested.
harvestingSound (path from sounds folder)
Sound that is played when harvesting begins and randomly during harvesting.
harvestedBlockCode (block code)
The harvestable block is replaced with this when harvesting is done. Typically this is an unharvestable block that converts back to harvestable block after a while using the Transient block entity class.
Icon Sign.png

Wondering where some links have gone?
The modding navbox is going through some changes! Check out Navigation Box Updates for more info and help finding specific pages.

Modding
Modding Introduction Getting Started Theme Pack
Content Modding Content Mods Developing a Content Mod Basic Tutorials Intermediate Tutorials Advanced Tutorials Content Mod Concepts
Code Modding Code Mods Setting up your Development Environment
Property Overview ItemEntityBlockBlock BehaviorsBlock ClassesBlock EntitiesBlock Entity BehaviorsWorld properties
Workflows & Infrastructure Modding Efficiency TipsMod-engine compatibilityMod ExtensibilityVS Engine
Additional Resources Community Resources Modding API Updates Programming Languages List of server commandsList of client commandsClient startup parametersServer startup parameters
Example ModsAPI DocsGitHub Repository