use of hellfirepvp.astralsorcery.common.constellation.ConstellationRegistry in project AstralSorcery by HellFirePvP.
the class EngravedStarMap method applyEffects.
@Nonnull
public ItemStack applyEffects(@Nonnull ItemStack stack) {
List<Tuple<EngravingEffect.ApplicableEffect, Float>> engravings = new LinkedList<>();
List<IConstellation> constellations = new LinkedList<>();
this.getConstellationKeys().stream().map(ConstellationRegistry::getConstellation).filter(Objects::nonNull).forEach(constellations::add);
for (IConstellation cst : constellations) {
EngravingEffect effect = cst.getEngravingEffect();
if (effect != null) {
List<EngravingEffect.ApplicableEffect> applicable = effect.getApplicableEffects(stack);
if (!applicable.isEmpty()) {
float distribution = this.getDistribution(cst);
for (EngravingEffect.ApplicableEffect applicableEffect : applicable) {
engravings.add(new Tuple<>(applicableEffect, distribution));
}
}
}
}
engravings.sort(Comparator.comparing(tpl -> {
EngravingEffect.ApplicableEffect effect = tpl.getA();
if (effect instanceof EngravingEffect.EnchantmentEffect) {
if (!((EngravingEffect.EnchantmentEffect) effect).isIgnoreCompatibility()) {
// Sort incompatible enchantments first since the others won't care.
return 0;
}
return 1;
}
return 2;
}));
for (Tuple<EngravingEffect.ApplicableEffect, Float> tpl : engravings) {
EngravingEffect.ApplicableEffect effect = tpl.getA();
float distribution = tpl.getB();
stack = effect.apply(stack, distribution, rand);
}
return stack;
}
use of hellfirepvp.astralsorcery.common.constellation.ConstellationRegistry in project AstralSorcery by HellFirePvP.
the class ItemTome method getStoredConstellations.
public static List<IConstellation> getStoredConstellations(ItemStack stack, PlayerEntity player) {
LinkedList<IConstellation> out = new LinkedList<>();
PlayerProgress prog = ResearchHelper.getProgress(player, player.getEntityWorld().isRemote() ? LogicalSide.CLIENT : LogicalSide.SERVER);
if (prog.isValid()) {
prog.getStoredConstellationPapers().stream().map(ConstellationRegistry::getConstellation).filter(Objects::nonNull).forEach(out::add);
}
return out;
}
Aggregations