Java Code Examples for net.minecraft.client.gui.widget.TextFieldWidget#setText()
The following examples show how to use
net.minecraft.client.gui.widget.TextFieldWidget#setText() .
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: EnterProfileNameScreen.java From Wurst7 with GNU General Public License v3.0 | 6 votes |
@Override public void init() { int x1 = width / 2 - 100; int y1 = 60; int y2 = height / 3 * 2; TextRenderer tr = client.textRenderer; valueField = new TextFieldWidget(tr, x1, y1, 200, 20, new LiteralText("")); valueField.setText(""); valueField.setSelectionStart(0); children.add(valueField); setInitialFocus(valueField); valueField.setSelected(true); doneButton = new ButtonWidget(x1, y2, 200, 20, new LiteralText("Done"), b -> done()); addButton(doneButton); }
Example 2
Source File: KeybindEditorScreen.java From Wurst7 with GNU General Public License v3.0 | 6 votes |
@Override public void init() { addButton(new ButtonWidget(width / 2 - 100, 60, 200, 20, new LiteralText("Change Key"), b -> client.openScreen(new PressAKeyScreen(this)))); addButton(new ButtonWidget(width / 2 - 100, height / 4 + 72, 200, 20, new LiteralText("Save"), b -> save())); addButton(new ButtonWidget(width / 2 - 100, height / 4 + 96, 200, 20, new LiteralText("Cancel"), b -> client.openScreen(prevScreen))); commandField = new TextFieldWidget(textRenderer, width / 2 - 100, 100, 200, 20, new LiteralText("")); commandField.setMaxLength(65536); children.add(commandField); setInitialFocus(commandField); commandField.setSelected(true); if(oldCommands != null) commandField.setText(oldCommands); }
Example 3
Source File: EditBlockScreen.java From Wurst7 with GNU General Public License v3.0 | 6 votes |
@Override public void init() { int x1 = width / 2 - 100; int y1 = 60; int y2 = height / 3 * 2; TextRenderer tr = client.textRenderer; String valueString = setting.getBlockName(); blockField = new TextFieldWidget(tr, x1, y1, 178, 18, new LiteralText("")); blockField.setText(valueString); blockField.setSelectionStart(0); children.add(blockField); setInitialFocus(blockField); blockField.setSelected(true); doneButton = new ButtonWidget(x1, y2, 200, 20, new LiteralText("Done"), b -> done()); addButton(doneButton); }
Example 4
Source File: EditSliderScreen.java From Wurst7 with GNU General Public License v3.0 | 6 votes |
@Override public void init() { int x1 = width / 2 - 100; int y1 = 60; int y2 = height / 3 * 2; TextRenderer tr = client.textRenderer; ValueDisplay vd = ValueDisplay.DECIMAL; String valueString = vd.getValueString(slider.getValue()); valueField = new TextFieldWidget(tr, x1, y1, 200, 20, new LiteralText("")); valueField.setText(valueString); valueField.setSelectionStart(0); children.add(valueField); setInitialFocus(valueField); valueField.setSelected(true); doneButton = new ButtonWidget(x1, y2, 200, 20, new LiteralText("Done"), b -> done()); addButton(doneButton); }
Example 5
Source File: ServerFinderScreen.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
@Override public void init() { addButton(searchButton = new ButtonWidget(width / 2 - 100, height / 4 + 96 + 12, 200, 20, new LiteralText("Search"), b -> searchOrCancel())); addButton(new ButtonWidget(width / 2 - 100, height / 4 + 120 + 12, 200, 20, new LiteralText("Tutorial"), b -> Util.getOperatingSystem().open( "https://www.wurstclient.net/wiki/Special_Features/Server_Finder/"))); addButton(new ButtonWidget(width / 2 - 100, height / 4 + 144 + 12, 200, 20, new LiteralText("Back"), b -> client.openScreen(prevScreen))); ipBox = new TextFieldWidget(textRenderer, width / 2 - 100, height / 4 + 34, 200, 20, new LiteralText("")); ipBox.setMaxLength(200); ipBox.setSelected(true); children.add(ipBox); maxThreadsBox = new TextFieldWidget(textRenderer, width / 2 - 32, height / 4 + 58, 26, 12, new LiteralText("")); maxThreadsBox.setMaxLength(3); maxThreadsBox.setText("128"); children.add(maxThreadsBox); setInitialFocus(ipBox); state = ServerFinderState.NOT_RUNNING; WurstClient.INSTANCE.getAnalytics() .trackPageView("/multiplayer/server-finder", "Server Finder"); }
Example 6
Source File: MixinMultiplayerScreen.java From ViaFabric with MIT License | 4 votes |
@Inject(method = "init", at = @At("TAIL")) private void onInit(CallbackInfo ci) { protocolVersion = new TextFieldWidget(this.textRenderer, this.width / 2 + 88, 13, 65, 15, new TranslatableText("gui.protocol_version_field.name")); protocolVersion.setTextPredicate(new VersionFormatFilter()); protocolVersion.setChangedListener((text) -> { protocolVersion.setSuggestion(null); int newVersion = ViaFabric.config.getClientSideVersion(); validProtocol = true; try { newVersion = Integer.parseInt(text); } catch (NumberFormatException e) { ProtocolVersion closest = ProtocolVersion.getClosest(text); if (closest != null) { newVersion = closest.getId(); } else { validProtocol = false; List<String> completions = ProtocolVersion.getProtocols().stream() .map(ProtocolVersion::getName) .flatMap(str -> Stream.concat( Arrays.stream(str.split("-")), Arrays.stream(new String[]{str}) )) .distinct() .filter(ver -> ver.startsWith(text)) .collect(Collectors.toList()); if (completions.size() == 1) { protocolVersion.setSuggestion(completions.get(0).substring(text.length())); } } } supportedProtocol = isSupported(newVersion); protocolVersion.setEditableColor(getTextColor()); int finalNewVersion = newVersion; if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null); latestProtocolSave = latestProtocolSave.thenRunAsync(() -> { ViaFabric.config.setClientSideVersion(finalNewVersion); ViaFabric.config.saveConfig(); }, ViaFabric.ASYNC_EXECUTOR); }); int clientSideVersion = ViaFabric.config.getClientSideVersion(); protocolVersion.setVisible(ViaFabric.config.isClientSideEnabled()); protocolVersion.setText(ProtocolVersion.isRegistered(clientSideVersion) ? ProtocolVersion.getProtocol(clientSideVersion).getName() : Integer.toString(clientSideVersion)); this.children.add(protocolVersion); enableClientSideViaVersion = new TexturedButtonWidget(this.width / 2 + 113, 10, 40, 20, // Size 0, 0, // Start pos of texture 20, // v Hover offset new Identifier("viafabric:textures/gui/via_button.png"), 64, 64, // Texture size button -> MinecraftClient.getInstance().openScreen(new ConfirmScreen( answer -> { MinecraftClient.getInstance().openScreen(this); if (answer) { ViaFabric.config.setClientSideEnabled(true); ViaFabric.config.saveConfig(); protocolVersion.setVisible(true); enableClientSideViaVersion.visible = false; } }, new TranslatableText("gui.enable_client_side.question"), new TranslatableText("gui.enable_client_side.warning"), new TranslatableText("gui.enable_client_side.enable"), new TranslatableText("gui.cancel") )), new TranslatableText("gui.enable_client_side_button")); enableClientSideViaVersion.visible = !protocolVersion.isVisible(); addButton(enableClientSideViaVersion); }