Table of Contents

Class BlockDropItemStack

Namespace
Vintagestory.API.Common
Assembly
VintagestoryAPI.dll

Represents an itemstack that is dropped when breaking a block, with a potentially random quantity.

public class BlockDropItemStack
Inheritance
BlockDropItemStack
Inherited Members
Extension Methods

Examples

"drops": [
	{
		"type": "item",
		"code": "bone",
		"quantity": {
			"avg": 4,
			"var": 2
		}
	}
]

Constructors

BlockDropItemStack()

public BlockDropItemStack()

BlockDropItemStack(ItemStack, float)

public BlockDropItemStack(ItemStack stack, float chance = 1)

Parameters

stack ItemStack
chance float

Fields

Attributes

Tree Attributes that should be attached to the resulting itemstack

[JsonProperty]
[JsonConverter(typeof(JsonAttributesConverter))]
public JsonObject Attributes

Field Value

JsonObject

Code

Code of the block or item

public AssetLocation Code

Field Value

AssetLocation

DropModbyStat

If set, the drop quantity will be modified by the collecting entity stat code - entity.Stats.GetBlended(code).

public string DropModbyStat

Field Value

string

LastDrop

If true, and this drop occurs, no further drops will happen.

public bool LastDrop

Field Value

bool

Quantity

Quantity to be dropped

public NatFloat Quantity

Field Value

NatFloat

ResolvedItemstack

The resulting ItemStack for this block being broken by a tool.

public ItemStack ResolvedItemstack

Field Value

ItemStack

Tool

If set, then the given tool is required to make this block drop anything.

public EnumTool? Tool

Field Value

EnumTool?

Type

Block or Item?

public EnumItemClass Type

Field Value

EnumItemClass

Methods

Clone()

Creates a deep copy of this object

public BlockDropItemStack Clone()

Returns

BlockDropItemStack

FromBytes(BinaryReader, IClassRegistryAPI)

Reads the contents of the block bytes and converts it into a block.

public virtual void FromBytes(BinaryReader reader, IClassRegistryAPI instancer)

Parameters

reader BinaryReader

The reader of the block

instancer IClassRegistryAPI

The block registry

GetNextItemStack(float)

Returns an itemstack with random quantity as configured via the Quantity field

public ItemStack GetNextItemStack(float dropQuantityMultiplier = 1)

Parameters

dropQuantityMultiplier float

Returns

ItemStack

Resolve(IWorldAccessor, string, AssetLocation)

Sets itemstack.block or itemstack.item

public bool Resolve(IWorldAccessor resolver, string sourceForErrorLogging, AssetLocation assetLoc)

Parameters

resolver IWorldAccessor
sourceForErrorLogging string
assetLoc AssetLocation

Returns

bool

ToBytes(BinaryWriter)

The save data writer.

public virtual void ToBytes(BinaryWriter writer)

Parameters

writer BinaryWriter

The writer to write blocks to.