Created
September 10, 2024 15:42
-
-
Save Densamisten/fe9c9151ebf3f903b5d0ff6823c1ae7b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package exonihility.client.gui; | |
| import net.minecraft.client.font.MultilineText; | |
| import net.minecraft.client.gui.DrawContext; | |
| import net.minecraft.client.gui.screen.Screen; | |
| import net.minecraft.client.gui.widget.EditBoxWidget; | |
| import net.minecraft.text.Text; | |
| public class AllyshipEditor extends Screen { | |
| private EditBoxWidget editBoxWidget; | |
| private MultilineText multilineText; | |
| protected AllyshipEditor() { | |
| super(Text.literal("In-Game Text Editor")); | |
| } | |
| @Override | |
| protected void init() { | |
| super.init(); | |
| // Create an EditBoxWidget for text input | |
| editBoxWidget = new EditBoxWidget(this.textRenderer, 10, 10, this.width - 20, 20, Text.literal("Type here..."), Text.literal("...")); | |
| editBoxWidget.setMaxLength(500); // Set the maximum length of input text | |
| editBoxWidget.setFocused(true); // Automatically focus the text box for input | |
| editBoxWidget.setText("Input...."); | |
| this.addSelectableChild(editBoxWidget); | |
| // Initialize multilineText with the current content of editBoxWidget | |
| multilineText = MultilineText.create(this.textRenderer, Text.literal(editBoxWidget.getText()), this.width - 20); | |
| } | |
| @Override | |
| public void tick() { | |
| // Update the multiline text with the contents of the edit box | |
| multilineText = MultilineText.create(this.textRenderer, Text.literal(editBoxWidget.getText()), this.width - 20); | |
| super.tick(); | |
| } | |
| @Override | |
| public void render(DrawContext context, int mouseX, int mouseY, float delta) { | |
| this.renderBackground(context, mouseX, mouseY, delta); // Render the background | |
| super.render(context, mouseX, mouseY, delta); | |
| // Render the EditBoxWidget | |
| editBoxWidget.render(context, mouseX, mouseY, delta); | |
| // Draw the multiline text below the EditBoxWidget | |
| if (multilineText != null) { | |
| multilineText.drawWithShadow(context, 10, 40, 10, 0xffffff); | |
| } | |
| } | |
| @Override | |
| public boolean shouldPause() { | |
| return false; // Don't pause the game while this screenshot is open | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment