The arc kind works might as well keep it around.

This commit is contained in:
AlgorithmX2
2014-07-17 20:16:53 -05:00
parent 683a5ee765
commit dcb1f84776
4 changed files with 76 additions and 23 deletions
+11
View File
@@ -21,6 +21,7 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.client.IItemRenderer;
@@ -38,6 +39,7 @@ import appeng.client.render.WorldRender;
import appeng.client.render.effects.AssemblerFX;
import appeng.client.render.effects.CraftingFx;
import appeng.client.render.effects.EnergyFx;
import appeng.client.render.effects.LightningArcFX;
import appeng.client.render.effects.LightningFX;
import appeng.client.render.effects.VibrantFX;
import appeng.client.texture.CableBusTextures;
@@ -255,6 +257,9 @@ public class ClientHelper extends ServerHelper
case Lightning:
spawnLightning( worldObj, posX, posY, posZ );
return;
case LightningArc:
spawnLightningArc( worldObj, posX, posY, posZ, (Vec3) o );
return;
}
}
}
@@ -280,6 +285,12 @@ public class ClientHelper extends ServerHelper
}
}
private void spawnLightningArc(World worldObj, double posX, double posY, double posZ, Vec3 second)
{
LightningFX fx = new LightningArcFX( worldObj, posX, posY, posZ, second.xCoord, second.yCoord, second.zCoord, 0.0f, 0.0f, 0.0f );
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}
private void spawnLightning(World worldObj, double posX, double posY, double posZ)
{
LightningFX fx = new LightningFX( worldObj, posX, posY + 0.3f, posZ, 0.0f, 0.0f, 0.0f );
+1 -1
View File
@@ -2,5 +2,5 @@ package appeng.client;
public enum EffectType
{
Energy, Lightning, Vibrant, Crafting, Assembler
Energy, Lightning, Vibrant, Crafting, Assembler, LightningArc
}
+38
View File
@@ -0,0 +1,38 @@
package appeng.client.render.effects;
import net.minecraft.world.World;
public class LightningArcFX extends LightningFX
{
double rx, ry, rz;
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.rx = ex - x;
this.ry = ey - y;
this.rz = ez - z;
regen();
}
@Override
protected void regen()
{
double i = 1.0 / (steps - 1);
double lastDirectionX = rx * i;
double lastDirectionY = ry * i;
double lastDirectionZ = rz * i;
double len = Math.sqrt( lastDirectionX * lastDirectionX + lastDirectionY * lastDirectionY + lastDirectionZ * lastDirectionZ );
for (int s = 0; s < steps; s++)
{
Steps[s][0] = (lastDirectionX + (rng.nextDouble() - 0.5) * len * 1.2) / 2.0;
Steps[s][1] = (lastDirectionY + (rng.nextDouble() - 0.5) * len * 1.2) / 2.0;
Steps[s][2] = (lastDirectionZ + (rng.nextDouble() - 0.5) * len * 1.2) / 2.0;
}
}
}
+26 -22
View File
@@ -14,28 +14,27 @@ import org.lwjgl.opengl.GL11;
public class LightningFX extends EntityFX
{
final int steps = 5;
final int steps = getSteps();
static Random rng = new Random();
double[][] Steps;
public LightningFX(World w, double x, double y, double z, double r, double g, double b) {
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 );
Steps = new double[steps][3];
motionX = 0;
motionY = 0;
motionZ = 0;
particleMaxAge = 6;
particleMaxAge = maxAge;
}
// particleMaxAge = 269;
double lastDirectionX = (rng.nextDouble() - 0.5) * 0.9;
double lastDirectionY = (rng.nextDouble() - 0.5) * 0.9;
double lastDirectionZ = (rng.nextDouble() - 0.5) * 0.9;
for (int s = 0; s < steps; s++)
{
Steps[s][0] = lastDirectionX = (lastDirectionX + (rng.nextDouble() - 0.5) * 0.9) / 2.0;
Steps[s][1] = lastDirectionY = (lastDirectionY + (rng.nextDouble() - 0.5) * 0.9) / 2.0;
Steps[s][2] = lastDirectionZ = (lastDirectionZ + (rng.nextDouble() - 0.5) * 0.9) / 2.0;
}
private int getSteps()
{
return 5;
}
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 );
regen();
}
float currentPoint = 0;
@@ -47,6 +46,19 @@ public class LightningFX extends EntityFX
return j1 << 20 | j1 << 4;
}
protected void regen()
{
double lastDirectionX = (rng.nextDouble() - 0.5) * 0.9;
double lastDirectionY = (rng.nextDouble() - 0.5) * 0.9;
double lastDirectionZ = (rng.nextDouble() - 0.5) * 0.9;
for (int s = 0; s < steps; s++)
{
Steps[s][0] = lastDirectionX = (lastDirectionX + (rng.nextDouble() - 0.5) * 0.9) / 2.0;
Steps[s][1] = lastDirectionY = (lastDirectionY + (rng.nextDouble() - 0.5) * 0.9) / 2.0;
Steps[s][2] = lastDirectionZ = (lastDirectionZ + (rng.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)
{
@@ -54,15 +66,7 @@ public class LightningFX extends EntityFX
tess.setColorRGBA_F( this.particleRed * j * 0.9f, this.particleGreen * j * 0.95f, this.particleBlue * j, this.particleAlpha );
if ( particleAge == 3 )
{
double lastDirectionX = (rng.nextDouble() - 0.5) * 0.9;
double lastDirectionY = (rng.nextDouble() - 0.5) * 0.9;
double lastDirectionZ = (rng.nextDouble() - 0.5) * 0.9;
for (int s = 0; s < steps; s++)
{
Steps[s][0] = lastDirectionX = (lastDirectionX + (rng.nextDouble() - 0.5) * 0.9) / 2.0;
Steps[s][1] = lastDirectionY = (lastDirectionY + (rng.nextDouble() - 0.5) * 0.9) / 2.0;
Steps[s][2] = lastDirectionZ = (lastDirectionZ + (rng.nextDouble() - 0.5) * 0.9) / 2.0;
}
regen();
}
double f6 = this.particleTextureIndexX / 16.0;
double f7 = f6 + 0.0324375F;