From 39786b4612f88385ec496e5e6694b9be5149d314 Mon Sep 17 00:00:00 2001
From: Jenny <jennytsonline@proton.me>
Date: Wed, 12 Feb 2025 13:19:47 +0100
Subject: [PATCH] arrow particle rewrite

---
 gradle.properties                                |  2 +-
 .../entities/arrows/baseArrow.java               | 11 ++++++++++-
 .../entities/arrows/carpetArrow.java             |  8 ++------
 .../entities/arrows/concussiveArrow.java         | 16 +++++-----------
 .../entities/arrows/tntArrow.java                | 11 +++--------
 .../entities/arrows/tunnelArrow.java             |  8 ++------
 6 files changed, 23 insertions(+), 33 deletions(-)

diff --git a/gradle.properties b/gradle.properties
index 4baf1c6..4c39961 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -38,7 +38,7 @@ mod_name=Enhanced Explosives
 # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
 mod_license=All Rights Reserved
 # The mod version. See https://semver.org/
-mod_version=0.13.1
+mod_version=0.13.2
 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
 # This should match the base package used for the mod sources.
 # See https://maven.apache.org/guides/mini/guide-naming-conventions.html
diff --git a/src/main/java/com/jenny/enhancedexplosives/entities/arrows/baseArrow.java b/src/main/java/com/jenny/enhancedexplosives/entities/arrows/baseArrow.java
index 22ac95c..f0af577 100644
--- a/src/main/java/com/jenny/enhancedexplosives/entities/arrows/baseArrow.java
+++ b/src/main/java/com/jenny/enhancedexplosives/entities/arrows/baseArrow.java
@@ -7,6 +7,7 @@ import net.minecraft.world.entity.projectile.AbstractArrow;
 import net.minecraft.world.item.ItemStack;
 import net.minecraft.world.item.Items;
 import net.minecraft.world.level.Level;
+import net.minecraft.world.phys.Vec3;
 import org.jetbrains.annotations.NotNull;
 
 public class baseArrow extends AbstractArrow {
@@ -39,8 +40,16 @@ public class baseArrow extends AbstractArrow {
         return new ItemStack(Items.ARROW);
     }
 
-    public void spawnParticles(float partialTicks) {
+    protected Vec3 particlePos(double dist) {
+        Double speed = getDeltaMovement().length();
+        return new Vec3(
+                level().getRandom().nextIntBetweenInclusive(-100, 100),
+                level().getRandom().nextIntBetweenInclusive(-100, 100),
+                level().getRandom().nextIntBetweenInclusive(-100, 100)
+        ).normalize().scale(dist + ((double) level().getRandom().nextIntBetweenInclusive(0, 100) / 100)).add(position());
+    }
 
+    public void spawnParticles(float partialTicks) {
     }
 
     public int getTick() {
diff --git a/src/main/java/com/jenny/enhancedexplosives/entities/arrows/carpetArrow.java b/src/main/java/com/jenny/enhancedexplosives/entities/arrows/carpetArrow.java
index 5a8b7a6..0042c47 100644
--- a/src/main/java/com/jenny/enhancedexplosives/entities/arrows/carpetArrow.java
+++ b/src/main/java/com/jenny/enhancedexplosives/entities/arrows/carpetArrow.java
@@ -54,14 +54,10 @@ public class carpetArrow extends baseArrow {
 
     @Override
     public void spawnParticles(float partialTicks) {
-        for (int i = 1; i <= ConfigClient.calcPCount(3); i++) {
+        for (int i = 1; i <= ConfigClient.calcPCount(5); i++) {
             double m = (double) level().getRandom().nextIntBetweenInclusive(-100, 100) / 100;
             Vec3 DeltaMovement = getDeltaMovement();
-            Vec3 pos = new Vec3(
-                    (double) level().getRandom().nextIntBetweenInclusive(-5, 5) / 10,
-                    0,
-                    (double) level().getRandom().nextIntBetweenInclusive(-5, 5) / 10
-            ).normalize().multiply(m, 0, m).add(getPosition(partialTicks));
+            Vec3 pos = particlePos(0.5);
             level().addParticle(particles.CARPET_ARROW_PARTICLE.get(), pos.x, pos.y, pos.z, DeltaMovement.x, DeltaMovement.y, DeltaMovement.z);
         }
     }
diff --git a/src/main/java/com/jenny/enhancedexplosives/entities/arrows/concussiveArrow.java b/src/main/java/com/jenny/enhancedexplosives/entities/arrows/concussiveArrow.java
index 301fc8a..b829571 100644
--- a/src/main/java/com/jenny/enhancedexplosives/entities/arrows/concussiveArrow.java
+++ b/src/main/java/com/jenny/enhancedexplosives/entities/arrows/concussiveArrow.java
@@ -1,10 +1,9 @@
 package com.jenny.enhancedexplosives.entities.arrows;
 
+import com.jenny.enhancedexplosives.config.ConfigClient;
 import com.jenny.enhancedexplosives.entities.entities;
 import com.jenny.enhancedexplosives.items.items;
-import com.jenny.enhancedexplosives.config.ConfigClient;
 import com.jenny.enhancedexplosives.particles.particles;
-
 import net.minecraft.world.entity.EntityType;
 import net.minecraft.world.entity.LivingEntity;
 import net.minecraft.world.item.ItemStack;
@@ -43,15 +42,10 @@ public class concussiveArrow extends baseArrow{
 
     @Override
     public void spawnParticles(float partialTicks) {
-        for (int i = 1; i <= ConfigClient.calcPCount(3); i++) {
-            double m = (double) level().getRandom().nextIntBetweenInclusive(- 100, 100) / 100;
-            Vec3 DeltaMovement = getDeltaMovement();
-            Vec3 pos = new Vec3(
-                    (double) level().getRandom().nextIntBetweenInclusive(-5, 5) / 10,
-                    0,
-                    (double) level().getRandom().nextIntBetweenInclusive(-5, 5) / 10
-            ).normalize().multiply(m, m, m).add(getPosition(partialTicks));
-            level().addParticle(particles.CONCUSSIVE_ARROW_PARTICLE.get(), pos.x, pos.y, pos.z, DeltaMovement.x, DeltaMovement.y, DeltaMovement.z);
+        for (int i = 1; i <= ConfigClient.calcPCount(5); i++) {
+            Vec3 delta = getDeltaMovement();
+            Vec3 pos = particlePos(0.5);
+            level().addParticle(particles.CONCUSSIVE_ARROW_PARTICLE.get(), pos.x, pos.y, pos.z, delta.x, delta.y, delta.z);
         }
     }
 }
diff --git a/src/main/java/com/jenny/enhancedexplosives/entities/arrows/tntArrow.java b/src/main/java/com/jenny/enhancedexplosives/entities/arrows/tntArrow.java
index f1c1e65..e3838fb 100644
--- a/src/main/java/com/jenny/enhancedexplosives/entities/arrows/tntArrow.java
+++ b/src/main/java/com/jenny/enhancedexplosives/entities/arrows/tntArrow.java
@@ -1,9 +1,8 @@
 package com.jenny.enhancedexplosives.entities.arrows;
 
 import com.jenny.enhancedexplosives.config.ConfigClient;
-import com.jenny.enhancedexplosives.items.items;
 import com.jenny.enhancedexplosives.entities.entities;
-
+import com.jenny.enhancedexplosives.items.items;
 import com.jenny.enhancedexplosives.particles.particles;
 import net.minecraft.world.entity.EntityType;
 import net.minecraft.world.entity.LivingEntity;
@@ -43,14 +42,10 @@ public class tntArrow extends baseArrow {
 
     @Override
     public void spawnParticles(float partialTicks) {
-        for (int i = 1; i <= ConfigClient.calcPCount(3); i++) {
+        for (int i = 1; i <= ConfigClient.calcPCount(5); i++) {
             double m = (double) level().getRandom().nextIntBetweenInclusive(- 100, 100) / 100;
             Vec3 DeltaMovement = getDeltaMovement();
-            Vec3 pos = new Vec3(
-                    (double) level().getRandom().nextIntBetweenInclusive(-5, 5) / 10,
-                    0,
-                    (double) level().getRandom().nextIntBetweenInclusive(-5, 5) / 10
-            ).normalize().multiply(m, m, m).add(getPosition(partialTicks));
+            Vec3 pos = particlePos(0.5);
             level().addParticle(particles.TNT_ARROW_PARTICLE.get(), pos.x, pos.y, pos.z, DeltaMovement.x, DeltaMovement.y, DeltaMovement.z);
         }
     }
diff --git a/src/main/java/com/jenny/enhancedexplosives/entities/arrows/tunnelArrow.java b/src/main/java/com/jenny/enhancedexplosives/entities/arrows/tunnelArrow.java
index ac3bf3f..dcebcb5 100644
--- a/src/main/java/com/jenny/enhancedexplosives/entities/arrows/tunnelArrow.java
+++ b/src/main/java/com/jenny/enhancedexplosives/entities/arrows/tunnelArrow.java
@@ -60,14 +60,10 @@ public class tunnelArrow extends baseArrow{
 
     @Override
     public void spawnParticles(float partialTicks) {
-        for (int i = 1; i <= ConfigClient.calcPCount(3); i++) {
+        for (int i = 1; i <= ConfigClient.calcPCount(5); i++) {
             double m = (double) level().getRandom().nextIntBetweenInclusive(- 100, 100) / 100;
             Vec3 DeltaMovement = getDeltaMovement();
-            Vec3 pos = new Vec3(
-                    (double) level().getRandom().nextIntBetweenInclusive(-5, 5) / 10,
-                    0,
-                    (double) level().getRandom().nextIntBetweenInclusive(-5, 5) / 10
-            ).normalize().multiply(m, m, m).add(getPosition(partialTicks));
+            Vec3 pos = particlePos(0.5);
             level().addParticle(particles.TUNNEL_ARROW_PARTICLE.get(), pos.x, pos.y, pos.z, DeltaMovement.x, DeltaMovement.y, DeltaMovement.z);
         }
     }