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 net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.world.World;
@@ -27,6 +28,7 @@ import appeng.client.EffectType;
import appeng.core.CommonHelper;
import appeng.entity.EntityFloatingItem;
public class AssemblerFX extends EntityFX
{
@@ -35,7 +37,8 @@ public class AssemblerFX extends EntityFX
float time = 0;
final float speed;
public AssemblerFX(World w, double x, double y, double z, double r, double g, double b, float speed, IAEItemStack is) {
public AssemblerFX( World w, double x, double y, double z, double r, double g, double b, float speed, IAEItemStack is )
{
super( w, x, y, z, r, g, b );
this.motionX = 0;
this.motionY = 0;
@@ -44,11 +47,12 @@ public class AssemblerFX extends EntityFX
this.speed = speed;
this.fi = new EntityFloatingItem( this, w, x, y, z, is.getItemStack() );
w.spawnEntityInWorld( this.fi );
this.particleMaxAge = (int) Math.ceil( Math.max( 1, 100.0f / speed ) ) + 2;
this.particleMaxAge = ( int ) Math.ceil( Math.max( 1, 100.0f / speed ) ) + 2;
this.noClip = true;
}
@Override
public int getBrightnessForRender(float par1)
public int getBrightnessForRender( float par1 )
{
int j1 = 13;
return j1 << 20 | j1 << 4;
@@ -63,20 +67,20 @@ public class AssemblerFX extends EntityFX
this.fi.setDead();
else
{
float lifeSpan = (float) this.particleAge / (float) this.particleMaxAge;
float lifeSpan = ( float ) this.particleAge / ( float ) this.particleMaxAge;
this.fi.setProgress( lifeSpan );
}
}
@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 )
{
this.time += l;
if ( this.time > 4.0 )
{
this.time -= 4.0;
// if ( CommonHelper.proxy.shouldAddParticles( r ) )
for (int x = 0; x < (int) Math.ceil( this.speed / 5 ); x++)
for ( int x = 0; x < ( int ) Math.ceil( this.speed / 5 ); x++ )
CommonHelper.proxy.spawnEffect( EffectType.Crafting, this.worldObj, this.posX, this.posY, this.posZ, null );
}
}
@@ -18,19 +18,22 @@
package appeng.client.render.effects;
import net.minecraft.client.particle.EntityReddustFX;
import net.minecraft.world.World;
public class ChargedOreFX extends EntityReddustFX
{
public ChargedOreFX(World w, double x, double y, double z, float r, float g, float b) {
public ChargedOreFX( World w, double x, double y, double z, float r, float g, float b )
{
super( w, x, y, z, 0.21f, 0.61f, 1.0f );
}
@Override
public int getBrightnessForRender(float par1)
public int getBrightnessForRender( float par1 )
{
int j1 = super.getBrightnessForRender( par1 );
j1 = Math.max( j1 >> 20, j1 >> 4 );
@@ -18,6 +18,7 @@
package appeng.client.render.effects;
import net.minecraft.client.particle.EntityBreakingFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.Item;
@@ -31,7 +32,8 @@ import cpw.mods.fml.relauncher.SideOnly;
import appeng.client.texture.ExtraBlockTextures;
@SideOnly(Side.CLIENT)
@SideOnly( Side.CLIENT )
public class CraftingFx extends EntityBreakingFX
{
@@ -47,7 +49,8 @@ public class CraftingFx extends EntityBreakingFX
return 1;
}
public CraftingFx(World par1World, double par2, double par4, double par6, Item par8Item) {
public CraftingFx( World par1World, double par2, double par4, double par6, Item par8Item )
{
super( par1World, par2, par4, par6, par8Item );
this.particleGravity = 0;
this.particleBlue = 1;
@@ -61,9 +64,11 @@ public class CraftingFx extends EntityBreakingFX
this.startBlkX = MathHelper.floor_double( this.posX );
this.startBlkY = MathHelper.floor_double( this.posY );
this.startBlkZ = MathHelper.floor_double( this.posZ );
this.noClip = true;
}
public void fromItem(ForgeDirection d)
public void fromItem( ForgeDirection d )
{
this.posX += 0.2 * d.offsetX;
this.posY += 0.2 * d.offsetY;
@@ -80,7 +85,7 @@ public class CraftingFx extends EntityBreakingFX
}
@Override
public void renderParticle(Tessellator par1Tessellator, float partialTick, float x, float y, float z, float rx, float rz)
public void renderParticle( Tessellator par1Tessellator, float partialTick, float x, float y, float z, float rx, float rz )
{
if ( partialTick < 0 || partialTick > 1 )
return;
@@ -91,9 +96,9 @@ public class CraftingFx extends EntityBreakingFX
float f9 = this.particleTextureIndex.getMaxV();
float scale = 0.1F * this.particleScale;
float offX = (float) (this.prevPosX + (this.posX - this.prevPosX) * partialTick);
float offY = (float) (this.prevPosY + (this.posY - this.prevPosY) * partialTick);
float offZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * partialTick);
float offX = ( float ) ( this.prevPosX + ( this.posX - this.prevPosX ) * partialTick );
float offY = ( float ) ( this.prevPosY + ( this.posY - this.prevPosY ) * partialTick );
float offZ = ( float ) ( this.prevPosZ + ( this.posZ - this.prevPosZ ) * partialTick );
float f14 = 1.0F;
int blkX = MathHelper.floor_double( offX );
@@ -18,6 +18,7 @@
package appeng.client.render.effects;
import net.minecraft.client.particle.EntityBreakingFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.Item;
@@ -31,7 +32,8 @@ import cpw.mods.fml.relauncher.SideOnly;
import appeng.client.texture.ExtraBlockTextures;
@SideOnly(Side.CLIENT)
@SideOnly( Side.CLIENT )
public class EnergyFx extends EntityBreakingFX
{
@@ -47,7 +49,8 @@ public class EnergyFx extends EntityBreakingFX
return 1;
}
public EnergyFx(World par1World, double par2, double par4, double par6, Item par8Item) {
public EnergyFx( World par1World, double par2, double par4, double par6, Item par8Item )
{
super( par1World, par2, par4, par6, par8Item );
this.particleGravity = 0;
this.particleBlue = 255;
@@ -60,9 +63,11 @@ public class EnergyFx extends EntityBreakingFX
this.startBlkX = MathHelper.floor_double( this.posX );
this.startBlkY = MathHelper.floor_double( this.posY );
this.startBlkZ = MathHelper.floor_double( this.posZ );
this.noClip = true;
}
public void fromItem(ForgeDirection d)
public void fromItem( ForgeDirection d )
{
this.posX += 0.2 * d.offsetX;
this.posY += 0.2 * d.offsetY;
@@ -79,7 +84,7 @@ public class EnergyFx extends EntityBreakingFX
}
@Override
public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
public void renderParticle( Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7 )
{
float f6 = this.particleTextureIndex.getMinU();
float f7 = this.particleTextureIndex.getMaxU();
@@ -87,9 +92,9 @@ public class EnergyFx extends EntityBreakingFX
float f9 = this.particleTextureIndex.getMaxV();
float f10 = 0.1F * this.particleScale;
float f11 = (float) (this.prevPosX + (this.posX - this.prevPosX) * par2 - interpPosX);
float f12 = (float) (this.prevPosY + (this.posY - this.prevPosY) * par2 - interpPosY);
float f13 = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * par2 - interpPosZ);
float f11 = ( float ) ( this.prevPosX + ( this.posX - this.prevPosX ) * par2 - interpPosX );
float f12 = ( float ) ( this.prevPosY + ( this.posY - this.prevPosY ) * par2 - interpPosY );
float f13 = ( float ) ( this.prevPosZ + ( this.posZ - this.prevPosZ ) * par2 - interpPosZ );
float f14 = 1.0F;
int blkX = MathHelper.floor_double( this.posX );
@@ -18,10 +18,12 @@
package appeng.client.render.effects;
import java.util.Random;
import net.minecraft.world.World;
public class LightningArcFX extends LightningFX
{
private static final Random RANDOM_GENERATOR = new Random();
@@ -30,8 +32,10 @@ public class LightningArcFX extends LightningFX
final double ry;
final double rz;
public LightningArcFX(World w, double x, double y, double z, double ex, double ey, double ez, double r, double g, double b) {
public LightningArcFX( World w, double x, double y, double z, double ex, double ey, double ez, double r, double g, double b )
{
super( w, x, y, z, r, g, b, 6 );
this.noClip = true;
this.rx = ex - x;
this.ry = ey - y;
@@ -43,17 +47,17 @@ public class LightningArcFX extends LightningFX
@Override
protected void regen()
{
double i = 1.0 / (this.steps - 1);
double i = 1.0 / ( this.steps - 1 );
double lastDirectionX = this.rx * i;
double lastDirectionY = this.ry * i;
double lastDirectionZ = this.rz * i;
double len = Math.sqrt( lastDirectionX * lastDirectionX + lastDirectionY * lastDirectionY + lastDirectionZ * lastDirectionZ );
for (int s = 0; s < this.steps; s++)
for ( int s = 0; s < this.steps; s++ )
{
this.Steps[s][0] = (lastDirectionX + ( RANDOM_GENERATOR.nextDouble() - 0.5) * len * 1.2) / 2.0;
this.Steps[s][1] = (lastDirectionY + ( RANDOM_GENERATOR.nextDouble() - 0.5) * len * 1.2) / 2.0;
this.Steps[s][2] = (lastDirectionZ + ( RANDOM_GENERATOR.nextDouble() - 0.5) * len * 1.2) / 2.0;
this.Steps[s][0] = ( lastDirectionX + ( RANDOM_GENERATOR.nextDouble() - 0.5 ) * len * 1.2 ) / 2.0;
this.Steps[s][1] = ( lastDirectionY + ( RANDOM_GENERATOR.nextDouble() - 0.5 ) * len * 1.2 ) / 2.0;
this.Steps[s][2] = ( lastDirectionZ + ( RANDOM_GENERATOR.nextDouble() - 0.5 ) * len * 1.2 ) / 2.0;
}
}
@@ -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];
@@ -18,6 +18,7 @@
package appeng.client.render.effects;
import net.minecraft.client.particle.EntityBreakingFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.Item;
@@ -27,12 +28,14 @@ import net.minecraftforge.common.util.ForgeDirection;
import appeng.client.texture.ExtraBlockTextures;
public class MatterCannonFX extends EntityBreakingFX
{
private final IIcon particleTextureIndex;
public MatterCannonFX(World par1World, double par2, double par4, double par6, Item par8Item) {
public MatterCannonFX( World par1World, double par2, double par4, double par6, Item par8Item )
{
super( par1World, par2, par4, par6, par8Item );
this.particleGravity = 0;
this.particleBlue = 255;
@@ -44,9 +47,10 @@ public class MatterCannonFX extends EntityBreakingFX
this.motionY = 0.0f;
this.motionZ = 0.0f;
this.particleTextureIndex = ExtraBlockTextures.BlockMatterCannonParticle.getIcon();
this.noClip = true;
}
public void fromItem(ForgeDirection d)
public void fromItem( ForgeDirection d )
{
this.particleScale *= 1.2f;
}
@@ -66,7 +70,7 @@ public class MatterCannonFX extends EntityBreakingFX
}
@Override
public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
public void renderParticle( Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7 )
{
float f6 = this.particleTextureIndex.getMinU();
float f7 = this.particleTextureIndex.getMaxU();
@@ -74,9 +78,9 @@ public class MatterCannonFX extends EntityBreakingFX
float f9 = this.particleTextureIndex.getMaxV();
float f10 = 0.05F * this.particleScale;
float f11 = (float) (this.prevPosX + (this.posX - this.prevPosX) * par2 - interpPosX);
float f12 = (float) (this.prevPosY + (this.posY - this.prevPosY) * par2 - interpPosY);
float f13 = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * par2 - interpPosZ);
float f11 = ( float ) ( this.prevPosX + ( this.posX - this.prevPosX ) * par2 - interpPosX );
float f12 = ( float ) ( this.prevPosY + ( this.posY - this.prevPosY ) * par2 - interpPosY );
float f13 = ( float ) ( this.prevPosZ + ( this.posZ - this.prevPosZ ) * par2 - interpPosZ );
float f14 = 1.0F;
par1Tessellator.setColorRGBA_F( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha );
@@ -18,17 +18,20 @@
package appeng.client.render.effects;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
@SideOnly( Side.CLIENT )
public class VibrantFX extends EntityFX
{
public VibrantFX(World par1World, double x, double y, double z, double par8, double par10, double par12) {
public VibrantFX( World par1World, double x, double y, double z, double par8, double par10, double par12 )
{
super( par1World, x, y, z, par8, par10, par12 );
float f = this.rand.nextFloat() * 0.1F + 0.8F;
this.particleRed = f * 0.7f;
@@ -43,12 +46,12 @@ public class VibrantFX extends EntityFX
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.particleMaxAge = (int) (20.0D / (Math.random() * 0.8D + 0.1D));
this.particleMaxAge = ( int ) ( 20.0D / ( Math.random() * 0.8D + 0.1D ) );
this.noClip = true;
}
@Override
public float getBrightness(float par1)
public float getBrightness( float par1 )
{
return 1.0f;
}