/** * Copyright (c) 22/Feb/2015 Davide Cossu & Matthew Albrecht. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 3 of the License, or (at your option) any * later version. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with * this program; if not, see <http://www.gnu.org/licenses>. */ package com.minestellar.core.particles; import net.minecraft.block.BlockLiquid; import net.minecraft.block.material.Material; import net.minecraft.client.particle.EntityFX; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class EntityCoreOilDripFX extends EntityFX { private final Material materialType; private int bobTimer; public EntityCoreOilDripFX(World par1World, double par2, double par4, double par6, Material par8Material) { super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D); this.motionX = this.motionY = this.motionZ = 0.0D; if (par8Material == Material.water) { this.particleGreen = 1.0F; this.particleBlue = 1.0F; this.particleRed = 1.0F; this.particleAlpha = 0.7F; } this.setParticleTextureIndex(113); this.setSize(0.01F, 0.01F); this.particleGravity = 0.06F; this.materialType = par8Material; this.particleGreen = 1.0F; this.particleBlue = 1.0F; this.particleRed = 1.0F; this.particleAlpha = 0.7F; this.bobTimer = 40; this.particleMaxAge = (int) (64.0D / (Math.random() * 0.8D + 0.2D)); this.motionX = this.motionY = this.motionZ = 0.0D; } @Override public int getBrightnessForRender(float par1) { return super.getBrightnessForRender(par1); } @Override public float getBrightness(float par1) { return super.getBrightness(par1); } @Override public void onUpdate() { this.prevPosX = this.posX; this.prevPosY = this.posY; this.prevPosZ = this.posZ; if (this.materialType == Material.water) { this.particleGreen = 1.0F; this.particleBlue = 1.0F; this.particleRed = 1.0F; this.particleAlpha = 0.7F; } this.motionY -= 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.setDead(); this.motionX *= 0.699999988079071D; this.motionZ *= 0.699999988079071D; } final Material var1 = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)).getMaterial(); if (var1.isLiquid() || var1.isSolid()) { final double var2 = MathHelper.floor_double(this.posY) + 1 - BlockLiquid.getLiquidHeightPercent(this.worldObj.getBlockMetadata(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ))); if (this.posY < var2) { this.setDead(); } } } }