use of hellfirepvp.astralsorcery.common.network.play.server.PktSyncPerkActivity in project AstralSorcery by HellFirePvP.
the class ResearchManager method removeAllAllocatedPerks.
private static void removeAllAllocatedPerks(PlayerProgress progress, PlayerEntity player) {
PlayerPerkData perkData = progress.getPerkData();
List<AbstractPerk> allocatedPerks = new ArrayList<>(perkData.getAllocatedPerks(PerkAllocationType.UNLOCKED));
List<AbstractPerk> syncRemovable = new ArrayList<>();
for (AbstractPerk perk : allocatedPerks) {
if (doRemovePerk(progress, player, LogicalSide.SERVER, perk, PlayerPerkAllocation.unlock(), false)) {
syncRemovable.add(perk);
}
}
List<ResourceLocation> removals = syncRemovable.stream().map(AbstractPerk::getRegistryName).collect(Collectors.toList());
PacketChannel.CHANNEL.sendToPlayer(player, new PktSyncPerkActivity(removals));
}
use of hellfirepvp.astralsorcery.common.network.play.server.PktSyncPerkActivity in project AstralSorcery by HellFirePvP.
the class PerkEffectHelper method onPlayerConnectEvent.
public static void onPlayerConnectEvent(ServerPlayerEntity player) {
modifyAllPerks(player, LogicalSide.SERVER, Action.ADD);
// Restore current overscaled health
CompoundNBT asData = NBTHelper.getPersistentData(player);
if (asData.contains("health", Constants.NBT.TAG_FLOAT)) {
player.setHealth(asData.getFloat("health"));
}
PacketChannel.CHANNEL.sendToPlayer(player, new PktSyncPerkActivity(PktSyncPerkActivity.Type.UNLOCKALL));
}
use of hellfirepvp.astralsorcery.common.network.play.server.PktSyncPerkActivity in project AstralSorcery by HellFirePvP.
the class PerkEffectHelper method onPlayerCloneEvent.
public static void onPlayerCloneEvent(ServerPlayerEntity original, ServerPlayerEntity newPlayer) {
modifyAllPerks(original, LogicalSide.SERVER, Action.REMOVE);
modifyAllPerks(newPlayer, LogicalSide.SERVER, Action.ADD);
PerkCooldownHelper.removeAllCooldowns(original, LogicalSide.SERVER);
PacketChannel.CHANNEL.sendToPlayer(newPlayer, new PktSyncPerkActivity(PktSyncPerkActivity.Type.UNLOCKALL));
}
use of hellfirepvp.astralsorcery.common.network.play.server.PktSyncPerkActivity in project AstralSorcery by HellFirePvP.
the class ResearchManager method setPerkData.
public static boolean setPerkData(PlayerEntity player, @Nonnull AbstractPerk perk, CompoundNBT prevoiusData, CompoundNBT newData) {
PlayerProgress progress = ResearchHelper.getProgress(player, LogicalSide.SERVER);
if (!progress.isValid())
return false;
PlayerPerkData perkData = progress.getPerkData();
if (!perkData.hasPerkAllocation(perk))
return false;
PerkEffectHelper.modifySource(player, LogicalSide.SERVER, perk, PerkEffectHelper.Action.REMOVE);
progress.getPerkData().updatePerkData(perk, newData);
PerkEffectHelper.modifySource(player, LogicalSide.SERVER, perk, PerkEffectHelper.Action.ADD);
PacketChannel.CHANNEL.sendToPlayer(player, new PktSyncPerkActivity(perk, prevoiusData, newData));
ResearchSyncHelper.pushProgressToClientUnsafe(progress, player);
ResearchHelper.savePlayerKnowledge(player);
return true;
}
Aggregations