net.minecraft.client.gui.GuiScreen Java Examples

The following examples show how to use net.minecraft.client.gui.GuiScreen. 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: TextField.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
public boolean handleKeyPress(int keyID, char keyChar) {
    if (!focused())
        return false;

    if (keyID == Keyboard.KEY_BACK) {
        if (text.length() > 0) {
            setText(text.substring(0, text.length() - 1));
            backdowntime = System.currentTimeMillis();
        }
    } else if (keyID == Keyboard.KEY_RETURN || keyID == Keyboard.KEY_ESCAPE) {
        setFocus(false);
        onExit();
    } else if (keyChar == 22)//paste
    {
        String pastestring = GuiScreen.getClipboardString();
        if (pastestring == null)
            pastestring = "";

        if (isValid(text + pastestring))
            setText(text + pastestring);
    } else if (isValid(text + keyChar))
        setText(text + keyChar);

    return true;
}
 
Example #2
Source File: MoCClientTickHandler.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData)
{
    if (type.equals(EnumSet.of(TickType.CLIENT)))
    {
        GuiScreen curScreen = Minecraft.getMinecraft().currentScreen;
        if (curScreen != null)
        {
            onTickInGui(curScreen);
        }
        else
        {
            onTickInGame();
        }
    }

}
 
Example #3
Source File: NEIClientEventHandler.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@SubscribeEvent
public void drawScreenPost(DrawScreenEvent.Post event) {
    GuiScreen screen = event.getGui();

    Point mousePos = GuiDraw.getMousePosition();
    List<String> tooltip = new LinkedList<>();
    ItemStack stack = ItemStack.EMPTY;
    if (instanceTooltipHandlers != null) {
        instanceTooltipHandlers.forEach(handler -> handler.handleTooltip(screen, mousePos.x, mousePos.y, tooltip));
    }

    if (screen instanceof GuiContainer) {
        if (tooltip.isEmpty() && GuiHelper.shouldShowTooltip(screen)) {
            GuiContainer container = (GuiContainer) screen;
            stack = GuiHelper.getStackMouseOver(container, false);

            if (!stack.isEmpty()) {
                tooltip.clear();
                tooltip.addAll(GuiHelper.itemDisplayNameMultiline(stack, container, false));
            }
        }
    }

    GuiDraw.drawMultiLineTip(stack, mousePos.x + 10, mousePos.y - 12, tooltip);
}
 
Example #4
Source File: LayoutManager.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
public boolean mouseClicked(GuiScreen gui, int mouseX, int mouseY, int button) {
    if (isHidden()) {
        return false;
    }

    if (!isEnabled()) {
        return options.contains(mouseX, mouseY) && options.handleClick(mouseX, mouseY, button);
    }

    for (Widget widget : controlWidgets) {
        widget.onGuiClick(mouseX, mouseY);
        if (widget.contains(mouseX, mouseY) ? widget.handleClick(mouseX, mouseY, button) : widget.handleClickExt(mouseX, mouseY, button)) {
            return true;
        }
    }

    return false;
}
 
Example #5
Source File: GuiProblemScreen.java    From VanillaFix with MIT License 6 votes vote down vote up
@Override
protected void actionPerformed(GuiButton button) {
    if (button.id == 1) {
        try {
            if (hasteLink == null) {
                hasteLink = HasteUpload.uploadToHaste(ModConfig.crashes.hasteURL, "mccrash", report.getCompleteReport());
            }
            ReflectionHelper.findField(GuiScreen.class, "clickedLinkURI", "field_175286_t").set(this, new URI(hasteLink));
            mc.displayGuiScreen(new GuiConfirmOpenLink(this, hasteLink, 31102009, false));
        } catch (Throwable e) {
            log.error("Exception when crash menu button clicked:", e);
            button.displayString = I18n.format("vanillafix.gui.failed");
            button.enabled = false;
        }
    }
}
 
Example #6
Source File: XRayAddGui.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
private void drawItem(ItemStack itemstack, int x, int y, String name) {
    GL11.glColor3ub((byte) -1, (byte) -1, (byte) -1);
    GL11.glDisable(2896);
    this.zLevel = 200.0f;
    GuiScreen.itemRender.zLevel = 200.0f;
    FontRenderer font = null;
    if (itemstack != null) {
        font = itemstack.getItem().getFontRenderer(itemstack);
    }
    if (font == null) {
        font = this.fontRendererObj;
    }
    GuiScreen.itemRender.renderItemAndEffectIntoGUI(font, this.mc.getTextureManager(), itemstack, x, y);
    GuiScreen.itemRender.renderItemOverlayIntoGUI(font, this.mc.getTextureManager(), itemstack, x, y, name);
    this.zLevel = 0.0f;
    GuiScreen.itemRender.zLevel = 0.0f;
    GL11.glEnable(2896);
}
 
Example #7
Source File: LayoutManager.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
public boolean lastKeyTyped(GuiScreen gui, char keyChar, int keyID) {
    if (KeyBindings.get("nei.options.keys.gui.hide").isActiveAndMatches(keyID)) {
        toggleBooleanSetting("inventory.hidden");
        //False, because we need to not consume the event.
        return false;
    }
    if (isEnabled() && !isHidden()) {
        for (Widget widget : controlWidgets) {
            if (inputFocused == null) {
                widget.lastKeyTyped(keyID, keyChar);
            }
        }
    }
    return false;
}
 
Example #8
Source File: GuiProgrammer.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void mouseClicked(int x, int y, int par3){
    ItemStack programmedItem = te.getStackInSlot(TileEntityProgrammer.PROGRAM_SLOT);
    if(nameField.isFocused() && programmedItem != null) {
        programmedItem.setStackDisplayName(nameField.getText());
        NetworkHandler.sendToServer(new PacketUpdateTextfield(te, 0));
    }
    super.mouseClicked(x, y, par3);

    if(par3 == 1 && showingWidgetProgress == 0) {
        IProgWidget widget = programmerUnit.getHoveredWidget(x, y);
        if(widget != null) {
            GuiScreen screen = widget.getOptionWindow(this);
            if(screen != null) mc.displayGuiScreen(screen);
        }
    }
}
 
Example #9
Source File: ProgWidgetCrafting.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public GuiScreen getOptionWindow(GuiProgrammer guiProgrammer){
    return new GuiProgWidgetImportExport(this, guiProgrammer){
        @Override
        protected boolean showSides(){
            return false;
        }
    };
}
 
Example #10
Source File: TerminalManagerClient.java    From OpenPeripheral-Addons with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onDragParamsSet(GlassesSetDragParamsEvent evt) {
	GuiScreen gui = FMLClientHandler.instance().getClient().currentScreen;

	if (gui instanceof GuiCapture) {
		final GuiCapture capture = (GuiCapture)gui;
		long guid = capture.getGuid();
		if (guid == evt.guid) capture.setDragParameters(evt.threshold, evt.period);
	}
}
 
Example #11
Source File: NEIController.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public void onMouseClickedPost(GuiScreen gui, int mouseX, int mouseY, int button) {
    if (!(gui instanceof GuiContainer) || !NEIClientConfig.isEnabled()) {
        return;
    }
    Slot slot = GuiHelper.getSlotMouseOver(((GuiContainer) gui));
    if (slot != null) {

        ItemStack nowHeld = NEIClientUtils.getHeldItem();

        if (heldTracker != nowHeld) {
            pickedUpFromSlot = slot.slotNumber;
        }
    }
}
 
Example #12
Source File: CCSlider.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public CCSlider(final GuiScreen screen, final int id, final String displayText, final int posX, final int posY, final int width, final int height, final int minValue, final int maxValue) {
    super(screen, id, displayText, posX, posY, width, height);
    setMinMaxValue(minValue, maxValue);
    boxWidth = 15;
    boxPosition = 1;
    offset = 0;
    mouseDown = false;
    value = 0;
    boxColour = CustomCrosshairAddon.PRIMARY_T;
}
 
Example #13
Source File: CCListDropBox.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public CCListDropBox(final GuiScreen screen) {
    super(screen);
    isOpen = false;
    itemList = new ArrayList<>();
    setWidth(100);
    setHeight(10);
    itemList.add("Item One");
    itemList.add("Item Two");
    itemList.add("Item Three");
    itemList.add("Item Four");
    itemList.add("Item Five");
}
 
Example #14
Source File: ProgWidgetEntityCondition.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public GuiScreen getOptionWindow(GuiProgrammer guiProgrammer){
    return new GuiProgWidgetCondition(this, guiProgrammer){
        @Override
        protected boolean isSidedWidget(){
            return false;
        }

        @Override
        protected boolean isUsingAndOr(){
            return false;
        }
    };
}
 
Example #15
Source File: ClientProxy.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean isPaused() {
	if (FMLClientHandler.instance().getClient().isSingleplayer() && !FMLClientHandler.instance().getClient().getIntegratedServer().getPublic()) {
		GuiScreen screen = FMLClientHandler.instance().getClient().currentScreen;
		if (screen != null) {
			if (screen.doesGuiPauseGame()) {
				return true;
			}
		}
	}
	return false;
}
 
Example #16
Source File: GuiCCTextField.java    From CodeChickenCore with MIT License 5 votes vote down vote up
@Override
public void keyTyped(char c, int keycode)
{
    if(!isEnabled || !isFocused)
        return;

    /*if(c == '\t')//tab
    {
        parentGuiScreen.selectNextField();
    }*/
    if(c == '\026')//paste
    {
        String s = GuiScreen.getClipboardString();
        if(s == null || s.equals(""))
            return;

        for(int i = 0; i < s.length(); i++)
        {
            if(text.length() == maxStringLength)
                return;

            char tc = s.charAt(i);
            if(canAddChar(tc))
                setText(text + tc);
        }
    }
    if(keycode == Keyboard.KEY_RETURN)
    {
        setFocused(false);
        sendAction(actionCommand, getText());
    }

    if(keycode == Keyboard.KEY_BACK && text.length() > 0)
        setText(text.substring(0, text.length() - 1));

    if((text.length() < maxStringLength || maxStringLength == 0) && canAddChar(c))
        setText(text + c);
}
 
Example #17
Source File: GuiConfigToroQuest.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
public GuiConfigToroQuest(GuiScreen parent) {
	super (parent, new ConfigElement(ConfigurationHandler.config.getCategory(Configuration.CATEGORY_CLIENT)).getChildElements(),
			ToroQuest.MODID,
			false,
			false,
			"ToroQuest");
	titleLine2 = ConfigurationHandler.config.getConfigFile().getAbsolutePath();
}
 
Example #18
Source File: ToolTip.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
private boolean isCorrectModeActive()
{
    switch (mode.toLowerCase())
    {
        case MODE_SHIFT:
            return GuiScreen.isShiftKeyDown();
        case MODE_CTRL:
            return GuiScreen.isCtrlKeyDown();
        case MODE_ALT:
            return GuiScreen.isAltKeyDown();
        case MODE_NO_SHIFT:
            return !GuiScreen.isShiftKeyDown();
        case MODE_NO_CTRL:
            return !GuiScreen.isCtrlKeyDown();
        case MODE_NO_ALT:
            return !GuiScreen.isAltKeyDown();
        default:
            return true;
    }
}
 
Example #19
Source File: ClientProxy.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean isPaused() {
	if (FMLClientHandler.instance().getClient().isSingleplayer() && !FMLClientHandler.instance().getClient().getIntegratedServer().getPublic()) {
		GuiScreen screen = FMLClientHandler.instance().getClient().currentScreen;
		if (screen != null) {
			if (screen.doesGuiPauseGame()) {
				return true;
			}
		}
	}
	return false;
}
 
Example #20
Source File: NEIClientEventHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onKeyTypedPost(KeyboardInputEvent.Post event) {

    GuiScreen gui = event.getGui();
    if (gui instanceof GuiContainer) {
        char c = Keyboard.getEventCharacter();
        int eventKey = Keyboard.getEventKey();

        if (eventKey == 0 && c >= 32 || Keyboard.getEventKeyState()) {

            if (eventKey != 1) {
                for (IInputHandler inputhander : inputHandlers) {
                    if (inputhander.lastKeyTyped(gui, c, eventKey)) {
                        event.setCanceled(true);
                        return;
                    }
                }
            }

            if (KeyBindings.get("nei.options.keys.gui.enchant").isActiveAndMatches(eventKey) && canPerformAction("enchant")) {
                NEIClientPacketHandler.sendOpenEnchantmentWindow();
                event.setCanceled(true);
            }
            if (KeyBindings.get("nei.options.keys.gui.potion").isActiveAndMatches(eventKey) && canPerformAction("potion")) {
                NEIClientPacketHandler.sendOpenPotionWindow();
                event.setCanceled(true);
            }
        }
    }

}
 
Example #21
Source File: ModGuiConfig.java    From Fullscreen-Windowed-Minecraft with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ModGuiConfig (GuiScreen parentScreen)
{
    super(parentScreen,
            new ConfigElement(ConfigurationHandler.instance().getConfigurationCategory()).getChildElements(),
            Reference.MOD_ID,
            false,
            false,
            GuiConfig.getAbridgedConfigPath(ConfigurationHandler.instance().toString()));
}
 
Example #22
Source File: GuiDrawScreenEvent.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public GuiDrawScreenEvent(GuiScreen screen, int mouseX, int mouseY, float partialTicks) {

        this.screen = screen;
        this.mouseX = mouseX;
        this.mouseY = mouseY;
        this.partialTicks = partialTicks;
    }
 
Example #23
Source File: MwGuiMarkerDialog.java    From mapwriter with MIT License 5 votes vote down vote up
public MwGuiMarkerDialog(GuiScreen parentScreen, MarkerManager markerManager, Marker editingMarker) {
      super(parentScreen, "Edit Marker Name:", editingMarker.name, "marker must have a name");
      this.markerManager = markerManager;
this.editingMarker = editingMarker;
this.markerName = editingMarker.name;
this.markerGroup = editingMarker.groupName;
this.markerX = editingMarker.x;
this.markerY = editingMarker.y;
this.markerZ = editingMarker.z;
this.dimension = editingMarker.dimension;
  }
 
Example #24
Source File: GuiSoundBlock.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void actionPerformedWithButton(GuiButton button, int mouseButton) throws IOException
{
    int dim = this.player.getEntityWorld().provider.getDimension();
    int amount = 0;

    if (mouseButton == 0 || mouseButton == 11)
    {
        amount = 1;
    }
    else if (mouseButton == 1 || mouseButton == 9)
    {
        amount = -1;
    }

    // Pitch and Volume
    if (button.id == 1 || button.id == 2)
    {
        if (GuiScreen.isShiftKeyDown()) { amount *= 10; }
        if (GuiScreen.isCtrlKeyDown())  { amount *= 100; }
    }
    // Clear the search field
    if (button.id == 20)
    {
        this.searchField.setText("");
        this.applyFilterString();
    }
    else
    {
        PacketHandler.INSTANCE.sendToServer(new MessageGuiAction(dim, this.tesb.getPos(),
                ReferenceGuiIds.GUI_ID_TILE_ENTITY_GENERIC, button.id, amount));
    }
}
 
Example #25
Source File: BackpacksConfigScreen.java    From WearableBackpacks with MIT License 5 votes vote down vote up
/** Creates a config GUI screen for Wearable Backpacks (and its GENERAL category). */
public BackpacksConfigScreen(GuiScreen parentScreen) {
	this(parentScreen, (String)null);
	
	// Add all settings from the GENERAL category to the entry list.
	for (Setting<?> setting : WearableBackpacks.CONFIG.getSettingsGeneral())
		addEntry(CreateEntryFromSetting(setting));
	
	// After adding all settings from the GENERAL category, add its sub-categories.
	for (String cat : WearableBackpacks.CONFIG.getCategories())
		addEntry(new EntryCategory(this, cat));
}
 
Example #26
Source File: MwGuiMarkerDialog.java    From mapwriter with MIT License 5 votes vote down vote up
public MwGuiMarkerDialog(GuiScreen parentScreen, MarkerManager markerManager, String markerName, String markerGroup, int x, int y, int z, int dimension) {
      super(parentScreen, "Marker Name:", markerName, "marker must have a name");
this.markerManager = markerManager;
this.markerName = markerName;
this.markerGroup = markerGroup;
this.markerX = x;
this.markerY = y;
this.markerZ = z;
this.editingMarker = null;
this.dimension = dimension;
  }
 
Example #27
Source File: WRAddonCPH.java    From WirelessRedstone with MIT License 5 votes vote down vote up
private static void processSnifferFreqUpdate(PacketCustom packet) {
    GuiScreen currentscreen = Minecraft.getMinecraft().currentScreen;
    if (currentscreen == null || !(currentscreen instanceof GuiWirelessSniffer))
        return;

    GuiWirelessSniffer sniffergui = ((GuiWirelessSniffer) currentscreen);
    sniffergui.setEtherFreq(packet.readUShort(), packet.readBoolean());
}
 
Example #28
Source File: GuiPastebin.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public GuiPastebin(GuiScreen parentScreen, String pastingString){
    xSize = 183;
    ySize = 202;
    this.pastingString = pastingString;
    this.parentScreen = parentScreen;
    Keyboard.enableRepeatEvents(true);
}
 
Example #29
Source File: SelectionManager.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void openEditGui(@Nullable GuiScreen parent)
{
    GuiBase gui = this.getEditGui();

    if (gui != null)
    {
        gui.setParent(parent);
        GuiBase.openGui(gui);
    }
}
 
Example #30
Source File: TerminalManagerClient.java    From OpenPeripheral-Addons with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onKeyRepeatSet(GlassesSetKeyRepeatEvent evt) {
	GuiScreen gui = FMLClientHandler.instance().getClient().currentScreen;

	if (gui instanceof GuiCapture) {
		final GuiCapture capture = (GuiCapture)gui;
		long guid = capture.getGuid();
		if (guid == evt.guid) capture.setKeyRepeat(evt.repeat);
	}
}