Search in sources :

Example 1 with GemSocketPerk

use of hellfirepvp.astralsorcery.common.perk.node.socket.GemSocketPerk in project AstralSorcery by HellFirePvP.

the class ScreenJournalPerkTree method mouseClicked.

@Override
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
    if (super.mouseClicked(mouseX, mouseY, mouseButton)) {
        return true;
    }
    Minecraft mc = Minecraft.getInstance();
    if (socketMenu != null && (mouseButton == 0 || mouseButton == 1) && rSocketMenu != null && !rSocketMenu.contains(mouseX, mouseY)) {
        closeSocketMenu();
    }
    if (mouseButton == 0) {
        if (socketMenu != null) {
            for (Rectangle.Float r : slotsSocketMenu.keySet()) {
                if (r.contains(mouseX, mouseY) && !socketMenu.hasItem(mc.player, LogicalSide.CLIENT)) {
                    int slotId = slotsSocketMenu.get(r);
                    if (tryInsertGem(slotId, socketMenu)) {
                        return true;
                    }
                }
            }
        }
        if (handleBookmarkClick(mouseX, mouseY)) {
            return true;
        }
        if (rectSealBox.contains(mouseX - guiLeft, mouseY - guiTop)) {
            if (!this.foundSeals.isEmpty()) {
                this.mouseSealStack = new ItemStack(ItemsAS.PERK_SEAL);
            }
            return true;
        }
        if (rStatStar.contains(mouseX, mouseY)) {
            this.expectReinit = true;
            mc.displayGuiScreen(new ScreenJournalOverlayPerkStatistics(this));
            return true;
        }
    }
    PlayerProgress prog = ResearchHelper.getClientProgress();
    PlayerPerkData perkData = prog.getPerkData();
    for (Map.Entry<AbstractPerk, Rectangle.Float> rctPerk : this.thisFramePerks.entrySet()) {
        if (rctPerk.getValue().contains(mouseX, mouseY) && this.guiBox.isInBox(mouseX - guiLeft, mouseY - guiTop)) {
            AbstractPerk perk = rctPerk.getKey();
            if (mouseButton == 0 && mc.gameSettings.showDebugInfo && hasControlDown()) {
                String perkKey = perk.getRegistryName().toString();
                Minecraft.getInstance().keyboardListener.setClipboardString(perkKey);
                mc.player.sendMessage(new TranslationTextComponent("astralsorcery.misc.ctrlcopy.copied", perkKey), Util.DUMMY_UUID);
                break;
            }
            if (mouseButton == 1) {
                if (perkData.hasPerkEffect(perk) && perk instanceof GemSocketPerk) {
                    if (((GemSocketPerk) perk).hasItem(mc.player, LogicalSide.CLIENT)) {
                        PktPerkGemModification pkt = PktPerkGemModification.dropItem(perk);
                        PacketChannel.CHANNEL.sendToServer(pkt);
                        AstralSorcery.getProxy().scheduleClientside(() -> {
                            if (mc.currentScreen == this) {
                                // Only if user hasn't closed
                                updateSearchHighlight();
                            }
                        }, 10);
                        SoundHelper.playSoundClient(SoundEvents.BLOCK_GLASS_PLACE, .35F, 9f);
                    } else {
                        this.socketMenu = (GemSocketPerk) perk;
                    }
                    return true;
                }
            } else if (mouseButton == 0) {
                if (perk.handleMouseClick(this, mouseX, mouseY)) {
                    return true;
                }
                if (!perkData.hasPerkAllocation(perk) && perk.mayUnlockPerk(prog, mc.player)) {
                    this.unlockPrimed = perk;
                } else if (this.sealBreakPrimed != null && this.tickSealBreak > 0) {
                    PktRequestPerkSealAction pkt = new PktRequestPerkSealAction(perk, false);
                    PacketChannel.CHANNEL.sendToServer(pkt);
                } else if (prog.getPerkData().isPerkSealed(perk)) {
                    this.sealBreakPrimed = perk;
                    this.tickSealBreak = 4;
                }
                return true;
            }
        }
    }
    return false;
}
Also used : PlayerPerkData(hellfirepvp.astralsorcery.common.data.research.PlayerPerkData) GemSocketPerk(hellfirepvp.astralsorcery.common.perk.node.socket.GemSocketPerk) Minecraft(net.minecraft.client.Minecraft) ScalingPoint(hellfirepvp.astralsorcery.client.screen.helper.ScalingPoint) PerkTreePoint(hellfirepvp.astralsorcery.common.perk.tree.PerkTreePoint) PlayerProgress(hellfirepvp.astralsorcery.common.data.research.PlayerProgress) ItemStack(net.minecraft.item.ItemStack) PktRequestPerkSealAction(hellfirepvp.astralsorcery.common.network.play.client.PktRequestPerkSealAction) ScreenJournalOverlayPerkStatistics(hellfirepvp.astralsorcery.client.screen.journal.overlay.ScreenJournalOverlayPerkStatistics) PktPerkGemModification(hellfirepvp.astralsorcery.common.network.play.client.PktPerkGemModification)

Aggregations

ScalingPoint (hellfirepvp.astralsorcery.client.screen.helper.ScalingPoint)1 ScreenJournalOverlayPerkStatistics (hellfirepvp.astralsorcery.client.screen.journal.overlay.ScreenJournalOverlayPerkStatistics)1 PlayerPerkData (hellfirepvp.astralsorcery.common.data.research.PlayerPerkData)1 PlayerProgress (hellfirepvp.astralsorcery.common.data.research.PlayerProgress)1 PktPerkGemModification (hellfirepvp.astralsorcery.common.network.play.client.PktPerkGemModification)1 PktRequestPerkSealAction (hellfirepvp.astralsorcery.common.network.play.client.PktRequestPerkSealAction)1 GemSocketPerk (hellfirepvp.astralsorcery.common.perk.node.socket.GemSocketPerk)1 PerkTreePoint (hellfirepvp.astralsorcery.common.perk.tree.PerkTreePoint)1 Minecraft (net.minecraft.client.Minecraft)1 ItemStack (net.minecraft.item.ItemStack)1