Java Code Examples for net.minecraft.client.gui.GuiScreen#isCtrlKeyDown()

The following examples show how to use net.minecraft.client.gui.GuiScreen#isCtrlKeyDown() . 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: EntityRendererHook.java    From SkyblockAddons with MIT License 6 votes vote down vote up
public static void removeEntities(List<Entity> list) {
    SkyblockAddons main = SkyblockAddons.getInstance();
    if (main.getUtils().isOnSkyblock()) {

        int keyCode = Minecraft.getMinecraft().gameSettings.keyBindUseItem.getKeyCode();
        boolean isUseKeyDown = false;
        try {
            if (keyCode < 0) {
                isUseKeyDown = Mouse.isButtonDown(Minecraft.getMinecraft().gameSettings.keyBindUseItem.getKeyCode() + 100);
            } else {
                isUseKeyDown = Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindUseItem.getKeyCode());
            }
        } catch (Throwable ex) {
            ex.printStackTrace();
            // Uhh I messed up something with the key detection... fix?
        }

        if (!GuiScreen.isCtrlKeyDown() && isUseKeyDown && main.getConfigValues().isEnabled(Feature.IGNORE_ITEM_FRAME_CLICKS)) {
            list.removeIf(listEntity -> listEntity instanceof EntityItemFrame &&
                    (((EntityItemFrame)listEntity).getDisplayedItem() != null || Minecraft.getMinecraft().thePlayer.getHeldItem() == null));
        }
        if (main.getConfigValues().isEnabled(Feature.HIDE_PLAYERS_NEAR_NPCS)) {
            list.removeIf(entity -> entity instanceof EntityOtherPlayerMP && NPCUtils.isNearAnyNPCWithTag(entity, Tag.IMPORTANT) && !NPCUtils.isNPC(entity));
        }
    }
}
 
Example 2
Source File: TextureMapRenderer.java    From VanillaFix with MIT License 6 votes vote down vote up
public static void draw() {
    float alpha = 1;
    if (GuiScreen.isCtrlKeyDown()) {
        alpha = 0.5f;
    }

    // Bind texture atlas and disable scaling for debug render (see MixinGlStateManager)
    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    pushTextureIdentity();

    Minecraft.getMinecraft().entityRenderer.setupOverlayRendering();
    GlStateManager.enableAlpha();
    GlStateManager.enableBlend();
    GlStateManager.disableColorLogic();
    GlStateManager.color(1, 1, 1, alpha);
    drawTexture(5, 5, 0, 0, 230 * stitcher.getImageWidth() / stitcher.getImageHeight(), 230, 1, 1);

    popTextureMatrix();
}
 
Example 3
Source File: InputEventHandler.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
private boolean buildersWandClientSideHandling()
{
    if (GuiScreen.isShiftKeyDown() || GuiScreen.isCtrlKeyDown() || GuiScreen.isAltKeyDown())
    {
        return false;
    }

    ItemStack stack = this.mc.player.getHeldItemMainhand();

    if (stack.isEmpty() == false && stack.getItem() == EnderUtilitiesItems.BUILDERS_WAND &&
        ItemBuildersWand.Mode.getMode(stack) == Mode.COPY)
    {
        this.mc.displayGuiScreen(new GuiScreenBuilderWandTemplate());
        return true;
    }

    return false;
}
 
Example 4
Source File: GuiDrawbridge.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void actionPerformedWithButton(GuiButton button, int mouseButton) throws IOException
{
    int dim = this.tedb.getWorld().provider.getDimension();
    int amount = 0;

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

    if (button.id >= 0 && button.id <= 3)
    {
        if (GuiScreen.isShiftKeyDown()) { amount *= 8; }
        if (GuiScreen.isCtrlKeyDown())  { amount *= 4; }

        PacketHandler.INSTANCE.sendToServer(new MessageGuiAction(dim, this.tedb.getPos(),
            ReferenceGuiIds.GUI_ID_TILE_ENTITY_GENERIC, button.id, amount));
    }
}
 
Example 5
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 6
Source File: GuiStats.java    From GokiStats with MIT License 5 votes vote down vote up
@Override
protected void actionPerformed(GuiButton button) {
    if ((button.id >= 0) && (button.id <= StatBase.totalStats)) {
        if ((button instanceof GuiStatButton)) {
            GuiStatButton statButton = (GuiStatButton) button;
            if (!GuiScreen.isCtrlKeyDown())
                GokiPacketHandler.CHANNEL.sendToServer(new C2SStatSync(StatBase.stats.indexOf(statButton.stat), 1));
            else // Downgrade
                GokiPacketHandler.CHANNEL.sendToServer(new C2SStatSync(StatBase.stats.indexOf(statButton.stat), -1));
        }
    }
}
 
Example 7
Source File: GuiASU.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.teasu.getWorld().provider.getDimension();
    int amount = 0;

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

    if (button.id == 0 || button.id == 1)
    {
        if (button.id == 1 && mouseButton == 2)
        {
            amount = GuiScreen.isShiftKeyDown() ? TileEntityASU.MAX_STACK_SIZE : -TileEntityASU.MAX_STACK_SIZE;
        }

        if (button.id == 1)
        {
            if (GuiScreen.isShiftKeyDown()) { amount *= 16; }
            if (GuiScreen.isCtrlKeyDown())  { amount *= 64; }
        }
        else
        {
            if (GuiScreen.isShiftKeyDown()) { amount *= 9; }
            if (GuiScreen.isCtrlKeyDown())  { amount *= 3; }
        }

        PacketHandler.INSTANCE.sendToServer(new MessageGuiAction(dim, this.teasu.getPos(),
            ReferenceGuiIds.GUI_ID_TILE_ENTITY_GENERIC, button.id, amount));
    }
}
 
Example 8
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 9
Source File: WrapperGuiScreen.java    From ClientBase with MIT License 4 votes vote down vote up
public static boolean isCtrlKeyDown() {
    return GuiScreen.isCtrlKeyDown();
}
 
Example 10
Source File: GuiTextField.java    From ehacks-pro with GNU General Public License v3.0 4 votes vote down vote up
public boolean textboxKeyTyped(char par1, int par2) {
    if (this.isEnabled && this.isFocused) {
        switch (par1) {
            case '\u0001': {
                this.setCursorPositionEnd();
                this.setSelectionPos(0);
                return true;
            }
            case '\u0003': {
                GuiScreen.setClipboardString(this.getSelectedtext());
                return true;
            }
            case '\u0016': {
                this.writeText(GuiScreen.getClipboardString());
                return true;
            }
            case '\u0018': {
                GuiScreen.setClipboardString(this.getSelectedtext());
                this.writeText("");
                return true;
            }
        }
        switch (par2) {
            case 14: {
                if (GuiScreen.isCtrlKeyDown()) {
                    this.deleteWords(-1);
                } else {
                    this.deleteFromCursor(-1);
                }
                return true;
            }
            case 199: {
                if (GuiScreen.isShiftKeyDown()) {
                    this.setSelectionPos(0);
                } else {
                    this.setCursorPositionZero();
                }
                return true;
            }
            case 203: {
                if (GuiScreen.isShiftKeyDown()) {
                    if (GuiScreen.isCtrlKeyDown()) {
                        this.setSelectionPos(this.getNthWordFromPos(-1, this.getSelectionEnd()));
                    } else {
                        this.setSelectionPos(this.getSelectionEnd() - 1);
                    }
                } else if (GuiScreen.isCtrlKeyDown()) {
                    this.setCursorPosition(this.getNthWordFromCursor(-1));
                } else {
                    this.moveCursorBy(-1);
                }
                return true;
            }
            case 205: {
                if (GuiScreen.isShiftKeyDown()) {
                    if (GuiScreen.isCtrlKeyDown()) {
                        this.setSelectionPos(this.getNthWordFromPos(1, this.getSelectionEnd()));
                    } else {
                        this.setSelectionPos(this.getSelectionEnd() + 1);
                    }
                } else if (GuiScreen.isCtrlKeyDown()) {
                    this.setCursorPosition(this.getNthWordFromCursor(1));
                } else {
                    this.moveCursorBy(1);
                }
                return true;
            }
            case 207: {
                if (GuiScreen.isShiftKeyDown()) {
                    this.setSelectionPos(this.text.length());
                } else {
                    this.setCursorPositionEnd();
                }
                return true;
            }
            case 211: {
                if (GuiScreen.isCtrlKeyDown()) {
                    this.deleteWords(1);
                } else {
                    this.deleteFromCursor(1);
                }
                return true;
            }
        }
        if (ChatAllowedCharacters.isAllowedCharacter((char) par1)) {
            this.writeText(Character.toString(par1));
            return true;
        }
        return false;
    }
    return false;
}
 
Example 11
Source File: MixinMinecraft.java    From VanillaFix with MIT License 4 votes vote down vote up
/** @reason Implement using Ctrl + 0-9 to select profiler sections 10-19. */
@ModifyVariable(method = "updateDebugProfilerName", at = @At("HEAD"), ordinal = 0)
private int getKeyCountForProfilerNameUpdate(int keyCount) {
    return GuiScreen.isCtrlKeyDown() ? keyCount + 10 : keyCount;
}
 
Example 12
Source File: GuiStatButton.java    From GokiStats with MIT License 4 votes vote down vote up
@Override
public void drawButton(@Nonnull Minecraft mc, int mouseX, int mouseY, float partialTicks) {
    if (this.visible) {
        int iconY = 24 * (this.stat.imageID % 10);
        int level = DataHelper.getPlayerStatLevel(this.player, this.stat);
        int cost = this.stat.getCost(level);
        int playerXP = DataHelper.getXPTotal(this.player);

        FontRenderer fontrenderer = mc.fontRenderer;
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        this.hovered = isUnderMouse(mouseX, mouseY);
        int hoverState = getHoverState(this.hovered);

        int iconX = INACTIVE_X;
        if (hoverState == 2) { // Hovering
            iconX = ACTIVATED_X;
        }
        if (playerXP < cost) {
            iconX = INACTIVE_X;
        }
        if (level >= this.stat.getLimit()) {
            iconX = MAXIMUM_X;
        }
        if (GuiScreen.isCtrlKeyDown()) {
            if (DataHelper.canPlayerRevertStat(player, this.stat))
                iconX = ACTIVATED_X;
            else
                iconX = DISABLED_X;
        }
        if (!stat.enabled)
            iconX = DISABLED_X;

        String message = level + "";
        if (!this.stat.enabled) {
            iconX = 48;
            message = "X";
        }

        int messageColor = 16777215;
        if (level >= this.stat.getLimit()) {
            message = "*" + level + "*";
            messageColor = 16763904;
        }

        iconX += this.stat.imageID % 20 / 10 * 24 * 4;

        if (this.stat.imageID >= 20) {
            mc.getTextureManager().bindTexture(Reference.RPG_ICON_2_TEXTURE_LOCATION);
        } else {
            mc.getTextureManager().bindTexture(Reference.RPG_ICON_TEXTURE_LOCATION);
        }
        GL11.glPushMatrix();
        GL11.glTranslatef(this.x, this.y, 0.0F);
        GL11.glScalef(GuiStats.SCALE, GuiStats.SCALE, 0.0F);
        drawTexturedModalRect(0, 0, iconX, iconY, this.width, this.height);

        GL11.glPopMatrix();
        GL11.glPushMatrix();
        GL11.glTranslatef(this.x, this.y, 0.0F);
        drawCenteredString(fontrenderer,
                message,
                (int) (this.width / 2 * GuiStats.SCALE),
                (int) (this.height * GuiStats.SCALE) + 2,
                messageColor);
        GL11.glPopMatrix();
    }
}
 
Example 13
Source File: GuiStatTooltip.java    From GokiStats with MIT License 4 votes vote down vote up
public void draw(int drawX, int drawY, int mouseButton) {
    Map<String, Integer> messageColorMap = new LinkedHashMap<>();

    AtomicInteger widthAtomic = new AtomicInteger(), heightAtomic = new AtomicInteger();

    int level = DataHelper.getPlayerStatLevel(this.player, this.stat);

    messageColorMap.put(this.stat.getLocalizedName() + " L" + level, -13312); // Header
    messageColorMap.put(this.stat.getLocalizedDescription(this.player), -1); // Message
    if (level >= this.stat.getLimit())
        messageColorMap.put(I18n.format("ui.max.name"), -16724737);
    else
        messageColorMap.put(I18n.format("ui.cost.name") + this.stat.getCost(level) + "xp", -16724737); // Cost

    if (GuiScreen.isCtrlKeyDown())
        messageColorMap.put(I18n.format("ui.return.name") + this.stat.getCost(level) * GokiConfig.globalModifiers.globalRevertFactor + "xp", -16724737); // Cost

    int revertLevel = DataHelper.getPlayerRevertStatLevel(player, stat);
    if (revertLevel > 0) {
        if (GokiConfig.globalModifiers.globalMaxRevertLevel != -1)
            messageColorMap.put(I18n.format("ui.reverted.name", revertLevel, String.valueOf(GokiConfig.globalModifiers.globalMaxRevertLevel)), -16724737); // Reverted
        else
            messageColorMap.put(I18n.format("ui.reverted.name", revertLevel, I18n.format("ui.infinite.name")), -16724737); // Reverted
    }

    if (GuiScreen.isCtrlKeyDown()) { // Is player reverting?
        if (DataHelper.canPlayerRevertStat(player, stat))
            messageColorMap.put(I18n.format("ui.revert.name"), 0xff0467ff);
        else
            messageColorMap.put(I18n.format("ui.norevert.name"), 0xfffb1a00);
    } else
        messageColorMap.put(I18n.format("ui.hover.name"), 0xff0467ff);

    messageColorMap.forEach((text, color) -> {
        widthAtomic.set(Math.max(widthAtomic.get(), this.mc.fontRenderer.getStringWidth(text)));
        heightAtomic.addAndGet(this.mc.fontRenderer.FONT_HEIGHT);
    });

    int width = widthAtomic.get() + this.padding * 2;
    int height = heightAtomic.get() + this.padding * 2;
    int h = height / messageColorMap.size();
    int x = drawX - width / 2;
    int leftEdge = 0;
    int left = x;
    if (left < leftEdge) {
        x -= leftEdge - left + 1;
    }
    int rightEdge = this.mc.currentScreen.width;
    int right = x + width;
    if (right > rightEdge) {
        x += rightEdge - right - 1;
    }
    drawRect(x, drawY, x + width, drawY - height, -872415232);

    for (int i = messageColorMap.size(); i >= 1; i--) {
        Map.Entry<String, Integer> entry = messageColorMap.entrySet().toArray(new Map.Entry[0])[messageColorMap.size() - i];
        drawString(this.mc.fontRenderer,
                entry.getKey(),
                x + this.padding / 2,
                drawY - h * i + this.padding / 2,
                entry.getValue());
    }

    drawBorder(x, drawY, width, height, -1);
}
 
Example 14
Source File: ClientProxy.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public boolean isControlKeyDown()
{
    return GuiScreen.isCtrlKeyDown();
}
 
Example 15
Source File: GuiInserter.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected void actionPerformedWithButton(GuiButton button, int mouseButton) throws IOException
{
    int dim = this.tef.getWorld().provider.getDimension();
    int amount = 0;

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

    if (button.id == 0)
    {
        if (mouseButton == 2)
        {
            amount = GuiScreen.isShiftKeyDown() ? 64 : -64;
        }
        else
        {
            if (GuiScreen.isShiftKeyDown()) { amount *= 16; }
            else if (GuiScreen.isCtrlKeyDown()) { amount *= 64; }
        }

        PacketHandler.INSTANCE.sendToServer(new MessageGuiAction(dim, this.tef.getPos(),
            ReferenceGuiIds.GUI_ID_TILE_ENTITY_GENERIC, TileEntityInserter.GuiAction.CHANGE_STACK_LIMIT.ordinal(), amount));
    }
    else if (button.id == 1)
    {
        if (mouseButton == 2)
        {
            amount = GuiScreen.isShiftKeyDown() ? 72000 : -72000;
        }
        else
        {
            if (GuiScreen.isShiftKeyDown() && GuiScreen.isCtrlKeyDown()) { amount *= 1000; }
            else if (GuiScreen.isShiftKeyDown()) { amount *= 10; }
            else if (GuiScreen.isCtrlKeyDown()) { amount *= 100; }
        }

        PacketHandler.INSTANCE.sendToServer(new MessageGuiAction(dim, this.tef.getPos(),
            ReferenceGuiIds.GUI_ID_TILE_ENTITY_GENERIC, TileEntityInserter.GuiAction.CHANGE_DELAY.ordinal(), amount));
    }
    if (button.id == 2)
    {
        PacketHandler.INSTANCE.sendToServer(new MessageGuiAction(dim, this.tef.getPos(),
            ReferenceGuiIds.GUI_ID_TILE_ENTITY_GENERIC, TileEntityInserter.GuiAction.CHANGE_REDSTONE_MODE.ordinal(), amount));
    }
    else if (button.id >= 10 && button.id <= 13)
    {
        PacketHandler.INSTANCE.sendToServer(new MessageGuiAction(dim, this.tef.getPos(),
            ReferenceGuiIds.GUI_ID_TILE_ENTITY_GENERIC, TileEntityInserter.GuiAction.CHANGE_FILTERS.ordinal(), 1 << (button.id - 10)));
    }
}