Search in sources :

Example 1 with WorldContext

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);
    }
}
Also used : World(net.minecraft.world.World) WorldContext(hellfirepvp.astralsorcery.common.constellation.world.WorldContext) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with WorldContext

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;
}
Also used : PktPlayEffect(hellfirepvp.astralsorcery.common.network.play.server.PktPlayEffect) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) WorldContext(hellfirepvp.astralsorcery.common.constellation.world.WorldContext) IWeakConstellation(hellfirepvp.astralsorcery.common.constellation.IWeakConstellation)

Example 3 with WorldContext

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);
            }
        }
    }
}
Also used : ClientWorld(net.minecraft.client.world.ClientWorld) WorldContext(hellfirepvp.astralsorcery.common.constellation.world.WorldContext) ChainingSkyRenderer(hellfirepvp.astralsorcery.client.sky.ChainingSkyRenderer)

Example 4 with WorldContext

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();
}
Also used : Vector3d(net.minecraft.util.math.vector.Vector3d) WorldContext(hellfirepvp.astralsorcery.common.constellation.world.WorldContext)

Example 5 with WorldContext

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);
}
Also used : WorldContext(hellfirepvp.astralsorcery.common.constellation.world.WorldContext)

Aggregations

WorldContext (hellfirepvp.astralsorcery.common.constellation.world.WorldContext)20 IConstellation (hellfirepvp.astralsorcery.common.constellation.IConstellation)8 World (net.minecraft.world.World)7 StarLocation (hellfirepvp.astralsorcery.common.constellation.star.StarLocation)4 ItemStack (net.minecraft.item.ItemStack)3 PlayerAngledConstellationInformation (hellfirepvp.astralsorcery.client.screen.telescope.PlayerAngledConstellationInformation)2 MoonPhase (hellfirepvp.astralsorcery.common.base.MoonPhase)2 DrawnConstellation (hellfirepvp.astralsorcery.common.constellation.DrawnConstellation)2 EngravedStarMap (hellfirepvp.astralsorcery.common.constellation.engraving.EngravedStarMap)2 PlayerProgress (hellfirepvp.astralsorcery.common.data.research.PlayerProgress)2 ClientWorld (net.minecraft.client.world.ClientWorld)2 ServerWorld (net.minecraft.world.server.ServerWorld)2 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 RenderSystem (com.mojang.blaze3d.systems.RenderSystem)1 ClientScheduler (hellfirepvp.astralsorcery.client.ClientScheduler)1 SpritesAS (hellfirepvp.astralsorcery.client.lib.SpritesAS)1 TexturesAS (hellfirepvp.astralsorcery.client.lib.TexturesAS)1 TileEntityScreen (hellfirepvp.astralsorcery.client.screen.base.TileEntityScreen)1 FullScreenDrawArea (hellfirepvp.astralsorcery.client.screen.telescope.FullScreenDrawArea)1 TelescopeRotationDrawArea (hellfirepvp.astralsorcery.client.screen.telescope.TelescopeRotationDrawArea)1