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