Search in sources :

Example 1 with IWeakConstellation

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;
}
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 2 with IWeakConstellation

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;
}
Also used : ItemCrystalBase(hellfirepvp.astralsorcery.common.item.crystal.ItemCrystalBase) IMinorConstellation(hellfirepvp.astralsorcery.common.constellation.IMinorConstellation) ItemStack(net.minecraft.item.ItemStack) ConstellationItem(hellfirepvp.astralsorcery.common.constellation.ConstellationItem) IWeakConstellation(hellfirepvp.astralsorcery.common.constellation.IWeakConstellation)

Example 3 with IWeakConstellation

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());
                }
            }
        }
    }
}
Also used : ItemEntity(net.minecraft.entity.item.ItemEntity) CompoundNBT(net.minecraft.nbt.CompoundNBT) ItemCrystalBase(hellfirepvp.astralsorcery.common.item.crystal.ItemCrystalBase) IMinorConstellation(hellfirepvp.astralsorcery.common.constellation.IMinorConstellation) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) ItemStack(net.minecraft.item.ItemStack) UUID(java.util.UUID) ConstellationItem(hellfirepvp.astralsorcery.common.constellation.ConstellationItem) IWeakConstellation(hellfirepvp.astralsorcery.common.constellation.IWeakConstellation) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity)

Example 4 with IWeakConstellation

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);
            }
        }
    }
}
Also used : MoonPhase(hellfirepvp.astralsorcery.common.base.MoonPhase) IConstellation(hellfirepvp.astralsorcery.common.constellation.IConstellation) IWeakConstellation(hellfirepvp.astralsorcery.common.constellation.IWeakConstellation)

Example 5 with IWeakConstellation

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IMinorConstellation(hellfirepvp.astralsorcery.common.constellation.IMinorConstellation) ConstellationTile(hellfirepvp.astralsorcery.common.constellation.ConstellationTile) ConstellationItem(hellfirepvp.astralsorcery.common.constellation.ConstellationItem) IWeakConstellation(hellfirepvp.astralsorcery.common.constellation.IWeakConstellation)

Aggregations

IWeakConstellation (hellfirepvp.astralsorcery.common.constellation.IWeakConstellation)24 IConstellation (hellfirepvp.astralsorcery.common.constellation.IConstellation)9 ItemStack (net.minecraft.item.ItemStack)9 IMinorConstellation (hellfirepvp.astralsorcery.common.constellation.IMinorConstellation)8 ConstellationItem (hellfirepvp.astralsorcery.common.constellation.ConstellationItem)4 CrystalAttributes (hellfirepvp.astralsorcery.common.crystal.CrystalAttributes)4 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)4 BlockTransmutation (hellfirepvp.astralsorcery.common.crafting.recipe.BlockTransmutation)3 BlockState (net.minecraft.block.BlockState)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 PlayerProgress (hellfirepvp.astralsorcery.common.data.research.PlayerProgress)2 ProgressionTier (hellfirepvp.astralsorcery.common.data.research.ProgressionTier)2 ItemCrystalBase (hellfirepvp.astralsorcery.common.item.crystal.ItemCrystalBase)2 BlockMatchInformation (hellfirepvp.astralsorcery.common.util.block.BlockMatchInformation)2 Vector3 (hellfirepvp.astralsorcery.common.util.data.Vector3)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Nullable (javax.annotation.Nullable)2 CompoundNBT (net.minecraft.nbt.CompoundNBT)2