use of org.blockartistry.DynSurround.registry.BiomeInfo in project DynamicSurroundings by OreCruncher.
the class BiomeSoundEffectsHandler method process.
@Override
public void process(@Nonnull final EntityPlayer player) {
this.biomes.update();
final TObjectFloatHashMap<SoundEffect> sounds = new TObjectFloatHashMap<>(Constants.DEFAULT_CAPACITY, Constants.DEFAULT_LOAD_FACTOR, -1F);
if (doBiomeSounds())
getBiomeSounds(sounds);
final ObjectArray<SoundEffect> playerSounds = new ObjectArray<>();
ClientRegistry.BIOME.PLAYER_INFO.findSoundMatches(playerSounds);
if (ModOptions.sound.enableBattleMusic)
ClientRegistry.BIOME.BATTLE_MUSIC_INFO.findSoundMatches(playerSounds);
if (EnvironState.inVillage())
ClientRegistry.BIOME.VILLAGE_INFO.findSoundMatches(playerSounds);
playerSounds.forEach(fx -> sounds.put(fx, 1.0F));
SoundEffectHandler.INSTANCE.queueAmbientSounds(sounds);
if (doBiomeSounds()) {
final BiomeInfo playerBiome = EnvironState.getPlayerBiome();
final SoundEffect sound = playerBiome.getSpotSound(this.RANDOM);
if (sound != null)
SoundEffectHandler.INSTANCE.playSoundAtPlayer(player, sound);
}
final SoundEffect sound = ClientRegistry.BIOME.PLAYER_INFO.getSpotSound(this.RANDOM);
if (sound != null)
SoundEffectHandler.INSTANCE.playSoundAtPlayer(player, sound);
}
use of org.blockartistry.DynSurround.registry.BiomeInfo in project DynamicSurroundings by OreCruncher.
the class StormRenderer method render.
/**
* Render rain and snow
*/
public void render(@Nonnull final EntityRenderer renderer, final float partialTicks) {
// Don't use EnvironState - may not have been initialized when rendering
// starts.
final Minecraft mc = Minecraft.getMinecraft();
final World world = mc.world;
if (!ClientRegistry.DIMENSION.hasWeather(world))
return;
final float rainStrength = Weather.getIntensityLevel();
if (rainStrength <= 0.0F)
return;
final float alphaRatio = rainStrength / Weather.getMaxIntensityLevel();
renderer.enableLightmap();
GlStateManager.disableCull();
GlStateManager.glNormal3f(0.0F, 1.0F, 0.0F);
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.alphaFunc(516, 0.1F);
final int range = mc.gameSettings.fancyGraphics ? 10 : 5;
final float f1 = RenderWeather.rendererUpdateCount + partialTicks;
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
final SeasonInfo season = ClientRegistry.SEASON.getData(world);
final Weather.Properties props = Weather.getWeatherProperties();
final Entity entity = mc.getRenderViewEntity();
final BlockPos playerPos = EnvironState.getPlayerPosition();
final int playerX = playerPos.getX();
final int playerY = playerPos.getY();
final int playerZ = playerPos.getZ();
for (int gridZ = playerZ - range; gridZ <= playerZ + range; ++gridZ) {
for (int gridX = playerX - range; gridX <= playerX + range; ++gridX) {
final int idx = (gridZ - playerZ + 16) * 32 + gridX - playerX + 16;
final double rainX = RAIN_X_COORDS[idx];
final double rainY = RAIN_Y_COORDS[idx];
this.mutable.setPos(gridX, 0, gridZ);
if (!RandomThings.shouldRain(world, this.mutable))
continue;
final BiomeInfo biome = ClientRegistry.BIOME.get(ClientChunkCache.INSTANCE.getBiome(this.mutable));
if (!biome.hasWeatherEffect())
continue;
final int precipHeight = season.getPrecipitationHeight(world, this.mutable).getY();
final int k2 = Math.max(playerY - range, precipHeight);
final int l2 = Math.max(playerY + range, precipHeight);
if (k2 == l2)
continue;
final int i3 = Math.max(precipHeight, locY);
this.random.setSeed(gridX * gridX * 3121 + gridX * 45238971 ^ gridZ * gridZ * 418711 + gridZ * 13761);
this.mutable.setPos(gridX, k2, gridZ);
final boolean canSnow = season.canWaterFreeze(world, this.mutable);
final double d6 = gridX + 0.5F - entity.posX;
final double d7 = gridZ + 0.5F - entity.posZ;
final float f3 = MathHelper.sqrt(d6 * d6 + d7 * d7) / range;
this.mutable.setPos(gridX, i3, gridZ);
final int combinedLight = ClientChunkCache.INSTANCE.getCombinedLight(this.mutable, 0);
if (!biome.getHasDust() && !canSnow) {
setupForRender(props.getRainTexture());
// d8 makes the rain fall down. Assumes texture height of 512 pixels.
final double d5 = ((double) (RenderWeather.rendererUpdateCount + gridX * gridX * 3121 + gridX * 45238971 + gridZ * gridZ * 418711 + gridZ * 13761 & 31) + (double) partialTicks) / 32.0D * (3.0D + this.random.nextDouble());
final float alpha = ((1.0F - f3 * f3) * 0.5F + 0.5F) * alphaRatio;
final int slX16 = combinedLight >> 16 & 65535;
final int blX16 = combinedLight & 65535;
worldrenderer.pos(gridX - rainX + 0.5D, k2, gridZ - rainY + 0.5D).tex(0.0D, k2 * 0.25D + d5).color(1.0F, 1.0F, 1.0F, alpha).lightmap(slX16, blX16).endVertex();
worldrenderer.pos(gridX + rainX + 0.5D, k2, gridZ + rainY + 0.5D).tex(1.0D, k2 * 0.25D + d5).color(1.0F, 1.0F, 1.0F, alpha).lightmap(slX16, blX16).endVertex();
worldrenderer.pos(gridX + rainX + 0.5D, l2, gridZ + rainY + 0.5D).tex(1.0D, l2 * 0.25D + d5).color(1.0F, 1.0F, 1.0F, alpha).lightmap(slX16, blX16).endVertex();
worldrenderer.pos(gridX - rainX + 0.5D, l2, gridZ - rainY + 0.5D).tex(0.0D, l2 * 0.25D + d5).color(1.0F, 1.0F, 1.0F, alpha).lightmap(slX16, blX16).endVertex();
} else {
ResourceLocation texture = props.getSnowTexture();
if (biome.getHasDust() && !canSnow)
texture = props.getDustTexture();
setupForRender(texture);
final Color color;
if (biome.getHasDust())
color = biome.getDustColor();
else
color = Color.WHITE;
// d8 makes the snow fall down. Assumes texture height of 512 pixels.
final double d8 = ((RenderWeather.rendererUpdateCount & 511) + partialTicks) / 512.0F;
// The 0.2F factor was originally 0.01F. It
// affects the horizontal movement of particles,
// which works well for dust.
final float factor = biome.getHasDust() ? 0.2F : 0.01F;
// d9 shifts the texture left/right
final double d9 = this.random.nextDouble() + (double) f1 * factor * ((float) this.random.nextGaussian());
// d10 shifts the texture up/down
final double d10 = this.random.nextDouble() + f1 * (float) this.random.nextGaussian() * 0.001D;
final float alpha = ((1.0F - f3 * f3) * 0.3F + 0.5F) * alphaRatio;
final int cl = (combinedLight * 3 + 15728880) / 4;
final int slX16 = cl >> 16 & 65535;
final int blX16 = cl & 65535;
worldrenderer.pos(gridX - rainX + 0.5D, k2, gridZ - rainY + 0.5D).tex(0.0D + d9, k2 * 0.25D + d8 + d10).color(color.red, color.green, color.blue, alpha).lightmap(slX16, blX16).endVertex();
worldrenderer.pos(gridX + rainX + 0.5D, k2, gridZ + rainY + 0.5D).tex(1.0D + d9, k2 * 0.25D + d8 + d10).color(color.red, color.green, color.blue, alpha).lightmap(slX16, blX16).endVertex();
worldrenderer.pos(gridX + rainX + 0.5D, l2, gridZ + rainY + 0.5D).tex(1.0D + d9, l2 * 0.25D + d8 + d10).color(color.red, color.green, color.blue, alpha).lightmap(slX16, blX16).endVertex();
worldrenderer.pos(gridX - rainX + 0.5D, l2, gridZ - rainY + 0.5D).tex(0.0D + d9, l2 * 0.25D + d8 + d10).color(color.red, color.green, color.blue, alpha).lightmap(slX16, blX16).endVertex();
}
}
}
closeRender();
GlStateManager.enableCull();
GlStateManager.disableBlend();
GlStateManager.alphaFunc(516, 0.1F);
renderer.disableLightmap();
}
use of org.blockartistry.DynSurround.registry.BiomeInfo in project DynamicSurroundings by OreCruncher.
the class BiomeFogRangeCalculator method calculate.
@Override
@Nonnull
public FogResult calculate(@Nonnull final EntityViewRenderEvent.RenderFogEvent event) {
final EntityLivingBase player = EnvironState.getPlayer();
final IBlockAccessEx provider = ClientChunkCache.INSTANCE;
final int playerX = MathStuff.floor(player.posX);
final int playerZ = MathStuff.floor(player.posZ);
final float rainStr = Weather.getIntensityLevel();
final Context ctx = this.context[event.getFogMode() == -1 ? 0 : 1];
if (ctx.returnCached(playerX, playerZ, rainStr, event))
return ctx.cached;
final BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(0, 0, 0);
float fpDistanceBiomeFog = 0F;
float weightBiomeFog = 0;
final boolean isRaining = Weather.isRaining();
ctx.rain = rainStr;
ctx.doScan = false;
for (int x = -DISTANCE; x <= DISTANCE; ++x) {
for (int z = -DISTANCE; z <= DISTANCE; ++z) {
pos.setPos(playerX + x, 0, playerZ + z);
// If the chunk is not available doScan will be set true. This will force
// another scan on the next tick.
ctx.doScan = ctx.doScan | !provider.isAvailable(pos);
final BiomeInfo biome = ClientRegistry.BIOME.get(provider.getBiome(pos));
float distancePart = 1F;
final float weightPart = 1;
if (isRaining && biome.getHasDust()) {
distancePart = 1F - DUST_FOG_IMPACT * rainStr;
} else if (biome.getHasFog()) {
distancePart = biome.getFogDensity();
}
fpDistanceBiomeFog += distancePart;
weightBiomeFog += weightPart;
}
}
final float weightMixed = (DISTANCE * 2 + 1) * (DISTANCE * 2 + 1);
final float weightDefault = weightMixed - weightBiomeFog;
final float fpDistanceBiomeFogAvg = (weightBiomeFog == 0) ? 0 : fpDistanceBiomeFog / weightBiomeFog;
float farPlaneDistance = (fpDistanceBiomeFog * 240 + event.getFarPlaneDistance() * weightDefault) / weightMixed;
final float farPlaneDistanceScaleBiome = (0.1f * (1 - fpDistanceBiomeFogAvg) + 0.75f * fpDistanceBiomeFogAvg);
final float farPlaneDistanceScale = (farPlaneDistanceScaleBiome * weightBiomeFog + 0.75f * weightDefault) / weightMixed;
ctx.posX = playerX;
ctx.posZ = playerZ;
ctx.lastFarPlane = event.getFarPlaneDistance();
farPlaneDistance = Math.min(farPlaneDistance, event.getFarPlaneDistance());
ctx.cached.set(event.getFogMode(), farPlaneDistance, farPlaneDistanceScale);
return ctx.cached;
}
use of org.blockartistry.DynSurround.registry.BiomeInfo in project DynamicSurroundings by OreCruncher.
the class BiomeFogColorCalculator method calculate.
@Override
@Nonnull
public Color calculate(@Nonnull final EntityViewRenderEvent.FogColors event) {
final EntityLivingBase player = EnvironState.getPlayer();
final World world = EnvironState.getWorld();
final IBlockAccessEx provider = ClientChunkCache.INSTANCE;
final int playerX = MathStuff.floor(player.posX);
final int playerZ = MathStuff.floor(player.posZ);
// ForgeHooksClient.getSkyBlendColour()
final GameSettings settings = Minecraft.getMinecraft().gameSettings;
final int[] ranges = ForgeModContainer.blendRanges;
int distance = 6;
if (settings.fancyGraphics && ranges.length > 0) {
distance = ranges[MathStuff.clamp(settings.renderDistanceChunks, 0, ranges.length - 1)];
}
final BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(0, 0, 0);
this.doScan |= this.posX != playerX || this.posZ != playerZ;
if (this.doScan) {
this.doScan = false;
this.posX = playerX;
this.posZ = playerZ;
this.biomeFogColor = new Color(0, 0, 0);
this.weightBiomeFog = 0;
for (int x = -distance; x <= distance; ++x) {
for (int z = -distance; z <= distance; ++z) {
pos.setPos(playerX + x, 0, playerZ + z);
// If the chunk is not available doScan will be set true. This will force
// another scan on the next tick.
this.doScan = this.doScan | !provider.isAvailable(pos);
final BiomeInfo biome = ClientRegistry.BIOME.get(provider.getBiome(pos));
final Color color;
// Fetch the color we are dealing with.
if (biome.getHasDust()) {
color = biome.getDustColor();
} else if (biome.getHasFog()) {
color = biome.getFogColor();
} else {
color = null;
}
if (color != null) {
this.biomeFogColor.add(color);
this.weightBiomeFog += 1F;
}
}
}
}
// If we have nothing then just return whatever Vanilla wanted
if (this.weightBiomeFog == 0 || distance == 0)
return super.calculate(event);
// WorldProvider.getFogColor() - need to calculate the scale based
// on sunlight and stuff.
final float partialTicks = (float) event.getRenderPartialTicks();
final float celestialAngle = world.getCelestialAngle(partialTicks);
final float baseScale = MathStuff.clamp(MathStuff.cos(celestialAngle * MathStuff.PI_F * 2.0F) * 2.0F + 0.5F, 0, 1);
double rScale = baseScale * 0.94F + 0.06F;
double gScale = baseScale * 0.94F + 0.06F;
double bScale = baseScale * 0.91F + 0.09F;
// EntityRenderer.updateFogColor() - adjust the scale further
// based on rain and thunder.
final float rainStrength = Weather.getIntensityLevel();
if (rainStrength > 0) {
rScale *= 1 - rainStrength * 0.5f;
gScale *= 1 - rainStrength * 0.5f;
bScale *= 1 - rainStrength * 0.4f;
}
final float thunderStrength = Weather.getThunderStrength();
if (thunderStrength > 0) {
rScale *= 1 - thunderStrength * 0.5f;
gScale *= 1 - thunderStrength * 0.5f;
bScale *= 1 - thunderStrength * 0.5f;
}
// Normalize the blended color components based on the biome weight.
// The components contain a summation of all the fog components
// in the area around the player.
final Color fogColor = new Color(this.biomeFogColor);
fogColor.scale(//
(float) (rScale / this.weightBiomeFog), //
(float) (gScale / this.weightBiomeFog), //
(float) (bScale / this.weightBiomeFog));
final Color processedColor = applyPlayerEffects(world, player, fogColor, partialTicks);
final double weightMixed = (distance * 2 + 1) * (distance * 2 + 1);
final double weightDefault = weightMixed - this.weightBiomeFog;
final Color vanillaColor = super.calculate(event);
processedColor.scale((float) this.weightBiomeFog);
vanillaColor.scale((float) weightDefault);
return processedColor.add(vanillaColor).scale((float) (1 / weightMixed));
}
use of org.blockartistry.DynSurround.registry.BiomeInfo in project DynamicSurroundings by OreCruncher.
the class StormSplashRenderer method addRainParticles.
public void addRainParticles(final EntityRenderer theThis) {
final Minecraft mc = Minecraft.getMinecraft();
if (mc.gameSettings.particleSetting == 2)
return;
final World world = mc.world;
if (!ClientRegistry.DIMENSION.hasWeather(world))
return;
float rainStrengthFactor = Weather.getIntensityLevel();
if (!mc.gameSettings.fancyGraphics)
rainStrengthFactor /= 2.0F;
if (rainStrengthFactor <= 0.0F)
return;
this.RANDOM.setSeed(RenderWeather.rendererUpdateCount * 312987231L);
final Entity entity = mc.getRenderViewEntity();
final int playerX = MathHelper.floor(entity.posX);
final int playerY = MathHelper.floor(entity.posY);
final int playerZ = MathHelper.floor(entity.posZ);
double spawnX = 0.0D;
double spawnY = 0.0D;
double spawnZ = 0.0D;
int particlesSpawned = 0;
final int RANGE = Math.max((ModOptions.general.specialEffectRange + 1) / 2, 10);
final float rangeFactor = RANGE / 10.0F;
int particleCount = (int) (ModOptions.rain.particleCountBase * rainStrengthFactor * rainStrengthFactor * rangeFactor);
if (mc.gameSettings.particleSetting == 1)
particleCount >>= 1;
for (int j1 = 0; j1 < particleCount; ++j1) {
final int locX = playerX + this.RANDOM.nextInt(RANGE) - this.RANDOM.nextInt(RANGE);
final int locZ = playerZ + this.RANDOM.nextInt(RANGE) - this.RANDOM.nextInt(RANGE);
this.pos.setPos(locX, 0, locZ);
if (!RandomThings.shouldRain(world, this.pos))
continue;
final BlockPos precipHeight = getPrecipitationHeight(world, RANGE / 2, this.pos);
final BiomeInfo biome = ClientRegistry.BIOME.get(world.getBiome(this.pos));
final boolean hasDust = biome.getHasDust();
final boolean canSnow = ClientRegistry.SEASON.canWaterFreeze(world, precipHeight);
if (precipHeight.getY() <= playerY + RANGE && precipHeight.getY() >= playerY - RANGE && (hasDust || (biome.getHasPrecipitation() && !canSnow))) {
final BlockPos blockPos = precipHeight.down();
final IBlockState state = WorldUtils.getBlockState(world, blockPos);
final double posX = locX + this.RANDOM.nextFloat();
final double posY = precipHeight.getY() + 0.1F - state.getBoundingBox(world, blockPos).minY;
final double posZ = locZ + this.RANDOM.nextFloat();
spawnBlockParticle(state, hasDust, world, posX, posY, posZ);
if (this.RANDOM.nextInt(++particlesSpawned) == 0) {
spawnX = posX;
spawnY = posY;
spawnZ = posZ;
}
}
}
if (particlesSpawned > 0 && this.RANDOM.nextInt(PARTICLE_SOUND_CHANCE) < this.rainSoundCounter++) {
this.rainSoundCounter = 0;
playSplashSound(theThis, world, entity, spawnX, spawnY, spawnZ);
}
}
Aggregations