use of hellfirepvp.astralsorcery.common.network.play.client.PktUnlockPerk in project AstralSorcery by HellFirePvP.
the class ScreenJournalPerkTree method mouseReleased.
@Override
public boolean mouseReleased(double mouseX, double mouseY, int state) {
if (super.mouseReleased(mouseX, mouseY, state)) {
return true;
}
PlayerEntity player = Minecraft.getInstance().player;
if (!this.mouseSealStack.isEmpty()) {
this.mouseSealStack = ItemStack.EMPTY;
if (Minecraft.getInstance().player == null) {
return false;
}
PlayerPerkData perkData = ResearchHelper.getClientProgress().getPerkData();
for (Map.Entry<AbstractPerk, Rectangle.Float> rctPerk : this.thisFramePerks.entrySet()) {
if (rctPerk.getValue().contains(mouseX, mouseY) && this.guiBox.isInBox(mouseX - guiLeft, mouseY - guiTop)) {
if (perkData.hasPerkEffect(rctPerk.getKey()) && !perkData.isPerkSealed(rctPerk.getKey()) && ItemPerkSeal.useSeal(player, true)) {
PktRequestPerkSealAction pkt = new PktRequestPerkSealAction(rctPerk.getKey(), true);
PacketChannel.CHANNEL.sendToServer(pkt);
return true;
}
}
}
}
if (this.unlockPrimed == null) {
return false;
}
for (Map.Entry<AbstractPerk, Rectangle.Float> rctPerk : this.thisFramePerks.entrySet()) {
if (this.unlockPrimed.equals(rctPerk.getKey()) && rctPerk.getValue().contains(mouseX, mouseY) && this.guiBox.isInBox(mouseX - guiLeft, mouseY - guiTop)) {
AbstractPerk perk = rctPerk.getKey();
PlayerProgress prog = ResearchHelper.getClientProgress();
PlayerPerkData perkData = prog.getPerkData();
if (!perkData.hasPerkAllocation(perk) && perk.mayUnlockPerk(prog, player)) {
PktUnlockPerk pkt = new PktUnlockPerk(false, rctPerk.getKey());
PacketChannel.CHANNEL.sendToServer(pkt);
break;
}
}
}
this.unlockPrimed = null;
return true;
}
Aggregations