Search in sources :

Example 1 with MoonPhase

use of hellfirepvp.astralsorcery.common.base.MoonPhase in project AstralSorcery by HellFirePvP.

the class ConstellationHandler method addConstellationCycle.

private void addConstellationCycle(IConstellation cst, Random rand, boolean[] slots) {
    if (cst instanceof IConstellationSpecialShowup) {
        return;
    }
    if (cst instanceof IMinorConstellation) {
        for (MoonPhase ph : ((IMinorConstellation) cst).getShowupMoonPhases(ctx.getSeed())) {
            this.activeMap.get(ph).add(cst);
        }
    } else {
        int start = searchForSpot(rand, slots);
        occupySlots(start, slots);
        if (getSlots(slots) <= 0) {
            Arrays.fill(slots, false);
        }
        for (int i = 0; i < 5; i++) {
            MoonPhase ph = getPhase(start + i);
            this.activeMap.get(ph).add(cst);
        }
        this.directOffsetMap.put(cst, getPhase(start));
    }
}
Also used : MoonPhase(hellfirepvp.astralsorcery.common.base.MoonPhase)

Example 2 with MoonPhase

use of hellfirepvp.astralsorcery.common.base.MoonPhase in project AstralSorcery by HellFirePvP.

the class DistributionHandler method updateDistribution.

private void updateDistribution(World world) {
    MoonPhase current = MoonPhase.fromWorld(world);
    Map<IConstellation, Float> distribution = new HashMap<>(this.dayDistributionMap.get(current.ordinal()));
    for (IConstellationSpecialShowup special : ConstellationRegistry.getSpecialShowupConstellations()) {
        if (special.doesShowUp(world, lastRecordedDay)) {
            distribution.put(special, MathHelper.clamp(special.getDistribution(world, lastRecordedDay, true), 0F, 1F));
        } else {
            distribution.put(special, MathHelper.clamp(special.getDistribution(world, lastRecordedDay, false), 0F, 1F));
        }
    }
    this.activeDistribution = distribution;
}
Also used : MoonPhase(hellfirepvp.astralsorcery.common.base.MoonPhase) HashMap(java.util.HashMap) IConstellation(hellfirepvp.astralsorcery.common.constellation.IConstellation) IConstellationSpecialShowup(hellfirepvp.astralsorcery.common.constellation.IConstellationSpecialShowup)

Example 3 with MoonPhase

use of hellfirepvp.astralsorcery.common.base.MoonPhase in project AstralSorcery by HellFirePvP.

the class DistributionHandler method initialize.

private void initialize() {
    this.dayDistributionMap.clear();
    for (MoonPhase ph : MoonPhase.values()) {
        this.dayDistributionMap.put(ph.ordinal(), Maps.newHashMap());
    }
    int phaseCount = MoonPhase.values().length;
    for (IConstellation cst : RegistriesAS.REGISTRY_CONSTELLATIONS) {
        if (cst instanceof IWeakConstellation) {
            MoonPhase offsetPhase = this.ctx.getConstellationHandler().getOffset(cst);
            // If it didn't get a mapping by the constellation handler it won't show up either.
            if (offsetPhase == null) {
                return;
            }
            int offset = offsetPhase.ordinal();
            for (MoonPhase ph : MoonPhase.values()) {
                int index = (offset + ph.ordinal()) % phaseCount;
                float distr = sineDistance(offset, index);
                dayDistributionMap.get(index).put(cst, distr);
            }
        } else {
            for (MoonPhase ph : MoonPhase.values()) {
                dayDistributionMap.get(ph.ordinal()).put(cst, 0F);
            }
        }
    }
}
Also used : MoonPhase(hellfirepvp.astralsorcery.common.base.MoonPhase) IConstellation(hellfirepvp.astralsorcery.common.constellation.IConstellation) IWeakConstellation(hellfirepvp.astralsorcery.common.constellation.IWeakConstellation)

Example 4 with MoonPhase

use of hellfirepvp.astralsorcery.common.base.MoonPhase in project AstralSorcery by HellFirePvP.

the class ScreenConstellationPaper method drawPhaseInformation.

private void drawPhaseInformation(MatrixStack renderStack) {
    if (this.phases == null) {
        this.resolvePhases();
    }
    List<MoonPhase> phases = this.phases == null ? Collections.emptyList() : this.phases;
    if (phases.isEmpty()) {
        ITextProperties text = new TranslationTextComponent("astralsorcery.journal.constellation.unknown");
        RenderingDrawUtils.renderStringCentered(Minecraft.getInstance().fontRenderer, renderStack, text, guiLeft + guiWidth / 2 + 25, guiTop + 239, 1.8F, 0xAA4D4D4D);
    } else {
        int size = 16;
        int offsetX = (width / 2) - (phases.size() * (size + 2)) / 2;
        int offsetY = guiTop + 237;
        for (int i = 0; i < phases.size(); i++) {
            phases.get(i).getTexture().bindTexture();
            RenderSystem.enableBlend();
            Blending.DEFAULT.apply();
            RenderingGuiUtils.drawRect(renderStack, offsetX + (i * (size + 2)), offsetY, this.getGuiZLevel(), size, size);
            RenderSystem.disableBlend();
        }
    }
}
Also used : MoonPhase(hellfirepvp.astralsorcery.common.base.MoonPhase) ITextProperties(net.minecraft.util.text.ITextProperties) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent)

Example 5 with MoonPhase

use of hellfirepvp.astralsorcery.common.base.MoonPhase in project AstralSorcery by HellFirePvP.

the class ConstellationHandler method updateActiveConstellations.

private void updateActiveConstellations(World world) {
    this.visibleSpecialConstellations.clear();
    MoonPhase ph = MoonPhase.fromWorld(world);
    LinkedList<IConstellation> active = new LinkedList<>(this.activeMap.computeIfAbsent(ph, p -> Lists.newLinkedList()));
    for (IConstellationSpecialShowup cst : ConstellationRegistry.getSpecialShowupConstellations()) {
        if (cst.doesShowUp(world, lastRecordedDay)) {
            this.visibleSpecialConstellations.add(cst);
        }
    }
    active.addAll(this.visibleSpecialConstellations);
    this.ctx.getActiveCelestialsHandler().updatePositions(active);
}
Also used : java.util(java.util) Lists(com.google.common.collect.Lists) GeneralConfig(hellfirepvp.astralsorcery.common.data.config.entry.GeneralConfig) MoonPhase(hellfirepvp.astralsorcery.common.base.MoonPhase) World(net.minecraft.world.World) Maps(com.google.common.collect.Maps) hellfirepvp.astralsorcery.common.constellation(hellfirepvp.astralsorcery.common.constellation) Nullable(javax.annotation.Nullable) MoonPhase(hellfirepvp.astralsorcery.common.base.MoonPhase)

Aggregations

MoonPhase (hellfirepvp.astralsorcery.common.base.MoonPhase)9 IConstellation (hellfirepvp.astralsorcery.common.constellation.IConstellation)3 WorldContext (hellfirepvp.astralsorcery.common.constellation.world.WorldContext)2 ITextProperties (net.minecraft.util.text.ITextProperties)2 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)2 World (net.minecraft.world.World)2 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 hellfirepvp.astralsorcery.common.constellation (hellfirepvp.astralsorcery.common.constellation)1 Constellation (hellfirepvp.astralsorcery.common.constellation.Constellation)1 IConstellationSpecialShowup (hellfirepvp.astralsorcery.common.constellation.IConstellationSpecialShowup)1 IWeakConstellation (hellfirepvp.astralsorcery.common.constellation.IWeakConstellation)1 ConstellationEffectProperties (hellfirepvp.astralsorcery.common.constellation.effect.ConstellationEffectProperties)1 StarLocation (hellfirepvp.astralsorcery.common.constellation.star.StarLocation)1 GeneralConfig (hellfirepvp.astralsorcery.common.data.config.entry.GeneralConfig)1 java.util (java.util)1 HashMap (java.util.HashMap)1 Nullable (javax.annotation.Nullable)1