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