pick 97420a31d The big reformat of 2020

This commit is contained in:
yueh
2020-06-16 21:41:28 +02:00
parent 5304b3febe
commit 5225ea426b
2252 changed files with 95466 additions and 118582 deletions
@@ -18,10 +18,12 @@
package appeng.client.render.effects;
import java.util.Locale;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.client.particle.IAnimatedSprite;
import net.minecraft.client.particle.IParticleFactory;
import net.minecraft.client.particle.IParticleRenderType;
@@ -39,200 +41,190 @@ import net.minecraft.particles.ItemParticleData;
import net.minecraft.particles.ParticleType;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.EffectType;
import appeng.core.AppEng;
import appeng.entity.EntityFloatingItem;
import appeng.entity.ICanDie;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import java.util.Locale;
public class AssemblerFX extends Particle implements ICanDie {
public static final ParticleType<AssemblerParticleData> TYPE = new ParticleType<>(false,
new AssemblerParticleData.Deserializer());
public class AssemblerFX extends Particle implements ICanDie
{
static {
TYPE.setRegistryName(AppEng.MOD_ID, "assembler_fx");
}
public static final ParticleType<AssemblerParticleData> TYPE = new ParticleType<>(false, new AssemblerParticleData.Deserializer());
private final EntityFloatingItem fi;
private final float speed;
private float time = 0;
static {
TYPE.setRegistryName(AppEng.MOD_ID, "assembler_fx");
}
public AssemblerFX(final World w, final double x, final double y, final double z, final double r, final double g,
final double b, final float speed, final ItemStack displayItem) {
super(w, x, y, z, r, g, b);
this.motionX = 0;
this.motionY = 0;
this.motionZ = 0;
this.speed = speed;
this.fi = new EntityFloatingItem(this, w, x, y, z, displayItem);
w.addEntity(this.fi);
this.maxAge = (int) Math.ceil(Math.max(1, 100.0f / speed)) + 2;
}
private final EntityFloatingItem fi;
private final float speed;
private float time = 0;
@Override
public boolean isDead() {
return this.isExpired;
}
public AssemblerFX( final World w, final double x, final double y, final double z, final double r, final double g, final double b, final float speed, final ItemStack displayItem )
{
super( w, x, y, z, r, g, b );
this.motionX = 0;
this.motionY = 0;
this.motionZ = 0;
this.speed = speed;
this.fi = new EntityFloatingItem( this, w, x, y, z, displayItem );
w.addEntity( this.fi );
this.maxAge = (int) Math.ceil( Math.max( 1, 100.0f / speed ) ) + 2;
}
@Override
public int getBrightnessForRender(final float par1) {
final int j1 = 13;
return j1 << 20 | j1 << 4;
}
@Override
public boolean isDead()
{
return this.isExpired;
}
@Override
public void tick() {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
@Override
public int getBrightnessForRender( final float par1 )
{
final int j1 = 13;
return j1 << 20 | j1 << 4;
}
if (this.age++ >= this.maxAge) {
this.setExpired();
}
@Override
public void tick()
{
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
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;
if( this.age++ >= this.maxAge )
{
this.setExpired();
}
if (this.isExpired) {
this.fi.remove();
} else {
final float lifeSpan = (float) this.age / (float) this.maxAge;
this.fi.setProgress(lifeSpan);
}
}
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 IParticleRenderType getRenderType() {
return IParticleRenderType.NO_RENDER;
}
if( this.isExpired )
{
this.fi.remove();
}
else
{
final float lifeSpan = (float) this.age / (float) this.maxAge;
this.fi.setProgress( lifeSpan );
}
}
@Override
public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) {
this.time += partialTicks;
if (this.time > 4.0) {
this.time -= 4.0;
// if ( AppEng.proxy.shouldAddParticles( r ) )
for (int x = 0; x < (int) Math.ceil(this.speed / 5); x++) {
AppEng.proxy.spawnEffect(EffectType.Crafting, this.world, this.posX, this.posY, this.posZ, null);
}
}
}
@Override
public IParticleRenderType getRenderType() {
return IParticleRenderType.NO_RENDER;
}
public static class AssemblerParticleData implements IParticleData {
@Override
public void renderParticle( IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks )
{
this.time += partialTicks;
if( this.time > 4.0 )
{
this.time -= 4.0;
// if ( AppEng.proxy.shouldAddParticles( r ) )
for( int x = 0; x < (int) Math.ceil( this.speed / 5 ); x++ )
{
AppEng.proxy.spawnEffect( EffectType.Crafting, this.world, this.posX, this.posY, this.posZ, null );
}
}
}
private final float r;
private final float g;
private final float b;
private final float speed;
private final ItemStack itemStack;
public static class AssemblerParticleData implements IParticleData {
public AssemblerParticleData(float r, float g, float b, float speed, ItemStack itemStack) {
this.r = r;
this.g = g;
this.b = b;
this.speed = speed;
this.itemStack = itemStack;
}
private final float r;
private final float g;
private final float b;
private final float speed;
private final ItemStack itemStack;
@Override
public ParticleType<?> getType() {
return TYPE;
}
public AssemblerParticleData(float r, float g, float b, float speed, ItemStack itemStack) {
this.r = r;
this.g = g;
this.b = b;
this.speed = speed;
this.itemStack = itemStack;
}
@Override
public void write(PacketBuffer buffer) {
buffer.writeFloat(r);
buffer.writeFloat(g);
buffer.writeFloat(b);
buffer.writeFloat(speed);
buffer.writeItemStack(itemStack);
}
@Override
public ParticleType<?> getType() {
return TYPE;
}
public static class Deserializer implements IDeserializer<AssemblerParticleData> {
@Override
public void write(PacketBuffer buffer) {
buffer.writeFloat(r);
buffer.writeFloat(g);
buffer.writeFloat(b);
buffer.writeFloat(speed);
buffer.writeItemStack(itemStack);
}
@Override
public AssemblerParticleData deserialize(ParticleType<AssemblerParticleData> particleTypeIn,
StringReader reader) throws CommandSyntaxException {
reader.expect(' ');
float r = reader.readFloat();
reader.expect(' ');
float g = reader.readFloat();
reader.expect(' ');
float b = reader.readFloat();
reader.expect(' ');
float speed = reader.readFloat();
reader.expect(' ');
ItemParser itemparser = (new ItemParser(reader, false)).parse();
ItemStack itemstack = (new ItemInput(itemparser.getItem(), itemparser.getNbt())).createStack(1, false);
return new AssemblerParticleData(r, g, b, speed, itemstack);
}
public static class Deserializer implements IDeserializer<AssemblerParticleData> {
@Override
public AssemblerParticleData read(ParticleType<AssemblerParticleData> particleTypeIn, PacketBuffer buffer) {
float r = buffer.readFloat();
float g = buffer.readFloat();
float b = buffer.readFloat();
float speed = buffer.readFloat();
ItemStack itemStack = buffer.readItemStack();
return new AssemblerParticleData(r, g, b, speed, itemStack);
}
@Override
public AssemblerParticleData deserialize(ParticleType<AssemblerParticleData> particleTypeIn, StringReader reader) throws CommandSyntaxException {
reader.expect(' ');
float r = reader.readFloat();
reader.expect(' ');
float g = reader.readFloat();
reader.expect(' ');
float b = reader.readFloat();
reader.expect(' ');
float speed = reader.readFloat();
reader.expect(' ');
ItemParser itemparser = (new ItemParser(reader, false)).parse();
ItemStack itemstack = (new ItemInput(itemparser.getItem(), itemparser.getNbt())).createStack(1, false);
return new AssemblerParticleData(r, g, b, speed, itemstack);
}
}
@Override
public AssemblerParticleData read(ParticleType<AssemblerParticleData> particleTypeIn, PacketBuffer buffer) {
float r = buffer.readFloat();
float g = buffer.readFloat();
float b = buffer.readFloat();
float speed = buffer.readFloat();
ItemStack itemStack = buffer.readItemStack();
return new AssemblerParticleData(r, g, b, speed, itemStack);
}
@Override
public String getParameters() {
return String.format(Locale.ROOT, "%s %.2f %.2f %.2f %.2f ", Registry.PARTICLE_TYPE.getKey(this.getType()),
this.r, this.g, this.b, this.speed)
+ (new ItemInput(this.itemStack.getItem(), this.itemStack.getTag())).serialize();
}
}
public float getR() {
return r;
}
@Override
public String getParameters() {
return String.format(Locale.ROOT, "%s %.2f %.2f %.2f %.2f ", Registry.PARTICLE_TYPE.getKey(this.getType()), this.r, this.g, this.b, this.speed)
+ (new ItemInput(this.itemStack.getItem(), this.itemStack.getTag())).serialize();
}
public float getG() {
return g;
}
public float getR() {
return r;
}
public float getB() {
return b;
}
public float getG() {
return g;
}
public float getSpeed() {
return speed;
}
public float getB() {
return b;
}
public ItemStack getItemStack() {
return itemStack;
}
}
public float getSpeed() {
return speed;
}
@OnlyIn(Dist.CLIENT)
public static class Factory implements IParticleFactory<AssemblerParticleData> {
public Factory(IAnimatedSprite spriteSet) {
}
public ItemStack getItemStack() {
return itemStack;
}
}
@OnlyIn(Dist.CLIENT)
public static class Factory implements IParticleFactory<AssemblerParticleData> {
public Factory(IAnimatedSprite spriteSet) {
}
public Particle makeParticle(AssemblerParticleData data, World world, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
return new AssemblerFX(world, x, y, z, data.r, data.g, data.b, data.speed, data.itemStack);
}
}
public Particle makeParticle(AssemblerParticleData data, World world, double x, double y, double z,
double xSpeed, double ySpeed, double zSpeed) {
return new AssemblerFX(world, x, y, z, data.r, data.g, data.b, data.speed, data.itemStack);
}
}
}
@@ -18,8 +18,6 @@
package appeng.client.render.effects;
import appeng.core.AppEng;
import net.minecraft.client.particle.IAnimatedSprite;
import net.minecraft.client.particle.IParticleFactory;
import net.minecraft.client.particle.Particle;
@@ -30,44 +28,45 @@ import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.core.AppEng;
@OnlyIn(Dist.CLIENT)
public class ChargedOreFX extends RedstoneParticle
{
public static final BasicParticleType TYPE = new BasicParticleType(false);
public class ChargedOreFX extends RedstoneParticle {
public static final BasicParticleType TYPE = new BasicParticleType(false);
static {
TYPE.setRegistryName(AppEng.MOD_ID, "charged_ore_fx");
}
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);
static {
TYPE.setRegistryName(AppEng.MOD_ID, "charged_ore_fx");
}
@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;
}
private static final RedstoneParticleData PARTICLE_DATA = new RedstoneParticleData(0.21f, 0.61f, 1.0f, 1.0f);
@OnlyIn(Dist.CLIENT)
public static class Factory implements IParticleFactory<BasicParticleType> {
private final IAnimatedSprite spriteSet;
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);
}
public Factory(IAnimatedSprite p_i50477_1_) {
this.spriteSet = p_i50477_1_;
}
@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;
}
public Particle makeParticle(BasicParticleType 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);
}
}
@OnlyIn(Dist.CLIENT)
public static class Factory implements IParticleFactory<BasicParticleType> {
private final IAnimatedSprite spriteSet;
public Factory(IAnimatedSprite p_i50477_1_) {
this.spriteSet = p_i50477_1_;
}
public Particle makeParticle(BasicParticleType 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);
}
}
}
@@ -18,9 +18,8 @@
package appeng.client.render.effects;
import appeng.core.AppEng;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.client.particle.*;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.BufferBuilder;
@@ -40,140 +39,142 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.api.util.AEPartLocation;
import appeng.core.AppEng;
@OnlyIn(Dist.CLIENT)
public class CraftingFx extends BreakingParticle {
@OnlyIn( Dist.CLIENT )
public class CraftingFx extends BreakingParticle
{
public static final BasicParticleType TYPE = new BasicParticleType(false);
public static final BasicParticleType TYPE = new BasicParticleType(false);
static {
TYPE.setRegistryName(AppEng.MOD_ID, "crafting_fx");
}
static {
TYPE.setRegistryName(AppEng.MOD_ID, "crafting_fx");
}
private final int startBlkX;
private final int startBlkY;
private final int startBlkZ;
private final int startBlkX;
private final int startBlkY;
private final int startBlkZ;
public CraftingFx(final World par1World, final double x, final double y, final double z,
final IAnimatedSprite sprite) {
super(par1World, x, y, z, new ItemStack(Items.DIAMOND));
this.particleGravity = 0;
this.particleBlue = 1;
this.particleGreen = 0.9f;
this.particleRed = 1;
this.particleAlpha = 1.3f;
this.particleScale = 1.5f;
this.selectSpriteRandomly(sprite);
this.maxAge /= 1.2;
public CraftingFx( final World par1World, final double x, final double y, final double z, final IAnimatedSprite sprite )
{
super( par1World, x, y, z, new ItemStack(Items.DIAMOND) );
this.particleGravity = 0;
this.particleBlue = 1;
this.particleGreen = 0.9f;
this.particleRed = 1;
this.particleAlpha = 1.3f;
this.particleScale = 1.5f;
this.selectSpriteRandomly(sprite);
this.maxAge /= 1.2;
this.startBlkX = MathHelper.floor(this.posX);
this.startBlkY = MathHelper.floor(this.posY);
this.startBlkZ = MathHelper.floor(this.posZ);
}
this.startBlkX = MathHelper.floor( this.posX );
this.startBlkY = MathHelper.floor( this.posY );
this.startBlkZ = MathHelper.floor( this.posZ );
}
@Override
public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) {
@Override
public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) {
if (partialTicks < 0 || partialTicks > 1) {
return;
}
if( partialTicks < 0 || partialTicks > 1 )
{
return;
}
float offX = (float) (MathHelper.lerp(partialTicks, this.prevPosX, this.posX));
float offY = (float) (MathHelper.lerp(partialTicks, this.prevPosY, this.posY));
float offZ = (float) (MathHelper.lerp(partialTicks, this.prevPosZ, this.posZ));
float offX = (float)(MathHelper.lerp(partialTicks, this.prevPosX, this.posX));
float offY = (float)(MathHelper.lerp(partialTicks, this.prevPosY, this.posY));
float offZ = (float)(MathHelper.lerp(partialTicks, this.prevPosZ, this.posZ));
final int blkX = MathHelper.floor(offX);
final int blkY = MathHelper.floor(offY);
final int blkZ = MathHelper.floor(offZ);
// 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)
if (blkX == this.startBlkX && blkY == this.startBlkY && blkZ == this.startBlkZ) {
Vec3d vec3d = renderInfo.getProjectedView();
offX -= vec3d.x;
offY -= vec3d.y;
offZ -= vec3d.z;
final int blkX = MathHelper.floor( offX );
final int blkY = MathHelper.floor( offY );
final int blkZ = MathHelper.floor( offZ );
// 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)
if( blkX == this.startBlkX && blkY == this.startBlkY && blkZ == this.startBlkZ )
{
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) };
float scale = this.getScale(partialTicks);
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)};
float scale = this.getScale(partialTicks);
for (int i = 0; i < 4; ++i) {
Vector3f vector3f = avector3f[i];
vector3f.transform(renderInfo.getRotation());
vector3f.mul(scale);
vector3f.add(offX, offY, offZ);
}
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 = this.getBrightnessForRender(partialTicks);
buffer.pos(avector3f[0].getX(), avector3f[0].getY(), avector3f[0].getZ()).tex(maxU, maxV)
.color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j)
.endVertex();
buffer.pos(avector3f[1].getX(), avector3f[1].getY(), avector3f[1].getZ()).tex(maxU, minV)
.color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j)
.endVertex();
buffer.pos(avector3f[2].getX(), avector3f[2].getY(), avector3f[2].getZ()).tex(minU, minV)
.color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j)
.endVertex();
buffer.pos(avector3f[3].getX(), avector3f[3].getY(), avector3f[3].getZ()).tex(minU, maxV)
.color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j)
.endVertex();
}
}
float minU = this.getMinU();
float maxU = this.getMaxU();
float minV = this.getMinV();
float maxV = this.getMaxV();
int j = this.getBrightnessForRender(partialTicks);
buffer.pos(avector3f[0].getX(), avector3f[0].getY(), avector3f[0].getZ()).tex(maxU, maxV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j).endVertex();
buffer.pos(avector3f[1].getX(), avector3f[1].getY(), avector3f[1].getZ()).tex(maxU, minV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j).endVertex();
buffer.pos(avector3f[2].getX(), avector3f[2].getY(), avector3f[2].getZ()).tex(minU, minV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j).endVertex();
buffer.pos(avector3f[3].getX(), avector3f[3].getY(), avector3f[3].getZ()).tex(minU, maxV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j).endVertex();
}
}
public void fromItem(final AEPartLocation d) {
this.posX += 0.2 * d.xOffset;
this.posY += 0.2 * d.yOffset;
this.posZ += 0.2 * d.zOffset;
this.particleScale *= 0.8f;
}
public void fromItem( final AEPartLocation d )
{
this.posX += 0.2 * d.xOffset;
this.posY += 0.2 * d.yOffset;
this.posZ += 0.2 * d.zOffset;
this.particleScale *= 0.8f;
}
@Override
public void tick() {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
@Override
public void tick()
{
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
if (this.age++ >= this.maxAge) {
this.setExpired();
}
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 *= 0.51f;
this.particleAlpha *= 0.51f;
}
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 *= 0.51f;
this.particleAlpha *= 0.51f;
}
public void setMotionX(float motionX) {
this.motionX = motionX;
}
public void setMotionX( float motionX )
{
this.motionX = motionX;
}
public void setMotionY(float motionY) {
this.motionY = motionY;
}
public void setMotionY( float motionY )
{
this.motionY = motionY;
}
public void setMotionZ(float motionZ) {
this.motionZ = motionZ;
}
public void setMotionZ( float motionZ )
{
this.motionZ = motionZ;
}
@OnlyIn(Dist.CLIENT)
public static class Factory implements IParticleFactory<BasicParticleType> {
private final IAnimatedSprite spriteSet;
@OnlyIn(Dist.CLIENT)
public static class Factory implements IParticleFactory<BasicParticleType> {
private final IAnimatedSprite spriteSet;
public Factory(IAnimatedSprite p_i50477_1_) {
this.spriteSet = p_i50477_1_;
}
public Factory(IAnimatedSprite p_i50477_1_) {
this.spriteSet = p_i50477_1_;
}
public Particle makeParticle(BasicParticleType data, World worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
return new CraftingFx(worldIn, x, y, z, spriteSet);
}
}
public Particle makeParticle(BasicParticleType data, World worldIn, double x, double y, double z, double xSpeed,
double ySpeed, double zSpeed) {
return new CraftingFx(worldIn, x, y, z, spriteSet);
}
}
}
@@ -18,8 +18,6 @@
package appeng.client.render.effects;
import appeng.core.AppEng;
import net.minecraft.client.particle.*;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
@@ -34,37 +32,36 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.api.util.AEPartLocation;
import appeng.core.AppEng;
@OnlyIn(Dist.CLIENT)
public class EnergyFx extends BreakingParticle {
@OnlyIn( Dist.CLIENT )
public class EnergyFx extends BreakingParticle
{
public static final BasicParticleType TYPE = new BasicParticleType(false);
public static final BasicParticleType TYPE = new BasicParticleType(false);
static {
TYPE.setRegistryName(AppEng.MOD_ID, "energy_fx");
}
static {
TYPE.setRegistryName(AppEng.MOD_ID, "energy_fx");
}
private final int startBlkX;
private final int startBlkY;
private final int startBlkZ;
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, new ItemStack(Items.DIAMOND));
this.particleGravity = 0;
this.particleBlue = 1;
this.particleGreen = 1;
this.particleRed = 1;
this.particleAlpha = 1.4f;
this.particleScale = 3.5f;
this.selectSpriteRandomly(sprite);
public EnergyFx( final World par1World, final double par2, final double par4, final double par6, final IAnimatedSprite sprite )
{
super( par1World, par2, par4, par6, new ItemStack(Items.DIAMOND) );
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 );
}
this.startBlkX = MathHelper.floor(this.posX);
this.startBlkY = MathHelper.floor(this.posY);
this.startBlkZ = MathHelper.floor(this.posZ);
}
// FIXME @Override
// FIXME public int getFXLayer()
@@ -125,13 +122,13 @@ public class EnergyFx extends BreakingParticle
// FIXME }
// FIXME }
// FIXME
public void fromItem( final AEPartLocation d )
{
this.posX += 0.2 * d.xOffset;
this.posY += 0.2 * d.yOffset;
this.posZ += 0.2 * d.zOffset;
this.particleScale *= 0.8f;
}
public void fromItem(final AEPartLocation d) {
this.posX += 0.2 * d.xOffset;
this.posY += 0.2 * d.yOffset;
this.posZ += 0.2 * d.zOffset;
this.particleScale *= 0.8f;
}
// FIXME
// FIXME @Override
// FIXME public void tick()
@@ -155,36 +152,34 @@ public class EnergyFx extends BreakingParticle
// FIXME this.particleAlpha *= 0.89f;
// FIXME }
// FIXME
public void setMotionX( float motionX )
{
this.motionX = motionX;
}
public void setMotionX(float motionX) {
this.motionX = motionX;
}
public void setMotionY( float motionY )
{
this.motionY = motionY;
}
public void setMotionY(float motionY) {
this.motionY = motionY;
}
public void setMotionZ( float motionZ )
{
this.motionZ = motionZ;
}
public void setMotionZ(float motionZ) {
this.motionZ = motionZ;
}
@OnlyIn(Dist.CLIENT)
public static class Factory implements IParticleFactory<BasicParticleType> {
private final IAnimatedSprite spriteSet;
@OnlyIn(Dist.CLIENT)
public static class Factory implements IParticleFactory<BasicParticleType> {
private final IAnimatedSprite spriteSet;
public Factory(IAnimatedSprite spriteSet) {
this.spriteSet = spriteSet;
}
public Factory(IAnimatedSprite spriteSet) {
this.spriteSet = spriteSet;
}
public Particle makeParticle(BasicParticleType typeIn, 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);
return result;
}
}
public Particle makeParticle(BasicParticleType typeIn, 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);
return result;
}
}
}
@@ -18,10 +18,8 @@
package appeng.client.render.effects;
import java.util.Random;
import appeng.core.AppEng;
import net.minecraft.client.particle.*;
import net.minecraft.particles.BasicParticleType;
import net.minecraft.particles.ParticleType;
@@ -29,64 +27,66 @@ import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.core.AppEng;
public class LightningArcFX extends LightningFX
{
public static final ParticleType<LightningArcParticleData> TYPE = new ParticleType<>(false, LightningArcParticleData.DESERIALIZER);
public class LightningArcFX extends LightningFX {
public static final ParticleType<LightningArcParticleData> TYPE = new ParticleType<>(false,
LightningArcParticleData.DESERIALIZER);
static {
TYPE.setRegistryName(AppEng.MOD_ID, "lightning_arc_fx");
}
static {
TYPE.setRegistryName(AppEng.MOD_ID, "lightning_arc_fx");
}
private static final Random RANDOM_GENERATOR = new Random();
private static final Random RANDOM_GENERATOR = new Random();
private final double rx;
private final double ry;
private final double rz;
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 );
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.rx = ex - x;
this.ry = ey - y;
this.rz = ez - z;
this.regen();
}
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;
@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();
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;
}
}
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;
}
}
@OnlyIn(Dist.CLIENT)
public static class Factory implements IParticleFactory<LightningArcParticleData> {
private final IAnimatedSprite spriteSet;
@OnlyIn(Dist.CLIENT)
public static class Factory implements IParticleFactory<LightningArcParticleData> {
private final IAnimatedSprite spriteSet;
public Factory(IAnimatedSprite spriteSet) {
this.spriteSet = spriteSet;
}
public Factory(IAnimatedSprite spriteSet) {
this.spriteSet = spriteSet;
}
public Particle makeParticle(LightningArcParticleData data, World worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
SpriteTexturedParticle 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;
}
}
public Particle makeParticle(LightningArcParticleData data, World worldIn, double x, double y, double z,
double xSpeed, double ySpeed, double zSpeed) {
SpriteTexturedParticle 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,16 +1,18 @@
package appeng.client.render.effects;
import java.util.Locale;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.network.PacketBuffer;
import net.minecraft.particles.IParticleData;
import net.minecraft.particles.ParticleType;
import net.minecraft.util.math.Vec3d;
import java.util.Locale;
/**
* Contains the target point of the lightning arc (the source point is infered from the particle starting position).
* Contains the target point of the lightning arc (the source point is infered
* from the particle starting position).
*/
public class LightningArcParticleData implements IParticleData {
@@ -22,7 +24,8 @@ public class LightningArcParticleData implements IParticleData {
public static final IDeserializer<LightningArcParticleData> DESERIALIZER = new IDeserializer<LightningArcParticleData>() {
@Override
public LightningArcParticleData deserialize(ParticleType<LightningArcParticleData> particleTypeIn, StringReader reader) throws CommandSyntaxException {
public LightningArcParticleData deserialize(ParticleType<LightningArcParticleData> particleTypeIn,
StringReader reader) throws CommandSyntaxException {
reader.expect(' ');
float x = reader.readFloat();
reader.expect(' ');
@@ -33,7 +36,8 @@ public class LightningArcParticleData implements IParticleData {
}
@Override
public LightningArcParticleData read(ParticleType<LightningArcParticleData> particleTypeIn, PacketBuffer buffer) {
public LightningArcParticleData read(ParticleType<LightningArcParticleData> particleTypeIn,
PacketBuffer buffer) {
float x = buffer.readFloat();
float y = buffer.readFloat();
float z = buffer.readFloat();
@@ -18,11 +18,10 @@
package appeng.client.render.effects;
import java.util.Random;
import appeng.core.AppEng;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.*;
import net.minecraft.client.renderer.ActiveRenderInfo;
@@ -38,251 +37,234 @@ import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn( Dist.CLIENT )
public class LightningFX extends SpriteTexturedParticle
{
public static final BasicParticleType TYPE = new BasicParticleType(false);
import appeng.core.AppEng;
static {
TYPE.setRegistryName(AppEng.MOD_ID, "lightning_fx");
}
@OnlyIn(Dist.CLIENT)
public class LightningFX extends SpriteTexturedParticle {
public static final BasicParticleType TYPE = new BasicParticleType(false);
private static final Random RANDOM_GENERATOR = new Random();
private static final int STEPS = 5;
private static final int BRIGHTNESS = 13 << 4;
static {
TYPE.setRegistryName(AppEng.MOD_ID, "lightning_fx");
}
private final double[][] precomputedSteps;
private final double[] vertices = new double[3];
private final double[] verticesWithUV = new double[3];
private boolean hasData = false;
private static final Random RANDOM_GENERATOR = new Random();
private static final int STEPS = 5;
private static final int BRIGHTNESS = 13 << 4;
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();
}
private final double[][] precomputedSteps;
private final double[] vertices = new double[3];
private final double[] verticesWithUV = new double[3];
private boolean hasData = false;
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;
}
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 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 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 int getSteps()
{
return LightningFX.STEPS;
}
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;
}
}
@Override
public IParticleRenderType getRenderType() {
// TODO: FIXME
return IParticleRenderType.PARTICLE_SHEET_OPAQUE;
}
protected int getSteps() {
return LightningFX.STEPS;
}
@Override
public void tick()
{
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
@Override
public IParticleRenderType getRenderType() {
// TODO: FIXME
return IParticleRenderType.PARTICLE_SHEET_OPAQUE;
}
if( this.age++ >= this.maxAge )
{
this.setExpired();
}
@Override
public void tick() {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
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;
}
if (this.age++ >= this.maxAge) {
this.setExpired();
}
@Override
public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) {
Vec3d vec3d = renderInfo.getProjectedView();
float centerX = (float)(MathHelper.lerp(partialTicks, this.prevPosX, this.posX) - vec3d.getX());
float centerY = (float)(MathHelper.lerp(partialTicks, this.prevPosY, this.posY) - vec3d.getY());
float centerZ = (float)(MathHelper.lerp(partialTicks, this.prevPosZ, this.posZ) - vec3d.getZ());
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;
}
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;
@Override
public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) {
Vec3d vec3d = renderInfo.getProjectedView();
float centerX = (float) (MathHelper.lerp(partialTicks, this.prevPosX, this.posX) - vec3d.getX());
float centerY = (float) (MathHelper.lerp(partialTicks, this.prevPosY, this.posY) - vec3d.getY());
float centerZ = (float) (MathHelper.lerp(partialTicks, this.prevPosZ, this.posZ) - vec3d.getZ());
if( this.age == 3 )
{
this.regen();
}
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;
float u = this.getMinU() + (this.getMaxU() - this.getMinU()) / 2;
float v = this.getMinV() + (this.getMaxV() - this.getMinV()) / 2;
if (this.age == 3) {
this.regen();
}
double scale = 0.02;// 0.02F * this.particleScale;
float u = this.getMinU() + (this.getMaxU() - this.getMinU()) / 2;
float v = this.getMinV() + (this.getMaxV() - this.getMinV()) / 2;
final double[] a = new double[3];
final double[] b = new double[3];
double scale = 0.02;// 0.02F * this.particleScale;
double ox = 0;
double oy = 0;
double oz = 0;
final double[] a = new double[3];
final double[] b = new double[3];
final PlayerEntity p = Minecraft.getInstance().player;
double ox = 0;
double oy = 0;
double oz = 0;
// 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
final PlayerEntity p = Minecraft.getInstance().player;
for( int layer = 0; layer < 2; layer++ )
{
if( layer == 0 )
{
scale = 0.04;
// 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
{
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;
}
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();
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;
// 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];
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;
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 );
}
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;
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;
a[0] = x + ox;
a[1] = y + oy;
a[2] = z + oz;
b[0] = x;
b[1] = y;
b[2] = z;
b[0] = x;
b[1] = y;
b[2] = z;
this.draw( red, green, blue, buffer, a, b, u, v );
this.draw(red, green, blue, buffer, a, b, u, v);
x = xN;
y = yN;
z = zN;
}
}
}
}
x = xN;
y = yN;
z = zN;
}
}
}
}
private void clear()
{
this.hasData = false;
}
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];
}
}
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;
}
protected double[][] getPrecomputedSteps() {
return this.precomputedSteps;
}
@OnlyIn(Dist.CLIENT)
public static class Factory implements IParticleFactory<BasicParticleType> {
private final IAnimatedSprite spriteSet;
@OnlyIn(Dist.CLIENT)
public static class Factory implements IParticleFactory<BasicParticleType> {
private final IAnimatedSprite spriteSet;
public Factory(IAnimatedSprite spriteSet) {
this.spriteSet = spriteSet;
}
public Factory(IAnimatedSprite spriteSet) {
this.spriteSet = spriteSet;
}
public Particle makeParticle(BasicParticleType 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;
}
}
public Particle makeParticle(BasicParticleType 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;
}
}
}
@@ -18,9 +18,8 @@
package appeng.client.render.effects;
import appeng.core.AppEng;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.client.particle.BreakingParticle;
import net.minecraft.client.particle.IAnimatedSprite;
import net.minecraft.client.particle.IParticleFactory;
@@ -32,74 +31,71 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.particles.BasicParticleType;
import net.minecraft.world.World;
import appeng.api.util.AEPartLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.api.util.AEPartLocation;
import appeng.core.AppEng;
public class MatterCannonFX extends BreakingParticle
{
public class MatterCannonFX extends BreakingParticle {
public static final BasicParticleType TYPE = new BasicParticleType(false);
public static final BasicParticleType TYPE = new BasicParticleType(false);
static {
TYPE.setRegistryName(AppEng.MOD_ID, "matter_cannon_fx");
}
static {
TYPE.setRegistryName(AppEng.MOD_ID, "matter_cannon_fx");
}
public MatterCannonFX( final World par1World, final double x, final double y, final double z, IAnimatedSprite sprite )
{
super( par1World, x, y, z, new ItemStack(Items.DIAMOND) );
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 MatterCannonFX(final World par1World, final double x, final double y, final double z,
IAnimatedSprite sprite) {
super(par1World, x, y, z, new ItemStack(Items.DIAMOND));
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;
}
public void fromItem(final AEPartLocation d) {
this.particleScale *= 1.2f;
}
@Override
public void tick()
{
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
@Override
public void tick() {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
if( this.age++ >= this.maxAge )
{
this.setExpired();
}
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.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;
}
this.particleScale *= 1.19f;
this.particleAlpha *= 0.59f;
}
@OnlyIn(Dist.CLIENT)
public static class Factory implements IParticleFactory<BasicParticleType> {
private final IAnimatedSprite spriteSet;
@OnlyIn(Dist.CLIENT)
public static class Factory implements IParticleFactory<BasicParticleType> {
private final IAnimatedSprite spriteSet;
public Factory(IAnimatedSprite spriteSet) {
this.spriteSet = spriteSet;
}
public Factory(IAnimatedSprite spriteSet) {
this.spriteSet = spriteSet;
}
public Particle makeParticle(BasicParticleType data, World world, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
return new MatterCannonFX(world, x, y, z, spriteSet);
}
}
public Particle makeParticle(BasicParticleType data, World world, double x, double y, double z, double xSpeed,
double ySpeed, double zSpeed) {
return new MatterCannonFX(world, x, y, z, spriteSet);
}
}
}
@@ -18,87 +18,83 @@
package appeng.client.render.effects;
import appeng.core.AppEng;
import net.minecraft.client.particle.*;
import net.minecraft.particles.BasicParticleType;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.core.AppEng;
@OnlyIn( Dist.CLIENT )
public class VibrantFX extends SpriteTexturedParticle
{
@OnlyIn(Dist.CLIENT)
public class VibrantFX extends SpriteTexturedParticle {
public static final BasicParticleType TYPE = new BasicParticleType(false);
public static final BasicParticleType TYPE = new BasicParticleType(false);
static {
TYPE.setRegistryName(AppEng.MOD_ID, "vibrant_fx");
}
static {
TYPE.setRegistryName(AppEng.MOD_ID, "vibrant_fx");
}
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.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.maxAge = (int) ( 20.0D / ( Math.random() * 0.8D + 0.1D ) );
}
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.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = 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 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;
}
@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.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
// this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.particleScale *= 0.95;
/**
* Called to update the entity's position/logic.
*/
@Override
public void tick() {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = 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--;
}
if (this.maxAge <= 0 || this.particleScale < 0.1) {
this.setExpired();
}
this.maxAge--;
}
@OnlyIn(Dist.CLIENT)
public static class Factory implements IParticleFactory<BasicParticleType> {
private final IAnimatedSprite spriteSet;
@OnlyIn(Dist.CLIENT)
public static class Factory implements IParticleFactory<BasicParticleType> {
private final IAnimatedSprite spriteSet;
public Factory(IAnimatedSprite spriteSet) {
this.spriteSet = spriteSet;
}
public Factory(IAnimatedSprite spriteSet) {
this.spriteSet = spriteSet;
}
public Particle makeParticle(BasicParticleType 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);
}
}
public Particle makeParticle(BasicParticleType 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);
}
}
}