use of hellfirepvp.astralsorcery.common.network.play.client.PktRequestPerkSealAction 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;
}
use of hellfirepvp.astralsorcery.common.network.play.client.PktRequestPerkSealAction 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;
}
Aggregations