Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(utils): method for drawing particle line
- Loading branch information
1 parent
44d33d3
commit 3e87c18
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/main/java/org/auioc/mcmod/arnicalib/utils/game/ParticleUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.auioc.mcmod.arnicalib.utils.game; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.core.particles.ParticleTypes; | ||
import net.minecraft.util.Mth; | ||
|
||
public class ParticleUtils { | ||
|
||
private static final Minecraft MC = Minecraft.getInstance(); | ||
|
||
public static void drawLine(double x1, double y1, double z1, double x2, double y2, double z2, double stepLength) { | ||
double lineLength = Mth.length((x2 - x1), (y2 - y1), (z2 - z1)); | ||
long pointCount = Math.round(lineLength / stepLength); | ||
|
||
double projectedStepLengthX = (x2 - x1) / pointCount; | ||
double projectedStepLengthY = (y2 - y1) / pointCount; | ||
double projectedStepLengthZ = (z2 - z1) / pointCount; | ||
|
||
for (long i = 0; i < pointCount; i++) { | ||
double x = x1 + projectedStepLengthX * i; | ||
double y = y1 + projectedStepLengthY * i; | ||
double z = z1 + projectedStepLengthZ * i; | ||
MC.level.addParticle(ParticleTypes.ELECTRIC_SPARK, x, y, z, 0.0D, 0.0D, 0.0D); | ||
} | ||
} | ||
|
||
} |