Effects should not collide with anything

This commit is contained in:
yueh
2015-01-02 20:34:00 +01:00
parent 59adde7c6b
commit 2f51568772
8 changed files with 101 additions and 68 deletions
@@ -18,6 +18,7 @@
package appeng.client.render.effects;
import java.util.Random;
import net.minecraft.client.Minecraft;
@@ -27,6 +28,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class LightningFX extends EntityFX
{
@@ -34,13 +36,15 @@ public class LightningFX extends EntityFX
private static final Random RANDOM_GENERATOR = new Random();
final double[][] Steps;
protected LightningFX(World w, double x, double y, double z, double r, double g, double b, int maxAge) {
protected LightningFX( World w, double x, double y, double z, double r, double g, double b, int maxAge )
{
super( w, x, y, z, r, g, b );
this.Steps = new double[this.steps][3];
this.motionX = 0;
this.motionY = 0;
this.motionZ = 0;
this.particleMaxAge = maxAge;
this.noClip = true;
}
private int getSteps()
@@ -48,7 +52,8 @@ public class LightningFX extends EntityFX
return 5;
}
public LightningFX(World w, double x, double y, double z, double r, double g, double b) {
public LightningFX( World w, double x, double y, double z, double r, double g, double b )
{
this( w, x, y, z, r, g, b, 6 );
this.regen();
}
@@ -56,7 +61,7 @@ public class LightningFX extends EntityFX
float currentPoint = 0;
@Override
public int getBrightnessForRender(float par1)
public int getBrightnessForRender( float par1 )
{
int j1 = 13;
return j1 << 20 | j1 << 4;
@@ -64,19 +69,19 @@ public class LightningFX extends EntityFX
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 < this.steps; s++)
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 < this.steps; s++ )
{
this.Steps[s][0] = lastDirectionX = (lastDirectionX + ( RANDOM_GENERATOR.nextDouble() - 0.5) * 0.9) / 2.0;
this.Steps[s][1] = lastDirectionY = (lastDirectionY + ( RANDOM_GENERATOR.nextDouble() - 0.5) * 0.9) / 2.0;
this.Steps[s][2] = lastDirectionZ = (lastDirectionZ + ( RANDOM_GENERATOR.nextDouble() - 0.5) * 0.9) / 2.0;
this.Steps[s][0] = lastDirectionX = ( lastDirectionX + ( RANDOM_GENERATOR.nextDouble() - 0.5 ) * 0.9 ) / 2.0;
this.Steps[s][1] = lastDirectionY = ( lastDirectionY + ( RANDOM_GENERATOR.nextDouble() - 0.5 ) * 0.9 ) / 2.0;
this.Steps[s][2] = lastDirectionZ = ( lastDirectionZ + ( RANDOM_GENERATOR.nextDouble() - 0.5 ) * 0.9 ) / 2.0;
}
}
@Override
public void renderParticle(Tessellator tess, float l, float rX, float rY, float rZ, float rYZ, float rXY)
public void renderParticle( Tessellator tess, float l, float rX, float rY, float rZ, float rYZ, float rXY )
{
float j = 1.0f;
tess.setColorRGBA_F( this.particleRed * j * 0.9f, this.particleGreen * j * 0.95f, this.particleBlue * j, this.particleAlpha );
@@ -103,10 +108,10 @@ public class LightningFX extends EntityFX
EntityPlayer p = Minecraft.getMinecraft().thePlayer;
double offX = -rZ;
double offY = MathHelper.cos( (float) (Math.PI / 2.0f + p.rotationPitch * 0.017453292F) );
double offY = MathHelper.cos( ( float ) ( Math.PI / 2.0f + p.rotationPitch * 0.017453292F ) );
double offZ = rX;
for (int layer = 0; layer < 2; layer++)
for ( int layer = 0; layer < 2; layer++ )
{
if ( layer == 0 )
{
@@ -125,15 +130,15 @@ public class LightningFX extends EntityFX
tess.setColorRGBA_F( this.particleRed * j * 0.9f, this.particleGreen * j * 0.65f, this.particleBlue * j * 0.85f, this.particleAlpha );
}
for (int cycle = 0; cycle < 3; cycle++)
for ( int cycle = 0; cycle < 3; cycle++ )
{
this.clear();
double x = (this.prevPosX + (this.posX - this.prevPosX) * l - interpPosX) - offX;
double y = (this.prevPosY + (this.posY - this.prevPosY) * l - interpPosY) - offY;
double z = (this.prevPosZ + (this.posZ - this.prevPosZ) * l - interpPosZ) - offZ;
double x = ( this.prevPosX + ( this.posX - this.prevPosX ) * l - interpPosX ) - offX;
double y = ( this.prevPosY + ( this.posY - this.prevPosY ) * l - interpPosY ) - offY;
double z = ( this.prevPosZ + ( this.posZ - this.prevPosZ ) * l - interpPosZ ) - offZ;
for (int s = 0; s < this.steps; s++)
for ( int s = 0; s < this.steps; s++ )
{
double xN = x + this.Steps[s][0];
double yN = y + this.Steps[s][1];
@@ -145,24 +150,24 @@ public class LightningFX extends EntityFX
if ( cycle == 0 )
{
ox = (yD * 0) - (1 * zD);
oy = (zD * 0) - (0 * xD);
oz = (xD * 1) - (0 * yD);
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);
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);
ox = ( yD * 0 ) - ( 0 * zD );
oy = ( zD * 1 ) - ( 0 * xD );
oz = ( xD * 0 ) - ( 1 * yD );
}
double ss = Math.sqrt( ox * ox + oy * oy + oz * oz ) / ((((double) this.steps - (double) s) / this.steps) * scale);
double ss = Math.sqrt( ox * ox + oy * oy + oz * oz ) / ( ( ( ( double ) this.steps - ( double ) s ) / this.steps ) * scale );
ox /= ss;
oy /= ss;
oz /= ss;
@@ -193,7 +198,7 @@ public class LightningFX extends EntityFX
final double[] I = new double[3];
final double[] K = new double[3];
private void draw(Tessellator tess, double[] a, double[] b, double f6, double f8)
private void draw( Tessellator tess, double[] a, double[] b, double f6, double f8 )
{
if ( this.hasData )
{
@@ -203,7 +208,7 @@ public class LightningFX extends EntityFX
tess.addVertexWithUV( b[0], b[1], b[2], f6, f8 );
}
this.hasData = true;
for (int x = 0; x < 3; x++)
for ( int x = 0; x < 3; x++ )
{
this.I[x] = a[x];
this.K[x] = b[x];