net.minecraft.client.gui.widget.TextFieldWidget Java Examples

The following examples show how to use net.minecraft.client.gui.widget.TextFieldWidget. 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 vote down vote up
@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 vote down vote up
@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 vote down vote up
@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 vote down vote up
@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: NavigatorMainScreen.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onResize()
{
	TextRenderer tr = WurstClient.MC.textRenderer;
	searchBar =
		new TextFieldWidget(tr, 0, 32, 200, 20, new LiteralText(""));
	searchBar.setHasBorder(false);
	searchBar.setMaxLength(128);
	
	children.add(searchBar);
	setInitialFocus(searchBar);
	searchBar.setSelected(true);
	
	searchBar.x = middleX - 100;
	setContentHeight(navigatorDisplayList.size() / 3 * 20);
}
 
Example #6
Source File: EditBlockListScreen.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void init()
{
	listGui = new ListGui(client, this, blockList.getBlockNames());
	
	blockNameField = new TextFieldWidget(client.textRenderer,
		width / 2 - 152, height - 55, 150, 18, new LiteralText(""));
	children.add(blockNameField);
	
	addButton(addButton = new ButtonWidget(width / 2 - 2, height - 56, 30,
		20, new LiteralText("Add"), b -> {
			blockList.add(blockToAdd);
			blockNameField.setText("");
		}));
	
	addButton(removeButton = new ButtonWidget(width / 2 + 52, height - 56,
		100, 20, new LiteralText("Remove Selected"),
		b -> blockList.remove(listGui.selected)));
	
	addButton(new ButtonWidget(width - 108, 8, 100, 20,
		new LiteralText("Reset to Defaults"),
		b -> client.openScreen(new ConfirmScreen(b2 -> {
			if(b2)
				blockList.resetToDefaults();
			client.openScreen(EditBlockListScreen.this);
		}, new LiteralText("Reset to Defaults"),
			new LiteralText("Are you sure?")))));
	
	addButton(
		doneButton = new ButtonWidget(width / 2 - 100, height - 28, 200, 20,
			new LiteralText("Done"), b -> client.openScreen(prevScreen)));
}
 
Example #7
Source File: EditItemListScreen.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void init()
{
	listGui = new ListGui(client, this, itemList.getItemNames());
	
	itemNameField = new TextFieldWidget(client.textRenderer,
		width / 2 - 152, height - 55, 150, 18, new LiteralText(""));
	children.add(itemNameField);
	
	addButton(addButton = new ButtonWidget(width / 2 - 2, height - 56, 30,
		20, new LiteralText("Add"), b -> {
			itemList.add(itemToAdd);
			itemNameField.setText("");
		}));
	
	addButton(removeButton = new ButtonWidget(width / 2 + 52, height - 56,
		100, 20, new LiteralText("Remove Selected"),
		b -> itemList.remove(listGui.selected)));
	
	addButton(new ButtonWidget(width - 108, 8, 100, 20,
		new LiteralText("Reset to Defaults"),
		b -> client.openScreen(new ConfirmScreen(b2 -> {
			if(b2)
				itemList.resetToDefaults();
			client.openScreen(EditItemListScreen.this);
		}, new LiteralText("Reset to Defaults"),
			new LiteralText("Are you sure?")))));
	
	addButton(
		doneButton = new ButtonWidget(width / 2 - 100, height - 28, 200, 20,
			new LiteralText("Done"), b -> client.openScreen(prevScreen)));
}
 
Example #8
Source File: ServerFinderScreen.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
@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 #9
Source File: LoginScreen.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
public void init() {
	this.addButton(new Button(width / 2 - 100, height / 3 + 84, 200, 20, "Done", (button) -> {
		minecraft.displayGuiScreen(new BleachMainMenu());
    }));
	this.addButton(new Button(width / 2 - 100, height / 3 + 62, 200, 20, "Login", (button) -> {
		loginResult = LoginManager.login(userField.getText(), passField.getText());
    }));
	
	this.userField = new TextFieldWidget(this.font, width / 2 - 98, height / 4 + 10, 196, 18, "");
	this.passField = new TextFieldWidget(this.font, width / 2 - 98, height / 4 + 40, 196, 18, "");
	
	super.init();
}
 
Example #10
Source File: GuiBlockList.java    From XRay-Mod with GNU General Public License v3.0 5 votes vote down vote up
@Override // @mcp: func_231160_c_ = init
public void func_231160_c_() {
    this.blockList = new ScrollingBlockList((getWidth() / 2) + 1, getHeight() / 2 - 12, 202, 185, this.blocks);
    this.field_230705_e_.add(this.blockList); // @mcp: field_230705_e_ = children

    search = new TextFieldWidget(getFontRender(), getWidth() / 2 - 100, getHeight() / 2 + 85, 140, 18, new StringTextComponent(""));
    search.func_231049_c__(true); // @mcp: func_231049_c__ = changeFocus
    this.func_231035_a_(search);// @mcp: func_231035_a_ = setFocused

    addButton(new Button(getWidth() / 2 + 43, getHeight() / 2 + 84, 60, 20, new TranslationTextComponent("xray.single.cancel"), b -> this.onClose()));
}
 
Example #11
Source File: MixinMultiplayerScreen.java    From ViaFabric with MIT License 4 votes vote down vote up
@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);
}