Java Code Examples for net.minecraft.client.Minecraft#displayGuiScreen()

The following examples show how to use net.minecraft.client.Minecraft#displayGuiScreen() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HudEditorModule.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onToggle() {
    super.onToggle();
    final Minecraft mc = Minecraft.getMinecraft();

    if (mc.world != null) {
        mc.displayGuiScreen(new GuiHudEditor());

        if(this.blur.getValue()) {
            if (OpenGlHelper.shadersSupported) {
                mc.entityRenderer.loadShader(new ResourceLocation("minecraft", "shaders/post/blur.json"));
            }
        }
        this.open = true;
    }
}
 
Example 2
Source File: DisconnectCommand.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void exec(String input) {
    if (!this.clamp(input, 1, 1)) {
        this.printUsage();
        return;
    }

    final Minecraft mc = Minecraft.getMinecraft();

    boolean flag = mc.isIntegratedServerRunning();
    boolean flag1 = mc.isConnectedToRealms();
    mc.world.sendQuittingDisconnectingPacket();
    mc.loadWorld(null);

    if (flag) {
        mc.displayGuiScreen(new GuiMainMenu());
    }
    else if (flag1) {
        RealmsBridge realmsbridge = new RealmsBridge();
        realmsbridge.switchToRealms(new GuiMainMenu());
    } else {
        mc.displayGuiScreen(new GuiMultiplayer(new GuiMainMenu()));
    }
}
 
Example 3
Source File: GuiCraftingRecipe.java    From NotEnoughItems with MIT License 6 votes vote down vote up
public static boolean openRecipeGui(String outputId, Object... results) {
    Minecraft mc = Minecraft.getMinecraft();
    GuiContainer prevscreen = mc.currentScreen instanceof GuiContainer ? (GuiContainer) mc.currentScreen : null;

    TaskProfiler profiler = ProfilerRecipeHandler.getProfiler();
    ArrayList<ICraftingHandler> handlers = new ArrayList<>();
    for (ICraftingHandler craftinghandler : craftinghandlers) {
        profiler.start(craftinghandler.getRecipeName());
        ICraftingHandler handler = craftinghandler.getRecipeHandler(outputId, results);
        if (handler.numRecipes() > 0) {
            handlers.add(handler);
        }
    }
    profiler.end();
    if (handlers.isEmpty()) {
        return false;
    }

    mc.displayGuiScreen(new GuiCraftingRecipe(prevscreen, handlers));
    return true;
}
 
Example 4
Source File: GuiUsageRecipe.java    From NotEnoughItems with MIT License 6 votes vote down vote up
public static boolean openRecipeGui(String inputId, Object... ingredients) {
    Minecraft mc = Minecraft.getMinecraft();
    GuiContainer prevscreen = mc.currentScreen instanceof GuiContainer ? (GuiContainer) mc.currentScreen : null;

    TaskProfiler profiler = ProfilerRecipeHandler.getProfiler();
    ArrayList<IUsageHandler> handlers = new ArrayList<IUsageHandler>();
    for (IUsageHandler usagehandler : usagehandlers) {
        profiler.start(usagehandler.getRecipeName());
        IUsageHandler handler = usagehandler.getUsageHandler(inputId, ingredients);
        if (handler.numRecipes() > 0)
            handlers.add(handler);
    }
    profiler.end();
    if (handlers.isEmpty())
        return false;

    mc.displayGuiScreen(new GuiUsageRecipe(prevscreen, handlers));
    return true;
}
 
Example 5
Source File: GuiCraftingRecipe.java    From NotEnoughItems with MIT License 6 votes vote down vote up
public static boolean openRecipeGui(String outputId, Object... results) {
    Minecraft mc = Minecraft.getMinecraft();
    GuiContainer prevscreen = mc.currentScreen instanceof GuiContainer ? (GuiContainer) mc.currentScreen : null;

    TaskProfiler profiler = ProfilerRecipeHandler.getProfiler();
    ArrayList<ICraftingHandler> handlers = new ArrayList<ICraftingHandler>();
    for (ICraftingHandler craftinghandler : craftinghandlers) {
        profiler.start(craftinghandler.getRecipeName());
        ICraftingHandler handler = craftinghandler.getRecipeHandler(outputId, results);
        if (handler.numRecipes() > 0)
            handlers.add(handler);
    }
    profiler.end();
    if (handlers.isEmpty())
        return false;

    mc.displayGuiScreen(new GuiCraftingRecipe(prevscreen, handlers));
    return true;
}
 
Example 6
Source File: GodModeModule.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
@Listener
public void onUpdate(EventPlayerUpdate event) {
    if (event.getStage() == EventStageable.EventStage.PRE) {
        final Minecraft mc = Minecraft.getMinecraft();

        if (this.mode.getValue() == Mode.LOCK) {
            if (mc.currentScreen instanceof GuiGameOver) {
                mc.displayGuiScreen(null);
            }
            mc.player.setHealth(20.0f);
            mc.player.getFoodStats().setFoodLevel(20);
            mc.player.isDead = false;
        }
    }
}
 
Example 7
Source File: GuiUsageRecipe.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public static boolean openRecipeGui(String inputId, Object... ingredients) {
    Minecraft mc = Minecraft.getMinecraft();
    GuiContainer prevscreen = mc.currentScreen instanceof GuiContainer ? (GuiContainer) mc.currentScreen : null;

    TaskProfiler profiler = ProfilerRecipeHandler.getProfiler();
    ArrayList<IUsageHandler> handlers = new ArrayList<>();
    for (IUsageHandler usagehandler : usagehandlers) {
        profiler.start(usagehandler.getRecipeName());
        IUsageHandler handler = usagehandler.getUsageHandler(inputId, ingredients);
        if (handler.numRecipes() > 0) {
            handlers.add(handler);
        }
    }
    profiler.end();
    if (handlers.isEmpty()) {
        return false;
    }

    mc.displayGuiScreen(new GuiUsageRecipe(prevscreen, handlers));
    return true;
}
 
Example 8
Source File: NEIClientPacketHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public void handlePacket(PacketCustom packet, Minecraft mc, INetHandlerPlayClient netHandler) {
    switch (packet.getType()) {
        case 1:
            handleServerSideCheck(packet.readUByte(), packet.readString(), mc.world);
            break;
        case 10:
            handleLoginState(packet);
            break;
        case 11:
            handleActionDisableStateChange(packet);
            break;
        case 12:
            handleActionEnabled(packet);
            break;
        case 13:
            MagnetModeHandler.INSTANCE.trackMagnetItem(packet.readInt(), mc.world);
            break;
        case 14:
            handleGameMode(mc, packet.readUByte());
            break;
        case 21:
            ClientUtils.openSMPGui(packet.readUByte(), new GuiEnchantmentModifier(mc.player.inventory, mc.world));
            break;
        case 23:
            if (packet.readBoolean()) {
                ClientUtils.openSMPGui(packet.readUByte(), new GuiExtendedCreativeInv(new ContainerCreativeInv(mc.player, new ExtendedCreativeInv(null, Side.CLIENT))));
            } else {
                mc.displayGuiScreen(new GuiInventory(mc.player));
            }
            break;
        case 24:
            ClientUtils.openSMPGui(packet.readUByte(), new GuiPotionCreator(mc.player.inventory));
            break;
    }
}
 
Example 9
Source File: QCraftProxyClient.java    From qcraft-mod with Apache License 2.0 5 votes vote down vote up
@Override
public void travelToServer( LostLuggage.Address address )
{
    // Disconnect from current server
    Minecraft minecraft = Minecraft.getMinecraft();
    minecraft.theWorld.sendQuittingDisconnectingPacket();
    minecraft.loadWorld((WorldClient)null);
    minecraft.displayGuiScreen( new GuiTravelStandby( address ) );
}
 
Example 10
Source File: NEICPH.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public void handlePacket(PacketCustom packet, Minecraft mc, INetHandlerPlayClient netHandler) {
    switch (packet.getType()) {
        case 1:
            handleSMPCheck(packet.readUByte(), packet.readString(), mc.theWorld);
            break;
        case 10:
            handleLoginState(packet);
            break;
        case 11:
            handleActionDisabled(packet);
            break;
        case 12:
            handleActionEnabled(packet);
            break;
        case 13:
            ClientHandler.instance().addSMPMagneticItem(packet.readInt(), mc.theWorld);
            break;
        case 14:
            handleGamemode(mc, packet.readUByte());
            break;
        case 21:
            ClientUtils.openSMPGui(packet.readUByte(), new GuiEnchantmentModifier(mc.thePlayer.inventory, mc.theWorld));
            break;
        case 23:
            if (packet.readBoolean())
                ClientUtils.openSMPGui(packet.readUByte(), new GuiExtendedCreativeInv(new ContainerCreativeInv(mc.thePlayer, new ExtendedCreativeInv(null, Side.CLIENT))));
            else
                mc.displayGuiScreen(new GuiInventory(mc.thePlayer));
            break;
        case 24:
            ClientUtils.openSMPGui(packet.readUByte(), new GuiPotionCreator(mc.thePlayer.inventory));
            break;
    }
}
 
Example 11
Source File: ShulkerPreviewModule.java    From seppuku with GNU General Public License v3.0 4 votes vote down vote up
@Listener
public void onRenderTooltip(EventRenderTooltip event) {
    if (event.getItemStack() == null)
        return;

    final Minecraft mc = Minecraft.getMinecraft();

    if (event.getItemStack().getItem() instanceof ItemShulkerBox) {
        ItemStack shulker = event.getItemStack();
        NBTTagCompound tagCompound = shulker.getTagCompound();
        if (tagCompound != null && tagCompound.hasKey("BlockEntityTag", 10)) {
            NBTTagCompound blockEntityTag = tagCompound.getCompoundTag("BlockEntityTag");
            if (blockEntityTag.hasKey("Items", 9)) {
                event.setCanceled(true); // cancel rendering the old tooltip

                NonNullList<ItemStack> nonnulllist = NonNullList.<ItemStack>withSize(27, ItemStack.EMPTY);
                ItemStackHelper.loadAllItems(blockEntityTag, nonnulllist); // load the itemstacks from the tag to the list

                // store mouse/event coords
                int x = event.getX();
                int y = event.getY();

                // translate to mouse x, y
                GlStateManager.translate(x + 10, y - 5, 0);

                GlStateManager.disableLighting();
                GlStateManager.disableDepth();
                // background
                RenderUtil.drawRect(-3, -mc.fontRenderer.FONT_HEIGHT - 4, 9 * 16 + 3, 3 * 16 + 3, 0x99101010);
                RenderUtil.drawRect(-2, -mc.fontRenderer.FONT_HEIGHT - 3, 9 * 16 + 2, 3 * 16 + 2, 0xFF202020);
                RenderUtil.drawRect(0, 0, 9 * 16, 3 * 16, 0xFF101010);

                // text
                mc.fontRenderer.drawStringWithShadow(shulker.getDisplayName(), 0, -mc.fontRenderer.FONT_HEIGHT - 1, 0xFFFFFFFF);

                GlStateManager.enableDepth();
                mc.getRenderItem().zLevel = 150.0F;
                RenderHelper.enableGUIStandardItemLighting();

                // loop through items in shulker inventory
                for (int i = 0; i < nonnulllist.size(); i++) {
                    ItemStack itemStack = nonnulllist.get(i);
                    int offsetX = (i % 9) * 16;
                    int offsetY = (i / 9) * 16;
                    mc.getRenderItem().renderItemAndEffectIntoGUI(itemStack, offsetX, offsetY);
                    mc.getRenderItem().renderItemOverlayIntoGUI(mc.fontRenderer, itemStack, offsetX, offsetY, null);
                }

                RenderHelper.disableStandardItemLighting();
                mc.getRenderItem().zLevel = 0.0F;
                GlStateManager.enableLighting();

                // reverse the translate
                GlStateManager.translate(-(x + 10), -(y - 5), 0);
            }
        }

        if(this.middleClick.getValue()) {
            if (Mouse.isButtonDown(2)) {
                if (!this.clicked) {
                    final BlockShulkerBox shulkerBox = (BlockShulkerBox) Block.getBlockFromItem(shulker.getItem());
                    if (shulkerBox != null) {
                        final NBTTagCompound tag = shulker.getTagCompound();
                        if (tag != null && tag.hasKey("BlockEntityTag", 10)) {
                            final NBTTagCompound entityTag = tag.getCompoundTag("BlockEntityTag");

                            final TileEntityShulkerBox te = new TileEntityShulkerBox();
                            te.setWorld(mc.world);
                            te.readFromNBT(entityTag);
                            mc.displayGuiScreen(new GuiShulkerBox(mc.player.inventory, te));
                        }
                    }
                }
                this.clicked = true;
            } else {
                this.clicked = false;
            }
        }
    }
}
 
Example 12
Source File: MixinNetHandlerPlayClient.java    From VanillaFix with MIT License 4 votes vote down vote up
@Redirect(method = "handleJoinGame", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;displayGuiScreen(Lnet/minecraft/client/gui/GuiScreen;)V"))
private void onGuiDisplayJoin(Minecraft mc, GuiScreen guiScreenIn) {
    mc.displayGuiScreen(null);
}
 
Example 13
Source File: MixinNetHandlerPlayClient.java    From VanillaFix with MIT License 4 votes vote down vote up
@Redirect(method = "handleRespawn", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;displayGuiScreen(Lnet/minecraft/client/gui/GuiScreen;)V"))
private void onGuiDisplayRespawn(Minecraft mc, GuiScreen guiScreenIn) {
    mc.displayGuiScreen(null);
}
 
Example 14
Source File: ChunkLoaderCPH.java    From ChickenChunks with MIT License 4 votes vote down vote up
@Override
public void handlePacket(PacketCustom packet, Minecraft mc, INetHandlerPlayClient handler) {
    switch (packet.getType()) {
        case 1:
            PlayerChunkViewer.openViewer((int) mc.thePlayer.posX, (int) mc.thePlayer.posZ, CommonUtils.getDimension(mc.theWorld));
            break;
        case 2:
            PlayerChunkViewer.instance().loadDimension(packet, mc.theWorld);
            break;
        case 3:
            PlayerChunkViewer.instance().unloadDimension(packet.readInt());
            break;
        case 4:
            PlayerChunkViewer.instance().handleChunkChange(
                    packet.readInt(),
                    new ChunkCoordIntPair(packet.readInt(), packet.readInt()),
                    packet.readBoolean());
            break;
        case 5:
            PlayerChunkViewer.instance().handleTicketChange(
                    packet.readInt(),
                    packet.readInt(),
                    new ChunkCoordIntPair(packet.readInt(), packet.readInt()),
                    packet.readBoolean());
            break;
        case 6:
            PlayerChunkViewer.instance().handlePlayerUpdate(
                    packet.readString(), packet.readInt(),
                    new Vector3(packet.readFloat(), packet.readFloat(), packet.readFloat()));
            break;
        case 7:
            PlayerChunkViewer.instance().removePlayer(packet.readString());
            break;
        case 8:
            PlayerChunkViewer.instance().handleNewTicket(packet, mc.theWorld);
            break;
        case 10:
            TileChunkLoader.handleDescriptionPacket(packet, mc.theWorld);
            break;
        case 11:
            TileSpotLoader.handleDescriptionPacket(packet, mc.theWorld);
            break;
        case 12:
            BlockCoord pos = packet.readCoord();
            TileEntity tile = mc.theWorld.getTileEntity(pos.x, pos.y, pos.z);
            if (tile instanceof TileChunkLoader)
                mc.displayGuiScreen(new GuiChunkLoader((TileChunkLoader) tile));
            break;

    }
}
 
Example 15
Source File: VoidWorldType.java    From YUNoMakeGoodMap with Apache License 2.0 4 votes vote down vote up
@SideOnly(Side.CLIENT)
public void onCustomizeButton(Minecraft mc, GuiCreateWorld guiCreateWorld)
{
    mc.displayGuiScreen(new GuiCustomizeWorld(guiCreateWorld));
}
 
Example 16
Source File: GuiCoordinateTrackerOptions.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void actionPerformed(GuiButton button){
    Minecraft mc = FMLClientHandler.instance().getClient();
    CoordTrackUpgradeHandler coordHandler = HUDHandler.instance().getSpecificRenderer(CoordTrackUpgradeHandler.class);
    switch(button.id){
        case 10:
            mc.displayGuiScreen((GuiScreen)null);
            mc.setIngameFocus();
            coordHandler.isListeningToCoordTrackerSetting = true;
            HUDHandler.instance().addMessage(new ArmorMessage("Changing Coordinate Tracker coordinate...", Arrays.asList("Right-click the desired coordinate"), 90, 0x7000AA00));
            break;
        case 11:
            mc.displayGuiScreen((GuiScreen)null);
            mc.setIngameFocus();
            switch(coordHandler.navigateToSurface(mc.thePlayer)){
                case EASY_PATH:
                    HUDHandler.instance().addMessage(new ArmorMessage(I18n.format("pneumaticHelmet.message.coordinateTracker.routeFound"), new ArrayList<String>(), 90, 0x7000AA00));
                    break;
                case DRONE_PATH:
                    HUDHandler.instance().addMessage(new ArmorMessage(I18n.format("pneumaticHelmet.message.coordinateTracker.harderRouteFound"), new ArrayList<String>(), 90, 0x7044AA00));
                    break;
                case NO_PATH:
                    HUDHandler.instance().addMessage(new ArmorMessage(I18n.format("pneumaticHelmet.message.coordinateTracker.noRouteFound"), new ArrayList<String>(), 90, 0x70FF0000));
                    break;
            }

            break;
        case 12:
            coordHandler.pathEnabled = !coordHandler.pathEnabled;
            break;
        case 13:
            coordHandler.wirePath = !coordHandler.wirePath;
            break;
        case 14:
            coordHandler.xRayEnabled = !coordHandler.xRayEnabled;
            break;
        case 15:
            coordHandler.pathUpdateSetting++;
            if(coordHandler.pathUpdateSetting > 2) {
                coordHandler.pathUpdateSetting = 0;
            }
            break;
    }
    updateButtonTexts();
    coordHandler.saveToConfig();
}