Search in sources :

Example 1 with PktProgressionUpdate

use of hellfirepvp.astralsorcery.common.network.play.server.PktProgressionUpdate in project AstralSorcery by HellFirePvP.

the class ResearchHelper method wipeKnowledge.

public static void wipeKnowledge(ServerPlayerEntity p) {
    ResearchManager.resetPerks(p);
    wipeFile(p);
    playerProgressServer.remove(p.getUniqueID());
    PktProgressionUpdate pkt = new PktProgressionUpdate();
    PacketChannel.CHANNEL.sendToPlayer(p, pkt);
    PktSyncKnowledge pk = new PktSyncKnowledge(PktSyncKnowledge.STATE_WIPE);
    PacketChannel.CHANNEL.sendToPlayer(p, pk);
    loadPlayerKnowledge(p);
    ResearchSyncHelper.pushProgressToClientUnsafe(getProgressServer(p), p);
}
Also used : PktSyncKnowledge(hellfirepvp.astralsorcery.common.network.play.server.PktSyncKnowledge) PktProgressionUpdate(hellfirepvp.astralsorcery.common.network.play.server.PktProgressionUpdate)

Example 2 with PktProgressionUpdate

use of hellfirepvp.astralsorcery.common.network.play.server.PktProgressionUpdate in project AstralSorcery by HellFirePvP.

the class ResearchManager method maximizeTier.

public static boolean maximizeTier(PlayerEntity player) {
    PlayerProgress progress = ResearchHelper.getProgress(player, LogicalSide.SERVER);
    if (!progress.isValid())
        return false;
    progress.setTierReached(ProgressionTier.values()[ProgressionTier.values().length - 1]);
    PktProgressionUpdate pkt = new PktProgressionUpdate();
    PacketChannel.CHANNEL.sendToPlayer(player, pkt);
    ResearchSyncHelper.pushProgressToClientUnsafe(progress, player);
    ResearchHelper.savePlayerKnowledge(player);
    return true;
}
Also used : PktProgressionUpdate(hellfirepvp.astralsorcery.common.network.play.server.PktProgressionUpdate)

Example 3 with PktProgressionUpdate

use of hellfirepvp.astralsorcery.common.network.play.server.PktProgressionUpdate in project AstralSorcery by HellFirePvP.

the class ResearchManager method unsafeForceGiveResearch.

public static void unsafeForceGiveResearch(ServerPlayerEntity player, ResearchProgression prog) {
    PlayerProgress progress = ResearchHelper.getProgress(player, LogicalSide.SERVER);
    if (!progress.isValid())
        return;
    ProgressionTier reqTier = prog.getRequiredProgress();
    if (!progress.getTierReached().isThisLaterOrEqual(reqTier)) {
        progress.setTierReached(reqTier);
    }
    LinkedList<ResearchProgression> progToGive = new LinkedList<>();
    progToGive.add(prog);
    while (!progToGive.isEmpty()) {
        ResearchProgression give = progToGive.pop();
        if (!progress.hasResearch(give)) {
            progress.forceGainResearch(give);
        }
        progToGive.addAll(give.getPreConditions());
    }
    PktProgressionUpdate pkt = new PktProgressionUpdate();
    PacketChannel.CHANNEL.sendToPlayer(player, pkt);
    ResearchSyncHelper.pushProgressToClientUnsafe(progress, player);
    ResearchHelper.savePlayerKnowledge(player);
}
Also used : PktProgressionUpdate(hellfirepvp.astralsorcery.common.network.play.server.PktProgressionUpdate)

Example 4 with PktProgressionUpdate

use of hellfirepvp.astralsorcery.common.network.play.server.PktProgressionUpdate in project AstralSorcery by HellFirePvP.

the class ResearchManager method forceMaximizeResearch.

public static boolean forceMaximizeResearch(PlayerEntity player) {
    PlayerProgress progress = ResearchHelper.getProgress(player, LogicalSide.SERVER);
    if (!progress.isValid())
        return false;
    for (ResearchProgression progression : ResearchProgression.values()) {
        progress.forceGainResearch(progression);
    }
    PktProgressionUpdate pkt = new PktProgressionUpdate();
    PacketChannel.CHANNEL.sendToPlayer(player, pkt);
    ResearchSyncHelper.pushProgressToClientUnsafe(progress, player);
    ResearchHelper.savePlayerKnowledge(player);
    return true;
}
Also used : PktProgressionUpdate(hellfirepvp.astralsorcery.common.network.play.server.PktProgressionUpdate)

Example 5 with PktProgressionUpdate

use of hellfirepvp.astralsorcery.common.network.play.server.PktProgressionUpdate in project AstralSorcery by HellFirePvP.

the class ResearchManager method grantProgress.

public static boolean grantProgress(PlayerEntity player, ProgressionTier tier) {
    PlayerProgress progress = ResearchHelper.getProgress(player, LogicalSide.SERVER);
    if (!progress.isValid())
        return false;
    ProgressionTier t = progress.getTierReached();
    // No higher tier available anyway.
    if (!t.hasNextTier())
        return false;
    ProgressionTier next = t.next();
    // Given one is not the next step.
    if (!next.equals(tier))
        return false;
    progress.setTierReached(next);
    PktProgressionUpdate pkt = new PktProgressionUpdate(next);
    PacketChannel.CHANNEL.sendToPlayer(player, pkt);
    ResearchSyncHelper.pushProgressToClientUnsafe(progress, player);
    ResearchHelper.savePlayerKnowledge(player);
    return true;
}
Also used : PktProgressionUpdate(hellfirepvp.astralsorcery.common.network.play.server.PktProgressionUpdate)

Aggregations

PktProgressionUpdate (hellfirepvp.astralsorcery.common.network.play.server.PktProgressionUpdate)8 PlayerProgress (hellfirepvp.astralsorcery.common.data.research.PlayerProgress)1 ProgressionTier (hellfirepvp.astralsorcery.common.data.research.ProgressionTier)1 PktSyncKnowledge (hellfirepvp.astralsorcery.common.network.play.server.PktSyncKnowledge)1 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)1