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
Fields
Attributes
Tree Attributes that should be attached to the resulting itemstack
[JsonProperty]
[JsonConverter(typeof(JsonAttributesConverter))]
public JsonObject Attributes
Field Value
Code
Code of the block or item
public AssetLocation Code
Field Value
DropModbyStat
If set, the drop quantity will be modified by the collecting entity stat code - entity.Stats.GetBlended(code).
public string DropModbyStat
Field Value
LastDrop
If true, and this drop occurs, no further drops will happen.
public bool LastDrop
Field Value
Quantity
Quantity to be dropped
public NatFloat Quantity
Field Value
ResolvedItemstack
The resulting ItemStack for this block being broken by a tool.
public ItemStack ResolvedItemstack
Field Value
Tool
If set, then the given tool is required to make this block drop anything.
public EnumTool? Tool
Field Value
Type
Block or Item?
public EnumItemClass Type
Field Value
Methods
Clone()
Creates a deep copy of this object
public BlockDropItemStack Clone()
Returns
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
BinaryReaderThe reader of the block
instancer
IClassRegistryAPIThe 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
Resolve(IWorldAccessor, string, AssetLocation)
Sets itemstack.block or itemstack.item
public bool Resolve(IWorldAccessor resolver, string sourceForErrorLogging, AssetLocation assetLoc)
Parameters
resolver
IWorldAccessorsourceForErrorLogging
stringassetLoc
AssetLocation
Returns
ToBytes(BinaryWriter)
The save data writer.
public virtual void ToBytes(BinaryWriter writer)
Parameters
writer
BinaryWriterThe writer to write blocks to.