QuartzFixture and (semi-borked) LightningFX

This commit is contained in:
Sebastian Hartte
2020-06-01 16:59:11 +02:00
parent 260b2d1c92
commit 2a1ba12516
37 changed files with 270 additions and 233 deletions
@@ -156,7 +156,7 @@ public class FacadeBuilder
{
double offset = thinFacades ? THIN_THICKNESS : THICK_THICKNESS;
AEAxisAlignedBB tmpBB = null;
for( Direction face : Direction.VALUES )
for( Direction face : Direction.values() )
{
// Only faces that aren't on our axis
if( face.getAxis() != side.getAxis() )
@@ -373,7 +373,7 @@ public class FacadeBuilder
private static List<BakedQuad> gatherQuads( IBakedModel model, BlockState state, long rand )
{
List<BakedQuad> modelQuads = new ArrayList<>();
for( Direction face : Direction.VALUES )
for( Direction face : Direction.values() )
{
modelQuads.addAll( model.getQuads( state, face, rand ) );
}
@@ -21,18 +21,31 @@ 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.IParticleRenderType;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.*;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.Quaternion;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.particles.BasicParticleType;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class LightningFX extends Particle
@OnlyIn( Dist.CLIENT )
public class LightningFX extends SpriteTexturedParticle
{
public static final BasicParticleType TYPE = new BasicParticleType(false);
static {
TYPE.setRegistryName(AppEng.MOD_ID, "lightning_fx");
}
private static final Random RANDOM_GENERATOR = new Random();
private static final int STEPS = 5;
@@ -43,13 +56,13 @@ public class LightningFX extends Particle
private final double[] verticesWithUV = new double[3];
private boolean hasData = false;
public LightningFX( final World w, final double x, final double y, final double z, final double r, final double g, final double b )
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 )
private 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];
@@ -80,7 +93,7 @@ public class LightningFX extends Particle
@Override
public IParticleRenderType getRenderType() {
// TODO: FIXME
return IParticleRenderType.NO_RENDER;
return IParticleRenderType.PARTICLE_SHEET_OPAQUE;
}
@Override
@@ -103,8 +116,13 @@ public class LightningFX extends Particle
}
@Override
public void renderParticle( final BufferBuilder tess, final Entity p_180434_2_, final float l, final float rX, final float rY, final float rZ, final float rYZ, final float rXY )
{
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());
final float j = 1.0f;
float red = this.particleRed * j * 0.9f;
float green = this.particleGreen * j * 0.95f;
@@ -115,13 +133,9 @@ public class LightningFX extends Particle
{
this.regen();
}
double f6 = this.particleTextureIndexX / 16.0;
final double f7 = f6 + 0.0324375F;
double f8 = this.particleTextureIndexY / 16.0;
final double f9 = f8 + 0.0324375F;
f6 = f7;
f8 = f9;
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;
@@ -133,27 +147,27 @@ public class LightningFX extends Particle
double oz = 0;
final PlayerEntity p = Minecraft.getInstance().player;
double offX = -rZ;
double offY = MathHelper.cos( (float) ( Math.PI / 2.0f + p.rotationPitch * 0.017453292F ) );
double offZ = rX;
// 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;
offX *= 0.001;
offY *= 0.001;
offZ *= 0.001;
// 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
{
offX = 0;
offY = 0;
offZ = 0;
// FIXME offX = 0;
// FIXME offY = 0;
// FIXME offZ = 0;
scale = 0.02;
red = this.particleRed * j * 0.9f;
green = this.particleGreen * j * 0.65f;
@@ -164,9 +178,10 @@ public class LightningFX extends Particle
{
this.clear();
double x = ( this.prevPosX + ( this.getPosX() - this.prevPosX ) * l - interpPosX ) - offX;
double y = ( this.prevPosY + ( this.getPosY() - this.prevPosY ) * l - interpPosY ) - offY;
double z = ( this.prevPosZ + ( this.getPosZ() - this.prevPosZ ) * l - interpPosZ ) - 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++ )
{
@@ -211,7 +226,7 @@ public class LightningFX extends Particle
b[1] = y;
b[2] = z;
this.draw( red, green, blue, tess, a, b, f6, f8 );
this.draw( red, green, blue, buffer, a, b, u, v );
x = xN;
y = yN;
@@ -219,10 +234,6 @@ public class LightningFX extends Particle
}
}
}
/*
* GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS ); GL11.glDisable( GL11.GL_CULL_FACE ); tess.draw();
* GL11.glPopAttrib(); tess.startDrawingQuads();
*/
}
private void clear()
@@ -230,22 +241,22 @@ public class LightningFX extends Particle
this.hasData = false;
}
private void draw( float red, float green, float blue, final BufferBuilder tess, final double[] a, final double[] b, final double f6, final double f8 )
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( f6, f8 ).color( red, green, blue, this.particleAlpha ).lightmap( BRIGHTNESS, BRIGHTNESS ).endVertex();
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( f6, f8 )
.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( f6, f8 )
.tex( u, v )
.color( red, green, blue, this.particleAlpha )
.lightmap( BRIGHTNESS, BRIGHTNESS )
.endVertex();
tess.pos( b[0], b[1], b[2] ).tex( f6, f8 ).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++ )
@@ -259,4 +270,20 @@ public class LightningFX extends Particle
{
return this.precomputedSteps;
}
@OnlyIn(Dist.CLIENT)
public static class Factory implements IParticleFactory<BasicParticleType> {
private final IAnimatedSprite 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;
}
}
}
@@ -65,7 +65,7 @@ public class SkyCompassTESR extends FastTESR<TileSkyCompass>
BlockState state = world.getBlockState( pos );
if( state.getPropertyKeys().contains( Properties.StaticProperty ) )
{
state = state.withProperty( Properties.StaticProperty, false );
state = state.with( Properties.StaticProperty, false );
}
if( state instanceof IExtendedBlockState )
@@ -73,7 +73,7 @@ public class SkyCompassTESR extends FastTESR<TileSkyCompass>
IExtendedBlockState exState = (IExtendedBlockState) state.getBlock().getExtendedState( state, world, pos );
IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState( exState.getClean() );
exState = exState.withProperty( BlockSkyCompass.ROTATION, getRotation( te ) );
exState = exState.with( BlockSkyCompass.ROTATION, getRotation( te ) );
// Flip forward/up for rendering, the base model is facing up without any rotation
Direction forward = exState.getValue( AEBaseTileBlock.FORWARD );
@@ -84,8 +84,8 @@ public class SkyCompassTESR extends FastTESR<TileSkyCompass>
{
up = Direction.NORTH;
}
exState = exState.withProperty( AEBaseTileBlock.FORWARD, up )
.withProperty( AEBaseTileBlock.UP, forward );
exState = exState.with( AEBaseTileBlock.FORWARD, up )
.with( AEBaseTileBlock.UP, forward );
buffer.setTranslation( x - pos.getX(), y - pos.getY(), z - pos.getZ() );