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