use of hellfirepvp.astralsorcery.common.constellation.IWeakConstellation 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.IWeakConstellation in project AstralSorcery by HellFirePvP.
the class AttuneCrystalRecipe method isApplicableCrystal.
public static boolean isApplicableCrystal(ItemEntity entity, IConstellation cst) {
ItemStack stack;
if (entity.isAlive() && !(stack = entity.getItem()).isEmpty() && stack.getItem() instanceof ItemCrystalBase) {
if (!(stack.getItem() instanceof ConstellationItem)) {
return cst instanceof IWeakConstellation;
} else {
IWeakConstellation attuned = ((ConstellationItem) stack.getItem()).getAttunedConstellation(stack);
IMinorConstellation trait = ((ConstellationItem) stack.getItem()).getTraitConstellation(stack);
if (attuned == null && cst instanceof IWeakConstellation) {
return true;
} else if (trait == null && cst instanceof IMinorConstellation) {
return true;
}
}
}
return false;
}
use of hellfirepvp.astralsorcery.common.constellation.IWeakConstellation in project AstralSorcery by HellFirePvP.
the class ActiveCrystalAttunementRecipe method finishRecipe.
@Override
public void finishRecipe(TileAttunementAltar altar) {
ItemEntity crystal = this.getEntity(altar.getWorld());
if (crystal != null) {
ItemStack stack = crystal.getItem();
if (!(stack.getItem() instanceof ConstellationItem) && stack.getItem() instanceof ItemCrystalBase) {
CompoundNBT tag = stack.getTag();
stack = new ItemStack(((ItemCrystalBase) stack.getItem()).getTunedItemVariant(), stack.getCount());
stack.setTag(tag);
}
if (stack.getItem() instanceof ConstellationItem) {
IWeakConstellation attuned = ((ConstellationItem) stack.getItem()).getAttunedConstellation(stack);
IMinorConstellation trait = ((ConstellationItem) stack.getItem()).getTraitConstellation(stack);
if (attuned == null) {
if (altar.getActiveConstellation() instanceof IWeakConstellation) {
((ConstellationItem) stack.getItem()).setAttunedConstellation(stack, (IWeakConstellation) altar.getActiveConstellation());
}
} else if (trait == null) {
if (altar.getActiveConstellation() instanceof IMinorConstellation) {
((ConstellationItem) stack.getItem()).setTraitConstellation(stack, (IMinorConstellation) altar.getActiveConstellation());
}
}
crystal.setItem(stack);
UUID throwerUUID = crystal.getThrowerId();
if (throwerUUID != null) {
PlayerEntity thrower = altar.getWorld().getPlayerByUuid(throwerUUID);
if (thrower instanceof ServerPlayerEntity) {
AdvancementsAS.ATTUNE_CRYSTAL.trigger((ServerPlayerEntity) thrower, altar.getActiveConstellation());
}
}
}
}
}
use of hellfirepvp.astralsorcery.common.constellation.IWeakConstellation 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.constellation.IWeakConstellation in project AstralSorcery by HellFirePvP.
the class CopyConstellation method doApply.
@Override
protected ItemStack doApply(ItemStack stack, LootContext context) {
if (context.has(LootParameters.BLOCK_ENTITY)) {
TileEntity tile = context.get(LootParameters.BLOCK_ENTITY);
if (tile instanceof ConstellationTile && stack.getItem() instanceof ConstellationItem) {
IWeakConstellation main = ((ConstellationTile) tile).getAttunedConstellation();
IMinorConstellation trait = ((ConstellationTile) tile).getTraitConstellation();
((ConstellationItem) stack.getItem()).setAttunedConstellation(stack, main);
((ConstellationItem) stack.getItem()).setTraitConstellation(stack, trait);
}
}
return stack;
}
Aggregations