Search in sources :

Example 1 with IMajorConstellation

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

the class ScreenJournalPerkTree method init.

@Override
protected void init() {
    super.init();
    if (this.expectReinit) {
        this.expectReinit = false;
        return;
    }
    this.guiOffsetX = guiLeft + 10;
    this.guiOffsetY = guiTop + 10;
    boolean shifted = false;
    PlayerProgress progress = ResearchHelper.getClientProgress();
    IMajorConstellation attunement = progress.getAttunedConstellation();
    if (attunement != null) {
        AbstractPerk root = PerkTree.PERK_TREE.getRootPerk(LogicalSide.CLIENT, attunement);
        if (root != null) {
            Point.Float shift = this.sizeHandler.evRelativePos(root.getOffset());
            this.moveMouse(MathHelper.floor(shift.x), MathHelper.floor(shift.y));
            shifted = true;
        }
    }
    if (!shifted) {
        this.moveMouse(MathHelper.floor(this.sizeHandler.getTotalWidth() / 2), MathHelper.floor(this.sizeHandler.getTotalHeight() / 2));
    }
    this.applyMovedMouseOffset();
}
Also used : IMajorConstellation(hellfirepvp.astralsorcery.common.constellation.IMajorConstellation) ScalingPoint(hellfirepvp.astralsorcery.client.screen.helper.ScalingPoint) PerkTreePoint(hellfirepvp.astralsorcery.common.perk.tree.PerkTreePoint) PlayerProgress(hellfirepvp.astralsorcery.common.data.research.PlayerProgress)

Example 2 with IMajorConstellation

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

the class PlayerProgress method load.

// Loading from flat-file, persistent data
public void load(CompoundNBT compound) {
    knownConstellations.clear();
    seenConstellations.clear();
    researchProgression.clear();
    storedConstellationPapers.clear();
    attunedConstellation = null;
    tierReached = ProgressionTier.DISCOVERY;
    wasOnceAttuned = false;
    tomeReceived = false;
    usePerkAbilities = true;
    if (compound.contains("seenConstellations")) {
        ListNBT list = compound.getList("seenConstellations", Constants.NBT.TAG_STRING);
        for (int i = 0; i < list.size(); i++) {
            seenConstellations.add(new ResourceLocation(list.getString(i)));
        }
    }
    if (compound.contains("constellations")) {
        ListNBT list = compound.getList("constellations", Constants.NBT.TAG_STRING);
        for (int i = 0; i < list.size(); i++) {
            ResourceLocation s = new ResourceLocation(list.getString(i));
            knownConstellations.add(s);
            if (!seenConstellations.contains(s)) {
                seenConstellations.add(s);
            }
        }
    }
    if (compound.contains("storedConstellationPapers")) {
        ListNBT list = compound.getList("storedConstellationPapers", Constants.NBT.TAG_STRING);
        for (int i = 0; i < list.size(); i++) {
            ResourceLocation s = new ResourceLocation(list.getString(i));
            storedConstellationPapers.add(s);
            if (!seenConstellations.contains(s)) {
                seenConstellations.add(s);
            }
        }
    }
    if (compound.contains("attuned")) {
        String cst = compound.getString("attuned");
        IConstellation c = ConstellationRegistry.getConstellation(new ResourceLocation(cst));
        if (!(c instanceof IMajorConstellation)) {
            AstralSorcery.log.warn("Failed to load attuned Constellation: " + cst + " - constellation doesn't exist or isn't major.");
        } else {
            attunedConstellation = (IMajorConstellation) c;
        }
    }
    this.perkData.load(this, compound);
    if (compound.contains("tierReached")) {
        int tierOrdinal = compound.getInt("tierReached");
        tierReached = MiscUtils.getEnumEntry(ProgressionTier.class, tierOrdinal);
    }
    if (compound.contains("research")) {
        int[] research = compound.getIntArray("research");
        for (int resOrdinal : research) {
            researchProgression.add(MiscUtils.getEnumEntry(ResearchProgression.class, resOrdinal));
        }
    }
    this.wasOnceAttuned = compound.getBoolean("wasAttuned");
    if (!compound.contains("bookReceived")) {
        // Legacy support for player progress files that do not have the tag yet.
        this.tomeReceived = true;
    } else {
        this.tomeReceived = compound.getBoolean("bookReceived");
    }
    if (compound.contains("usePerkAbilities")) {
        this.usePerkAbilities = compound.getBoolean("usePerkAbilities");
    }
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) IMajorConstellation(hellfirepvp.astralsorcery.common.constellation.IMajorConstellation) ResourceLocation(net.minecraft.util.ResourceLocation) IConstellation(hellfirepvp.astralsorcery.common.constellation.IConstellation)

Example 3 with IMajorConstellation

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

the class ItemShiftingStar method onItemUseFinish.

@Override
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, LivingEntity entityLiving) {
    if (!worldIn.isRemote() && entityLiving instanceof ServerPlayerEntity) {
        ServerPlayerEntity player = (ServerPlayerEntity) entityLiving;
        IMajorConstellation cst = this.getBaseConstellation();
        if (cst != null) {
            PlayerProgress prog = ResearchHelper.getProgress(player, LogicalSide.SERVER);
            if (!prog.isValid() || !prog.wasOnceAttuned() || !prog.hasConstellationDiscovered(cst)) {
                return stack;
            }
            double perkExp = prog.getPerkData().getPerkExp();
            if (ResearchManager.setAttunedConstellation(player, cst)) {
                ResearchManager.setExp(player, MathHelper.lfloor(perkExp));
                player.sendMessage(new TranslationTextComponent("astralsorcery.progress.switch.attunement").mergeStyle(TextFormatting.BLUE), Util.DUMMY_UUID);
                SoundHelper.playSoundAround(SoundEvents.BLOCK_GLASS_BREAK, worldIn, entityLiving.getPosition(), 1F, 1F);
                return ItemStack.EMPTY;
            }
        } else if (ResearchManager.setAttunedConstellation(player, null)) {
            player.sendMessage(new TranslationTextComponent("astralsorcery.progress.remove.attunement").mergeStyle(TextFormatting.BLUE), Util.DUMMY_UUID);
            SoundHelper.playSoundAround(SoundEvents.BLOCK_GLASS_BREAK, worldIn, entityLiving.getPosition(), 1F, 1F);
            return ItemStack.EMPTY;
        }
    }
    return stack;
}
Also used : IMajorConstellation(hellfirepvp.astralsorcery.common.constellation.IMajorConstellation) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) PlayerProgress(hellfirepvp.astralsorcery.common.data.research.PlayerProgress)

Example 4 with IMajorConstellation

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

the class CommandAttune method run.

@Override
public int run(CommandContext<CommandSource> context) throws CommandSyntaxException {
    PlayerEntity player = (PlayerEntity) context.getArgument("player", EntitySelector.class).selectOne(context.getSource());
    IMajorConstellation cst = (IMajorConstellation) context.getArgument("constellation", IConstellation.class);
    if (ResearchManager.setAttunedConstellation(player, cst)) {
        context.getSource().sendFeedback(new StringTextComponent("Success! Player has been attuned to ").append(cst.getConstellationName().mergeStyle(TextFormatting.BLUE)).mergeStyle(TextFormatting.GREEN), true);
    } else {
        context.getSource().sendFeedback(new StringTextComponent("Failed! Player specified doesn't seem to have the research progress necessary!").mergeStyle(TextFormatting.RED), true);
    }
    return 0;
}
Also used : IMajorConstellation(hellfirepvp.astralsorcery.common.constellation.IMajorConstellation) StringTextComponent(net.minecraft.util.text.StringTextComponent) PlayerEntity(net.minecraft.entity.player.PlayerEntity) IConstellation(hellfirepvp.astralsorcery.common.constellation.IConstellation)

Example 5 with IMajorConstellation

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

the class ItemShiftingStar method playUseEffects.

@OnlyIn(Dist.CLIENT)
private void playUseEffects(LivingEntity player, int tick, int total) {
    IMajorConstellation cst = this.getBaseConstellation();
    if (cst == null) {
        FXFacingParticle p = EffectHelper.of(EffectTemplatesAS.GENERIC_PARTICLE).spawn(Vector3.atEntityCorner(player).addY(player.getHeight() / 2)).setMotion(new Vector3(-0.1 + random.nextFloat() * 0.2, 0.01, -0.1 + random.nextFloat() * 0.2)).setScaleMultiplier(0.2F + random.nextFloat());
        if (random.nextBoolean()) {
            p.color(VFXColorFunction.WHITE);
        }
    } else {
        float percCycle = (float) ((((float) (tick % total)) / ((float) total)) * 2 * Math.PI);
        int parts = 5;
        for (int i = 0; i < parts; i++) {
            float angleSwirl = 75F;
            Vector3 center = Vector3.atEntityCorner(player).addY(player.getHeight() / 2);
            Vector3 v = Vector3.RotAxis.X_AXIS.clone();
            float originalAngle = (((float) i) / ((float) parts)) * 360F;
            double angle = originalAngle + (MathHelper.sin(percCycle) * angleSwirl);
            v.rotate(-Math.toRadians(angle), Vector3.RotAxis.Y_AXIS).normalize().multiply(4);
            Vector3 pos = center.clone().add(v);
            Vector3 mot = center.clone().subtract(pos).normalize().multiply(0.1);
            FXFacingParticle p = EffectHelper.of(EffectTemplatesAS.GENERIC_PARTICLE).spawn(pos).setScaleMultiplier(0.25F + random.nextFloat() * 0.4F).setMotion(mot).setMaxAge(50);
            if (random.nextInt(4) == 0) {
                p.color(VFXColorFunction.WHITE);
            } else if (random.nextInt(3) == 0) {
                p.color(VFXColorFunction.constant(cst.getConstellationColor().brighter()));
            } else {
                p.color(VFXColorFunction.constant(cst.getConstellationColor()));
            }
        }
    }
}
Also used : IMajorConstellation(hellfirepvp.astralsorcery.common.constellation.IMajorConstellation) FXFacingParticle(hellfirepvp.astralsorcery.client.effect.vfx.FXFacingParticle) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Aggregations

IMajorConstellation (hellfirepvp.astralsorcery.common.constellation.IMajorConstellation)8 IConstellation (hellfirepvp.astralsorcery.common.constellation.IConstellation)3 PlayerProgress (hellfirepvp.astralsorcery.common.data.research.PlayerProgress)2 Vector3 (hellfirepvp.astralsorcery.common.util.data.Vector3)2 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)2 FXFacingParticle (hellfirepvp.astralsorcery.client.effect.vfx.FXFacingParticle)1 ScalingPoint (hellfirepvp.astralsorcery.client.screen.helper.ScalingPoint)1 PlayerAngledConstellationInformation (hellfirepvp.astralsorcery.client.screen.telescope.PlayerAngledConstellationInformation)1 PerkTreePoint (hellfirepvp.astralsorcery.common.perk.tree.PerkTreePoint)1 TileCollectorCrystal (hellfirepvp.astralsorcery.common.tile.TileCollectorCrystal)1 Nullable (javax.annotation.Nullable)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 ListNBT (net.minecraft.nbt.ListNBT)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 StringTextComponent (net.minecraft.util.text.StringTextComponent)1 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)1 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)1