-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
146 additions
and
14 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
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
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
88 changes: 88 additions & 0 deletions
88
src/main/java/com/fusionflux/portalcubed/client/particle/EnergySparkParticle.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,88 @@ | ||
package com.fusionflux.portalcubed.client.particle; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.blaze3d.vertex.VertexConsumer; | ||
import net.minecraft.client.Camera; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.multiplayer.ClientLevel; | ||
import net.minecraft.client.particle.Particle; | ||
import net.minecraft.client.particle.ParticleRenderType; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.util.Mth; | ||
import net.minecraft.world.phys.Vec3; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.quiltmc.loader.api.minecraft.ClientOnly; | ||
|
||
@ClientOnly | ||
public class EnergySparkParticle extends Particle { | ||
private double xoo, yoo, zoo; | ||
|
||
public EnergySparkParticle( | ||
ClientLevel clientLevel, | ||
double x, double y, double z, | ||
double xSpeed, double ySpeed, double zSpeed | ||
) { | ||
super(clientLevel, x, y, z, xSpeed, ySpeed, zSpeed); | ||
xoo = x; | ||
yoo = y; | ||
zoo = z; | ||
friction = 1f; | ||
gravity = 0.8f; | ||
lifetime *= 4; | ||
} | ||
|
||
@Override | ||
public void render(VertexConsumer buffer, Camera renderInfo, float partialTicks) { | ||
final PoseStack poseStack = new PoseStack(); | ||
final Vec3 position = renderInfo.getPosition(); | ||
poseStack.translate(-position.x, -position.y, -position.z); | ||
final MultiBufferSource.BufferSource bufferSource = Minecraft.getInstance().renderBuffers().bufferSource(); | ||
final VertexConsumer vertexConsumer = bufferSource.getBuffer(RenderType.lines()); | ||
render0(poseStack, vertexConsumer, partialTicks); | ||
bufferSource.endBatch(); | ||
} | ||
|
||
private void render0(PoseStack poseStack, VertexConsumer vertexConsumer, float partialTicks) { | ||
final float x1 = (float)Mth.lerp(partialTicks, xoo, xo); | ||
final float y1 = (float)Mth.lerp(partialTicks, yoo, yo); | ||
final float z1 = (float)Mth.lerp(partialTicks, zoo, zo); | ||
|
||
final float x2 = (float)Mth.lerp(partialTicks, xo, x); | ||
final float y2 = (float)Mth.lerp(partialTicks, yo, y); | ||
final float z2 = (float)Mth.lerp(partialTicks, zo, z); | ||
|
||
final float nx = x2 - x1; | ||
final float ny = y2 - y1; | ||
final float nz = z2 - z1; | ||
|
||
final PoseStack.Pose matrix = poseStack.last(); | ||
vertexConsumer | ||
.vertex(matrix.pose(), x1, y1, z1) | ||
.color(242 / 255f, 177 / 255f, 46 / 255f, 1f) | ||
.normal(matrix.normal(), nx, ny, nz) | ||
.endVertex(); | ||
vertexConsumer | ||
.vertex(matrix.pose(), x2, y2, z2) | ||
.color(97 / 255f, 67 / 255f, 6 / 255f, 1f) | ||
.normal(matrix.normal(), nx, ny, nz) | ||
.endVertex(); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public ParticleRenderType getRenderType() { | ||
return ParticleRenderType.CUSTOM; | ||
} | ||
|
||
@Override | ||
public void tick() { | ||
xoo = xo; | ||
yoo = yo; | ||
zoo = zo; | ||
super.tick(); | ||
if (onGround) { | ||
yd = -yd * 0.75; | ||
} | ||
} | ||
} |
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
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
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
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
5 changes: 5 additions & 0 deletions
5
src/main/resources/assets/portalcubed/particles/energy_spark.json
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,5 @@ | ||
{ | ||
"textures": [ | ||
"portalcubed:energy_spark" | ||
] | ||
} |
Binary file added
BIN
+84 Bytes
src/main/resources/assets/portalcubed/textures/particle/energy_spark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.