Search in sources :

Example 1 with ConstellationItem

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

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

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

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

the class BlockCrystalContainer method getPickBlock.

@Override
public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos, PlayerEntity player) {
    ItemStack stack = super.getPickBlock(state, target, world, pos, player);
    if (stack.getItem() instanceof CrystalAttributeItem) {
        CrystalAttributeTile cat = MiscUtils.getTileAt(world, pos, CrystalAttributeTile.class, true);
        if (cat != null) {
            ((CrystalAttributeItem) stack.getItem()).setAttributes(stack, cat.getAttributes());
        }
    }
    if (stack.getItem() instanceof ConstellationItem) {
        ConstellationTile ct = MiscUtils.getTileAt(world, pos, ConstellationTile.class, true);
        if (ct != null) {
            ((ConstellationItem) stack.getItem()).setAttunedConstellation(stack, ct.getAttunedConstellation());
            ((ConstellationItem) stack.getItem()).setTraitConstellation(stack, ct.getTraitConstellation());
        }
    }
    return stack;
}
Also used : ItemStack(net.minecraft.item.ItemStack) CrystalAttributeItem(hellfirepvp.astralsorcery.common.crystal.CrystalAttributeItem) CrystalAttributeTile(hellfirepvp.astralsorcery.common.crystal.CrystalAttributeTile) ConstellationItem(hellfirepvp.astralsorcery.common.constellation.ConstellationItem) ConstellationTile(hellfirepvp.astralsorcery.common.constellation.ConstellationTile)

Example 5 with ConstellationItem

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

the class BlockCollectorCrystal method addInformation.

@Override
@OnlyIn(Dist.CLIENT)
public void addInformation(ItemStack stack, @Nullable IBlockReader world, List<ITextComponent> toolTip, ITooltipFlag flag) {
    super.addInformation(stack, world, toolTip, flag);
    CrystalAttributes attr = CrystalAttributes.getCrystalAttributes(stack);
    CrystalAttributes.TooltipResult result = null;
    if (attr != null) {
        result = attr.addTooltip(toolTip, CalculationContext.Builder.withSource(new AttunedSourceInstance(CrystalPropertiesAS.Sources.SOURCE_TILE_COLLECTOR_CRYSTAL, ((ConstellationItem) stack.getItem()).getAttunedConstellation(stack))).addUsage(CrystalPropertiesAS.Usages.USE_COLLECTOR_CRYSTAL).addUsage(CrystalPropertiesAS.Usages.USE_LENS_TRANSFER).build());
    }
    if (result != null) {
        PlayerProgress clientProgress = ResearchHelper.getClientProgress();
        ProgressionTier tier = clientProgress.getTierReached();
        boolean addedMissing = result != CrystalAttributes.TooltipResult.ADDED_ALL;
        IWeakConstellation c = ((ConstellationItem) stack.getItem()).getAttunedConstellation(stack);
        if (c != null) {
            if (GatedKnowledge.COLLECTOR_TYPE.canSee(tier) && clientProgress.hasConstellationDiscovered(c)) {
                toolTip.add(new TranslationTextComponent("crystal.info.astralsorcery.collect.type", c.getConstellationName().mergeStyle(TextFormatting.BLUE)).mergeStyle(TextFormatting.GRAY));
            } else if (!addedMissing) {
                toolTip.add(new TranslationTextComponent("astralsorcery.progress.missing.knowledge").mergeStyle(TextFormatting.GRAY));
            }
        }
        IMinorConstellation tr = ((ConstellationItem) stack.getItem()).getTraitConstellation(stack);
        if (tr != null) {
            if (GatedKnowledge.CRYSTAL_TRAIT.canSee(tier) && clientProgress.hasConstellationDiscovered(tr)) {
                toolTip.add(new TranslationTextComponent("crystal.info.astralsorcery.trait", tr.getConstellationName().mergeStyle(TextFormatting.BLUE)).mergeStyle(TextFormatting.GRAY));
            } else if (!addedMissing) {
                toolTip.add(new TranslationTextComponent("astralsorcery.progress.missing.knowledge").mergeStyle(TextFormatting.GRAY));
            }
        }
    }
}
Also used : CrystalAttributes(hellfirepvp.astralsorcery.common.crystal.CrystalAttributes) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) AttunedSourceInstance(hellfirepvp.astralsorcery.common.crystal.source.AttunedSourceInstance) IMinorConstellation(hellfirepvp.astralsorcery.common.constellation.IMinorConstellation) PlayerProgress(hellfirepvp.astralsorcery.common.data.research.PlayerProgress) ProgressionTier(hellfirepvp.astralsorcery.common.data.research.ProgressionTier) IWeakConstellation(hellfirepvp.astralsorcery.common.constellation.IWeakConstellation) ConstellationItem(hellfirepvp.astralsorcery.common.constellation.ConstellationItem) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Aggregations

ConstellationItem (hellfirepvp.astralsorcery.common.constellation.ConstellationItem)6 IMinorConstellation (hellfirepvp.astralsorcery.common.constellation.IMinorConstellation)4 IWeakConstellation (hellfirepvp.astralsorcery.common.constellation.IWeakConstellation)4 ConstellationTile (hellfirepvp.astralsorcery.common.constellation.ConstellationTile)3 ItemStack (net.minecraft.item.ItemStack)3 CrystalAttributeItem (hellfirepvp.astralsorcery.common.crystal.CrystalAttributeItem)2 CrystalAttributeTile (hellfirepvp.astralsorcery.common.crystal.CrystalAttributeTile)2 ItemCrystalBase (hellfirepvp.astralsorcery.common.item.crystal.ItemCrystalBase)2 CrystalAttributes (hellfirepvp.astralsorcery.common.crystal.CrystalAttributes)1 AttunedSourceInstance (hellfirepvp.astralsorcery.common.crystal.source.AttunedSourceInstance)1 PlayerProgress (hellfirepvp.astralsorcery.common.data.research.PlayerProgress)1 ProgressionTier (hellfirepvp.astralsorcery.common.data.research.ProgressionTier)1 UUID (java.util.UUID)1 ItemEntity (net.minecraft.entity.item.ItemEntity)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)1 Item (net.minecraft.item.Item)1 CompoundNBT (net.minecraft.nbt.CompoundNBT)1 TileEntity (net.minecraft.tileentity.TileEntity)1 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)1