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

56 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;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import net.minecraft.client.particle.Particle;
2017-06-17 00:48:49 +02:00
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.entity.Entity;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
2021-02-26 22:15:48 +01:00
import net.minecraftforge.fml.relauncher.OnlyIn;
2021-02-26 22:15:48 +01:00
@OnlyIn(Dist.CLIENT)
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;
2019-05-02 09:10:29 +02:00
public ParticleBeam(World 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;
this.particleMaxAge = maxAge;
this.alpha = alpha;
}
@Override
2019-05-02 09:10:29 +02:00
public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
float ageRatio = (float) this.particleAge / (float) this.particleMaxAge;
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
2019-05-02 09:10:29 +02:00
public int getFXLayer() {
return 3;
}
}