Search in sources :

Example 1 with ItemCaptchaCard

use of com.mraof.minestuck.item.ItemCaptchaCard 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

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