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);
}
}
Aggregations