Class CollectibleObject
- Namespace
- Vintagestory.API.Common
- Assembly
- VintagestoryAPI.dll
Contains all properties shared by Blocks and Items
public abstract class CollectibleObject : RegistryObject
- Inheritance
-
CollectibleObject
- Derived
- Inherited Members
- Extension Methods
Fields
AttackPower
How much damage this collectible deals when used as a weapon
public float AttackPower
Field Value
AttackRange
Until how for away can you attack entities using this collectibe
public float AttackRange
Field Value
Attributes
Custom Attributes that's always assiociated with this item
public JsonObject Attributes
Field Value
CollectibleBehaviors
Modifiers that can alter the behavior of the item or block, mostly for held interaction
public CollectibleBehavior[] CollectibleBehaviors
Field Value
CombustibleProps
Information about the burnable states
public CombustibleProperties CombustibleProps
Field Value
CreativeInventoryStacks
If you want to add itemstacks with custom attributes to the creative inventory, add them to this list
public CreativeTabAndStackList[] CreativeInventoryStacks
Field Value
CreativeInventoryTabs
List of creative tabs in which this collectible should appear in
public string[] CreativeInventoryTabs
Field Value
- string[]
CrushingProps
If set, the collectible can be crushed into something else
public CrushingProperties CrushingProps
Field Value
DamagedBy
From which damage sources does the item takes durability damage
public EnumItemDamageSource[] DamagedBy
Field Value
Dimensions
Physical size of this collectible, 0.5 x 0.5 x 0.5 meters by default
public Size3f Dimensions
Field Value
Durability
How many uses does this collectible has when being used. Item disappears at durability 0
public int Durability
Field Value
FpHandTransform
Used for scaling, rotation or offseting the block when rendered in the first person mode hand
public ModelTransform FpHandTransform
Field Value
GrindingProps
If set, the collectible can be ground into something else
public GrindingProperties GrindingProps
Field Value
GroundTransform
Used for scaling, rotation or offseting the rendered as a dropped item on the ground
public ModelTransform GroundTransform
Field Value
GuiTransform
Used for scaling, rotation or offseting the block when rendered in guis
public ModelTransform GuiTransform
Field Value
HeldLeftReadyAnimation
public string HeldLeftReadyAnimation
Field Value
HeldLeftTpIdleAnimation
The animation to play in 3rd person mod when holding this collectible in the left hand
public string HeldLeftTpIdleAnimation
Field Value
HeldPriorityInteract
If true, when the player holds the sneak key and right clicks with this item in hand, calls OnHeldInteractStart first. Without it, the order is reversed. Takes precedence over priority interact placed blocks.
public bool HeldPriorityInteract
Field Value
HeldRightReadyAnimation
public string HeldRightReadyAnimation
Field Value
HeldRightTpIdleAnimation
The animation to play in 3rd person mod when holding this collectible in the right hand
public string HeldRightTpIdleAnimation
Field Value
HeldSounds
public HeldSounds HeldSounds
Field Value
HeldTpHitAnimation
The animation to play in 3rd person mod when hitting with this collectible
public string HeldTpHitAnimation
Field Value
HeldTpUseAnimation
The animation to play in 3rd person mod when using this collectible
public string HeldTpUseAnimation
Field Value
LightHsv
For light emitting collectibles: hue, saturation and brightness value
public byte[] LightHsv
Field Value
- byte[]
LiquidSelectable
When true, liquids become selectable to the player when being held in hands
public bool LiquidSelectable
Field Value
MaterialDensity
Determines on whether an object floats on liquids or not. Water has a density of 1000
public int MaterialDensity
Field Value
MatterState
Liquids are handled and rendered differently than solid blocks.
public EnumMatterState MatterState
Field Value
MaxStackSize
Max amount of collectible that one default inventory slot can hold
public int MaxStackSize
Field Value
MiningSpeed
Modifies how fast the player can break a block when holding this item
public Dictionary<EnumBlockMaterial, float> MiningSpeed
Field Value
NutritionProps
Information about the nutrition states
public FoodNutritionProperties NutritionProps
Field Value
ParticleProperties
Particles that should spawn in regular intervals from this block or item when held in hands
public AdvancedParticleProperties[] ParticleProperties
Field Value
RenderAlphaTest
Alpha test value for rendering in gui, fp hand, tp hand or on the ground
public float RenderAlphaTest
Field Value
StorageFlags
Determines in which kind of bags the item can be stored in
public EnumItemStorageFlags StorageFlags
Field Value
Tool
If set, this item will be classified as given tool
public EnumTool? Tool
Field Value
ToolTier
What tier this block can mine when held in hands
public int ToolTier
Field Value
TopMiddlePos
The origin point from which particles are being spawned
public Vec3f TopMiddlePos
Field Value
TpHandTransform
Used for scaling, rotation or offseting the block when rendered in the third person mode hand
public ModelTransform TpHandTransform
Field Value
TpOffHandTransform
Used for scaling, rotation or offseting the block when rendered in the third person mode offhand
public ModelTransform TpOffHandTransform
Field Value
TransitionableProps
Information about the transitionable states
public TransitionableProperties[] TransitionableProps
Field Value
api
The api object, assigned during OnLoaded
protected ICoreAPI api
Field Value
Properties
Id
The block or item id
public abstract int Id { get; }
Property Value
IsMissing
This value is set the the BlockId or ItemId-Remapper if it encounters a block/item in the savegame, but no longer exists as a loaded block/item
public bool IsMissing { get; set; }
Property Value
ItemClass
Block or Item?
public abstract EnumItemClass ItemClass { get; }
Property Value
MiningTier
[Obsolete("Use tool tier")]
public int MiningTier { get; set; }
Property Value
Methods
AppendPerishableInfoText(ItemSlot, StringBuilder, IWorldAccessor)
public virtual float AppendPerishableInfoText(ItemSlot inSlot, StringBuilder dsc, IWorldAccessor world)
Parameters
inSlot
ItemSlotdsc
StringBuilderworld
IWorldAccessor
Returns
AppendPerishableInfoText(ItemSlot, StringBuilder, IWorldAccessor, TransitionState, bool)
protected virtual float AppendPerishableInfoText(ItemSlot inSlot, StringBuilder dsc, IWorldAccessor world, TransitionState state, bool nowSpoiling)
Parameters
inSlot
ItemSlotdsc
StringBuilderworld
IWorldAccessorstate
TransitionStatenowSpoiling
bool
Returns
CanBePlacedInto(ItemStack, ItemSlot)
Should return true if the stack can be placed into given slot
public virtual bool CanBePlacedInto(ItemStack stack, ItemSlot slot)
Parameters
Returns
CanSmelt(IWorldAccessor, ISlotProvider, ItemStack, ItemStack)
Should return true if this collectible is smeltable in an open fire
public virtual bool CanSmelt(IWorldAccessor world, ISlotProvider cookingSlotsProvider, ItemStack inputStack, ItemStack outputStack)
Parameters
world
IWorldAccessorcookingSlotsProvider
ISlotProviderinputStack
ItemStackoutputStack
ItemStack
Returns
CanSpoil(ItemStack)
Returns true if the stack can spoil
public virtual bool CanSpoil(ItemStack itemstack)
Parameters
itemstack
ItemStack
Returns
CarryOverFreshness(ICoreAPI, ItemSlot, ItemStack, TransitionableProperties)
public static void CarryOverFreshness(ICoreAPI api, ItemSlot inputSlot, ItemStack outputStack, TransitionableProperties perishProps)
Parameters
api
ICoreAPIinputSlot
ItemSlotoutputStack
ItemStackperishProps
TransitionableProperties
CarryOverFreshness(ICoreAPI, ItemSlot[], ItemStack[], TransitionableProperties)
public static void CarryOverFreshness(ICoreAPI api, ItemSlot[] inputSlots, ItemStack[] outStacks, TransitionableProperties perishProps)
Parameters
api
ICoreAPIinputSlots
ItemSlot[]outStacks
ItemStack[]perishProps
TransitionableProperties
ConsumeCraftingIngredients(ItemSlot[], ItemSlot, GridRecipe)
Called after the player has taken out the item from the output slot
public virtual bool ConsumeCraftingIngredients(ItemSlot[] slots, ItemSlot outputSlot, GridRecipe matchingRecipe)
Parameters
slots
ItemSlot[]outputSlot
ItemSlotmatchingRecipe
GridRecipe
Returns
- bool
true to prevent default ingredient consumption
DamageItem(IWorldAccessor, Entity, ItemSlot, int)
Causes the item to be damaged. Will play a breaking sound and removes the itemstack if no more durability is left
public virtual void DamageItem(IWorldAccessor world, Entity byEntity, ItemSlot itemslot, int amount = 1)
Parameters
world
IWorldAccessorbyEntity
Entityitemslot
ItemSlotamount
intAmount of damage
DoSmelt(IWorldAccessor, ISlotProvider, ItemSlot, ItemSlot)
Transform the item to it's smelted variant
public virtual void DoSmelt(IWorldAccessor world, ISlotProvider cookingSlotsProvider, ItemSlot inputSlot, ItemSlot outputSlot)
Parameters
world
IWorldAccessorcookingSlotsProvider
ISlotProviderinputSlot
ItemSlotoutputSlot
ItemSlot
Equals(ItemStack, ItemStack, params string[])
Should return true if given stacks are equal, ignoring their stack size.
public virtual bool Equals(ItemStack thisStack, ItemStack otherStack, params string[] ignoreAttributeSubTrees)
Parameters
Returns
GeldHeldFpHitAnimation(ItemSlot, Entity)
Not implemented yet
[Obsolete]
public virtual ModelTransformKeyFrame[] GeldHeldFpHitAnimation(ItemSlot slot, Entity byEntity)
Parameters
Returns
GetAttackPower(IItemStack)
The amount of damage dealt when used as a weapon
public virtual float GetAttackPower(IItemStack withItemStack)
Parameters
withItemStack
IItemStack
Returns
GetAttackRange(IItemStack)
The the attack range when used as a weapon
public virtual float GetAttackRange(IItemStack withItemStack)
Parameters
withItemStack
IItemStack
Returns
GetBehavior(Type)
Returns the blocks behavior of given type, if it has such behavior
public CollectibleBehavior GetBehavior(Type type)
Parameters
type
Type
Returns
GetBehavior(CollectibleBehavior[], Type, bool)
protected virtual CollectibleBehavior GetBehavior(CollectibleBehavior[] fromList, Type type, bool withInheritance)
Parameters
fromList
CollectibleBehavior[]type
TypewithInheritance
bool
Returns
GetBehavior<T>()
Returns the blocks behavior of given type, if it has such behavior
public T GetBehavior<T>() where T : CollectibleBehavior
Returns
- T
Type Parameters
T
GetCollectibleBehavior(Type, bool)
Returns the blocks behavior of given type, if it has such behavior
public CollectibleBehavior GetCollectibleBehavior(Type type, bool withInheritance)
Parameters
Returns
GetCollectibleBehavior<T>(bool)
public T GetCollectibleBehavior<T>(bool withInheritance) where T : CollectibleBehavior
Parameters
withInheritance
bool
Returns
- T
Type Parameters
T
GetCollectibleInterface<T>()
Returns instance of class that implements this interface in the following order
- Collectible (returns itself)
- CollectibleBlockBehavior (returns on of our own behavior)
public virtual T GetCollectibleInterface<T>() where T : class
Returns
- T
Type Parameters
T
GetDurability(IItemStack)
[Obsolete("Use GetMaxDurability instead")]
public virtual int GetDurability(IItemStack itemstack)
Parameters
itemstack
IItemStack
Returns
GetHandBookStacks(ICoreClientAPI)
public virtual List<ItemStack> GetHandBookStacks(ICoreClientAPI capi)
Parameters
capi
ICoreClientAPI
Returns
GetHashCode()
For blocks and items, the hashcode is the id - useful when building HashSets
public override int GetHashCode()
Returns
GetHeldInteractionHelp(ItemSlot)
Interaction help thats displayed above the hotbar, when the player puts this item/block in his active hand slot
public virtual WorldInteraction[] GetHeldInteractionHelp(ItemSlot inSlot)
Parameters
inSlot
ItemSlot
Returns
GetHeldItemInfo(ItemSlot, StringBuilder, IWorldAccessor, bool)
Called by the inventory system when you hover over an item stack. This is the text that is getting displayed.
public virtual void GetHeldItemInfo(ItemSlot inSlot, StringBuilder dsc, IWorldAccessor world, bool withDebugInfo)
Parameters
inSlot
ItemSlotdsc
StringBuilderworld
IWorldAccessorwithDebugInfo
bool
GetHeldItemName(ItemStack)
Called by the inventory system when you hover over an item stack. This is the item stack name that is getting displayed.
public virtual string GetHeldItemName(ItemStack itemStack)
Parameters
itemStack
ItemStack
Returns
GetHeldReadyAnimation(ItemSlot, Entity, EnumHand)
Called when an entity holds this item in hands in 3rd person mode
public virtual string GetHeldReadyAnimation(ItemSlot activeHotbarSlot, Entity forEntity, EnumHand hand)
Parameters
Returns
GetHeldTpHitAnimation(ItemSlot, Entity)
Called when an entity uses this item to hit something in 3rd person mode
public virtual string GetHeldTpHitAnimation(ItemSlot slot, Entity byEntity)
Parameters
Returns
GetHeldTpIdleAnimation(ItemSlot, Entity, EnumHand)
Called when an entity holds this item in hands in 3rd person mode
public virtual string GetHeldTpIdleAnimation(ItemSlot activeHotbarSlot, Entity forEntity, EnumHand hand)
Parameters
Returns
GetHeldTpUseAnimation(ItemSlot, Entity)
Called when an entity holds this item in hands in 3rd person mode
public virtual string GetHeldTpUseAnimation(ItemSlot activeHotbarSlot, Entity forEntity)
Parameters
Returns
GetItemDamageColor(ItemStack)
Returns a hardcoded rgb color (green->yellow->red) that is representative for its remaining durability vs total durability
public virtual int GetItemDamageColor(ItemStack itemstack)
Parameters
itemstack
ItemStack
Returns
GetItemDescText()
public virtual string GetItemDescText()
Returns
GetLightHsv(IBlockAccessor, BlockPos, ItemStack)
Should return the light HSV values. Warning: This method is likely to get called in a background thread. Please make sure your code in here is thread safe.
public virtual byte[] GetLightHsv(IBlockAccessor blockAccessor, BlockPos pos, ItemStack stack = null)
Parameters
blockAccessor
IBlockAccessorpos
BlockPosMay be null
stack
ItemStackSet if its an itemstack for which the engine wants to check the light level
Returns
- byte[]
GetMaxDurability(ItemStack)
Returns the items total durability
public virtual int GetMaxDurability(ItemStack itemstack)
Parameters
itemstack
ItemStack
Returns
GetMeltingDuration(IWorldAccessor, ISlotProvider, ItemSlot)
If the item is smeltable, this is the time it takes to smelt at smelting point
public virtual float GetMeltingDuration(IWorldAccessor world, ISlotProvider cookingSlotsProvider, ItemSlot inputSlot)
Parameters
world
IWorldAccessorcookingSlotsProvider
ISlotProviderinputSlot
ItemSlot
Returns
GetMeltingPoint(IWorldAccessor, ISlotProvider, ItemSlot)
If the item is smeltable, this is its melting point
public virtual float GetMeltingPoint(IWorldAccessor world, ISlotProvider cookingSlotsProvider, ItemSlot inputSlot)
Parameters
world
IWorldAccessorcookingSlotsProvider
ISlotProviderinputSlot
ItemSlot
Returns
GetMergableQuantity(ItemStack, ItemStack, EnumMergePriority)
Should return the max. number of items that can be placed from sourceStack into the sinkStack
public virtual int GetMergableQuantity(ItemStack sinkStack, ItemStack sourceStack, EnumMergePriority priority)
Parameters
sinkStack
ItemStacksourceStack
ItemStackpriority
EnumMergePriority
Returns
GetMiningSpeed(IItemStack, BlockSelection, Block, IPlayer)
Called every game tick when the player breaks a block with this item in his hands. Returns the mining speed for given block.
public virtual float GetMiningSpeed(IItemStack itemstack, BlockSelection blockSel, Block block, IPlayer forPlayer)
Parameters
itemstack
IItemStackblockSel
BlockSelectionblock
BlockforPlayer
IPlayer
Returns
GetNutritionProperties(IWorldAccessor, ItemStack, Entity)
Should return the nutrition properties of the item/block
public virtual FoodNutritionProperties GetNutritionProperties(IWorldAccessor world, ItemStack itemstack, Entity forEntity)
Parameters
world
IWorldAccessoritemstack
ItemStackforEntity
Entity
Returns
GetRandomColor(ICoreClientAPI, ItemStack)
Should return a random pixel within the items/blocks texture
public virtual int GetRandomColor(ICoreClientAPI capi, ItemStack stack)
Parameters
capi
ICoreClientAPIstack
ItemStack
Returns
GetRemainingDurability(ItemStack)
public virtual int GetRemainingDurability(ItemStack itemstack)
Parameters
itemstack
ItemStack
Returns
GetStorageFlags(ItemStack)
Should return in which storage containers this item can be placed in
public virtual EnumItemStorageFlags GetStorageFlags(ItemStack itemstack)
Parameters
itemstack
ItemStack
Returns
GetTemperature(IWorldAccessor, ItemStack)
Returns the stacks item temperature in degree celsius
public virtual float GetTemperature(IWorldAccessor world, ItemStack itemstack)
Parameters
world
IWorldAccessoritemstack
ItemStack
Returns
GetTemperature(IWorldAccessor, ItemStack, double)
Returns the stacks item temperature in degree celsius
public virtual float GetTemperature(IWorldAccessor world, ItemStack itemstack, double didReceiveHeat)
Parameters
world
IWorldAccessoritemstack
ItemStackdidReceiveHeat
doubleThe amount of time it did receive heat since last update/call to this methode
Returns
GetToolMode(ItemSlot, IPlayer, BlockSelection)
Should return the current items tool mode.
public virtual int GetToolMode(ItemSlot slot, IPlayer byPlayer, BlockSelection blockSelection)
Parameters
slot
ItemSlotbyPlayer
IPlayerblockSelection
BlockSelection
Returns
GetToolModes(ItemSlot, IClientPlayer, BlockSelection)
public virtual SkillItem[] GetToolModes(ItemSlot slot, IClientPlayer forPlayer, BlockSelection blockSel)
Parameters
slot
ItemSlotforPlayer
IClientPlayerblockSel
BlockSelection
Returns
GetTransitionRateMul(IWorldAccessor, ItemSlot, EnumTransitionType)
public virtual float GetTransitionRateMul(IWorldAccessor world, ItemSlot inSlot, EnumTransitionType transType)
Parameters
world
IWorldAccessorinSlot
ItemSlottransType
EnumTransitionType
Returns
GetTransitionableProperties(IWorldAccessor, ItemStack, Entity)
Should return the transition properties of the item/block when in itemstack form
public virtual TransitionableProperties[] GetTransitionableProperties(IWorldAccessor world, ItemStack itemstack, Entity forEntity)
Parameters
world
IWorldAccessoritemstack
ItemStackforEntity
Entity
Returns
HasBehavior(string, IClassRegistryAPI)
Returns true if the block has given behavior
public virtual bool HasBehavior(string type, IClassRegistryAPI classRegistry)
Parameters
type
stringclassRegistry
IClassRegistryAPI
Returns
HasBehavior(Type, bool)
Returns true if the block has given behavior
public virtual bool HasBehavior(Type type, bool withInheritance = false)
Parameters
Returns
HasBehavior<T>(bool)
Returns true if the block has given behavior
public virtual bool HasBehavior<T>(bool withInheritance = false) where T : CollectibleBehavior
Parameters
withInheritance
bool
Returns
Type Parameters
T
HasTemperature(IItemStack)
Returns true if the stack has a temperature attribute
public virtual bool HasTemperature(IItemStack itemstack)
Parameters
itemstack
IItemStack
Returns
InGuiIdle(IWorldAccessor, ItemStack)
Called every frame when this item is being displayed in the gui
public virtual void InGuiIdle(IWorldAccessor world, ItemStack stack)
Parameters
world
IWorldAccessorstack
ItemStack
IsBackPack(IItemStack)
[Obsolete]
public static bool IsBackPack(IItemStack itemstack)
Parameters
itemstack
IItemStack
Returns
IsEmptyBackPack(IItemStack)
[Obsolete]
public static bool IsEmptyBackPack(IItemStack itemstack)
Parameters
itemstack
IItemStack
Returns
IsLiquid()
Returns true if this blocks matterstate is liquid. (Liquid blocks should also implement IBlockFlowing)
IMPORTANT: Calling code should have looked up the block using IBlockAccessor.GetBlock(pos, EnumBlockLayersAccess.LiquidOnly) !!!
public virtual bool IsLiquid()
Returns
IsReasonablyFresh(IWorldAccessor, ItemStack)
Test is failed for Perish-able items which have less than 50% of their fresh state remaining (or are already starting to spoil)
public virtual bool IsReasonablyFresh(IWorldAccessor world, ItemStack itemstack)
Parameters
world
IWorldAccessoritemstack
ItemStack
Returns
MatchesForCrafting(ItemStack, GridRecipe, CraftingRecipeIngredient)
Called when this collectible is attempted to being used as part of a crafting recipe and should get consumed now. Return false if it doesn't match the ingredient
public virtual bool MatchesForCrafting(ItemStack inputStack, GridRecipe gridRecipe, CraftingRecipeIngredient ingredient)
Parameters
inputStack
ItemStackgridRecipe
GridRecipeingredient
CraftingRecipeIngredient
Returns
OnAttackingWith(IWorldAccessor, Entity, Entity, ItemSlot)
An entity used this collectibe to attack something
public virtual void OnAttackingWith(IWorldAccessor world, Entity byEntity, Entity attackedEntity, ItemSlot itemslot)
Parameters
world
IWorldAccessorbyEntity
EntityattackedEntity
Entityitemslot
ItemSlot
OnBeforeRender(ICoreClientAPI, ItemStack, EnumItemRenderTarget, ref ItemRenderInfo)
This method is called before rendering the item stack into GUI, first person hand, third person hand and/or on the ground The renderinfo object is pre-filled with default values.
public virtual void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
Parameters
capi
ICoreClientAPIitemstack
ItemStacktarget
EnumItemRenderTargetrenderinfo
ItemRenderInfo
OnBlockBreaking(IPlayer, BlockSelection, ItemSlot, float, float, int)
Player is holding this collectible and breaks the targeted block
public virtual float OnBlockBreaking(IPlayer player, BlockSelection blockSel, ItemSlot itemslot, float remainingResistance, float dt, int counter)
Parameters
player
IPlayerblockSel
BlockSelectionitemslot
ItemSlotremainingResistance
floatdt
floatcounter
int
Returns
OnBlockBrokenWith(IWorldAccessor, Entity, ItemSlot, BlockSelection, float)
Player has broken a block while holding this collectible. Return false if you want to cancel the block break event.
public virtual bool OnBlockBrokenWith(IWorldAccessor world, Entity byEntity, ItemSlot itemslot, BlockSelection blockSel, float dropQuantityMultiplier = 1)
Parameters
world
IWorldAccessorbyEntity
Entityitemslot
ItemSlotblockSel
BlockSelectiondropQuantityMultiplier
float
Returns
OnCollected(ItemStack, Entity)
Called when this item was collected by an entity
public virtual void OnCollected(ItemStack stack, Entity entity)
Parameters
OnConsumedByCrafting(ItemSlot[], ItemSlot, GridRecipe, CraftingRecipeIngredient, IPlayer, int)
Called when this collectible is being used as part of a crafting recipe and should get consumed now
public virtual void OnConsumedByCrafting(ItemSlot[] allInputSlots, ItemSlot stackInSlot, GridRecipe gridRecipe, CraftingRecipeIngredient fromIngredient, IPlayer byPlayer, int quantity)
Parameters
allInputSlots
ItemSlot[]stackInSlot
ItemSlotgridRecipe
GridRecipefromIngredient
CraftingRecipeIngredientbyPlayer
IPlayerquantity
int
OnCreatedByCrafting(ItemSlot[], ItemSlot, GridRecipe)
Called when a matching grid recipe has been found and an item is placed into the crafting output slot (which is still before the player clicks on the output slot to actually craft the item and consume the ingredients)
public virtual void OnCreatedByCrafting(ItemSlot[] allInputslots, ItemSlot outputSlot, GridRecipe byRecipe)
Parameters
allInputslots
ItemSlot[]outputSlot
ItemSlotbyRecipe
GridRecipe
OnGroundIdle(EntityItem)
Called every game tick when this collectible is in dropped form in the world (i.e. as EntityItem)
public virtual void OnGroundIdle(EntityItem entityItem)
Parameters
entityItem
EntityItem
OnHandbookRecipeRender(ICoreClientAPI, GridRecipe, ItemSlot, double, double, double, double)
public virtual void OnHandbookRecipeRender(ICoreClientAPI capi, GridRecipe recipe, ItemSlot slot, double x, double y, double z, double size)
Parameters
capi
ICoreClientAPIrecipe
GridRecipeslot
ItemSlotx
doubley
doublez
doublesize
double
OnHeldActionAnimStart(ItemSlot, EntityAgent, EnumHandInteract)
public virtual void OnHeldActionAnimStart(ItemSlot slot, EntityAgent byEntity, EnumHandInteract type)
Parameters
slot
ItemSlotbyEntity
EntityAgenttype
EnumHandInteract
OnHeldAttackCancel(float, ItemSlot, EntityAgent, BlockSelection, EntitySelection, EnumItemUseCancelReason)
When the player has canceled a custom attack action. Return false to deny action cancellation.
public virtual bool OnHeldAttackCancel(float secondsPassed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSelection, EntitySelection entitySel, EnumItemUseCancelReason cancelReason)
Parameters
secondsPassed
floatslot
ItemSlotbyEntity
EntityAgentblockSelection
BlockSelectionentitySel
EntitySelectioncancelReason
EnumItemUseCancelReason
Returns
OnHeldAttackStart(ItemSlot, EntityAgent, BlockSelection, EntitySelection, ref EnumHandHandling)
When the player has begun using this item for attacking (left mouse click). Return true to play a custom action.
public virtual void OnHeldAttackStart(ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, ref EnumHandHandling handling)
Parameters
slot
ItemSlotbyEntity
EntityAgentblockSel
BlockSelectionentitySel
EntitySelectionhandling
EnumHandHandlingWhether or not to do any subsequent actions. If not set or set to NotHandled, the action will not called on the server.
OnHeldAttackStep(float, ItemSlot, EntityAgent, BlockSelection, EntitySelection)
Called continously when a custom attack action is playing. Return false to stop the action.
public virtual bool OnHeldAttackStep(float secondsPassed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSelection, EntitySelection entitySel)
Parameters
secondsPassed
floatslot
ItemSlotbyEntity
EntityAgentblockSelection
BlockSelectionentitySel
EntitySelection
Returns
OnHeldAttackStop(float, ItemSlot, EntityAgent, BlockSelection, EntitySelection)
Called when a custom attack action is finished
public virtual void OnHeldAttackStop(float secondsPassed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSelection, EntitySelection entitySel)
Parameters
secondsPassed
floatslot
ItemSlotbyEntity
EntityAgentblockSelection
BlockSelectionentitySel
EntitySelection
OnHeldDropped(IWorldAccessor, IPlayer, ItemSlot, int, ref EnumHandling)
Callback when the player dropped this item from his inventory. You can set handling to PreventDefault to prevent dropping this item. You can also check if the entityplayer of this player is dead to check if dropping of this item was due the players death
public virtual void OnHeldDropped(IWorldAccessor world, IPlayer byPlayer, ItemSlot slot, int quantity, ref EnumHandling handling)
Parameters
world
IWorldAccessorbyPlayer
IPlayerslot
ItemSlotquantity
intAmount of items the player wants to drop
handling
EnumHandling
OnHeldIdle(ItemSlot, EntityAgent)
Called every frame when the player is holding this collectible in his hands. Is not called during OnUsing() or OnAttacking()
public virtual void OnHeldIdle(ItemSlot slot, EntityAgent byEntity)
Parameters
slot
ItemSlotbyEntity
EntityAgent
OnHeldInteractCancel(float, ItemSlot, EntityAgent, BlockSelection, EntitySelection, EnumItemUseCancelReason)
When the player released the right mouse button. Return false to deny the cancellation (= will keep using the item until OnHeldInteractStep returns false).
public virtual bool OnHeldInteractCancel(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, EnumItemUseCancelReason cancelReason)
Parameters
secondsUsed
floatslot
ItemSlotbyEntity
EntityAgentblockSel
BlockSelectionentitySel
EntitySelectioncancelReason
EnumItemUseCancelReason
Returns
OnHeldInteractStart(ItemSlot, EntityAgent, BlockSelection, EntitySelection, bool, ref EnumHandHandling)
Called when the player right clicks while holding this block/item in his hands
public virtual void OnHeldInteractStart(ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, bool firstEvent, ref EnumHandHandling handling)
Parameters
slot
ItemSlotbyEntity
EntityAgentblockSel
BlockSelectionentitySel
EntitySelectionfirstEvent
boolTrue when the player pressed the right mouse button on this block. Every subsequent call, while the player holds right mouse down will be false, it gets called every second while right mouse is down
handling
EnumHandHandlingWhether or not to do any subsequent actions. If not set or set to NotHandled, the action will not called on the server.
OnHeldInteractStep(float, ItemSlot, EntityAgent, BlockSelection, EntitySelection)
Called every frame while the player is using this collectible. Return false to stop the interaction.
public virtual bool OnHeldInteractStep(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel)
Parameters
secondsUsed
floatslot
ItemSlotbyEntity
EntityAgentblockSel
BlockSelectionentitySel
EntitySelection
Returns
- bool
False if the interaction should be stopped. True if the interaction should continue
OnHeldInteractStop(float, ItemSlot, EntityAgent, BlockSelection, EntitySelection)
Called when the player successfully completed the using action, always called once an interaction is over
public virtual void OnHeldInteractStop(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel)
Parameters
secondsUsed
floatslot
ItemSlotbyEntity
EntityAgentblockSel
BlockSelectionentitySel
EntitySelection
OnHeldRenderOit(ItemSlot, IClientPlayer)
This method is called during the order independent transparency render pass when this item or block is being held in hands
public virtual void OnHeldRenderOit(ItemSlot inSlot, IClientPlayer byPlayer)
Parameters
inSlot
ItemSlotbyPlayer
IClientPlayer
OnHeldRenderOpaque(ItemSlot, IClientPlayer)
This method is called during the opaque render pass when this item or block is being held in hands
public virtual void OnHeldRenderOpaque(ItemSlot inSlot, IClientPlayer byPlayer)
Parameters
inSlot
ItemSlotbyPlayer
IClientPlayer
OnHeldRenderOrtho(ItemSlot, IClientPlayer)
This method is called during the ortho (for 2D GUIs) render pass when this item or block is being held in hands
public virtual void OnHeldRenderOrtho(ItemSlot inSlot, IClientPlayer byPlayer)
Parameters
inSlot
ItemSlotbyPlayer
IClientPlayer
OnHeldUseCancel(float, ItemSlot, EntityAgent, BlockSelection, EntitySelection, EnumItemUseCancelReason)
General cancel use access. Override OnHeldAttackCancel or OnHeldInteractCancel to alter the behavior.
public EnumHandInteract OnHeldUseCancel(float secondsPassed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, EnumItemUseCancelReason cancelReason)
Parameters
secondsPassed
floatslot
ItemSlotbyEntity
EntityAgentblockSel
BlockSelectionentitySel
EntitySelectioncancelReason
EnumItemUseCancelReason
Returns
OnHeldUseStart(ItemSlot, EntityAgent, BlockSelection, EntitySelection, EnumHandInteract, bool, ref EnumHandHandling)
General begin use access. Override OnHeldAttackStart or OnHeldInteractStart to alter the behavior.
public virtual void OnHeldUseStart(ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, EnumHandInteract useType, bool firstEvent, ref EnumHandHandling handling)
Parameters
slot
ItemSlotbyEntity
EntityAgentblockSel
BlockSelectionentitySel
EntitySelectionuseType
EnumHandInteractfirstEvent
boolTrue on first mouse down
handling
EnumHandHandlingWhether or not to do any subsequent actions. If not set or set to NotHandled, the action will not called on the server.
OnHeldUseStep(float, ItemSlot, EntityAgent, BlockSelection, EntitySelection)
General using access. Override OnHeldAttackStep or OnHeldInteractStep to alter the behavior.
public EnumHandInteract OnHeldUseStep(float secondsPassed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel)
Parameters
secondsPassed
floatslot
ItemSlotbyEntity
EntityAgentblockSel
BlockSelectionentitySel
EntitySelection
Returns
OnHeldUseStop(float, ItemSlot, EntityAgent, BlockSelection, EntitySelection, EnumHandInteract)
General use over access. Override OnHeldAttackStop or OnHeldInteractStop to alter the behavior.
public void OnHeldUseStop(float secondsPassed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, EnumHandInteract useType)
Parameters
secondsPassed
floatslot
ItemSlotbyEntity
EntityAgentblockSel
BlockSelectionentitySel
EntitySelectionuseType
EnumHandInteract
OnLoadCollectibleMappings(IWorldAccessor, ItemSlot, Dictionary<int, AssetLocation>, Dictionary<int, AssetLocation>)
This method is called after a block/item like this has been imported as part of a block schematic. Has to restore fix the block/item id mappings as they are probably different compared to the world from where they were exported. By default iterates over all the itemstacks attributes and searches for attribute sof type ItenStackAttribute and calls .FixMapping() on them.
[Obsolete("Use the variant with resolveImports parameter")]
public virtual void OnLoadCollectibleMappings(IWorldAccessor worldForResolve, ItemSlot inSlot, Dictionary<int, AssetLocation> oldBlockIdMapping, Dictionary<int, AssetLocation> oldItemIdMapping)
Parameters
worldForResolve
IWorldAccessorinSlot
ItemSlotoldBlockIdMapping
Dictionary<int, AssetLocation>oldItemIdMapping
Dictionary<int, AssetLocation>
OnLoadCollectibleMappings(IWorldAccessor, ItemSlot, Dictionary<int, AssetLocation>, Dictionary<int, AssetLocation>, bool)
This method is called after a block/item like this has been imported as part of a block schematic. Has to restore fix the block/item id mappings as they are probably different compared to the world from where they were exported. By default iterates over all the itemstacks attributes and searches for attribute sof type ItenStackAttribute and calls .FixMapping() on them.
public virtual void OnLoadCollectibleMappings(IWorldAccessor worldForResolve, ItemSlot inSlot, Dictionary<int, AssetLocation> oldBlockIdMapping, Dictionary<int, AssetLocation> oldItemIdMapping, bool resolveImports)
Parameters
worldForResolve
IWorldAccessorinSlot
ItemSlotoldBlockIdMapping
Dictionary<int, AssetLocation>oldItemIdMapping
Dictionary<int, AssetLocation>resolveImports
boolTurn it off to spawn structures as they are. For example, in this mode, instead of traders, their meta spawners will spawn
OnLoaded(ICoreAPI)
Server Side: Called one the collectible has been registered Client Side: Called once the collectible has been loaded from server packet
public virtual void OnLoaded(ICoreAPI api)
Parameters
api
ICoreAPI
OnLoadedNative(ICoreAPI)
public void OnLoadedNative(ICoreAPI api)
Parameters
api
ICoreAPI
OnModifiedInInventorySlot(IWorldAccessor, ItemSlot, ItemStack)
Whenever the collectible was modified while inside a slot, usually when it was moved, split or merged.
public virtual void OnModifiedInInventorySlot(IWorldAccessor world, ItemSlot slot, ItemStack extractedStack = null)
Parameters
world
IWorldAccessorslot
ItemSlotThe slot the item is or was in
extractedStack
ItemStackNon null if the itemstack was removed from this slot
OnSmeltAttempt(InventoryBase)
Called immediately prior to a firepit or similar testing whether this Collectible can be smelted
Returns true if the caller should be marked dirty
public virtual bool OnSmeltAttempt(InventoryBase inventorySmelting)
Parameters
inventorySmelting
InventoryBase
Returns
OnStoreCollectibleMappings(IWorldAccessor, ItemSlot, Dictionary<int, AssetLocation>, Dictionary<int, AssetLocation>)
This method is for example called by chests when they are being exported as part of a block schematic. Has to store all the currents block/item id mappings so it can be correctly imported again. By default it puts itself into the mapping and searches the itemstack attributes for attributes of type ItemStackAttribute and adds those to the mapping as well.
public virtual void OnStoreCollectibleMappings(IWorldAccessor world, ItemSlot inSlot, Dictionary<int, AssetLocation> blockIdMapping, Dictionary<int, AssetLocation> itemIdMapping)
Parameters
world
IWorldAccessorinSlot
ItemSlotblockIdMapping
Dictionary<int, AssetLocation>itemIdMapping
Dictionary<int, AssetLocation>
OnTransitionNow(ItemSlot, TransitionableProperties)
Called when any of its TransitionableProperties causes the stack to transition to another stack. Default behavior is to return props.TransitionedStack.ResolvedItemstack and set the stack size according to the transition rtio
public virtual ItemStack OnTransitionNow(ItemSlot slot, TransitionableProperties props)
Parameters
slot
ItemSlotprops
TransitionableProperties
Returns
- ItemStack
The stack it should transition into
OnUnloaded(ICoreAPI)
Called when the client/server is shutting down
public virtual void OnUnloaded(ICoreAPI api)
Parameters
api
ICoreAPI
QuantityBackPackSlots(IItemStack)
[Obsolete]
public static int QuantityBackPackSlots(IItemStack itemstack)
Parameters
itemstack
IItemStack
Returns
RefillSlotIfEmpty(ItemSlot, EntityAgent, ActionConsumable<ItemStack>)
public virtual void RefillSlotIfEmpty(ItemSlot slot, EntityAgent byEntity, ActionConsumable<ItemStack> matcher)
Parameters
slot
ItemSlotbyEntity
EntityAgentmatcher
ActionConsumable<ItemStack>
RequiresTransitionableTicking(IWorldAccessor, ItemStack)
Should returns true if this collectible requires UpdateAndGetTransitionStates() to be called when ticking.
Typical usage: true if this collectible itself has transitionable properties, or true for collectibles which hold other itemstacks with transitionable properties (for example, a cooked food container)
public virtual bool RequiresTransitionableTicking(IWorldAccessor world, ItemStack itemstack)
Parameters
world
IWorldAccessoritemstack
ItemStack
Returns
Satisfies(ItemStack, ItemStack)
Should return true if thisStack is a satisfactory replacement of otherStack. It's bascially an Equals() test, but it ignores any additional attributes that exist in otherStack
public virtual bool Satisfies(ItemStack thisStack, ItemStack otherStack)
Parameters
Returns
SetDurability(ItemStack, int)
Sets the items durability
public virtual void SetDurability(ItemStack itemstack, int amount)
Parameters
SetTemperature(IWorldAccessor, ItemStack, float, bool)
Sets the stacks item temperature in degree celsius
public virtual void SetTemperature(IWorldAccessor world, ItemStack itemstack, float temperature, bool delayCooldown = true)
Parameters
world
IWorldAccessoritemstack
ItemStacktemperature
floatdelayCooldown
bool
SetToolMode(ItemSlot, IPlayer, BlockSelection, int)
Should set given toolmode
public virtual void SetToolMode(ItemSlot slot, IPlayer byPlayer, BlockSelection blockSelection, int toolMode)
Parameters
slot
ItemSlotbyPlayer
IPlayerblockSelection
BlockSelectiontoolMode
int
SetTransitionState(ItemStack, EnumTransitionType, float)
public virtual void SetTransitionState(ItemStack stack, EnumTransitionType type, float transitionedHours)
Parameters
stack
ItemStacktype
EnumTransitionTypetransitionedHours
float
ShouldDisplayItemDamage(ItemStack)
Return true if remaining durability != total durability
public virtual bool ShouldDisplayItemDamage(ItemStack itemstack)
Parameters
itemstack
ItemStack
Returns
TryMergeStacks(ItemStackMergeOperation)
Is always called on the sink slots item
public virtual void TryMergeStacks(ItemStackMergeOperation op)
Parameters
UpdateAndGetTransitionState(IWorldAccessor, ItemSlot, EnumTransitionType)
Returns the transition state of given transition type
public virtual TransitionState UpdateAndGetTransitionState(IWorldAccessor world, ItemSlot inslot, EnumTransitionType type)
Parameters
world
IWorldAccessorinslot
ItemSlottype
EnumTransitionType
Returns
UpdateAndGetTransitionStates(IWorldAccessor, ItemSlot)
Returns a list of the current transition states of this item, redirects to UpdateAndGetTransitionStatesNative
public virtual TransitionState[] UpdateAndGetTransitionStates(IWorldAccessor world, ItemSlot inslot)
Parameters
world
IWorldAccessorinslot
ItemSlot
Returns
UpdateAndGetTransitionStatesNative(IWorldAccessor, ItemSlot)
Returns a list of the current transition states of this item. Seperate from UpdateAndGetTransitionStates() so that you can call still call this methods several inheritances down, i.e. there is no base.base.Method() syntax in C#
protected virtual TransitionState[] UpdateAndGetTransitionStatesNative(IWorldAccessor world, ItemSlot inslot)
Parameters
world
IWorldAccessorinslot
ItemSlot
Returns
playEatSound(EntityAgent, string, int)
protected void playEatSound(EntityAgent byEntity, string eatSound = "eat", int eatSoundRepeats = 1)
Parameters
byEntity
EntityAgenteatSound
stringeatSoundRepeats
int
tryEatBegin(ItemSlot, EntityAgent, ref EnumHandHandling, string, int)
Tries to eat the contents in the slot, first call
protected virtual void tryEatBegin(ItemSlot slot, EntityAgent byEntity, ref EnumHandHandling handling, string eatSound = "eat", int eatSoundRepeats = 1)
Parameters
slot
ItemSlotbyEntity
EntityAgenthandling
EnumHandHandlingeatSound
stringeatSoundRepeats
int
tryEatStep(float, ItemSlot, EntityAgent, ItemStack)
Tries to eat the contents in the slot, eat step call
protected virtual bool tryEatStep(float secondsUsed, ItemSlot slot, EntityAgent byEntity, ItemStack spawnParticleStack = null)
Parameters
secondsUsed
floatslot
ItemSlotbyEntity
EntityAgentspawnParticleStack
ItemStack
Returns
tryEatStop(float, ItemSlot, EntityAgent)
Finished eating the contents in the slot, final call
protected virtual void tryEatStop(float secondsUsed, ItemSlot slot, EntityAgent byEntity)
Parameters
secondsUsed
floatslot
ItemSlotbyEntity
EntityAgent