Added some particeles from Thaumcraft, thanks to Azanor. I'm not cleaning this freaking code.

This commit is contained in:
Vasco Lavos committed 2014-01-17 17:40:29 +00:00
1 parent ef8e4b951c
commit 3072fa98f4
8 files changed
+623

No files matched your search

@@ -0,0 +1,331 @@
/**
* This class was created by <Azanor>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
* File Created @ [? (GMT)]
*/
package vazkii.botania.client.fx;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.core.helper.ObfuscationHelper;
import cpw.mods.fml.client.FMLClientHandler;
public class FXSparkle extends EntityFX
{
public static final ResourceLocation particles = new ResourceLocation(LibResources.MISC_PARTICLES);
public FXSparkle(World world, double d, double d1, double d2, float f, float f1, float f2, float f3, int m)
{
super(world, d, d1, d2, 0.0D, 0.0D, 0.0D);
if(f1 == 0.0F) f1 = 1.0F;
particleRed = f1;
particleGreen = f2;
particleBlue = f3;
particleGravity=0;
motionX=motionY=motionZ=0;
particleScale *= f;
particleMaxAge = 3*m;
multiplier=m;
noClip = false;
this.setSize(0.01F, 0.01F);
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
}
public FXSparkle(World world, double d, double d1, double d2, float f, int type, int m)
{
this(world, d, d1, d2, f, 0f, 0f, 0f, m);
currentColor = type;
switch (type) {
case 0:
particleRed=.75f + world.rand.nextFloat()*.25f;
particleGreen=.25f + world.rand.nextFloat()*.25f;
particleBlue=.75f + world.rand.nextFloat()*.25f;
break;
case 1:
particleRed=.5f + world.rand.nextFloat()*.3f;
particleGreen=.5f + world.rand.nextFloat()*.3f;
particleBlue=.2f;
break;
case 2:
particleRed=.2f;
particleGreen=.2f;
particleBlue=.7f + world.rand.nextFloat()*.3f;
break;
case 3:
particleRed=.2f;
particleGreen=.7f + world.rand.nextFloat()*.3f;
particleBlue=.2f;
break;
case 4:
particleRed=.7f + world.rand.nextFloat()*.3f;
particleGreen=.2f;
particleBlue=.2f;
break;
case 5:
blendmode=771;
particleRed= world.rand.nextFloat()*.1f;
particleGreen= world.rand.nextFloat()*.1f;
particleBlue= world.rand.nextFloat()*.1f;
break;
case 6:
particleRed= .8f+world.rand.nextFloat()*.2f;
particleGreen= .8f+world.rand.nextFloat()*.2f;
particleBlue= .8f+world.rand.nextFloat()*.2f;
break;
case 7:
particleRed=.2f;
particleGreen=.5f + world.rand.nextFloat()*.3f;
particleBlue=.6f + world.rand.nextFloat()*.3f;
break;
}
}
public FXSparkle(World world, double d, double d1, double d2, double x, double y, double z,
float f, int type, int m)
{
this(world, d, d1, d2, f, type, m);
double dx = x - posX;
double dy = y - posY;
double dz = z - posZ;
motionX = dx / particleMaxAge;
motionY = dy / particleMaxAge;
motionZ = dz / particleMaxAge;
}
public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5)
{
tessellator.draw();
GL11.glPushMatrix();
GL11.glDepthMask(false);
GL11.glEnable(3042);
GL11.glBlendFunc(770, blendmode);
Minecraft.getMinecraft().renderEngine.bindTexture(particles);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.75F);
int part = particle + particleAge/multiplier;
float var8 = (float)(part % 8) / 8.0F;
float var9 = var8 + 0.0624375F*2;
float var10 = (float)(part / 8) / 8.0F;
float var11 = var10 + 0.0624375F*2;
float var12 = 0.1F * this.particleScale;
if (shrink) var12 *= ((particleMaxAge-particleAge+1)/(float)particleMaxAge);
float var13 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)f - interpPosX);
float var14 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)f - interpPosY);
float var15 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)f - interpPosZ);
float var16 = 1.0F;
tessellator.startDrawingQuads();
tessellator.setBrightness(0x0000f0);
tessellator.setColorRGBA_F(this.particleRed * var16, this.particleGreen * var16, this.particleBlue * var16, 1);
tessellator.addVertexWithUV((double)(var13 - f1 * var12 - f4 * var12), (double)(var14 - f2 * var12), (double)(var15 - f3 * var12 - f5 * var12), (double)var9, (double)var11);
tessellator.addVertexWithUV((double)(var13 - f1 * var12 + f4 * var12), (double)(var14 + f2 * var12), (double)(var15 - f3 * var12 + f5 * var12), (double)var9, (double)var10);
tessellator.addVertexWithUV((double)(var13 + f1 * var12 + f4 * var12), (double)(var14 + f2 * var12), (double)(var15 + f3 * var12 + f5 * var12), (double)var8, (double)var10);
tessellator.addVertexWithUV((double)(var13 + f1 * var12 - f4 * var12), (double)(var14 - f2 * var12), (double)(var15 + f3 * var12 - f5 * var12), (double)var8, (double)var11);
tessellator.draw();
GL11.glDisable(3042);
GL11.glDepthMask(true);
GL11.glPopMatrix();
Minecraft.getMinecraft().renderEngine.bindTexture(ObfuscationHelper.getParticleTexture());
tessellator.startDrawingQuads();
}
public void onUpdate()
{
// if (!leyLineEffect) {
// EntityLiving renderentity = FMLClientHandler.instance().getClient().renderViewEntity;
// int visibleDistance = 50;
// if (!FMLClientHandler.instance().getClient().gameSettings.fancyGraphics) visibleDistance=25;
// if (renderentity.getDistance(posX, posY, posZ)>visibleDistance) particleMaxAge=0;
// }
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
if (particleAge==0 && tinkle && worldObj.rand.nextInt(10)==0)
worldObj.playSoundAtEntity(this, "random.orb", 0.02F, 0.7F * ((worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.6F + 2F));
if (particleAge++ >= particleMaxAge)
{
setDead();
}
motionY -= 0.040000000000000001D * (double)particleGravity;
if (noClip==false) pushOutOfBlocks(this.posX, (this.boundingBox.minY + this.boundingBox.maxY) / 2.0D, this.posZ);
// moveEntity(motionX, motionY, motionZ);
posX+=motionX;
posY+=motionY;
posZ+=motionZ;
if (slowdown) {
motionX *= 0.908000001907348633D;
motionY *= 0.908000001907348633D;
motionZ *= 0.908000001907348633D;
if (onGround)
{
motionX *= 0.69999998807907104D;
motionZ *= 0.69999998807907104D;
}
}
if (leyLineEffect) {
FXSparkle fx = new FXSparkle(worldObj,
prevPosX+(worldObj.rand.nextFloat()-worldObj.rand.nextFloat())*.1f,
prevPosY+(worldObj.rand.nextFloat()-worldObj.rand.nextFloat())*.1f,
prevPosZ+(worldObj.rand.nextFloat()-worldObj.rand.nextFloat())*.1f,
1f, currentColor, 3+worldObj.rand.nextInt(3));
fx.noClip=true;
FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx);
}
}
public void setGravity(float value) {
particleGravity = value;
}
protected boolean pushOutOfBlocks(double par1, double par3, double par5)
{
int var7 = MathHelper.floor_double(par1);
int var8 = MathHelper.floor_double(par3);
int var9 = MathHelper.floor_double(par5);
double var10 = par1 - (double)var7;
double var12 = par3 - (double)var8;
double var14 = par5 - (double)var9;
if (!this.worldObj.isAirBlock(var7, var8, var9))
{
boolean var16 = !this.worldObj.isBlockNormalCube(var7 - 1, var8, var9);
boolean var17 = !this.worldObj.isBlockNormalCube(var7 + 1, var8, var9);
boolean var18 = !this.worldObj.isBlockNormalCube(var7, var8 - 1, var9);
boolean var19 = !this.worldObj.isBlockNormalCube(var7, var8 + 1, var9);
boolean var20 = !this.worldObj.isBlockNormalCube(var7, var8, var9 - 1);
boolean var21 = !this.worldObj.isBlockNormalCube(var7, var8, var9 + 1);
byte var22 = -1;
double var23 = 9999.0D;
if (var16 && var10 < var23)
{
var23 = var10;
var22 = 0;
}
if (var17 && 1.0D - var10 < var23)
{
var23 = 1.0D - var10;
var22 = 1;
}
if (var18 && var12 < var23)
{
var23 = var12;
var22 = 2;
}
if (var19 && 1.0D - var12 < var23)
{
var23 = 1.0D - var12;
var22 = 3;
}
if (var20 && var14 < var23)
{
var23 = var14;
var22 = 4;
}
if (var21 && 1.0D - var14 < var23)
{
var23 = 1.0D - var14;
var22 = 5;
}
float var25 = this.rand.nextFloat() * 0.05F + 0.025F;
float var26 = (this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F;
if (var22 == 0)
{
this.motionX = (double)(-var25);
motionY=motionZ=var26;
}
if (var22 == 1)
{
this.motionX = (double)var25;
motionY=motionZ=var26;
}
if (var22 == 2)
{
this.motionY = (double)(-var25);
motionX=motionZ=var26;
}
if (var22 == 3)
{
this.motionY = (double)var25;
motionX=motionZ=var26;
}
if (var22 == 4)
{
this.motionZ = (double)(-var25);
motionY=motionX=var26;
}
if (var22 == 5)
{
this.motionZ = (double)var25;
motionY=motionX=var26;
}
return true;
}
else
{
return false;
}
}
public boolean leyLineEffect=false;
public int multiplier=2;
public boolean shrink=true;
public int particle=16;
public boolean tinkle=false;
public int blendmode=1;
public boolean slowdown=true;
public int currentColor=0;
}
+245
View File
@@ -0,0 +1,245 @@
/**
* This class was created by <Azanor>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
* File Created @ [? (GMT)]
*/
package vazkii.botania.client.fx;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.core.helper.ObfuscationHelper;
import cpw.mods.fml.client.FMLClientHandler;
public class FXWisp extends EntityFX
{
public static final ResourceLocation particles = new ResourceLocation(LibResources.MISC_WISP_LARGE);
public FXWisp(World world, double d, double d1, double d2, float f, float f1, float f2)
{
this(world, d, d1, d2, 1.0F, f, f1, f2);
}
public FXWisp(World world, double d, double d1, double d2, float f, float red, float green, float blue)
{
super(world, d, d1, d2, 0.0D, 0.0D, 0.0D);
if(red == 0.0F) red = 1.0F;
particleRed = red;
particleGreen = green;
particleBlue = blue;
particleGravity=0;
motionX=motionY=motionZ=0;
particleScale *= f;
moteParticleScale = particleScale;
particleMaxAge = (int)(36D / (Math.random() * 0.3D + 0.7D));
moteHalfLife = particleMaxAge / 2;
noClip = false;
this.setSize(0.01F, 0.01F);
EntityLivingBase renderentity = FMLClientHandler.instance().getClient().renderViewEntity;
int visibleDistance = 50;
if (!FMLClientHandler.instance().getClient().gameSettings.fancyGraphics) visibleDistance=25;
if (renderentity.getDistance(posX, posY, posZ)>visibleDistance) particleMaxAge=0;
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
}
public FXWisp(World world, double d, double d1, double d2, float f, int type)
{
this(world, d, d1, d2, f, 0f, 0f, 0f);
switch (type) {
case 0:
particleRed=.75f + world.rand.nextFloat()*.25f;
particleGreen=.25f + world.rand.nextFloat()*.25f;
particleBlue=.75f + world.rand.nextFloat()*.25f;
break;
case 1:
particleRed=.5f + world.rand.nextFloat()*.3f;
particleGreen=.5f + world.rand.nextFloat()*.3f;
particleBlue=.2f;
break;
case 2:
particleRed=.2f;
particleGreen=.2f;
particleBlue=.7f + world.rand.nextFloat()*.3f;
break;
case 3:
particleRed=.2f;
particleGreen=.7f + world.rand.nextFloat()*.3f;
particleBlue=.2f;
break;
case 4:
particleRed=.7f + world.rand.nextFloat()*.3f;
particleGreen=.2f;
particleBlue=.2f;
break;
case 5:
blendmode=771;
particleRed= world.rand.nextFloat()*.1f;
particleGreen= world.rand.nextFloat()*.1f;
particleBlue= world.rand.nextFloat()*.1f;
break;
case 6:
particleRed= .8f+world.rand.nextFloat()*.2f;
particleGreen= .8f+world.rand.nextFloat()*.2f;
particleBlue= .8f+world.rand.nextFloat()*.2f;
break;
case 7:
particleRed=.7f + world.rand.nextFloat()*.3f;
particleGreen=.5f + world.rand.nextFloat()*.2f;
particleBlue=.3f + world.rand.nextFloat()*.1f;
break;
}
}
public FXWisp(World world, double d, double d1, double d2, double x, double y, double z, float f, int type)
{
this(world, d, d1, d2, f, type);
if (particleMaxAge>0) {
double dx = x - posX;
double dy = y - posY;
double dz = z - posZ;
motionX = dx / particleMaxAge;
motionY = dy / particleMaxAge;
motionZ = dz / particleMaxAge;
}
}
public FXWisp(World world, double d, double d1, double d2, double x, double y, double z,
float f, float red, float green, float blue)
{
this(world, d, d1, d2, f, red,green,blue);
if (particleMaxAge>0) {
double dx = x - posX;
double dy = y - posY;
double dz = z - posZ;
motionX = dx / particleMaxAge;
motionY = dy / particleMaxAge;
motionZ = dz / particleMaxAge;
}
}
public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5)
{
float agescale = 0;
if (shrink) {
agescale = ((float)particleMaxAge-(float)particleAge) / (float)particleMaxAge;
} else {
agescale = (float)particleAge / (float)moteHalfLife;
if (agescale>1f) agescale = 2-agescale;
}
this.particleScale = moteParticleScale * agescale;
tessellator.draw();
GL11.glPushMatrix();
GL11.glDepthMask(false);
GL11.glEnable(3042);
GL11.glBlendFunc(770, blendmode);
Minecraft.getMinecraft().renderEngine.bindTexture(particles);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.75F);
float f10 = 0.5F * particleScale;
float f11 = (float)((prevPosX + (posX - prevPosX) * (double)f) - interpPosX);
float f12 = (float)((prevPosY + (posY - prevPosY) * (double)f) - interpPosY);
float f13 = (float)((prevPosZ + (posZ - prevPosZ) * (double)f) - interpPosZ);
tessellator.startDrawingQuads();
tessellator.setBrightness(0x0000f0);
tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, 0.5F);
tessellator.addVertexWithUV(f11 - f1 * f10 - f4 * f10, f12 - f2 * f10, f13 - f3 * f10 - f5 * f10, 0, 1);
tessellator.addVertexWithUV((f11 - f1 * f10) + f4 * f10, f12 + f2 * f10, (f13 - f3 * f10) + f5 * f10, 1, 1);
tessellator.addVertexWithUV(f11 + f1 * f10 + f4 * f10, f12 + f2 * f10, f13 + f3 * f10 + f5 * f10, 1, 0);
tessellator.addVertexWithUV((f11 + f1 * f10) - f4 * f10, f12 - f2 * f10, (f13 + f3 * f10) - f5 * f10, 0, 0);
tessellator.draw();
GL11.glDisable(3042);
GL11.glDepthMask(true);
GL11.glPopMatrix();
Minecraft.getMinecraft().renderEngine.bindTexture(ObfuscationHelper.getParticleTexture());
tessellator.startDrawingQuads();
}
public void onUpdate()
{
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
if (particleAge==0 && tinkle && worldObj.rand.nextInt(3)==0)
worldObj.playSoundAtEntity(this, "random.orb", 0.02F, 0.5F * ((worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.6F + 2F));
if (particleAge++ >= particleMaxAge)
{
setDead();
}
motionY -= 0.040000000000000001D * (double)particleGravity;
// moveEntity(motionX, motionY, motionZ);
posX+=motionX;
posY+=motionY;
posZ+=motionZ;
motionX *= 0.98000001907348633D;
motionY *= 0.98000001907348633D;
motionZ *= 0.98000001907348633D;
if (onGround)
{
motionX *= 0.69999998807907104D;
motionZ *= 0.69999998807907104D;
}
}
public void setGravity(float value) {
particleGravity = value;
}
public boolean shrink=false;
float moteParticleScale;
int moteHalfLife;
public boolean tinkle=false;
public int blendmode=1;
}
@@ -28,6 +28,10 @@ public final class LibResources {
public static final String ENTRY_FLOWERS = PREFIX_ENTRIES + "flowers.png";
public static final String MISC_PARTICLES = PREFIX_MISC + "particles.png";
public static final String MISC_WISP_LARGE = PREFIX_MISC + "wispLarge.png";
public static final String MISC_WISP_SMALL = PREFIX_MISC + "wispSmall.png";
public static final String[] LANGS = new String[] {
"en_US"
};
@@ -0,0 +1,24 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
* File Created @ [Jan 17, 2014, 4:52:37 PM (GMT)]
*/
package vazkii.botania.common.core.helper;
import vazkii.botania.common.lib.LibObfuscation;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.util.ResourceLocation;
import cpw.mods.fml.relauncher.ReflectionHelper;
public class ObfuscationHelper {
public static ResourceLocation getParticleTexture() {
return ReflectionHelper.getPrivateValue(EffectRenderer.class, null, LibObfuscation.PARTICLE_TEXTURES);
}
}
@@ -0,0 +1,19 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
* File Created @ [Jan 17, 2014, 4:52:15 PM (GMT)]
*/
package vazkii.botania.common.lib;
public final class LibObfuscation {
// EffectRenderer
public static final String[] PARTICLE_TEXTURES = new String[] { "particleTextures", "b", "field_110737_b" };
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 904 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 408 B