2016-12-27 17:40:27 +01:00
|
|
|
/*
|
|
|
|
* This file ("ParticleLaserItem.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;
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
import org.lwjgl.opengl.GL14;
|
|
|
|
|
2016-12-27 17:40:27 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.particle.Particle;
|
2017-06-17 00:48:49 +02:00
|
|
|
import net.minecraft.client.renderer.BufferBuilder;
|
2016-12-27 17:40:27 +01:00
|
|
|
import net.minecraft.client.renderer.GlStateManager;
|
|
|
|
import net.minecraft.client.renderer.RenderHelper;
|
|
|
|
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
2019-05-02 09:10:29 +02:00
|
|
|
public class ParticleLaserItem extends Particle {
|
2016-12-27 17:40:27 +01:00
|
|
|
|
|
|
|
private final double otherX;
|
|
|
|
private final double otherY;
|
|
|
|
private final double otherZ;
|
|
|
|
|
|
|
|
private final ItemStack stack;
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
private ParticleLaserItem(World world, double posX, double posY, double posZ, ItemStack stack, double motionY) {
|
2016-12-27 17:40:27 +01:00
|
|
|
this(world, posX, posY, posZ, stack, motionY, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public ParticleLaserItem(World world, double posX, double posY, double posZ, ItemStack stack, double motionY, double otherX, double otherY, double otherZ) {
|
|
|
|
super(world, posX + (world.rand.nextDouble() - 0.5) / 8, posY, posZ + (world.rand.nextDouble() - 0.5) / 8);
|
2016-12-27 17:40:27 +01:00
|
|
|
this.stack = stack;
|
|
|
|
this.otherX = otherX;
|
|
|
|
this.otherY = otherY;
|
|
|
|
this.otherZ = otherZ;
|
|
|
|
|
|
|
|
this.motionX = 0;
|
|
|
|
this.motionY = motionY;
|
|
|
|
this.motionZ = 0;
|
|
|
|
|
2016-12-27 21:43:00 +01:00
|
|
|
this.particleMaxAge = 10;
|
2016-12-27 17:40:27 +01:00
|
|
|
this.canCollide = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void setExpired() {
|
2016-12-27 17:40:27 +01:00
|
|
|
super.setExpired();
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
if (this.otherX != 0 || this.otherY != 0 || this.otherZ != 0) {
|
2016-12-27 17:40:27 +01:00
|
|
|
Particle fx = new ParticleLaserItem(this.world, this.otherX, this.otherY, this.otherZ, this.stack, -0.025);
|
|
|
|
Minecraft.getMinecraft().effectRenderer.addEffect(fx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@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) {
|
2016-12-27 17:40:27 +01:00
|
|
|
GlStateManager.pushMatrix();
|
|
|
|
RenderHelper.enableStandardItemLighting();
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
GlStateManager.translate(this.posX - TileEntityRendererDispatcher.staticPlayerX, this.posY - TileEntityRendererDispatcher.staticPlayerY, this.posZ - TileEntityRendererDispatcher.staticPlayerZ);
|
2016-12-27 17:40:27 +01:00
|
|
|
GlStateManager.scale(0.3F, 0.3F, 0.3F);
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
double boop = Minecraft.getSystemTime() / 600D;
|
|
|
|
GlStateManager.rotate((float) (boop * 40D % 360), 0, 1, 0);
|
2016-12-27 17:40:27 +01:00
|
|
|
|
|
|
|
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
|
|
|
GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_CONSTANT_COLOR, GlStateManager.SourceFactor.ONE.factor, GlStateManager.DestFactor.ZERO.factor);
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
float ageRatio = (float) this.particleAge / (float) this.particleMaxAge;
|
|
|
|
float color = this.motionY < 0 ? 1F - ageRatio : ageRatio;
|
2016-12-27 17:40:27 +01:00
|
|
|
GL14.glBlendColor(color, color, color, color);
|
|
|
|
|
|
|
|
AssetUtil.renderItemWithoutScrewingWithColors(this.stack);
|
|
|
|
|
|
|
|
RenderHelper.disableStandardItemLighting();
|
|
|
|
GlStateManager.popMatrix();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public int getFXLayer() {
|
2016-12-27 17:40:27 +01:00
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
}
|