Confirmedusers, Bureaucrats, editor, Administrators
1,522
edits
No edit summary |
VeryGoodDog (talk | contribs) m (VeryGoodDog moved page Simple Particles to Modding:Simple Particles) |
||
(One intermediate revision by one other user not shown) | |||
Line 9: | Line 9: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Now we have the property, the only thing left to do is to set the position and spawn the particles into the world. I'm gonna use the <code> | Now we have the property, the only thing left to do is to set the position and spawn the particles into the world. I'm gonna use the <code>OnHeldInteractStart</code> and *Step method inside a custom made Item class (you can read more about this in the [[Collectible|Collectibles Tutorial]]): | ||
<syntaxhighlight lang="c#"> | <syntaxhighlight lang="c#"> | ||
public override bool | public override void OnHeldInteractStart(ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, ref EnumHandHandling handHandling) | ||
{ | |||
handHandling = EnumHandHandling.Handled; | |||
} | |||
public override bool OnHeldInteractStep(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel) | |||
{ | { | ||
myParticles.minPos = byEntity.Pos.XYZ.Add(0, byEntity.EyeHeight(), 0).Ahead(1f, byEntity.Pos.Pitch, byEntity.Pos.Yaw); | myParticles.minPos = byEntity.Pos.XYZ.Add(0, byEntity.EyeHeight(), 0).Ahead(1f, byEntity.Pos.Pitch, byEntity.Pos.Yaw); | ||
byEntity.World.SpawnParticles(myParticles); | byEntity.World.SpawnParticles(myParticles); | ||
return true; | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |