Add Fluid drip particles

This commit is contained in:
CovertJaguar 2013-07-18 22:19:23 -07:00
parent bf46a1a6af
commit 39855eed65
3 changed files with 125 additions and 1 deletions

View file

@ -169,7 +169,7 @@ public class BuildCraftEnergy {
if (fluidFuel.getBlockID() == -1) {
if (blockFuelId > 0) {
blockFuel = new BlockBuildcraftFluid(blockFuelId, fluidFuel, Material.water).setFlammable(true).setFlammability(5);
blockFuel = new BlockBuildcraftFluid(blockFuelId, fluidFuel, Material.water).setFlammable(true).setFlammability(5).setParticleColor(0.7F, 0.7F, 0.0F);
blockFuel.setUnlocalizedName("blockFuel");
CoreProxy.proxy.addName(blockFuel, "Fuel");
CoreProxy.proxy.registerBlock(blockFuel);

View file

@ -8,9 +8,15 @@
*/
package buildcraft.energy;
import buildcraft.energy.render.EntityDropParticleFX;
import buildcraft.transport.render.TileEntityPickupFX;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
@ -25,6 +31,10 @@ import net.minecraftforge.fluids.Fluid;
*/
public class BlockBuildcraftFluid extends BlockFluidClassic {
protected float particleRed;
protected float particleGreen;
protected float particleBlue;
public BlockBuildcraftFluid(int id, Fluid fluid, Material material) {
super(id, fluid, material);
}
@ -73,4 +83,25 @@ public class BlockBuildcraftFluid extends BlockFluidClassic {
public boolean isFireSource(World world, int x, int y, int z, int metadata, ForgeDirection side) {
return flammable && flammability == 0;
}
public BlockBuildcraftFluid setParticleColor(float particleRed, float particleGreen, float particleBlue){
this.particleRed = particleRed;
this.particleGreen = particleGreen;
this.particleBlue = particleBlue;
return this;
}
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
super.randomDisplayTick(world, x, y, z, rand);
if (rand.nextInt(10) == 0 && world.doesBlockHaveSolidTopSurface(x, y - 1, z) && !world.getBlockMaterial(x, y - 2, z).blocksMovement()) {
double px = (double) ((float) x + rand.nextFloat());
double py = (double) y - 1.05D;
double pz = (double) ((float) z + rand.nextFloat());
EntityFX fx = new EntityDropParticleFX(world, px, py, pz, particleRed, particleGreen, particleBlue);
FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx);
}
}
}

View file

@ -0,0 +1,93 @@
package buildcraft.energy.render;
import net.minecraft.client.particle.*;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockFluid;
import net.minecraft.block.material.Material;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
@SideOnly(Side.CLIENT)
public class EntityDropParticleFX extends EntityFX {
/**
* The height of the current bob
*/
private int bobTimer;
public EntityDropParticleFX(World world, double x, double y, double z, float particleRed, float particleGreen, float particleBlue) {
super(world, x, y, z, 0.0D, 0.0D, 0.0D);
this.motionX = this.motionY = this.motionZ = 0.0D;
// if (par8Material == Material.water)
// {
// this.particleRed = 0.0F;
// this.particleGreen = 0.0F;
// this.particleBlue = 1.0F;
// }
// else
// {
// this.particleRed = 1.0F;
// this.particleGreen = 0.0F;
// this.particleBlue = 0.0F;
// }
this.particleRed = particleRed;
this.particleGreen = particleGreen;
this.particleBlue = particleBlue;
this.setParticleTextureIndex(113);
this.setSize(0.01F, 0.01F);
this.particleGravity = 0.06F;
this.bobTimer = 40;
this.particleMaxAge = (int) (64.0D / (Math.random() * 0.8D + 0.2D));
this.motionX = this.motionY = this.motionZ = 0.0D;
}
/**
* Called to update the entity's position/logic.
*/
@Override
public void onUpdate() {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.motionY -= (double) this.particleGravity;
if (this.bobTimer-- > 0) {
this.motionX *= 0.02D;
this.motionY *= 0.02D;
this.motionZ *= 0.02D;
this.setParticleTextureIndex(113);
} else {
this.setParticleTextureIndex(112);
}
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.9800000190734863D;
this.motionY *= 0.9800000190734863D;
this.motionZ *= 0.9800000190734863D;
if (this.particleMaxAge-- <= 0) {
this.setDead();
}
if (this.onGround) {
this.setParticleTextureIndex(114);
this.motionX *= 0.699999988079071D;
this.motionZ *= 0.699999988079071D;
}
Material material = this.worldObj.getBlockMaterial(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ));
if (material.isLiquid() || material.isSolid()) {
double d0 = (double) ((float) (MathHelper.floor_double(this.posY) + 1) - BlockFluid.getFluidHeightPercent(this.worldObj.getBlockMetadata(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ))));
if (this.posY < d0) {
this.setDead();
}
}
}
}