Search in sources :

Example 1 with IMinorConstellation

use of hellfirepvp.astralsorcery.common.constellation.IMinorConstellation 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 2 with IMinorConstellation

use of hellfirepvp.astralsorcery.common.constellation.IMinorConstellation 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 3 with IMinorConstellation

use of hellfirepvp.astralsorcery.common.constellation.IMinorConstellation 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)

Example 4 with IMinorConstellation

use of hellfirepvp.astralsorcery.common.constellation.IMinorConstellation in project AstralSorcery by HellFirePvP.

the class ScreenJournalConstellationDetail method buildRitualText.

private void buildRitualText() {
    if (this.constellation instanceof IMinorConstellation) {
        if (ResearchHelper.getClientProgress().getTierReached().isThisLaterOrEqual(ProgressionTier.TRAIT_CRAFT)) {
            ITextComponent txtRitual = ((IMinorConstellation) this.constellation).getInfoTraitEffect();
            ITextProperties headTxt = new TranslationTextComponent("astralsorcery.journal.constellation.ritual.trait");
            locTextRitual.add(localize(headTxt));
            locTextRitual.add(IReorderingProcessor.field_242232_a);
            List<IReorderingProcessor> lines = new LinkedList<>();
            for (String segment : txtRitual.getString().split("<NL>")) {
                lines.addAll(font.trimStringToWidth(new StringTextComponent(segment), JournalPage.DEFAULT_WIDTH));
                lines.add(IReorderingProcessor.field_242232_a);
            }
            locTextRitual.addAll(lines);
        }
    } else if (this.constellation instanceof IWeakConstellation) {
        if (ResearchHelper.getClientProgress().getTierReached().isThisLaterOrEqual(ProgressionTier.ATTUNEMENT)) {
            ITextComponent txtRitual = ((IWeakConstellation) this.constellation).getInfoRitualEffect();
            ITextProperties headTxt = new TranslationTextComponent("astralsorcery.journal.constellation.ritual");
            locTextRitual.add(localize(headTxt));
            locTextRitual.add(IReorderingProcessor.field_242232_a);
            List<IReorderingProcessor> lines = new LinkedList<>();
            for (String segment : txtRitual.getString().split("<NL>")) {
                lines.addAll(font.trimStringToWidth(new StringTextComponent(segment), JournalPage.DEFAULT_WIDTH));
                lines.add(IReorderingProcessor.field_242232_a);
            }
            locTextRitual.addAll(lines);
            locTextRitual.add(IReorderingProcessor.field_242232_a);
        }
        if (ResearchHelper.getClientProgress().getTierReached().isThisLaterOrEqual(ProgressionTier.TRAIT_CRAFT)) {
            ITextComponent txtCorruptedRitual = ((IWeakConstellation) this.constellation).getInfoCorruptedRitualEffect();
            ITextProperties headTxt = new TranslationTextComponent("astralsorcery.journal.constellation.corruption");
            locTextRitual.add(localize(headTxt));
            locTextRitual.add(IReorderingProcessor.field_242232_a);
            List<IReorderingProcessor> lines = new LinkedList<>();
            for (String segment : txtCorruptedRitual.getString().split("<NL>")) {
                lines.addAll(font.trimStringToWidth(new StringTextComponent(segment), JournalPage.DEFAULT_WIDTH));
                lines.add(IReorderingProcessor.field_242232_a);
            }
            locTextRitual.addAll(lines);
            locTextRitual.add(IReorderingProcessor.field_242232_a);
        }
    }
}
Also used : IReorderingProcessor(net.minecraft.util.IReorderingProcessor) ITextProperties(net.minecraft.util.text.ITextProperties) ITextComponent(net.minecraft.util.text.ITextComponent) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) IMinorConstellation(hellfirepvp.astralsorcery.common.constellation.IMinorConstellation) StringTextComponent(net.minecraft.util.text.StringTextComponent) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) LinkedList(java.util.LinkedList) IWeakConstellation(hellfirepvp.astralsorcery.common.constellation.IWeakConstellation)

Example 5 with IMinorConstellation

use of hellfirepvp.astralsorcery.common.constellation.IMinorConstellation in project AstralSorcery by HellFirePvP.

the class CEffectBootes method playEffect.

@Override
public boolean playEffect(World world, BlockPos pos, ConstellationEffectProperties properties, @Nullable IMinorConstellation trait) {
    boolean didEffect = false;
    List<LivingEntity> entities = this.collectEntities(world, pos, properties);
    Collections.shuffle(entities);
    entities.subList(0, Math.min(25, entities.size()));
    for (LivingEntity entity : entities) {
        AnimalHelper.HerdableAnimal animal = AnimalHelper.getHandler(entity);
        if (animal == null) {
            continue;
        }
        if (properties.isCorrupted()) {
            entity.hurtResistantTime = 0;
            entity.addPotionEffect(new EffectInstance(EffectsAS.EFFECT_DROP_MODIFIER, 1000, 5));
            if (DamageUtil.attackEntityFrom(entity, CommonProxy.DAMAGE_SOURCE_STELLAR, 5_000)) {
                didEffect = true;
            }
            continue;
        }
        if (rand.nextFloat() < CONFIG.herdingChance.get()) {
            didEffect = MiscUtils.executeWithChunk(world, entity.getPosition(), didEffect, (didEffectFlag) -> {
                List<ItemStack> rawDrops = EntityUtils.generateLoot(entity, rand, CommonProxy.DAMAGE_SOURCE_STELLAR, null);
                List<ItemStack> drops = new ArrayList<>();
                rawDrops.forEach(drop -> {
                    for (int i = 0; i < drop.getCount(); i++) {
                        drops.add(ItemUtils.copyStackWithSize(drop, 1));
                    }
                });
                for (ItemStack drop : drops) {
                    if (rand.nextFloat() < CONFIG.herdingLootChance.get() && ItemUtils.dropItemNaturally(world, entity.getPosX(), entity.getPosY(), entity.getPosZ(), drop) != null) {
                        didEffectFlag = true;
                    }
                }
                return didEffectFlag;
            }, false);
            sendConstellationPing(world, Vector3.atEntityCorner(entity));
        }
    }
    return didEffect;
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) TileRitualPedestal(hellfirepvp.astralsorcery.common.tile.TileRitualPedestal) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) DamageUtil(hellfirepvp.astralsorcery.common.util.DamageUtil) CommonProxy(hellfirepvp.astralsorcery.common.CommonProxy) ForgeConfigSpec(net.minecraftforge.common.ForgeConfigSpec) IMinorConstellation(hellfirepvp.astralsorcery.common.constellation.IMinorConstellation) ConstellationsAS(hellfirepvp.astralsorcery.common.lib.ConstellationsAS) PlayerAffectionFlags(hellfirepvp.astralsorcery.common.event.PlayerAffectionFlags) Dist(net.minecraftforge.api.distmarker.Dist) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) EffectInstance(net.minecraft.potion.EffectInstance) ILocatable(hellfirepvp.astralsorcery.common.util.block.ILocatable) EffectTemplatesAS(hellfirepvp.astralsorcery.client.lib.EffectTemplatesAS) MiscUtils(hellfirepvp.astralsorcery.common.util.MiscUtils) AnimalHelper(hellfirepvp.astralsorcery.common.auxiliary.AnimalHelper) ColorsAS(hellfirepvp.astralsorcery.common.lib.ColorsAS) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) VFXAlphaFunction(hellfirepvp.astralsorcery.client.effect.function.VFXAlphaFunction) LivingEntity(net.minecraft.entity.LivingEntity) World(net.minecraft.world.World) BlockPos(net.minecraft.util.math.BlockPos) ConstellationEffectEntityCollect(hellfirepvp.astralsorcery.common.constellation.effect.base.ConstellationEffectEntityCollect) EffectHelper(hellfirepvp.astralsorcery.client.effect.handler.EffectHelper) EntityUtils(hellfirepvp.astralsorcery.common.util.entity.EntityUtils) List(java.util.List) VFXColorFunction(hellfirepvp.astralsorcery.client.effect.function.VFXColorFunction) EffectsAS(hellfirepvp.astralsorcery.common.lib.EffectsAS) ItemUtils(hellfirepvp.astralsorcery.common.util.item.ItemUtils) Collections(java.util.Collections) ConstellationEffectProperties(hellfirepvp.astralsorcery.common.constellation.effect.ConstellationEffectProperties) ArrayList(java.util.ArrayList) List(java.util.List) ItemStack(net.minecraft.item.ItemStack) AnimalHelper(hellfirepvp.astralsorcery.common.auxiliary.AnimalHelper) EffectInstance(net.minecraft.potion.EffectInstance)

Aggregations

IMinorConstellation (hellfirepvp.astralsorcery.common.constellation.IMinorConstellation)12 IWeakConstellation (hellfirepvp.astralsorcery.common.constellation.IWeakConstellation)8 ItemStack (net.minecraft.item.ItemStack)6 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)6 ConstellationItem (hellfirepvp.astralsorcery.common.constellation.ConstellationItem)4 ConstellationEffectProperties (hellfirepvp.astralsorcery.common.constellation.effect.ConstellationEffectProperties)4 Vector3 (hellfirepvp.astralsorcery.common.util.data.Vector3)4 CompoundNBT (net.minecraft.nbt.CompoundNBT)4 VFXColorFunction (hellfirepvp.astralsorcery.client.effect.function.VFXColorFunction)3 EffectHelper (hellfirepvp.astralsorcery.client.effect.handler.EffectHelper)3 EffectTemplatesAS (hellfirepvp.astralsorcery.client.lib.EffectTemplatesAS)3 PlayerAffectionFlags (hellfirepvp.astralsorcery.common.event.PlayerAffectionFlags)3 ColorsAS (hellfirepvp.astralsorcery.common.lib.ColorsAS)3 ConstellationsAS (hellfirepvp.astralsorcery.common.lib.ConstellationsAS)3 TileRitualPedestal (hellfirepvp.astralsorcery.common.tile.TileRitualPedestal)3 MiscUtils (hellfirepvp.astralsorcery.common.util.MiscUtils)3 ILocatable (hellfirepvp.astralsorcery.common.util.block.ILocatable)3 ItemUtils (hellfirepvp.astralsorcery.common.util.item.ItemUtils)3 List (java.util.List)3 Nonnull (javax.annotation.Nonnull)3