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

The following examples show how to use net.minecraft.client.gui.GuiScreen#isShiftKeyDown() . 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: 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 2
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 3
Source File: ItemSubCollar.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 6 votes vote down vote up
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {

    list.add(EnumChatFormatting.GOLD + StatCollector.translateToLocal("item.capacity.text") + " " + this.getMaxVis(stack) / 100);
    if(stack.hasTagCompound()) {
        Iterator count = Aspect.getPrimalAspects().iterator();

        while(count.hasNext()) {
            Aspect aspect = (Aspect)count.next();
            if(stack.stackTagCompound.hasKey(aspect.getTag())) {
                String amount = this.myFormatter.format((double)((float)stack.stackTagCompound.getInteger(aspect.getTag()) / 100.0F));
                list.add("\u00a7" + aspect.getChatcolor() + aspect.getName() + EnumChatFormatting.RESET + " x " + amount);
            }
        }
        if(stack.stackTagCompound.hasKey("owner"))
            list.add(StatCollector.translateToLocal("tooltip.collar.owner") + " " + stack.stackTagCompound.getString("owner"));

        if(Compat.botan && GuiScreen.isShiftKeyDown() && getCosmeticItem(stack) != null)
            list.add(String.format(StatCollector.translateToLocal("botaniamisc.hasCosmetic"), getCosmeticItem(stack).getDisplayName()).replaceAll("&", "\u00a7"));

    }

}
 
Example 4
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 5
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 6
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 7
Source File: LangUtils.java    From WearableBackpacks with MIT License 5 votes vote down vote up
/** If shift is not held down, adds a formatted "Hold SHIFT for more info" tooltip
 *  to the tooltip list and returns false. Otherwise returns true, adding nothing. */
@SideOnly(Side.CLIENT)
public static boolean tooltipIsShiftKeyDown(List<String> tooltip) {
	boolean shift = GuiScreen.isShiftKeyDown();
	if (!shift) formatTooltip(tooltip, "moreInfo", "\u00A76SHIFT\u00A77");
	return shift;
}
 
Example 8
Source File: GuiScreenHook.java    From SkyblockAddons with MIT License 4 votes vote down vote up
public static void renderBackpack(ItemStack stack, int x, int y, ReturnValue<?> returnValue) {
    SkyblockAddons main = SkyblockAddons.getInstance();
    if (stack.getItem().equals(Items.skull) && main.getConfigValues().isEnabled(Feature.SHOW_BACKPACK_PREVIEW)) {
        if (main.getConfigValues().isEnabled(Feature.SHOW_BACKPACK_HOLDING_SHIFT) && !GuiScreen.isShiftKeyDown()) {
            return;
        }

        Container playerContainer = Minecraft.getMinecraft().thePlayer.openContainer;
        if (playerContainer instanceof ContainerChest) { // Avoid showing backpack preview in auction stuff.
            IInventory chestInventory = ((ContainerChest) playerContainer).getLowerChestInventory();
            if (chestInventory.hasCustomName()) {
                String chestName = chestInventory.getDisplayName().getUnformattedText();
                if (chestName.contains("Auction") || "Your Bids".equals(chestName)) {

                    // Show preview for backpacks in player inventory if enabled.
                    if (!main.getConfigValues().isEnabled(Feature.BACKPACK_PREVIEW_AH)) {
                        return;
                    }

                    /*
                    If the backpack is in the auction house window, ignore it.
                    Empty backpacks can't be listed in the auction.
                     */
                    for (int i = 0; i < chestInventory.getSizeInventory(); i++) {
                        if (ItemStack.areItemStackTagsEqual(chestInventory.getStackInSlot(i), stack)) {
                            return;
                        }
                    }
                }
            }
        }

        Backpack backpack = BackpackManager.getFromItem(stack);
        if (backpack != null) {
            backpack.setX(x);
            backpack.setY(y);
            if (isFreezeKeyDown() && System.currentTimeMillis() - lastBackpackFreezeKey > 500) {
                lastBackpackFreezeKey = System.currentTimeMillis();
                GuiContainerHook.setFreezeBackpack(!GuiContainerHook.isFreezeBackpack());
                main.getUtils().setBackpackToPreview(backpack);
            }
            if (!GuiContainerHook.isFreezeBackpack()) {
                main.getUtils().setBackpackToPreview(backpack);
            }
            main.getPlayerListener().onItemTooltip(new ItemTooltipEvent(stack, null, null, false));
            returnValue.cancel();
        }
    }
    if (GuiContainerHook.isFreezeBackpack()) {
        returnValue.cancel();
    }
}
 
Example 9
Source File: KeyBindings.java    From EmergingTechnology with MIT License 4 votes vote down vote up
@SideOnly(Side.CLIENT)
public static boolean showExtendedTooltips() {
    return GuiScreen.isShiftKeyDown();
}
 
Example 10
Source File: WrapperGuiScreen.java    From ClientBase with MIT License 4 votes vote down vote up
public static boolean isShiftKeyDown() {
    return GuiScreen.isShiftKeyDown();
}
 
Example 11
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 12
Source File: ClientProxy.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public boolean isShiftKeyDown()
{
    return GuiScreen.isShiftKeyDown();
}
 
Example 13
Source File: GuiHandyBag.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
{
    super.actionPerformed(button);

    if (button.id >= BTN_ID_FIRST_SELECT_MODULE && button.id < (BTN_ID_FIRST_SELECT_MODULE + this.numModuleSlots))
    {
        PacketHandler.INSTANCE.sendToServer(new MessageGuiAction(0, new BlockPos(0, 0, 0),
            ReferenceGuiIds.GUI_ID_HANDY_BAG, ItemHandyBag.GUI_ACTION_SELECT_MODULE, button.id - BTN_ID_FIRST_SELECT_MODULE));
    }
    else if (button.id >= BTN_ID_FIRST_MOVE_ITEMS && button.id <= (BTN_ID_FIRST_MOVE_ITEMS + 5))
    {
        int value = button.id - BTN_ID_FIRST_MOVE_ITEMS;

        if (GuiScreen.isShiftKeyDown())
        {
            value |= 0x8000;
        }

        PacketHandler.INSTANCE.sendToServer(new MessageGuiAction(0, new BlockPos(0, 0, 0),
            ReferenceGuiIds.GUI_ID_HANDY_BAG, ItemHandyBag.GUI_ACTION_MOVE_ITEMS, value));
    }
    else if (button.id >= BTN_ID_FIRST_SORT && button.id < (BTN_ID_FIRST_SORT + 4))
    {
        PacketHandler.INSTANCE.sendToServer(new MessageGuiAction(0, new BlockPos(0, 0, 0),
            ReferenceGuiIds.GUI_ID_HANDY_BAG, ItemHandyBag.GUI_ACTION_SORT_ITEMS, button.id - BTN_ID_FIRST_SORT));
    }
    else if (button.id >= BTN_ID_FIRST_BLOCK && button.id < (BTN_ID_FIRST_BLOCK + 3))
    {
        PacketHandler.INSTANCE.sendToServer(new MessageGuiAction(0, new BlockPos(0, 0, 0),
            ReferenceGuiIds.GUI_ID_HANDY_BAG, ItemHandyBag.GUI_ACTION_TOGGLE_BLOCK, button.id - BTN_ID_FIRST_BLOCK));
    }
    else if (button.id >= BTN_ID_FIRST_MODES && button.id < (BTN_ID_FIRST_MODES + 3))
    {
        int data = button.id - BTN_ID_FIRST_MODES;

        if (mouseButton == 1)
        {
            data |= 0x8000;
        }

        PacketHandler.INSTANCE.sendToServer(new MessageGuiAction(0, new BlockPos(0, 0, 0),
            ReferenceGuiIds.GUI_ID_HANDY_BAG, ItemHandyBag.GUI_ACTION_TOGGLE_MODES, data));
    }
    else if (button.id >= 20 && button.id <= 22)
    {
        PacketHandler.INSTANCE.sendToServer(new MessageGuiAction(0, new BlockPos(0, 0, 0),
            ReferenceGuiIds.GUI_ID_HANDY_BAG, ItemHandyBag.GUI_ACTION_TOGGLE_UPDATE, button.id - 20));
    }
    else if (button.id == 23)
    {
        PacketHandler.INSTANCE.sendToServer(new MessageGuiAction(0, new BlockPos(0, 0, 0),
            ReferenceGuiIds.GUI_ID_HANDY_BAG, ItemHandyBag.GUI_ACTION_TOGGLE_SHIFTCLICK, mouseButton));
    }
    else if (button.id == 100 && this.baublesLoaded)
    {
        PacketHandler.INSTANCE.sendToServer(new MessageGuiAction(0, new BlockPos(0, 0, 0),
                ReferenceGuiIds.GUI_ID_HANDY_BAG, ItemHandyBag.GUI_ACTION_OPEN_BAUBLES, 0));
    }
}
 
Example 14
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)));
    }
}
 
Example 15
Source File: ItemRingNutrition.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 3 votes vote down vote up
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {

    if(Compat.botan && GuiScreen.isShiftKeyDown() && getCosmeticItem(stack) != null)
            list.add(String.format(StatCollector.translateToLocal("botaniamisc.hasCosmetic"), getCosmeticItem(stack).getDisplayName()).replaceAll("&", "\u00a7"));

}