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

The following examples show how to use net.minecraft.client.gui.GuiScreen#setClipboardString() . 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: CmdReport.java    From I18nUpdateMod with MIT License 6 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) {
    ItemStack stack = Minecraft.getMinecraft().player.inventory.getCurrentItem();
    if (!stack.isEmpty()) {
        String text = String.format("模组ID:%s\n非本地化名称:%s\n显示名称:%s", stack.getItem().getCreatorModId(stack), stack.getItem().getUnlocalizedName(), stack.getDisplayName());
        String url = I18nConfig.key.reportURL;
        try {
            GuiScreen.setClipboardString(text);
            Desktop.getDesktop().browse(new URI(url));
        } catch (Exception urlException) {
            urlException.printStackTrace();
        }
    } else {
        Minecraft.getMinecraft().player.sendMessage(new TextComponentTranslation("message.i18nmod.cmd_report.empty"));
    }
}
 
Example 2
Source File: HotKeyHandler.java    From I18nUpdateMod with MIT License 5 votes vote down vote up
/**
 * 获取物品信息,并打开浏览器
 *
 * @param stack 物品
 * @return 是否成功
 */
private boolean openReport(ItemStack stack) {
    String text = String.format("模组ID:%s\n非本地化名称:%s\n显示名称:%s", stack.getItem().getCreatorModId(stack), stack.getItem().getUnlocalizedName(), stack.getDisplayName());
    String url = I18nConfig.key.reportURL;
    try {
        GuiScreen.setClipboardString(text);
        Desktop.getDesktop().browse(new URI(url));
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
    return true;
}
 
Example 3
Source File: GuiPastebin.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void actionPerformed(IGuiWidget widget){
    super.actionPerformed(widget);
    errorMessage = "";
    if(widget.getID() == 0) {
        PastebinHandler.login(usernameBox.getText(), passwordBox.getText());
        state = EnumState.LOGIN;
        errorMessage = I18n.format("gui.pastebin.loggingIn");
    } else if(widget.getID() == 1) {
        PastebinHandler.put(pastingString);
        state = EnumState.PUTTING;
        errorMessage = I18n.format("gui.pastebin.uploadingToPastebin");
    } else if(widget.getID() == 2) {
        PastebinHandler.get(pastebinBox.getText());
        state = EnumState.GETTING;
        errorMessage = I18n.format("gui.pastebin.retrievingFromPastebin");
    } else if(widget.getID() == 3) {
        PastebinHandler.logout();
        state = EnumState.LOGOUT;
    } else if(widget.getID() == 4) {
        GuiScreen.setClipboardString(pastingString);
        errorMessage = I18n.format("gui.pastebin.clipboardSetToContents");
    } else if(widget.getID() == 5) {
        errorMessage = I18n.format("gui.pastebin.retrievedFromClipboard");
        readFromString(GuiScreen.getClipboardString());
    }
}
 
Example 4
Source File: WrapperGuiScreen.java    From ClientBase with MIT License 4 votes vote down vote up
public static void setClipboardString(String var0) {
    GuiScreen.setClipboardString(var0);
}
 
Example 5
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;
}