Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(next): remove server-side particle painter
- Loading branch information
1 parent
023170b
commit 6aa3dc5
Showing
7 changed files
with
88 additions
and
264 deletions.
There are no files selected for viewing
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
25 changes: 0 additions & 25 deletions
25
src/main/java/org/auioc/mcmod/arnicalib/common/network/AHPacketHandler.java
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
src/main/java/org/auioc/mcmod/arnicalib/common/network/AHPackets.java
This file was deleted.
Oops, something went wrong.
63 changes: 0 additions & 63 deletions
63
...uioc/mcmod/arnicalib/common/network/packet/client/ClientboundDrawParticleShapePacket.java
This file was deleted.
Oops, something went wrong.
81 changes: 81 additions & 0 deletions
81
src/main/java/org/auioc/mcmod/arnicalib/game/particle/ClientParticlePainter.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,81 @@ | ||
package org.auioc.mcmod.arnicalib.game.particle; | ||
|
||
import org.auioc.mcmod.arnicalib.base.phys.Shape; | ||
import org.auioc.mcmod.arnicalib.utils.game.AABBUtils; | ||
import org.auioc.mcmod.arnicalib.utils.game.NbtUtils; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.util.Mth; | ||
import net.minecraft.world.phys.AABB; | ||
import net.minecraft.world.phys.Vec3; | ||
import net.minecraftforge.api.distmarker.Dist; | ||
import net.minecraftforge.api.distmarker.OnlyIn; | ||
|
||
@OnlyIn(Dist.CLIENT) | ||
public class ClientParticlePainter { | ||
|
||
@SuppressWarnings("resource") | ||
public static void drawPoint(ParticlePainterOptions options, double x, double y, double z) { | ||
Minecraft.getInstance().levelRenderer.addParticle(options.particle(), options.force(), !options.force(), x, y, z, 0.0D, 0.0D, 0.0D); | ||
} | ||
|
||
public static void drawLine(ParticlePainterOptions options, double x1, double y1, double z1, double x2, double y2, double z2) { | ||
double diffX = (x2 - x1); | ||
double diffY = (y2 - y1); | ||
double diffZ = (z2 - z1); | ||
|
||
double lineLength = Mth.length(diffX, diffY, diffZ); | ||
|
||
long pointCount = Math.round(lineLength / options.stepLength()); | ||
|
||
double projectedStepLengthX = diffX / pointCount; | ||
double projectedStepLengthY = diffY / pointCount; | ||
double projectedStepLengthZ = diffZ / pointCount; | ||
|
||
for (long i = 0; i < pointCount; i++) { | ||
double x = x1 + projectedStepLengthX * i; | ||
double y = y1 + projectedStepLengthY * i; | ||
double z = z1 + projectedStepLengthZ * i; | ||
drawPoint(options, x, y, z); | ||
} | ||
} | ||
|
||
public static void drawPolygon(ParticlePainterOptions options, Vec3[] vertexes) { | ||
for (int i = 0, l = vertexes.length; i < l; i++) { | ||
Vec3 a = vertexes[i]; | ||
Vec3 b = vertexes[(i + 1 == l) ? 0 : i + 1]; | ||
drawLine(options, a.x, a.y, a.z, b.x, b.y, b.z); | ||
} | ||
} | ||
|
||
public static void drawCuboid(ParticlePainterOptions options, AABB aabb) { | ||
double[][] edges = AABBUtils.getEdges(aabb); | ||
for (double[] edge : edges) { | ||
drawLine(options, edge[0], edge[1], edge[2], edge[3], edge[4], edge[5]); | ||
} | ||
} | ||
|
||
|
||
public static void draw(Shape shape, ParticlePainterOptions options, CompoundTag data) { | ||
switch (shape) { | ||
case LINE -> { | ||
double[] p1 = NbtUtils.getDoubleArray(data, "StartPoint"); | ||
double[] p2 = NbtUtils.getDoubleArray(data, "EndPoint"); | ||
drawLine(options, p1[0], p1[1], p1[2], p2[0], p2[1], p2[2]); | ||
} | ||
case CUBOID -> { | ||
drawCuboid(options, NbtUtils.getAABB(data, "AABB")); | ||
} | ||
case POLYGON -> { | ||
double[] p = NbtUtils.getDoubleArray(data, "Vertexes"); | ||
Vec3[] vertexes = new Vec3[p.length / 3]; | ||
for (int i = 0, j = 0; i < vertexes.length; i++, j = i * 3) { | ||
vertexes[i] = new Vec3(p[j], p[j + 1], p[j + 2]); | ||
} | ||
drawPolygon(options, vertexes); | ||
} | ||
default -> throw new IllegalArgumentException("Unexpected shape: " + shape); | ||
} | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/org/auioc/mcmod/arnicalib/game/particle/ParticlePainterOptions.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,7 @@ | ||
package org.auioc.mcmod.arnicalib.game.particle; | ||
|
||
import net.minecraft.core.particles.ParticleOptions; | ||
|
||
public record ParticlePainterOptions(double stepLength, ParticleOptions particle, boolean force) { | ||
|
||
} |
162 changes: 0 additions & 162 deletions
162
src/main/java/org/auioc/mcmod/arnicalib/utils/game/ParticlePainter.java
This file was deleted.
Oops, something went wrong.