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;
}
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());
}
}
}
}
}
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;
}
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;
}
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));
}
}
}
}
Aggregations