This commit is contained in:
Sebastian Hartte
2020-06-28 16:18:11 +02:00
parent f5412152a4
commit 3df93fc66d
52 changed files with 43 additions and 36 deletions
@@ -1,66 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.client.render.effects;
import net.fabricmc.api.Environment;
import net.minecraft.client.particle.IAnimatedSprite;
import net.minecraft.client.particle.IParticleFactory;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.RedstoneParticle;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.particles.RedstoneParticleData;
import net.minecraft.world.World;
import net.fabricmc.api.EnvType;
@Environment(EnvType.CLIENT)
public class ChargedOreFX extends RedstoneParticle {
private static final RedstoneParticleData PARTICLE_DATA = new RedstoneParticleData(0.21f, 0.61f, 1.0f, 1.0f);
private ChargedOreFX(World worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed,
IAnimatedSprite spriteSet) {
super(worldIn, x, y, z, xSpeed, ySpeed, zSpeed, PARTICLE_DATA, spriteSet);
}
@Override
public int getBrightnessForRender(final float par1) {
int j1 = super.getBrightnessForRender(par1);
j1 = Math.max(j1 >> 20, j1 >> 4);
j1 += 3;
if (j1 > 15) {
j1 = 15;
}
return j1 << 20 | j1 << 4;
}
@Environment(EnvType.CLIENT)
public static class Factory implements IParticleFactory<DefaultParticleType> {
private final IAnimatedSprite spriteSet;
public Factory(IAnimatedSprite p_i50477_1_) {
this.spriteSet = p_i50477_1_;
}
@Override
public Particle makeParticle(DefaultParticleType typeIn, World worldIn, double x, double y, double z,
double xSpeed, double ySpeed, double zSpeed) {
return new ChargedOreFX(worldIn, x, y, z, xSpeed, ySpeed, zSpeed, this.spriteSet);
}
}
}
@@ -1,143 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.client.render.effects;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.fabricmc.api.EnvType;
import net.minecraft.client.particle.IAnimatedSprite;
import net.minecraft.client.particle.IParticleFactory;
import net.minecraft.client.particle.IParticleRenderType;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.SpriteBillboardParticle;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.fabricmc.api.Environment;
@Environment(EnvType.CLIENT)
public class CraftingFx extends SpriteBillboardParticle {
// Offset relative to center of block, is the starting point of the particle
// movement
private final float offsetX;
private final float offsetY;
private final float offsetZ;
public CraftingFx(final World par1World, final double x, final double y, final double z,
final IAnimatedSprite sprite) {
super(par1World, x, y, z);
// Pick a random normal, offset it by 0.35 and use that as the particle origin
Vector3f off = new Vector3f(rand.nextFloat() - 0.5f, rand.nextFloat() - 0.5f, rand.nextFloat() - 0.5f);
off.normalize();
off.mul(0.35f);
offsetX = off.getX();
offsetY = off.getY();
offsetZ = off.getZ();
this.particleGravity = 0;
this.particleBlue = 1;
this.particleGreen = 0.9f;
this.particleRed = 1;
this.selectSpriteRandomly(sprite);
this.maxAge /= 1.2;
this.canCollide = false; // we're INSIDE the block anyway
}
@Override
public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) {
float f = (this.age + partialTicks) / this.maxAge;
float offX = (float) posX + MathHelper.lerp(f, offsetX, 0);
float offY = (float) posY + MathHelper.lerp(f, offsetY, 0);
float offZ = (float) posZ + MathHelper.lerp(f, offsetZ, 0);
float alpha = MathHelper.lerp(easeOutCirc(f), 1.3f, 0.1f);
float scale = MathHelper.lerp(easeOutCirc(f), 0.13f, 0.0f);
// I believe this particle is same as breaking particle, but should not exit the
// original block it was
// spawned in (which is encased in glass)
Vec3d vec3d = renderInfo.getProjectedView();
offX -= vec3d.x;
offY -= vec3d.y;
offZ -= vec3d.z;
Vector3f[] avector3f = new Vector3f[] { new Vector3f(-1.0F, -1.0F, 0.0F), new Vector3f(-1.0F, 1.0F, 0.0F),
new Vector3f(1.0F, 1.0F, 0.0F), new Vector3f(1.0F, -1.0F, 0.0F) };
for (int i = 0; i < 4; ++i) {
Vector3f vector3f = avector3f[i];
vector3f.transform(renderInfo.getRotation());
vector3f.mul(scale);
vector3f.add(offX, offY, offZ);
}
float minU = this.getMinU();
float maxU = this.getMaxU();
float minV = this.getMinV();
float maxV = this.getMaxV();
int j = 15728880; // full brightness
buffer.pos(avector3f[0].getX(), avector3f[0].getY(), avector3f[0].getZ()).tex(maxU, maxV)
.color(this.particleRed, this.particleGreen, this.particleBlue, alpha).lightmap(j).endVertex();
buffer.pos(avector3f[1].getX(), avector3f[1].getY(), avector3f[1].getZ()).tex(maxU, minV)
.color(this.particleRed, this.particleGreen, this.particleBlue, alpha).lightmap(j).endVertex();
buffer.pos(avector3f[2].getX(), avector3f[2].getY(), avector3f[2].getZ()).tex(minU, minV)
.color(this.particleRed, this.particleGreen, this.particleBlue, alpha).lightmap(j).endVertex();
buffer.pos(avector3f[3].getX(), avector3f[3].getY(), avector3f[3].getZ()).tex(minU, maxV)
.color(this.particleRed, this.particleGreen, this.particleBlue, alpha).lightmap(j).endVertex();
}
// https://easings.net/#easeOutCirc
private static float easeOutCirc(float x) {
return (float) Math.sqrt(1 - Math.pow(x - 1, 2));
}
@Override
public IParticleRenderType getRenderType() {
return IParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
}
@Override
public void tick() {
if (this.age++ >= this.maxAge) {
this.setExpired();
}
}
@Environment(EnvType.CLIENT)
public static class Factory implements IParticleFactory<DefaultParticleType> {
private final IAnimatedSprite spriteSet;
public Factory(IAnimatedSprite p_i50477_1_) {
this.spriteSet = p_i50477_1_;
}
@Override
public Particle makeParticle(DefaultParticleType data, World worldIn, double x, double y, double z, double xSpeed,
double ySpeed, double zSpeed) {
return new CraftingFx(worldIn, x, y, z, spriteSet);
}
}
}
@@ -1,124 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.client.render.effects;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.particle.*;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
@Environment(EnvType.CLIENT)
public class EnergyFx extends SpriteBillboardParticle {
private final int startBlkX;
private final int startBlkY;
private final int startBlkZ;
public EnergyFx(final World par1World, final double par2, final double par4, final double par6,
final IAnimatedSprite sprite) {
super(par1World, par2, par4, par6);
this.particleGravity = 0;
this.particleBlue = 1;
this.particleGreen = 1;
this.particleRed = 1;
this.particleAlpha = 1.4f;
this.particleScale = 3.5f;
this.selectSpriteRandomly(sprite);
this.startBlkX = MathHelper.floor(this.posX);
this.startBlkY = MathHelper.floor(this.posY);
this.startBlkZ = MathHelper.floor(this.posZ);
}
@Override
public IParticleRenderType getRenderType() {
return IParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
}
@Override
public float getScale(float scaleFactor) {
return 0.1f * this.particleScale;
}
@Override
public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) {
float x = (float) (this.prevX + (this.posX - this.prevX) * partialTicks);
float y = (float) (this.prevY + (this.posY - this.prevY) * partialTicks);
float z = (float) (this.prevZ + (this.posZ - this.prevZ) * partialTicks);
final int blkX = MathHelper.floor(x);
final int blkY = MathHelper.floor(y);
final int blkZ = MathHelper.floor(z);
if (blkX == this.startBlkX && blkY == this.startBlkY && blkZ == this.startBlkZ) {
super.renderParticle(buffer, renderInfo, partialTicks);
}
}
@Override
public void tick() {
super.tick();
this.onGround = false;
this.particleScale *= 0.89f;
this.particleAlpha *= 0.89f;
}
public void setMotionX(float motionX) {
this.motionX = motionX;
}
public void setMotionY(float motionY) {
this.motionY = motionY;
}
public void setMotionZ(float motionZ) {
this.motionZ = motionZ;
}
@Environment(EnvType.CLIENT)
public static class Factory implements IParticleFactory<EnergyParticleData> {
private final IAnimatedSprite spriteSet;
public Factory(IAnimatedSprite spriteSet) {
this.spriteSet = spriteSet;
}
@Override
public Particle makeParticle(EnergyParticleData data, World worldIn, double x, double y, double z,
double xSpeed, double ySpeed, double zSpeed) {
EnergyFx result = new EnergyFx(worldIn, x, y, z, spriteSet);
result.setMotionX((float) xSpeed);
result.setMotionY((float) ySpeed);
result.setMotionZ((float) zSpeed);
if (data.forItem) {
result.posX += -0.2 * data.direction.xOffset;
result.posY += -0.2 * data.direction.yOffset;
result.posZ += -0.2 * data.direction.zOffset;
result.particleScale *= 0.8f;
}
return result;
}
}
}
@@ -1,80 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.client.render.effects;
import java.util.Locale;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.particle.ParticleEffect;
import net.minecraft.particle.ParticleType;
import appeng.api.util.AEPartLocation;
public class EnergyParticleData implements ParticleEffect {
public static final EnergyParticleData FOR_BLOCK = new EnergyParticleData(false, AEPartLocation.INTERNAL);
public final boolean forItem;
public final AEPartLocation direction;
public EnergyParticleData(boolean forItem, AEPartLocation direction) {
this.forItem = forItem;
this.direction = direction;
}
public static final Factory<EnergyParticleData> DESERIALIZER = new Factory<EnergyParticleData>() {
@Override
public EnergyParticleData read(ParticleType<EnergyParticleData> particleTypeIn, StringReader reader)
throws CommandSyntaxException {
reader.expect(' ');
boolean forItem = reader.readBoolean();
reader.expect(' ');
AEPartLocation direction = AEPartLocation.valueOf(reader.readString().toUpperCase());
return new EnergyParticleData(forItem, direction);
}
@Override
public EnergyParticleData read(ParticleType<EnergyParticleData> particleTypeIn, PacketByteBuf buffer) {
boolean forItem = buffer.readBoolean();
AEPartLocation direction = AEPartLocation.values()[buffer.readByte()];
return new EnergyParticleData(forItem, direction);
}
};
@Override
public ParticleType<?> getType() {
return ParticleTypes.ENERGY;
}
@Override
public void write(PacketByteBuf buffer) {
buffer.writeBoolean(forItem);
buffer.writeByte((byte) direction.ordinal());
}
@Override
public String asString() {
return String.format(Locale.ROOT, "%s %s", forItem ? "true" : "false", direction.name().toLowerCase());
}
}
@@ -1,87 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.client.render.effects;
import java.util.Random;
import net.fabricmc.api.Environment;
import net.minecraft.client.particle.IAnimatedSprite;
import net.minecraft.client.particle.IParticleFactory;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.SpriteBillboardParticle;
import net.minecraft.world.World;
import net.fabricmc.api.EnvType;
@Environment(EnvType.CLIENT)
public class LightningArcFX extends LightningFX {
private static final Random RANDOM_GENERATOR = new Random();
private final double rx;
private final double ry;
private final double rz;
public LightningArcFX(final World w, final double x, final double y, final double z, final double ex,
final double ey, final double ez, final double r, final double g, final double b) {
super(w, x, y, z, r, g, b, 6);
this.rx = ex - x;
this.ry = ey - y;
this.rz = ez - z;
this.regen();
}
@Override
protected void regen() {
final double i = 1.0 / (this.getSteps() - 1);
final double lastDirectionX = this.rx * i;
final double lastDirectionY = this.ry * i;
final double lastDirectionZ = this.rz * i;
final double len = Math.sqrt(
lastDirectionX * lastDirectionX + lastDirectionY * lastDirectionY + lastDirectionZ * lastDirectionZ);
for (int s = 0; s < this.getSteps(); s++) {
final double[][] localSteps = this.getPrecomputedSteps();
localSteps[s][0] = (lastDirectionX + (RANDOM_GENERATOR.nextDouble() - 0.5) * len * 1.2) / 2.0;
localSteps[s][1] = (lastDirectionY + (RANDOM_GENERATOR.nextDouble() - 0.5) * len * 1.2) / 2.0;
localSteps[s][2] = (lastDirectionZ + (RANDOM_GENERATOR.nextDouble() - 0.5) * len * 1.2) / 2.0;
}
}
@Environment(EnvType.CLIENT)
public static class Factory implements IParticleFactory<LightningArcParticleData> {
private final IAnimatedSprite spriteSet;
public Factory(IAnimatedSprite spriteSet) {
this.spriteSet = spriteSet;
}
@Override
public Particle makeParticle(LightningArcParticleData data, World worldIn, double x, double y, double z,
double xSpeed, double ySpeed, double zSpeed) {
SpriteBillboardParticle lightningFX = new LightningArcFX(worldIn, x, y, z, data.target.x, data.target.y,
data.target.z, 0, 0, 0);
lightningFX.selectSpriteRandomly(this.spriteSet);
return lightningFX;
}
}
}
@@ -1,65 +0,0 @@
package appeng.client.render.effects;
import java.util.Locale;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.particle.ParticleEffect;
import net.minecraft.particle.ParticleType;
import net.minecraft.util.math.Vec3d;
/**
* Contains the target point of the lightning arc (the source point is infered
* from the particle starting position).
*/
public class LightningArcParticleData implements ParticleEffect {
public final Vec3d target;
public LightningArcParticleData(Vec3d target) {
this.target = target;
}
public static final Factory<LightningArcParticleData> DESERIALIZER = new Factory<LightningArcParticleData>() {
@Override
public LightningArcParticleData read(ParticleType<LightningArcParticleData> particleTypeIn,
StringReader reader) throws CommandSyntaxException {
reader.expect(' ');
float x = reader.readFloat();
reader.expect(' ');
float y = reader.readFloat();
reader.expect(' ');
float z = reader.readFloat();
return new LightningArcParticleData(new Vec3d(x, y, z));
}
@Override
public LightningArcParticleData read(ParticleType<LightningArcParticleData> particleTypeIn,
PacketByteBuf buffer) {
float x = buffer.readFloat();
float y = buffer.readFloat();
float z = buffer.readFloat();
return new LightningArcParticleData(new Vec3d(x, y, z));
}
};
@Override
public ParticleType<?> getType() {
return ParticleTypes.LIGHTNING_ARC;
}
@Override
public void write(PacketByteBuf buffer) {
buffer.writeFloat((float) target.x);
buffer.writeFloat((float) target.y);
buffer.writeFloat((float) target.z);
}
@Override
public String asString() {
return String.format(Locale.ROOT, "%.2f %.2f %.2f", target.x, target.y, target.z);
}
}
@@ -1,264 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.client.render.effects;
import java.util.Random;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.particle.IAnimatedSprite;
import net.minecraft.client.particle.IParticleFactory;
import net.minecraft.client.particle.IParticleRenderType;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.SpriteBillboardParticle;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
@Environment(EnvType.CLIENT)
public class LightningFX extends SpriteBillboardParticle {
private static final Random RANDOM_GENERATOR = new Random();
private static final int STEPS = 5;
private static final int BRIGHTNESS = 13 << 4;
private final double[][] precomputedSteps;
private final double[] vertices = new double[3];
private final double[] verticesWithUV = new double[3];
private boolean hasData = false;
private LightningFX(final World w, final double x, final double y, final double z, final double r, final double g,
final double b) {
this(w, x, y, z, r, g, b, 6);
this.regen();
}
protected LightningFX(final World w, final double x, final double y, final double z, final double r, final double g,
final double b, final int maxAge) {
super(w, x, y, z, r, g, b);
this.precomputedSteps = new double[LightningFX.STEPS][3];
this.motionX = 0;
this.motionY = 0;
this.motionZ = 0;
this.maxAge = maxAge;
}
protected void regen() {
double lastDirectionX = (RANDOM_GENERATOR.nextDouble() - 0.5) * 0.9;
double lastDirectionY = (RANDOM_GENERATOR.nextDouble() - 0.5) * 0.9;
double lastDirectionZ = (RANDOM_GENERATOR.nextDouble() - 0.5) * 0.9;
for (int s = 0; s < LightningFX.STEPS; s++) {
this.precomputedSteps[s][0] = lastDirectionX = (lastDirectionX
+ (RANDOM_GENERATOR.nextDouble() - 0.5) * 0.9) / 2.0;
this.precomputedSteps[s][1] = lastDirectionY = (lastDirectionY
+ (RANDOM_GENERATOR.nextDouble() - 0.5) * 0.9) / 2.0;
this.precomputedSteps[s][2] = lastDirectionZ = (lastDirectionZ
+ (RANDOM_GENERATOR.nextDouble() - 0.5) * 0.9) / 2.0;
}
}
protected int getSteps() {
return LightningFX.STEPS;
}
@Override
public IParticleRenderType getRenderType() {
// TODO: FIXME
return IParticleRenderType.PARTICLE_SHEET_OPAQUE;
}
@Override
public void tick() {
this.prevX = this.posX;
this.prevY = this.posY;
this.prevZ = this.posZ;
if (this.age++ >= this.maxAge) {
this.setExpired();
}
this.motionY -= 0.04D * this.particleGravity;
this.move(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.9800000190734863D;
this.motionY *= 0.9800000190734863D;
this.motionZ *= 0.9800000190734863D;
}
@Override
public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) {
Vec3d vec3d = renderInfo.getProjectedView();
float centerX = (float) (MathHelper.lerp(partialTicks, this.prevX, this.posX) - vec3d.getX());
float centerY = (float) (MathHelper.lerp(partialTicks, this.prevY, this.posY) - vec3d.getY());
float centerZ = (float) (MathHelper.lerp(partialTicks, this.prevZ, this.posZ) - vec3d.getZ());
final float j = 1.0f;
float red = this.particleRed * j * 0.9f;
float green = this.particleGreen * j * 0.95f;
float blue = this.particleBlue * j;
final float alpha = this.particleAlpha;
if (this.age == 3) {
this.regen();
}
float u = this.getMinU() + (this.getMaxU() - this.getMinU()) / 2;
float v = this.getMinV() + (this.getMaxV() - this.getMinV()) / 2;
double scale = 0.02;// 0.02F * this.particleScale;
final double[] a = new double[3];
final double[] b = new double[3];
double ox = 0;
double oy = 0;
double oz = 0;
final PlayerEntity p = MinecraftClient.getInstance().player;
// FIXME: Billboard rotation is not applied to the particle yet,
// FIXME The old version apparently did this by hand using rX,rZ -> replicate
// using the quaternion
for (int layer = 0; layer < 2; layer++) {
if (layer == 0) {
scale = 0.04;
// FIXME offX *= 0.001;
// FIXME offY *= 0.001;
// FIXME offZ *= 0.001;
red = this.particleRed * j * 0.4f;
green = this.particleGreen * j * 0.25f;
blue = this.particleBlue * j * 0.45f;
} else {
// FIXME offX = 0;
// FIXME offY = 0;
// FIXME offZ = 0;
scale = 0.02;
red = this.particleRed * j * 0.9f;
green = this.particleGreen * j * 0.65f;
blue = this.particleBlue * j * 0.85f;
}
for (int cycle = 0; cycle < 3; cycle++) {
this.clear();
// FIXME removed interpPos here, check if this is correct
double x = centerX; // FIXME - offX;
double y = centerY; // FIXME - offY;
double z = centerZ; // FIXME - offZ;
for (int s = 0; s < LightningFX.STEPS; s++) {
final double xN = x + this.precomputedSteps[s][0];
final double yN = y + this.precomputedSteps[s][1];
final double zN = z + this.precomputedSteps[s][2];
final double xD = xN - x;
final double yD = yN - y;
final double zD = zN - z;
if (cycle == 0) {
ox = (yD * 0) - (1 * zD);
oy = (zD * 0) - (0 * xD);
oz = (xD * 1) - (0 * yD);
}
if (cycle == 1) {
ox = (yD * 1) - (0 * zD);
oy = (zD * 0) - (1 * xD);
oz = (xD * 0) - (0 * yD);
}
if (cycle == 2) {
ox = (yD * 0) - (0 * zD);
oy = (zD * 1) - (0 * xD);
oz = (xD * 0) - (1 * yD);
}
final double ss = Math.sqrt(ox * ox + oy * oy + oz * oz)
/ ((((double) LightningFX.STEPS - (double) s) / LightningFX.STEPS) * scale);
ox /= ss;
oy /= ss;
oz /= ss;
a[0] = x + ox;
a[1] = y + oy;
a[2] = z + oz;
b[0] = x;
b[1] = y;
b[2] = z;
this.draw(red, green, blue, buffer, a, b, u, v);
x = xN;
y = yN;
z = zN;
}
}
}
}
private void clear() {
this.hasData = false;
}
private void draw(float red, float green, float blue, final IVertexBuilder tess, final double[] a, final double[] b,
final float u, final float v) {
if (this.hasData) {
tess.pos(a[0], a[1], a[2]).tex(u, v).color(red, green, blue, this.particleAlpha)
.lightmap(BRIGHTNESS, BRIGHTNESS).endVertex();
tess.pos(this.vertices[0], this.vertices[1], this.vertices[2]).tex(u, v)
.color(red, green, blue, this.particleAlpha).lightmap(BRIGHTNESS, BRIGHTNESS).endVertex();
tess.pos(this.verticesWithUV[0], this.verticesWithUV[1], this.verticesWithUV[2]).tex(u, v)
.color(red, green, blue, this.particleAlpha).lightmap(BRIGHTNESS, BRIGHTNESS).endVertex();
tess.pos(b[0], b[1], b[2]).tex(u, v).color(red, green, blue, this.particleAlpha)
.lightmap(BRIGHTNESS, BRIGHTNESS).endVertex();
}
this.hasData = true;
for (int x = 0; x < 3; x++) {
this.vertices[x] = a[x];
this.verticesWithUV[x] = b[x];
}
}
protected double[][] getPrecomputedSteps() {
return this.precomputedSteps;
}
@Environment(EnvType.CLIENT)
public static class Factory implements IParticleFactory<DefaultParticleType> {
private final IAnimatedSprite spriteSet;
public Factory(IAnimatedSprite spriteSet) {
this.spriteSet = spriteSet;
}
@Override
public Particle makeParticle(DefaultParticleType typeIn, World worldIn, double x, double y, double z,
double xSpeed, double ySpeed, double zSpeed) {
LightningFX lightningFX = new LightningFX(worldIn, x, y, z, xSpeed, ySpeed, zSpeed);
lightningFX.selectSpriteRandomly(this.spriteSet);
return lightningFX;
}
}
}
@@ -1,90 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.client.render.effects;
import net.fabricmc.api.EnvType;
import net.minecraft.client.particle.*;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.world.World;
import net.fabricmc.api.Environment;
import appeng.api.util.AEPartLocation;
public class MatterCannonFX extends SpriteBillboardParticle {
public MatterCannonFX(final World par1World, final double x, final double y, final double z,
IAnimatedSprite sprite) {
super(par1World, x, y, z);
this.particleGravity = 0;
this.particleBlue = 1;
this.particleGreen = 1;
this.particleRed = 1;
this.particleAlpha = 1.4f;
this.particleScale = 1.1f;
this.motionX = 0.0f;
this.motionY = 0.0f;
this.motionZ = 0.0f;
this.selectSpriteRandomly(sprite);
}
public void fromItem(final AEPartLocation d) {
this.particleScale *= 1.2f;
}
@Override
public IParticleRenderType getRenderType() {
return IParticleRenderType.PARTICLE_SHEET_OPAQUE;
}
@Override
public void tick() {
this.prevX = this.posX;
this.prevY = this.posY;
this.prevZ = this.posZ;
if (this.age++ >= this.maxAge) {
this.setExpired();
}
this.motionY -= 0.04D * this.particleGravity;
this.move(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.9800000190734863D;
this.motionY *= 0.9800000190734863D;
this.motionZ *= 0.9800000190734863D;
this.particleScale *= 1.19f;
this.particleAlpha *= 0.59f;
}
@Environment(EnvType.CLIENT)
public static class Factory implements IParticleFactory<DefaultParticleType> {
private final IAnimatedSprite spriteSet;
public Factory(IAnimatedSprite spriteSet) {
this.spriteSet = spriteSet;
}
@Override
public Particle makeParticle(DefaultParticleType data, World world, double x, double y, double z, double xSpeed,
double ySpeed, double zSpeed) {
return new MatterCannonFX(world, x, y, z, spriteSet);
}
}
}
@@ -1,34 +0,0 @@
package appeng.client.render.effects;
import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.particle.ParticleType;
import appeng.core.AppEng;
public final class ParticleTypes {
private ParticleTypes() {
}
public static final DefaultParticleType CHARGED_ORE = FabricParticleTypes.simple(false);
public static final DefaultParticleType CRAFTING = FabricParticleTypes.simple(false);
public static final ParticleType<EnergyParticleData> ENERGY = FabricParticleTypes.complex(false,
EnergyParticleData.DESERIALIZER);
public static final ParticleType<LightningArcParticleData> LIGHTNING_ARC = FabricParticleTypes.complex(false,
LightningArcParticleData.DESERIALIZER);
public static final DefaultParticleType LIGHTNING = FabricParticleTypes.simple(false);
public static final DefaultParticleType MATTER_CANNON = FabricParticleTypes.simple(false);
public static final DefaultParticleType VIBRANT = FabricParticleTypes.simple(false);
static {
CHARGED_ORE.setRegistryName(AppEng.MOD_ID, "charged_ore_fx");
CRAFTING.setRegistryName(AppEng.MOD_ID, "crafting_fx");
ENERGY.setRegistryName(AppEng.MOD_ID, "energy_fx");
LIGHTNING_ARC.setRegistryName(AppEng.MOD_ID, "lightning_arc_fx");
LIGHTNING.setRegistryName(AppEng.MOD_ID, "lightning_fx");
MATTER_CANNON.setRegistryName(AppEng.MOD_ID, "matter_cannon_fx");
VIBRANT.setRegistryName(AppEng.MOD_ID, "vibrant_fx");
}
}
@@ -1,97 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.client.render.effects;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.particle.IAnimatedSprite;
import net.minecraft.client.particle.IParticleFactory;
import net.minecraft.client.particle.IParticleRenderType;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.SpriteBillboardParticle;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.world.World;
@Environment(EnvType.CLIENT)
public class VibrantFX extends SpriteBillboardParticle {
public VibrantFX(final World par1World, final double x, final double y, final double z, final double par8,
final double par10, final double par12, IAnimatedSprite sprite) {
super(par1World, x, y, z, par8, par10, par12);
final float f = this.rand.nextFloat() * 0.1F + 0.8F;
this.particleRed = f * 0.7f;
this.particleGreen = f * 0.89f;
this.particleBlue = f * 0.9f;
this.selectSpriteRandomly(sprite);
this.setSize(0.04F, 0.04F);
this.particleScale *= this.rand.nextFloat() * 0.6F + 1.9F;
this.motionX = 0.0D;
this.motionY = 0.0D;
this.motionZ = 0.0D;
this.prevX = this.posX;
this.prevY = this.posY;
this.prevZ = this.posZ;
this.maxAge = (int) (20.0D / (Math.random() * 0.8D + 0.1D));
}
@Override
public IParticleRenderType getRenderType() {
// FIXME Might be PARTICLE_SHEET_LIT
return IParticleRenderType.PARTICLE_SHEET_OPAQUE;
}
@Override
public int getBrightnessForRender(final float par1) {
// This just means full brightness
return 15 << 20 | 15 << 4;
}
/**
* Called to update the entity's position/logic.
*/
@Override
public void tick() {
this.prevX = this.posX;
this.prevY = this.posY;
this.prevZ = this.posZ;
// this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.particleScale *= 0.95;
if (this.maxAge <= 0 || this.particleScale < 0.1) {
this.setExpired();
}
this.maxAge--;
}
@Environment(EnvType.CLIENT)
public static class Factory implements IParticleFactory<DefaultParticleType> {
private final IAnimatedSprite spriteSet;
public Factory(IAnimatedSprite spriteSet) {
this.spriteSet = spriteSet;
}
@Override
public Particle makeParticle(DefaultParticleType typeIn, World worldIn, double x, double y, double z,
double xSpeed, double ySpeed, double zSpeed) {
return new VibrantFX(worldIn, x, y, z, xSpeed, ySpeed, zSpeed, spriteSet);
}
}
}