Confirmedusers, editor, Administrators
886
edits
CreativeMD (talk | contribs) No edit summary |
CreativeMD (talk | contribs) No edit summary |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 3: | Line 3: | ||
== Preparations == | == Preparations == | ||
I highly recommend to read about [[Advanced Items|The Item Class]] first. Additionally you can download the assets [ | I highly recommend to read about [[Advanced Items|The Item Class]] first. Additionally you can download the assets [https://wiki.vintagestory.at/images/4/4d/MagicWand_-_No_CS_File.zip here]. | ||
All of this should be familiar to you, creating and registering the item class ... | All of this should be familiar to you, creating and registering the item class ... | ||
Line 30: | Line 30: | ||
<syntaxhighlight lang="c#"> | <syntaxhighlight lang="c#"> | ||
public override bool | 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> | 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 | 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 109: | Line 109: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
If we put everything together the <code> | If we put everything together the <code>OnHeldInteractStep</code> method will look like this ... | ||
<syntaxhighlight lang="c#"> | <syntaxhighlight lang="c#"> | ||
public override bool | 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 161: | Line 161: | ||
Feel free to try it out yourself: | Feel free to try it out yourself: | ||
[ | [https://wiki.vintagestory.at/images/3/38/MagicWand.zip MagicWand.zip] | ||
{{Navbox/modding|Vintage Story}} |