Moving to source sets

This commit is contained in:
Sebastian Hartte
2020-07-01 23:36:51 +02:00
parent f2e3d81fd7
commit 2642ced86b
2924 changed files with 794 additions and 796 deletions
@@ -0,0 +1,66 @@
/*
* 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.ParticleFactory;
import net.minecraft.client.particle.SpriteProvider;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.RedDustParticle;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.particle.DustParticleEffect;
import net.fabricmc.api.EnvType;
@Environment(EnvType.CLIENT)
public class ChargedOreFX extends RedDustParticle {
private static final DustParticleEffect PARTICLE_DATA = new DustParticleEffect(0.21f, 0.61f, 1.0f, 1.0f);
private ChargedOreFX(ClientWorld world, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed,
SpriteProvider spriteSet) {
super(world, x, y, z, xSpeed, ySpeed, zSpeed, PARTICLE_DATA, spriteSet);
}
@Override
public int getColorMultiplier(final float par1) {
int j1 = super.getColorMultiplier(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 ParticleFactory<DefaultParticleType> {
private final SpriteProvider spriteSet;
public Factory(SpriteProvider p_i50477_1_) {
this.spriteSet = p_i50477_1_;
}
@Override
public Particle createParticle(DefaultParticleType effect, ClientWorld world, double x, double y, double z,
double xSpeed, double ySpeed, double zSpeed) {
return new ChargedOreFX(world, x, y, z, xSpeed, ySpeed, zSpeed, this.spriteSet);
}
}
}
@@ -0,0 +1,142 @@
/*
* 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.minecraft.client.render.VertexConsumer;
import net.fabricmc.api.EnvType;
import net.minecraft.client.particle.*;
import net.minecraft.client.particle.ParticleTextureSheet;
import net.minecraft.client.render.Camera;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
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(ClientWorld world, final double x, final double y, final double z,
final SpriteProvider sprite) {
super(world, x, y, z);
// Pick a random normal, offset it by 0.35 and use that as the particle origin
Vector3f off = new Vector3f(random.nextFloat() - 0.5f, random.nextFloat() - 0.5f, random.nextFloat() - 0.5f);
off.normalize();
off.scale(0.35f);
offsetX = off.getX();
offsetY = off.getY();
offsetZ = off.getZ();
this.gravityStrength = 0;
this.colorBlue = 1;
this.colorGreen = 0.9f;
this.colorRed = 1;
this.setSprite(sprite);
this.maxAge /= 1.2;
this.collidesWithWorld = false; // we're INSIDE the block anyway
}
@Override
public void buildGeometry(VertexConsumer buffer, Camera camera, float partialTicks) {
float f = (this.age + partialTicks) / this.maxAge;
float offX = (float) x + MathHelper.lerp(f, offsetX, 0);
float offY = (float) y + MathHelper.lerp(f, offsetY, 0);
float offZ = (float) z + 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 = camera.getPos();
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.rotate(camera.getRotation());
vector3f.scale(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.vertex(avector3f[0].getX(), avector3f[0].getY(), avector3f[0].getZ()).texture(maxU, maxV)
.color(this.colorRed, this.colorGreen, this.colorBlue, alpha).light(j).next();
buffer.vertex(avector3f[1].getX(), avector3f[1].getY(), avector3f[1].getZ()).texture(maxU, minV)
.color(this.colorRed, this.colorGreen, this.colorBlue, alpha).light(j).next();
buffer.vertex(avector3f[2].getX(), avector3f[2].getY(), avector3f[2].getZ()).texture(minU, minV)
.color(this.colorRed, this.colorGreen, this.colorBlue, alpha).light(j).next();
buffer.vertex(avector3f[3].getX(), avector3f[3].getY(), avector3f[3].getZ()).texture(minU, maxV)
.color(this.colorRed, this.colorGreen, this.colorBlue, alpha).light(j).next();
}
// https://easings.net/#easeOutCirc
private static float easeOutCirc(float x) {
return (float) Math.sqrt(1 - Math.pow(x - 1, 2));
}
@Override
public ParticleTextureSheet getType() {
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
}
@Override
public void tick() {
if (this.age++ >= this.maxAge) {
this.markDead();
}
}
@Environment(EnvType.CLIENT)
public static class Factory implements ParticleFactory<DefaultParticleType> {
private final SpriteProvider spriteSet;
public Factory(SpriteProvider p_i50477_1_) {
this.spriteSet = p_i50477_1_;
}
@Override
public Particle createParticle(DefaultParticleType effect, ClientWorld world, double x, double y, double z, double xSpeed,
double ySpeed, double zSpeed) {
return new CraftingFx(world, x, y, z, spriteSet);
}
}
}
@@ -0,0 +1,124 @@
/*
* 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.minecraft.client.render.VertexConsumer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.particle.*;
import net.minecraft.client.render.Camera;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.util.math.MathHelper;
@Environment(EnvType.CLIENT)
public class EnergyFx extends SpriteBillboardParticle {
private final int startBlkX;
private final int startBlkY;
private final int startBlkZ;
public EnergyFx(ClientWorld world, final double par2, final double par4, final double par6,
final SpriteProvider sprite) {
super(world, par2, par4, par6);
this.gravityStrength = 0;
this.colorBlue = 1;
this.colorGreen = 1;
this.colorRed = 1;
this.colorAlpha = 1.4f;
this.scale = 3.5f;
this.setSprite(sprite);
this.startBlkX = MathHelper.floor(this.x);
this.startBlkY = MathHelper.floor(this.y);
this.startBlkZ = MathHelper.floor(this.z);
}
@Override
public ParticleTextureSheet getType() {
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
}
@Override
public float getSize(float tickDelta) {
return 0.1f * this.scale;
}
@Override
public void buildGeometry(VertexConsumer buffer, Camera camera, float partialTicks) {
float x = (float) (this.prevPosX + (this.x - this.prevPosX) * partialTicks);
float y = (float) (this.prevPosY + (this.y - this.prevPosY) * partialTicks);
float z = (float) (this.prevPosZ + (this.z - this.prevPosZ) * 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.buildGeometry(buffer, camera, partialTicks);
}
}
@Override
public void tick() {
super.tick();
this.onGround = false;
this.scale *= 0.89f;
this.colorAlpha *= 0.89f;
}
public void setVelocityX(float velocityX) {
this.velocityX = velocityX;
}
public void setVelocityY(float velocityY) {
this.velocityY = velocityY;
}
public void setVelocityZ(float velocityZ) {
this.velocityZ = velocityZ;
}
@Environment(EnvType.CLIENT)
public static class Factory implements ParticleFactory<EnergyParticleData> {
private final SpriteProvider spriteSet;
public Factory(SpriteProvider spriteSet) {
this.spriteSet = spriteSet;
}
@Override
public Particle createParticle(EnergyParticleData effect, ClientWorld world, double x, double y, double z,
double xSpeed, double ySpeed, double zSpeed) {
EnergyFx result = new EnergyFx(world, x, y, z, spriteSet);
result.setVelocityX((float) xSpeed);
result.setVelocityY((float) ySpeed);
result.setVelocityZ((float) zSpeed);
if (effect.forItem) {
result.x += -0.2 * effect.direction.xOffset;
result.y += -0.2 * effect.direction.yOffset;
result.z += -0.2 * effect.direction.zOffset;
result.scale *= 0.8f;
}
return result;
}
}
}
@@ -0,0 +1,80 @@
/*
* 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());
}
}
@@ -0,0 +1,88 @@
/*
* 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.SpriteProvider;
import net.minecraft.client.particle.ParticleFactory;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.SpriteBillboardParticle;
import net.minecraft.client.world.ClientWorld;
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(ClientWorld world, 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(world, 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 ParticleFactory<LightningArcParticleData> {
private final SpriteProvider spriteSet;
public Factory(SpriteProvider spriteSet) {
this.spriteSet = spriteSet;
}
@Override
public Particle createParticle(LightningArcParticleData effect, ClientWorld world, double x, double y, double z,
double xSpeed, double ySpeed, double zSpeed) {
SpriteBillboardParticle lightningFX = new LightningArcFX(world, x, y, z, effect.target.x, effect.target.y,
effect.target.z, 0, 0, 0);
lightningFX.setSprite(this.spriteSet);
return lightningFX;
}
}
}
@@ -0,0 +1,65 @@
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);
}
}
@@ -0,0 +1,261 @@
/*
* 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.minecraft.client.render.VertexConsumer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.particle.*;
import net.minecraft.client.particle.ParticleTextureSheet;
import net.minecraft.client.render.Camera;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
@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(ClientWorld world, final double x, final double y, final double z, final double r, final double g,
final double b) {
this(world, x, y, z, r, g, b, 6);
this.regen();
}
protected LightningFX(ClientWorld world, final double x, final double y, final double z, final double r, final double g,
final double b, final int maxAge) {
super(world, x, y, z, r, g, b);
this.precomputedSteps = new double[LightningFX.STEPS][3];
this.velocityX = 0;
this.velocityY = 0;
this.velocityZ = 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 ParticleTextureSheet getType() {
// TODO: FIXME
return ParticleTextureSheet.PARTICLE_SHEET_OPAQUE;
}
@Override
public void tick() {
this.prevPosX = this.x;
this.prevPosY = this.y;
this.prevPosZ = this.z;
if (this.age++ >= this.maxAge) {
this.markDead();
}
this.velocityY -= 0.04D * this.gravityStrength;
this.move(this.velocityX, this.velocityY, this.velocityZ);
this.velocityX *= 0.9800000190734863D;
this.velocityY *= 0.9800000190734863D;
this.velocityZ *= 0.9800000190734863D;
}
@Override
public void buildGeometry(VertexConsumer buffer, Camera camera, float partialTicks) {
Vec3d vec3d = camera.getPos();
float centerX = (float) (MathHelper.lerp(partialTicks, this.prevPosX, this.x) - vec3d.getX());
float centerY = (float) (MathHelper.lerp(partialTicks, this.prevPosY, this.y) - vec3d.getY());
float centerZ = (float) (MathHelper.lerp(partialTicks, this.prevPosZ, this.z) - vec3d.getZ());
final float j = 1.0f;
float red = this.colorRed * j * 0.9f;
float green = this.colorGreen * j * 0.95f;
float blue = this.colorBlue * j;
final float alpha = this.colorAlpha;
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.scale;
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.colorRed * j * 0.4f;
green = this.colorGreen * j * 0.25f;
blue = this.colorBlue * j * 0.45f;
} else {
// FIXME offX = 0;
// FIXME offY = 0;
// FIXME offZ = 0;
scale = 0.02;
red = this.colorRed * j * 0.9f;
green = this.colorGreen * j * 0.65f;
blue = this.colorBlue * 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 VertexConsumer tess, final double[] a, final double[] b,
final float u, final float v) {
if (this.hasData) {
tess.vertex(a[0], a[1], a[2]).texture(u, v).color(red, green, blue, this.colorAlpha)
.light(BRIGHTNESS, BRIGHTNESS).next();
tess.vertex(this.vertices[0], this.vertices[1], this.vertices[2]).texture(u, v)
.color(red, green, blue, this.colorAlpha).light(BRIGHTNESS, BRIGHTNESS).next();
tess.vertex(this.verticesWithUV[0], this.verticesWithUV[1], this.verticesWithUV[2]).texture(u, v)
.color(red, green, blue, this.colorAlpha).light(BRIGHTNESS, BRIGHTNESS).next();
tess.vertex(b[0], b[1], b[2]).texture(u, v).color(red, green, blue, this.colorAlpha)
.light(BRIGHTNESS, BRIGHTNESS).next();
}
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 ParticleFactory<DefaultParticleType> {
private final SpriteProvider spriteSet;
public Factory(SpriteProvider spriteSet) {
this.spriteSet = spriteSet;
}
@Override
public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z,
double xSpeed, double ySpeed, double zSpeed) {
LightningFX lightningFX = new LightningFX(world, x, y, z, xSpeed, ySpeed, zSpeed);
lightningFX.setSprite(this.spriteSet);
return lightningFX;
}
}
}
@@ -0,0 +1,90 @@
/*
* 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.client.world.ClientWorld;
import net.minecraft.particle.DefaultParticleType;
import net.fabricmc.api.Environment;
import appeng.api.util.AEPartLocation;
public class MatterCannonFX extends SpriteBillboardParticle {
public MatterCannonFX(ClientWorld world, final double x, final double y, final double z,
SpriteProvider sprite) {
super(world, x, y, z);
this.gravityStrength = 0;
this.colorBlue = 1;
this.colorGreen = 1;
this.colorRed = 1;
this.colorAlpha = 1.4f;
this.scale = 1.1f;
this.velocityX = 0.0f;
this.velocityY = 0.0f;
this.velocityZ = 0.0f;
this.setSprite(sprite);
}
public void fromItem(final AEPartLocation d) {
this.scale *= 1.2f;
}
@Override
public ParticleTextureSheet getType() {
return ParticleTextureSheet.PARTICLE_SHEET_OPAQUE;
}
@Override
public void tick() {
this.prevPosX = this.x;
this.prevPosY = this.y;
this.prevPosZ = this.z;
if (this.age++ >= this.maxAge) {
this.markDead();
}
this.velocityY -= 0.04D * this.gravityStrength;
this.move(this.velocityX, this.velocityY, this.velocityZ);
this.velocityX *= 0.9800000190734863D;
this.velocityY *= 0.9800000190734863D;
this.velocityZ *= 0.9800000190734863D;
this.scale *= 1.19f;
this.colorAlpha *= 0.59f;
}
@Environment(EnvType.CLIENT)
public static class Factory implements ParticleFactory<DefaultParticleType> {
private final SpriteProvider spriteSet;
public Factory(SpriteProvider spriteSet) {
this.spriteSet = spriteSet;
}
@Override
public Particle createParticle(DefaultParticleType effect, ClientWorld world, double x, double y, double z, double xSpeed,
double ySpeed, double zSpeed) {
return new MatterCannonFX(world, x, y, z, spriteSet);
}
}
}
@@ -0,0 +1,34 @@
package appeng.client.render.effects;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.particle.ParticleManager;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.particle.ParticleType;
import appeng.core.AppEng;
import net.minecraft.util.registry.Registry;
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);
public static void registerClient() {
}
}
@@ -0,0 +1,96 @@
/*
* 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.*;
import net.minecraft.client.particle.ParticleFactory;
import net.minecraft.client.particle.ParticleTextureSheet;
import net.minecraft.client.particle.SpriteProvider;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.particle.DefaultParticleType;
@Environment(EnvType.CLIENT)
public class VibrantFX extends SpriteBillboardParticle {
public VibrantFX(ClientWorld world, final double x, final double y, final double z, final double par8,
final double par10, final double par12, SpriteProvider sprite) {
super(world, x, y, z, par8, par10, par12);
final float f = this.random.nextFloat() * 0.1F + 0.8F;
this.colorRed = f * 0.7f;
this.colorGreen = f * 0.89f;
this.colorBlue = f * 0.9f;
this.setSprite(sprite);
this.setBoundingBoxSpacing(0.04F, 0.04F);
this.scale *= this.random.nextFloat() * 0.6F + 1.9F;
this.velocityX = 0.0D;
this.velocityY = 0.0D;
this.velocityZ = 0.0D;
this.prevPosX = this.x;
this.prevPosY = this.y;
this.prevPosZ = this.z;
this.maxAge = (int) (20.0D / (Math.random() * 0.8D + 0.1D));
}
@Override
public ParticleTextureSheet getType() {
// FIXME Might be PARTICLE_SHEET_LIT
return ParticleTextureSheet.PARTICLE_SHEET_OPAQUE;
}
@Override
public int getColorMultiplier(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.prevPosX = this.x;
this.prevPosY = this.y;
this.prevPosZ = this.z;
// this.moveEntity(this.velocityX, this.velocityY, this.velocityZ);
this.scale *= 0.95;
if (this.maxAge <= 0 || this.scale < 0.1) {
this.markDead();
}
this.maxAge--;
}
@Environment(EnvType.CLIENT)
public static class Factory implements ParticleFactory<DefaultParticleType> {
private final SpriteProvider spriteSet;
public Factory(SpriteProvider spriteSet) {
this.spriteSet = spriteSet;
}
@Override
public Particle createParticle(DefaultParticleType effect, ClientWorld world, double x, double y, double z,
double xSpeed, double ySpeed, double zSpeed) {
return new VibrantFX(world, x, y, z, xSpeed, ySpeed, zSpeed, spriteSet);
}
}
}