| 1 | package net.minecraft.client.particle;
|
| 2 |
|
| 3 | import net.minecraft.block.BlockLiquid;
|
| 4 | import net.minecraft.block.material.Material;
|
| 5 | import net.minecraft.block.state.IBlockState;
|
| 6 | import net.minecraft.util.BlockPos;
|
| 7 | import net.minecraft.util.EnumParticleTypes;
|
| 8 | import net.minecraft.util.MathHelper;
|
| 9 | import net.minecraft.world.World;
|
| 10 |
|
| 11 | public class EntityDropParticleFX extends EntityFX
|
| 12 | {
|
| 13 | /** the material type for dropped items/blocks */
|
| 14 | private Material materialType;
|
| 15 |
|
| 16 | /** The height of the current bob */
|
| 17 | private int bobTimer;
|
| 18 |
|
| 19 | protected EntityDropParticleFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, Material p_i1203_8_)
|
| 20 | {
|
| 21 | super(worldIn, xCoordIn, yCoordIn, zCoordIn, 0.0D, 0.0D, 0.0D);
|
| 22 | this.motionX = this.motionY = this.motionZ = 0.0D;
|
| 23 |
|
| 24 | if (p_i1203_8_ == Material.water)
|
| 25 | {
|
| 26 | this.particleRed = 0.0F;
|
| 27 | this.particleGreen = 0.0F;
|
| 28 | this.particleBlue = 1.0F;
|
| 29 | }
|
| 30 | else
|
| 31 | {
|
| 32 | this.particleRed = 1.0F;
|
| 33 | this.particleGreen = 0.0F;
|
| 34 | this.particleBlue = 0.0F;
|
| 35 | }
|
| 36 |
|
| 37 | this.setParticleTextureIndex(113);
|
| 38 | this.setSize(0.01F, 0.01F);
|
| 39 | this.particleGravity = 0.06F;
|
| 40 | this.materialType = p_i1203_8_;
|
| 41 | this.bobTimer = 40;
|
| 42 | this.particleMaxAge = (int)(64.0D / (Math.random() * 0.8D + 0.2D));
|
| 43 | this.motionX = this.motionY = this.motionZ = 0.0D;
|
| 44 | }
|
| 45 |
|
| 46 | public int getBrightnessForRender(float partialTicks)
|
| 47 | {
|
| 48 | return this.materialType == Material.water ? super.getBrightnessForRender(partialTicks) : 257;
|
| 49 | }
|
| 50 |
|
| 51 | /**
|
| 52 | * Gets how bright this entity is.
|
| 53 | */
|
| 54 | public float getBrightness(float partialTicks)
|
| 55 | {
|
| 56 | return this.materialType == Material.water ? super.getBrightness(partialTicks) : 1.0F;
|
| 57 | }
|
| 58 |
|
| 59 | /**
|
| 60 | * Called to update the entity's position/logic.
|
| 61 | */
|
| 62 | public void onUpdate()
|
| 63 | {
|
| 64 | this.prevPosX = this.posX;
|
| 65 | this.prevPosY = this.posY;
|
| 66 | this.prevPosZ = this.posZ;
|
| 67 |
|
| 68 | if (this.materialType == Material.water)
|
| 69 | {
|
| 70 | this.particleRed = 0.2F;
|
| 71 | this.particleGreen = 0.3F;
|
| 72 | this.particleBlue = 1.0F;
|
| 73 | }
|
| 74 | else
|
| 75 | {
|
| 76 | this.particleRed = 1.0F;
|
| 77 | this.particleGreen = 16.0F / (float)(40 - this.bobTimer + 16);
|
| 78 | this.particleBlue = 4.0F / (float)(40 - this.bobTimer + 8);
|
| 79 | }
|
| 80 |
|
| 81 | this.motionY -= (double)this.particleGravity;
|
| 82 |
|
| 83 | if (this.bobTimer-- > 0)
|
| 84 | {
|
| 85 | this.motionX *= 0.02D;
|
| 86 | this.motionY *= 0.02D;
|
| 87 | this.motionZ *= 0.02D;
|
| 88 | this.setParticleTextureIndex(113);
|
| 89 | }
|
| 90 | else
|
| 91 | {
|
| 92 | this.setParticleTextureIndex(112);
|
| 93 | }
|
| 94 |
|
| 95 | this.moveEntity(this.motionX, this.motionY, this.motionZ);
|
| 96 | this.motionX *= 0.9800000190734863D;
|
| 97 | this.motionY *= 0.9800000190734863D;
|
| 98 | this.motionZ *= 0.9800000190734863D;
|
| 99 |
|
| 100 | if (this.particleMaxAge-- <= 0)
|
| 101 | {
|
| 102 | this.setDead();
|
| 103 | }
|
| 104 |
|
| 105 | if (this.onGround)
|
| 106 | {
|
| 107 | if (this.materialType == Material.water)
|
| 108 | {
|
| 109 | this.setDead();
|
| 110 | this.worldObj.spawnParticle(EnumParticleTypes.WATER_SPLASH, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, new int[0]);
|
| 111 | }
|
| 112 | else
|
| 113 | {
|
| 114 | this.setParticleTextureIndex(114);
|
| 115 | }
|
| 116 |
|
| 117 | this.motionX *= 0.699999988079071D;
|
| 118 | this.motionZ *= 0.699999988079071D;
|
| 119 | }
|
| 120 |
|
| 121 | BlockPos blockpos = new BlockPos(this);
|
| 122 | IBlockState iblockstate = this.worldObj.getBlockState(blockpos);
|
| 123 | Material material = iblockstate.getBlock().getMaterial();
|
| 124 |
|
| 125 | if (material.isLiquid() || material.isSolid())
|
| 126 | {
|
| 127 | double d0 = 0.0D;
|
| 128 |
|
| 129 | if (iblockstate.getBlock() instanceof BlockLiquid)
|
| 130 | {
|
| 131 | d0 = (double)BlockLiquid.getLiquidHeightPercent(((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue());
|
| 132 | }
|
| 133 |
|
| 134 | double d1 = (double)(MathHelper.floor_double(this.posY) + 1) - d0;
|
| 135 |
|
| 136 | if (this.posY < d1)
|
| 137 | {
|
| 138 | this.setDead();
|
| 139 | }
|
| 140 | }
|
| 141 | }
|
| 142 |
|
| 143 | public static class LavaFactory implements IParticleFactory
|
| 144 | {
|
| 145 | public EntityFX getEntityFX(int particleID, World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int... p_178902_15_)
|
| 146 | {
|
| 147 | return new EntityDropParticleFX(worldIn, xCoordIn, yCoordIn, zCoordIn, Material.lava);
|
| 148 | }
|
| 149 | }
|
| 150 |
|
| 151 | public static class WaterFactory implements IParticleFactory
|
| 152 | {
|
| 153 | public EntityFX getEntityFX(int particleID, World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int... p_178902_15_)
|
| 154 | {
|
| 155 | return new EntityDropParticleFX(worldIn, xCoordIn, yCoordIn, zCoordIn, Material.water);
|
| 156 | }
|
| 157 | }
|
| 158 | }
|
| 159 |
|