Search in sources :

Example 1 with SimplePageView

use of com.almuradev.almura.feature.guide.client.gui.SimplePageView in project Almura by AlmuraDev.

the class ClientboundPageChangeResponsePacketHandler method handleMessage.

@SideOnly(Side.CLIENT)
@Override
public void handleMessage(ClientboundPageChangeResponsePacket message, RemoteConnection connection, Platform.Type side) {
    if (side.isClient() && message.success) {
        final Minecraft client = Minecraft.getMinecraft();
        if (PacketUtil.checkThreadAndEnqueue(client, message, this, connection, side)) {
            final GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen;
            if (currentScreen != null && currentScreen instanceof SimplePageView) {
                if (message.changeType == PageChangeType.REMOVE) {
                    ((SimplePageView) currentScreen).close();
                    manager.network.sendToServer(new ServerboundGuideOpenRequestPacket());
                } else {
                    ((SimplePageView) currentScreen).refreshPage();
                }
            }
        }
    }
}
Also used : GuiScreen(net.minecraft.client.gui.GuiScreen) Minecraft(net.minecraft.client.Minecraft) SimplePageView(com.almuradev.almura.feature.guide.client.gui.SimplePageView) ServerboundGuideOpenRequestPacket(com.almuradev.almura.feature.guide.network.ServerboundGuideOpenRequestPacket) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with SimplePageView

use of com.almuradev.almura.feature.guide.client.gui.SimplePageView in project Almura by AlmuraDev.

the class ClientboundPageOpenResponsePacketHandler method handleMessage.

@Override
public void handleMessage(ClientboundPageOpenResponsePacket message, RemoteConnection connection, Platform.Type side) {
    if (side.isClient()) {
        final Minecraft client = Minecraft.getMinecraft();
        if (PacketUtil.checkThreadAndEnqueue(client, message, this, connection, side)) {
            this.manager.setPage(message.page);
            SimplePageView view = null;
            final GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen;
            if (currentScreen instanceof UIMessageBox.MessageBoxDialogScreen && ((UIMessageBox.MessageBoxDialogScreen) currentScreen).getParent() instanceof SimplePageView) {
                view = (SimplePageView) ((UIMessageBox.MessageBoxDialogScreen) currentScreen).getParent();
            } else if (currentScreen instanceof SimplePageView) {
                view = (SimplePageView) currentScreen;
            }
            if (view != null) {
                view.refreshPage();
            }
        }
    }
}
Also used : UIMessageBox(com.almuradev.almura.shared.client.ui.component.dialog.UIMessageBox) GuiScreen(net.minecraft.client.gui.GuiScreen) Minecraft(net.minecraft.client.Minecraft) SimplePageView(com.almuradev.almura.feature.guide.client.gui.SimplePageView)

Example 3 with SimplePageView

use of com.almuradev.almura.feature.guide.client.gui.SimplePageView in project Almura by AlmuraDev.

the class ClientboundPageListingsPacketHandler method handleMessage.

@Override
public void handleMessage(ClientboundPageListingsPacket message, RemoteConnection connection, Platform.Type side) {
    if (side.isClient()) {
        final Minecraft client = Minecraft.getMinecraft();
        if (PacketUtil.checkThreadAndEnqueue(client, message, this, connection, side)) {
            this.manager.setPageEntries(message.pageEntries, message.switchToPageId);
            SimplePageView view = null;
            final GuiScreen currentScreen = client.currentScreen;
            if (currentScreen instanceof UIMessageBox.MessageBoxDialogScreen && ((UIMessageBox.MessageBoxDialogScreen) currentScreen).getParent() instanceof SimplePageView) {
                view = (SimplePageView) ((UIMessageBox.MessageBoxDialogScreen) currentScreen).getParent();
            } else if (currentScreen instanceof SimplePageView) {
                view = (SimplePageView) currentScreen;
            }
            if (view != null) {
                view.refreshPageEntries(message.switchToPageId);
            }
        }
    }
}
Also used : UIMessageBox(com.almuradev.almura.shared.client.ui.component.dialog.UIMessageBox) GuiScreen(net.minecraft.client.gui.GuiScreen) Minecraft(net.minecraft.client.Minecraft) SimplePageView(com.almuradev.almura.feature.guide.client.gui.SimplePageView)

Aggregations

SimplePageView (com.almuradev.almura.feature.guide.client.gui.SimplePageView)3 Minecraft (net.minecraft.client.Minecraft)3 GuiScreen (net.minecraft.client.gui.GuiScreen)3 UIMessageBox (com.almuradev.almura.shared.client.ui.component.dialog.UIMessageBox)2 ServerboundGuideOpenRequestPacket (com.almuradev.almura.feature.guide.network.ServerboundGuideOpenRequestPacket)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1