Modding:Block and Item Interactions: Difference between revisions

From Vintage Story Wiki
No edit summary
Line 30: Line 30:


<syntaxhighlight lang="c#">
<syntaxhighlight lang="c#">
         public override bool OnBeginInteract(IItemSlot slot, IEntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel)
         public override bool OnHeldInteractStart(IItemSlot slot, IEntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel)
         {
         {
             return true;
             return true;
Line 36: Line 36:
</syntaxhighlight>
</syntaxhighlight>


The method <code>OnInteracting</code> allows us to spawn particles per tick while the player is using the item, but it would be better to implement an animation first. Particles should spawn after the animation is done ...
The method <code>OnHeldInteractStep</code> allows us to spawn particles per tick while the player is using the item, but it would be better to implement an animation first. Particles should spawn after the animation is done ...


<syntaxhighlight lang="c#">
<syntaxhighlight lang="c#">
         public override bool OnInteracting(float secondsUsed, IItemSlot slot, IEntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel)
         public override bool OnHeldInteractStep(float secondsUsed, IItemSlot slot, IEntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel)
         {
         {
             if (byEntity.World is IClientWorldAccessor)
             if (byEntity.World is IClientWorldAccessor)
Line 112: Line 112:


<syntaxhighlight lang="c#">
<syntaxhighlight lang="c#">
         public override bool OnInteracting(float secondsUsed, IItemSlot slot, IEntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel)
         public override bool OnHeldInteractStep(float secondsUsed, IItemSlot slot, IEntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel)
         {
         {
             if (byEntity.World is IClientWorldAccessor)
             if (byEntity.World is IClientWorldAccessor)
Confirmedusers, editor, Administrators
886

edits