Class CollectibleBehavior
- Namespace
- Vintagestory.API.Common
- Assembly
- VintagestoryAPI.dll
public abstract class CollectibleBehavior
- Inheritance
-
CollectibleBehavior
- Derived
- Inherited Members
- Extension Methods
Constructors
CollectibleBehavior(CollectibleObject)
public CollectibleBehavior(CollectibleObject collObj)
Parameters
collObj
CollectibleObject
Fields
collObj
The collectible object (item or block) for this behavior instance.
public CollectibleObject collObj
Field Value
propertiesAtString
The properties of this block behavior.
public string propertiesAtString
Field Value
Properties
ClientSideOptional
If true, this behavior is not required on the client. This is here because copygirl doesn't stop asking for it. Probably breaks things. If it breaks things, complain to copygirl please :p
public virtual bool ClientSideOptional { get; }
Property Value
Methods
GetHeldInteractionHelp(ItemSlot, ref EnumHandling)
Interaction help that is shown when selecting the item in the hotbar slot
public virtual WorldInteraction[] GetHeldInteractionHelp(ItemSlot inSlot, ref EnumHandling handling)
Parameters
inSlot
ItemSlothandling
EnumHandling
Returns
GetHeldItemInfo(ItemSlot, StringBuilder, IWorldAccessor, bool)
public virtual void GetHeldItemInfo(ItemSlot inSlot, StringBuilder dsc, IWorldAccessor world, bool withDebugInfo)
Parameters
inSlot
ItemSlotdsc
StringBuilderworld
IWorldAccessorwithDebugInfo
bool
GetHeldItemName(StringBuilder, ItemStack)
public virtual void GetHeldItemName(StringBuilder sb, ItemStack itemStack)
Parameters
sb
StringBuilderitemStack
ItemStack
GetHeldReadyAnimation(ItemSlot, Entity, EnumHand, ref EnumHandling)
public virtual string GetHeldReadyAnimation(ItemSlot activeHotbarSlot, Entity forEntity, EnumHand hand, ref EnumHandling bhHandling)
Parameters
activeHotbarSlot
ItemSlotforEntity
Entityhand
EnumHandbhHandling
EnumHandling
Returns
GetHeldTpHitAnimation(ItemSlot, Entity, ref EnumHandling)
public virtual string GetHeldTpHitAnimation(ItemSlot slot, Entity byEntity, ref EnumHandling bhHandling)
Parameters
slot
ItemSlotbyEntity
EntitybhHandling
EnumHandling
Returns
GetHeldTpIdleAnimation(ItemSlot, Entity, EnumHand, ref EnumHandling)
public virtual string GetHeldTpIdleAnimation(ItemSlot activeHotbarSlot, Entity forEntity, EnumHand hand, ref EnumHandling bhHandling)
Parameters
activeHotbarSlot
ItemSlotforEntity
Entityhand
EnumHandbhHandling
EnumHandling
Returns
GetHeldTpUseAnimation(ItemSlot, Entity, ref EnumHandling)
public virtual string GetHeldTpUseAnimation(ItemSlot activeHotbarSlot, Entity forEntity, ref EnumHandling bhHandling)
Parameters
activeHotbarSlot
ItemSlotforEntity
EntitybhHandling
EnumHandling
Returns
GetStorageFlags(ItemStack, ref EnumHandling)
public virtual EnumItemStorageFlags GetStorageFlags(ItemStack itemstack, ref EnumHandling handling)
Parameters
itemstack
ItemStackhandling
EnumHandling
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)
Called when the tool mode (F) key is pressed to generate the GUI
public virtual SkillItem[] GetToolModes(ItemSlot slot, IClientPlayer forPlayer, BlockSelection blockSel)
Parameters
slot
ItemSlotforPlayer
IClientPlayerblockSel
BlockSelection
Returns
Initialize(JsonObject)
Called right after the block behavior was created, must call base method
public virtual void Initialize(JsonObject properties)
Parameters
properties
JsonObject
OnBeforeRender(ICoreClientAPI, ItemStack, EnumItemRenderTarget, ref ItemRenderInfo)
Called when the collectible is rendered in hands, inventory or on the ground
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, ref EnumHandling)
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, ref EnumHandling handled)
Parameters
player
IPlayerblockSel
BlockSelectionitemslot
ItemSlotremainingResistance
floatdt
floatcounter
inthandled
EnumHandling
Returns
OnBlockBrokenWith(IWorldAccessor, Entity, ItemSlot, BlockSelection, float, ref EnumHandling)
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, ref EnumHandling bhHandling)
Parameters
world
IWorldAccessorbyEntity
Entityitemslot
ItemSlotblockSel
BlockSelectiondropQuantityMultiplier
floatbhHandling
EnumHandling
Returns
OnCreatedByCrafting(ItemSlot[], ItemSlot, ref EnumHandling)
public virtual void OnCreatedByCrafting(ItemSlot[] allInputslots, ItemSlot outputSlot, ref EnumHandling bhHandling)
Parameters
allInputslots
ItemSlot[]outputSlot
ItemSlotbhHandling
EnumHandling
OnHeldAttackCancel(float, ItemSlot, EntityAgent, BlockSelection, EntitySelection, EnumItemUseCancelReason, ref EnumHandling)
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, ref EnumHandling handling)
Parameters
secondsPassed
floatslot
ItemSlotbyEntity
EntityAgentblockSelection
BlockSelectionentitySel
EntitySelectioncancelReason
EnumItemUseCancelReasonhandling
EnumHandling
Returns
OnHeldAttackStart(ItemSlot, EntityAgent, BlockSelection, EntitySelection, ref EnumHandHandling, ref EnumHandling)
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 handHandling, ref EnumHandling handling)
Parameters
slot
ItemSlotbyEntity
EntityAgentblockSel
BlockSelectionentitySel
EntitySelectionhandHandling
EnumHandHandlinghandling
EnumHandling
OnHeldAttackStep(float, ItemSlot, EntityAgent, BlockSelection, EntitySelection, ref EnumHandling)
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, ref EnumHandling handling)
Parameters
secondsPassed
floatslot
ItemSlotbyEntity
EntityAgentblockSelection
BlockSelectionentitySel
EntitySelectionhandling
EnumHandling
Returns
OnHeldAttackStop(float, ItemSlot, EntityAgent, BlockSelection, EntitySelection, ref EnumHandling)
Called when a custom attack action is finished
public virtual void OnHeldAttackStop(float secondsPassed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSelection, EntitySelection entitySel, ref EnumHandling handling)
Parameters
secondsPassed
floatslot
ItemSlotbyEntity
EntityAgentblockSelection
BlockSelectionentitySel
EntitySelectionhandling
EnumHandling
OnHeldInteractCancel(float, ItemSlot, EntityAgent, BlockSelection, EntitySelection, EnumItemUseCancelReason, ref EnumHandling)
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, ref EnumHandling handled)
Parameters
secondsUsed
floatslot
ItemSlotbyEntity
EntityAgentblockSel
BlockSelectionentitySel
EntitySelectioncancelReason
EnumItemUseCancelReasonhandled
EnumHandling
Returns
OnHeldInteractStart(ItemSlot, EntityAgent, BlockSelection, EntitySelection, bool, ref EnumHandHandling, ref EnumHandling)
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 handHandling, ref EnumHandling handling)
Parameters
slot
ItemSlotbyEntity
EntityAgentblockSel
BlockSelectionentitySel
EntitySelectionfirstEvent
boolhandHandling
EnumHandHandlingWhether or not to do any subsequent actions. If not set or set to NotHandled, the action will not called on the server.
handling
EnumHandlingSet to PreventDefault to not try eating the item, set to PreventSubsequent to ignore any subsequent calls to OnHeldInteractStart() of other behaviors
OnHeldInteractStep(float, ItemSlot, EntityAgent, BlockSelection, EntitySelection, ref EnumHandling)
Called every frame while the player is using this collectible
public virtual bool OnHeldInteractStep(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, ref EnumHandling handling)
Parameters
secondsUsed
floatslot
ItemSlotbyEntity
EntityAgentblockSel
BlockSelectionentitySel
EntitySelectionhandling
EnumHandling
Returns
OnHeldInteractStop(float, ItemSlot, EntityAgent, BlockSelection, EntitySelection, ref EnumHandling)
Called when the player successfully completed the using action, not called when successfully cancelled
public virtual void OnHeldInteractStop(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, ref EnumHandling handling)
Parameters
secondsUsed
floatslot
ItemSlotbyEntity
EntityAgentblockSel
BlockSelectionentitySel
EntitySelectionhandling
EnumHandling
OnLoaded(ICoreAPI)
Server Side: Called once 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
OnUnloaded(ICoreAPI)
public virtual void OnUnloaded(ICoreAPI api)
Parameters
api
ICoreAPI
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