ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/mod/particle/ParticleBeam.java

54 lines
2 KiB
Java
Raw Normal View History

/*
* This file ("ParticleBeam.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
2017-01-01 16:23:26 +01:00
* © 2015-2017 Ellpeck
*/
2016-12-27 17:40:27 +01:00
package de.ellpeck.actuallyadditions.mod.particle;
2021-02-27 21:24:26 +01:00
import com.mojang.blaze3d.vertex.IVertexBuilder;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
2021-02-27 21:24:26 +01:00
import net.minecraft.client.particle.IParticleRenderType;
import net.minecraft.client.particle.Particle;
2021-02-27 21:24:26 +01:00
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.world.ClientWorld;
2019-05-02 09:10:29 +02:00
public class ParticleBeam extends Particle {
private final double endX;
private final double endY;
private final double endZ;
private final float[] color;
private final double rotationTime;
private final float size;
private final float alpha;
2021-02-27 21:24:26 +01:00
public ParticleBeam(ClientWorld world, double startX, double startY, double startZ, double endX, double endY, double endZ, float[] color, int maxAge, double rotationTime, float size, float alpha) {
super(world, startX, startY, startZ);
this.endX = endX;
this.endY = endY;
this.endZ = endZ;
this.color = color;
this.rotationTime = rotationTime;
this.size = size;
2021-02-27 21:24:26 +01:00
this.maxAge = maxAge;
this.alpha = alpha;
}
@Override
2021-02-27 21:24:26 +01:00
public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) {
float ageRatio = (float) this.age / (float) this.maxAge;
2019-05-02 09:10:29 +02:00
float currAlpha = this.alpha - ageRatio * this.alpha;
AssetUtil.renderLaser(this.posX + 0.5, this.posY + 0.5, this.posZ + 0.5, this.endX + 0.5, this.endY + 0.5, this.endZ + 0.5, this.rotationTime, currAlpha, this.size, this.color);
}
@Override
2021-02-27 21:24:26 +01:00
public IParticleRenderType getRenderType() {
return IParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
}
}