use of hellfirepvp.astralsorcery.common.constellation.world.WorldContext in project AstralSorcery by HellFirePvP.
the class MixinWorld method solarEclipseSunBrightnessServer.
@Inject(method = "calculateInitialSkylight", at = @At("RETURN"), cancellable = true)
public void solarEclipseSunBrightnessServer(CallbackInfo ci) {
World world = (World) (Object) this;
WorldContext ctx = SkyHandler.getContext(world);
String strDimKey = world.getDimensionKey().getLocation().toString();
if (ctx != null && ctx.getCelestialEventHandler().getSolarEclipse().isActiveNow()) {
this.skylightSubtracted = 11 - Math.round(ctx.getCelestialEventHandler().getSolarEclipsePercent() * 11F);
}
}
use of hellfirepvp.astralsorcery.common.constellation.world.WorldContext in project AstralSorcery by HellFirePvP.
the class IndependentCrystalSource method produceStarlightTick.
@Override
public float produceStarlightTick(ServerWorld world, BlockPos pos) {
if (!doesSeeSky || crystalAttributes == null) {
return 0F;
}
IWeakConstellation cst = getStarlightType();
WorldContext ctx = SkyHandler.getContext(world, LogicalSide.SERVER);
if (ctx == null || cst == null) {
return 0F;
}
if (posDistribution == -1) {
posDistribution = SkyCollectionHelper.getSkyNoiseDistribution(world, pos);
}
if (closestOtherCollector != null && rand.nextInt(40) == 0) {
PktPlayEffect pkt = new PktPlayEffect(PktPlayEffect.Type.LIGHTNING).addData(buf -> {
ByteBufUtils.writeVector(buf, new Vector3(pos).add(0.5, 0.5, 0.5));
ByteBufUtils.writeVector(buf, new Vector3(closestOtherCollector).add(0.5, 0.5, 0.5));
buf.writeInt(this.constellation.getConstellationColor().darker().getRGB());
});
PacketChannel.CHANNEL.sendToAllAround(pkt, PacketChannel.pointFromPos(world, pos, 32));
}
Function<Float, Float> distrFunction = getDistributionFunc();
float perc = CrystalCalculations.getCollectorCrystalCollectionRate(this);
perc *= distrFunction.apply(0.3F + (0.7F * DayTimeHelper.getCurrentDaytimeDistribution(world)));
perc *= collectionDstMultiplier;
perc *= 1 + (0.3 * posDistribution);
perc *= 0.4 + 0.6 * ctx.getDistributionHandler().getDistribution(cst);
return perc;
}
use of hellfirepvp.astralsorcery.common.constellation.world.WorldContext in project AstralSorcery by HellFirePvP.
the class SkyRenderEventHandler method onFog.
public static void onFog(EntityViewRenderEvent.FogColors event) {
ClientWorld world = Minecraft.getInstance().world;
if (world != null) {
String strDimKey = world.getDimensionKey().getLocation().toString();
if (world.func_239132_a_().func_241683_c_() == DimensionRenderInfo.FogType.NORMAL && RenderingConfig.CONFIG.dimensionsWithSkyRendering.get().contains(strDimKey) && !RenderingConfig.CONFIG.dimensionsWithOnlyConstellationRendering.get().contains(strDimKey) && world.func_239132_a_().getSkyRenderHandler() instanceof ChainingSkyRenderer) {
WorldContext ctx = SkyHandler.getContext(world, LogicalSide.CLIENT);
if (ctx != null && ctx.getCelestialEventHandler().getSolarEclipse().isActiveNow()) {
float perc = ctx.getCelestialEventHandler().getSolarEclipsePercent();
perc = 0.05F + (perc * 0.95F);
event.setRed(event.getRed() * perc);
event.setGreen(event.getGreen() * perc);
event.setBlue(event.getBlue() * perc);
}
}
}
}
use of hellfirepvp.astralsorcery.common.constellation.world.WorldContext in project AstralSorcery by HellFirePvP.
the class AstralSkyRenderer method render.
@Override
public void render(int ticks, float pTicks, MatrixStack renderStack, ClientWorld world, Minecraft mc) {
if (AssetLibrary.isReloading()) {
return;
}
if (!initialized) {
initialize();
}
Vector3d color = world.getSkyColor(mc.gameRenderer.getActiveRenderInfo().getBlockPos(), pTicks);
float skyR = (float) color.x;
float skyG = (float) color.y;
float skyB = (float) color.z;
WorldContext ctx = SkyHandler.getContext(world, LogicalSide.CLIENT);
if (ctx != null && ctx.getCelestialEventHandler().getSolarEclipse().isActiveNow()) {
float perc = ctx.getCelestialEventHandler().getSolarEclipsePercent();
perc = 0.05F + (perc * 0.95F);
skyR *= perc;
skyG *= perc;
skyB *= perc;
}
// Sky
RenderSystem.disableTexture();
FogRenderer.applyFog();
RenderSystem.depthMask(false);
RenderSystem.enableFog();
RenderSystem.color4f(skyR, skyG, skyB, 1F);
this.sky.render(renderStack);
RenderSystem.disableFog();
// Sunrise/Sunset tint
RenderSystem.disableAlphaTest();
RenderSystem.enableBlend();
Blending.DEFAULT.apply();
RenderSystem.shadeModel(GL11.GL_SMOOTH);
float[] duskDawnColors = world.func_239132_a_().func_230492_a_(world.func_242415_f(pTicks), pTicks);
if (duskDawnColors != null) {
this.renderDuskDawn(duskDawnColors, renderStack, world, pTicks);
}
RenderSystem.shadeModel(GL11.GL_FLAT);
// Prep celestials
RenderSystem.enableTexture();
Blending.ADDITIVE_ALPHA.apply();
renderStack.push();
renderStack.rotate(Vector3f.YP.rotationDegrees(-90.0F));
renderStack.rotate(Vector3f.XP.rotationDegrees(world.func_242415_f(pTicks) * 360.0F));
this.renderCelestials(world, renderStack, pTicks);
this.renderStars(world, renderStack, pTicks);
renderStack.pop();
// Constellations
renderStack.push();
renderStack.rotate(Vector3f.XP.rotationDegrees(180));
renderConstellationsSky(world, renderStack, pTicks);
renderStack.pop();
RenderSystem.disableBlend();
RenderSystem.enableAlphaTest();
RenderSystem.enableFog();
// Draw horizon
RenderSystem.disableTexture();
RenderSystem.color4f(0F, 0F, 0F, 1F);
double horizonDiff = Minecraft.getInstance().player.getEyePosition(pTicks).y - world.getWorldInfo().getVoidFogHeight();
if (horizonDiff < 0D) {
renderStack.push();
renderStack.translate(0, 12, 0);
this.skyHorizon.render(renderStack);
renderStack.pop();
}
RenderSystem.color4f(1F, 1F, 1F, 1F);
RenderSystem.enableTexture();
RenderSystem.depthMask(true);
RenderSystem.disableFog();
}
use of hellfirepvp.astralsorcery.common.constellation.world.WorldContext in project AstralSorcery by HellFirePvP.
the class AstralSkyRenderer method renderCelestials.
private void renderCelestials(ClientWorld world, MatrixStack renderStack, float pTicks) {
WorldContext ctx = SkyHandler.getContext(world, LogicalSide.CLIENT);
float rainAlpha = 1F - world.getRainStrength(pTicks);
RenderSystem.color4f(1F, 1F, 1F, rainAlpha);
if (ctx != null && ctx.getCelestialEventHandler().getSolarEclipse().isActiveNow()) {
this.renderSolarEclipseSun(renderStack, ctx);
} else {
this.renderSun(renderStack);
}
if (ctx != null && ctx.getCelestialEventHandler().getLunarEclipse().isActiveNow()) {
int lunarHalf = ctx.getCelestialEventHandler().getLunarEclipse().getEventDuration() / 2;
float eclTick = ctx.getCelestialEventHandler().getLunarEclipse().getEffectTick(0F);
if (eclTick >= lunarHalf) {
// fading out
eclTick -= lunarHalf;
} else {
eclTick = lunarHalf - eclTick;
}
float perc = ((float) eclTick) / lunarHalf;
RenderSystem.color4f(1F, 0.4F + (0.6F * perc), 0.4F + (0.6F * perc), rainAlpha);
this.renderMoon(renderStack, world);
} else {
this.renderMoon(renderStack, world);
}
RenderSystem.color4f(1F, 1F, 1F, 1F);
}
Aggregations