Search in sources :

Example 21 with EntityFX

use of net.minecraft.client.particle.EntityFX in project BetterRain by OreCruncher.

the class StormSplashRenderer method addRainParticles.

public void addRainParticles(final EntityRenderer theThis) {
    if (theThis.mc.gameSettings.particleSetting == 2)
        return;
    if (!DimensionRegistry.hasWeather(EnvironState.getWorld()))
        return;
    float rainStrengthFactor = theThis.mc.theWorld.getRainStrength(1.0F);
    if (!theThis.mc.gameSettings.fancyGraphics)
        rainStrengthFactor /= 2.0F;
    if (rainStrengthFactor <= 0.0F)
        return;
    RANDOM.setSeed((long) theThis.rendererUpdateCount * 312987231L);
    final Entity entity = theThis.mc.getRenderViewEntity();
    final WorldClient worldclient = theThis.mc.theWorld;
    final int playerX = MathHelper.floor_double(entity.posX);
    final int playerY = MathHelper.floor_double(entity.posY);
    final int playerZ = MathHelper.floor_double(entity.posZ);
    double spawnX = 0.0D;
    double spawnY = 0.0D;
    double spawnZ = 0.0D;
    int particlesSpawned = 0;
    int particleCount = (int) (ModOptions.particleCountBase * rainStrengthFactor * rainStrengthFactor);
    if (theThis.mc.gameSettings.particleSetting == 1)
        particleCount >>= 1;
    BlockPos.MutableBlockPos posXZ = new BlockPos.MutableBlockPos();
    for (int j1 = 0; j1 < particleCount; ++j1) {
        final int locX = playerX + RANDOM.nextInt(RANGE) - RANDOM.nextInt(RANGE);
        final int locZ = playerZ + RANDOM.nextInt(RANGE) - RANDOM.nextInt(RANGE);
        posXZ.set(locX, 0, locZ);
        final BlockPos precipHeight = getPrecipitationHeight(worldclient, RANGE / 2, posXZ);
        final BiomeGenBase biome = worldclient.getBiomeGenForCoords(posXZ);
        final boolean hasDust = WeatherUtils.biomeHasDust(biome);
        if (precipHeight.getY() <= playerY + RANGE && precipHeight.getY() >= playerY - RANGE && (hasDust || (BiomeRegistry.hasPrecipitation(biome) && biome.getFloatTemperature(precipHeight) >= 0.15F))) {
            final Block block = worldclient.getBlockState(precipHeight.down()).getBlock();
            final double posX = locX + RANDOM.nextFloat();
            final double posY = precipHeight.getY() + 0.1F - block.getBlockBoundsMinY();
            final double posZ = locZ + RANDOM.nextFloat();
            final EntityFX particle = getBlockParticleFX(block, hasDust, worldclient, posX, posY, posZ);
            if (particle != null)
                theThis.mc.effectRenderer.addEffect(particle);
            if (RANDOM.nextInt(++particlesSpawned) == 0) {
                spawnX = posX;
                spawnY = posY;
                spawnZ = posZ;
            }
        }
    }
    if (particlesSpawned > 0 && RANDOM.nextInt(PARTICLE_SOUND_CHANCE) < theThis.rainSoundCounter++) {
        theThis.rainSoundCounter = 0;
        playSplashSound(theThis, worldclient, entity, spawnX, spawnY, spawnZ);
    }
}
Also used : Entity(net.minecraft.entity.Entity) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.BlockPos) EntityFX(net.minecraft.client.particle.EntityFX) BiomeGenBase(net.minecraft.world.biome.BiomeGenBase) WorldClient(net.minecraft.client.multiplayer.WorldClient)

Aggregations

EntityFX (net.minecraft.client.particle.EntityFX)21 Minecraft (net.minecraft.client.Minecraft)5 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)4 EntityExplodeFX (net.minecraft.client.particle.EntityExplodeFX)3 Tessellator (net.minecraft.client.renderer.Tessellator)3 SideOnly (cpw.mods.fml.relauncher.SideOnly)2 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)2 Block (net.minecraft.block.Block)2 WorldClient (net.minecraft.client.multiplayer.WorldClient)2 Entity (net.minecraft.entity.Entity)2 TileEntity (net.minecraft.tileentity.TileEntity)2 Pos (com.builtbroken.mc.imp.transform.vector.Pos)1 FXEnderPortalPartical (com.builtbroken.mc.lib.render.fx.FXEnderPortalPartical)1 FXSmoke (com.builtbroken.mc.lib.render.fx.FXSmoke)1 BlockHint (com.github.technus.tectech.entity.fx.BlockHint)1 GameProfile (com.mojang.authlib.GameProfile)1 Property (com.mojang.authlib.properties.Property)1 FXAntimatterPartical (icbm.classic.client.fx.FXAntimatterPartical)1 IOException (java.io.IOException)1 Random (java.util.Random)1