Search in sources :

Example 1 with CPacketCloseWindow

use of net.minecraft.network.play.client.CPacketCloseWindow in project Minestuck by mraof.

the class GuiPlayerStats method openGui.

public static void openGui(boolean reload) {
    Minecraft mc = Minecraft.getMinecraft();
    if (reload || mc.currentScreen == null) {
        if (mc.currentScreen != null && mc.currentScreen instanceof GuiContainer) {
            mc.player.connection.sendPacket(new CPacketCloseWindow(mc.player.openContainer.windowId));
            mc.player.inventory.setItemStack(ItemStack.EMPTY);
        }
        if (ClientEditHandler.isActive() ? editmodeTab.isContainer : normalTab.isContainer) {
            GuiPlayerStatsContainer guiContainer = (GuiPlayerStatsContainer) (ClientEditHandler.isActive() ? editmodeTab.createGuiInstance() : normalTab.createGuiInstance());
            int ordinal = (ClientEditHandler.isActive() ? editmodeTab : normalTab).ordinal();
            guiContainer.inventorySlots.windowId = ContainerHandler.clientWindowIdStart + ordinal;
            MinestuckChannelHandler.sendToServer(MinestuckPacket.makePacket(Type.CONTAINER, ordinal));
            mc.displayGuiScreen(guiContainer);
        } else
            mc.displayGuiScreen(ClientEditHandler.isActive() ? editmodeTab.createGuiInstance() : normalTab.createGuiInstance());
    } else if (mc.currentScreen instanceof GuiPlayerStats || mc.currentScreen instanceof GuiPlayerStatsContainer)
        mc.displayGuiScreen(null);
}
Also used : GuiContainer(net.minecraft.client.gui.inventory.GuiContainer) CPacketCloseWindow(net.minecraft.network.play.client.CPacketCloseWindow) Minecraft(net.minecraft.client.Minecraft)

Example 2 with CPacketCloseWindow

use of net.minecraft.network.play.client.CPacketCloseWindow in project Minestuck by mraof.

the class GuiCaptchaDeck method actionPerformed.

@Override
protected void actionPerformed(GuiButton button) {
    if (button == this.modusButton && !container.inventory.getStackInSlot(0).isEmpty()) {
        ItemStack stack = container.inventory.getStackInSlot(0);
        if (!(stack.getItem() instanceof ItemCaptchaCard)) {
            Modus newModus = CaptchaDeckHandler.createInstance(CaptchaDeckHandler.getType(stack), Side.CLIENT);
            if (newModus != null && CaptchaDeckHandler.clientSideModus != null && newModus.getClass() != CaptchaDeckHandler.clientSideModus.getClass() && !newModus.canSwitchFrom(CaptchaDeckHandler.clientSideModus)) {
                mc.currentScreen = new GuiYesNo(this, I18n.format("gui.emptySylladex1"), I18n.format("gui.emptySylladex2"), 0) {

                    @Override
                    public void onGuiClosed() {
                        mc.currentScreen = (GuiScreen) parentScreen;
                        mc.player.closeScreen();
                    }
                };
                mc.currentScreen.setWorldAndResolution(mc, width, height);
                return;
            }
        }
        MinestuckChannelHandler.sendToServer(MinestuckPacket.makePacket(Type.CAPTCHA, CaptchaDeckPacket.MODUS));
    } else if (button == this.sylladexMap && CaptchaDeckHandler.clientSideModus != null) {
        mc.player.connection.sendPacket(new CPacketCloseWindow(mc.player.openContainer.windowId));
        mc.player.inventory.setItemStack(ItemStack.EMPTY);
        mc.displayGuiScreen(CaptchaDeckHandler.clientSideModus.getGuiHandler());
        mc.player.openContainer = mc.player.inventoryContainer;
    }
}
Also used : Modus(com.mraof.minestuck.inventory.captchalouge.Modus) GuiYesNo(net.minecraft.client.gui.GuiYesNo) ItemCaptchaCard(com.mraof.minestuck.item.ItemCaptchaCard) GuiScreen(net.minecraft.client.gui.GuiScreen) CPacketCloseWindow(net.minecraft.network.play.client.CPacketCloseWindow) ItemStack(net.minecraft.item.ItemStack)

Aggregations

CPacketCloseWindow (net.minecraft.network.play.client.CPacketCloseWindow)2 Modus (com.mraof.minestuck.inventory.captchalouge.Modus)1 ItemCaptchaCard (com.mraof.minestuck.item.ItemCaptchaCard)1 Minecraft (net.minecraft.client.Minecraft)1 GuiScreen (net.minecraft.client.gui.GuiScreen)1 GuiYesNo (net.minecraft.client.gui.GuiYesNo)1 GuiContainer (net.minecraft.client.gui.inventory.GuiContainer)1 ItemStack (net.minecraft.item.ItemStack)1