diff --git a/pom.xml b/pom.xml
index 8611844..38eac62 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,13 +30,40 @@
The sound data for the sound to play
* @param animationDataThe animation data for the animation to play
* @param durationTicksThe duration of the work animation
+ * @param npcPositionThe npc position to animate
*/ private void startWorkAnimation(@NotNull Entity entity, @NotNull SoundData soundData, - @NotNull AnimationData animationData, long durationTicks) { + @NotNull AnimationData animationData, long durationTicks, + @Nullable NPCPosition npcPosition) { BlacksmithVisuals instance = BlacksmithVisuals.getInstance(); BukkitScheduler scheduler = Bukkit.getScheduler(); int playWorkSound = scheduler.scheduleSyncRepeatingTask(instance, - () -> animateNPC(entity, soundData, animationData), 20, animationData.animationDelay()); + () -> animateNPC(entity, soundData, animationData, npcPosition), 20, animationData.animationDelay()); scheduler.scheduleSyncDelayedTask(instance, () -> scheduler.cancelTask(playWorkSound), durationTicks); } @@ -237,8 +244,10 @@ public class BlacksmithListener implements Listener { * @param entityThe entity to animate and play the sound at
* @param soundDataThe sound to be played
* @param animationDataThe animation to be played
+ * @param npcPositionThe npc position to animate
*/ - private void animateNPC(@NotNull Entity entity, @NotNull SoundData soundData, @NotNull AnimationData animationData) { + private void animateNPC(@NotNull Entity entity, @NotNull SoundData soundData, @NotNull AnimationData animationData, + @Nullable NPCPosition npcPosition) { if (random.nextInt(100) >= animationData.animationChance()) { return; } @@ -256,6 +265,34 @@ public class BlacksmithListener implements Listener { } else { animateOffhand(entity); } + + if (npcPosition == null) { + npcPosition = NPCPosition.WORKING_REPAIRABLE; + } + for (int i = 0; i < random.nextInt(5) + 1; i++) { + spawnSparkParticle(entity, npcPosition); + } + } + + /** + * Spawns a spark particle at the given NPC's work station + * + * @param entityThe entity whose working station should produce a spark
+ * @param npcPositionThe npc potion to spawn a particle for
+ */ + private void spawnSparkParticle(@NotNull Entity entity, @NotNull NPCPosition npcPosition) { + double randomX = this.random.nextDouble(-1, 1); + double randomY = this.random.nextDouble(0.1, 1); + double randomZ = this.random.nextDouble(-1, 1); + Particle particle; + if (npcPosition == NPCPosition.WORKING_CRAFTING) { + particle = Particle.ELECTRIC_SPARK; + } else { + particle = Particle.FLAME; + } + Location spawnLocation = entity.getLocation().clone().getBlock().getRelative(entity.getFacing()).getLocation().add(0.5, 0, 0.5); + ParticleConfig particleConfig = new ParticleConfig(ParticleMode.SINGLE, particle, 0, 0, 1.1, randomX, randomY, randomZ, 0.1); + ParticleHelper.spawnParticle(entity.getWorld(), spawnLocation, particleConfig, 1); } /**