use of net.minecraft.text.Text in project SpeedRunIGT by RedLime.
the class SpeedRunOptionScreen method getToolTip.
public ArrayList<Text> getToolTip(int mouseX, int mouseY) {
ArrayList<Text> tooltipList = new ArrayList<>();
Optional<Element> e = buttonListWidget.hoveredElement(mouseX, mouseY);
if (e.isPresent()) {
Element element = e.get();
if (element instanceof ButtonScrollListWidget.Entry) {
ButtonScrollListWidget.Entry entry = (ButtonScrollListWidget.Entry) element;
AbstractButtonWidget buttonWidget = entry.getButtonWidget();
if (tooltips.containsKey(buttonWidget)) {
String text = tooltips.get(buttonWidget).get();
for (String s : text.split("\n")) {
tooltipList.add(new LiteralText(s));
}
return tooltipList;
}
}
}
if (SpeedRunIGTInfoScreen.UPDATE_STATUS == SpeedRunIGTInfoScreen.UpdateStatus.OUTDATED) {
tooltipList.add(new TranslatableText("speedrunigt.message.update_found"));
}
return tooltipList;
}
use of net.minecraft.text.Text in project Rug by RubixDev.
the class SudoCommand method register.
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
LiteralArgumentBuilder<ServerCommandSource> command = literal("sudo").requires((player) -> SettingsManager.canUseCommand(player, RugSettings.commandSudo)).then(argument("player", StringArgumentType.word()).suggests(((context, builder) -> suggestMatching(getPlayers(context.getSource()), builder))).then(literal("chat").then(argument("message", StringArgumentType.greedyString()).executes(context -> {
String targetPlayerName = StringArgumentType.getString(context, "player");
MinecraftServer server = context.getSource().getServer();
PlayerManager playerManager = server.getPlayerManager();
ServerPlayerEntity targetPlayer = playerManager.getPlayer(targetPlayerName);
if (targetPlayer == null) {
context.getSource().sendError(new LiteralText("Targeted Player could not be found"));
return 0;
}
Text text = new TranslatableText("chat.type.text", targetPlayerName, StringArgumentType.getString(context, "message"));
playerManager.broadcast(text, MessageType.CHAT, targetPlayer.getUuid());
return 1;
}))).then(literal("command").redirect(dispatcher.getRoot(), context -> {
String targetPlayerName = StringArgumentType.getString(context, "player");
MinecraftServer server = context.getSource().getServer();
ServerPlayerEntity player = server.getPlayerManager().getPlayer(targetPlayerName);
if (player == null) {
Message errorMessage = new LiteralText("Targeted player could not be found");
throw new CommandSyntaxException(new SimpleCommandExceptionType(errorMessage), errorMessage);
}
return player.getCommandSource();
})));
dispatcher.register(command);
}
use of net.minecraft.text.Text in project Skyblocker by LifeIsAParadox.
the class ItemUtils method getTooltipStrings.
public static List<String> getTooltipStrings(ItemStack item) {
List<Text> lines = getTooltip(item);
List<String> list = new ArrayList<>();
for (Text line : lines) {
String string = line.getString();
if (!WHITESPACES.matcher(string).matches())
list.add(string);
}
return list;
}
use of net.minecraft.text.Text in project Skyblocker by LifeIsAParadox.
the class ItemListWidget method render.
@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
if (this.isOpen()) {
matrices.push();
matrices.translate(0.0D, 0.0D, 100.0D);
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderTexture(0, TEXTURE);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
this.searchField = ((RecipeBookWidgetAccessor) this).getSearchField();
int i = (this.parentWidth - 147) / 2 - this.leftOffset;
int j = (this.parentHeight - 166) / 2;
this.drawTexture(matrices, i, j, 1, 1, 147, 166);
this.searchField = ((RecipeBookWidgetAccessor) this).getSearchField();
if (!this.searchField.isFocused() && this.searchField.getText().isEmpty()) {
Text hintText = (new TranslatableText("gui.recipebook.search_hint")).formatted(Formatting.ITALIC).formatted(Formatting.GRAY);
drawTextWithShadow(matrices, this.client.textRenderer, hintText, i + 25, j + 14, -1);
} else {
this.searchField.render(matrices, mouseX, mouseY, delta);
}
this.updateSearchResult();
this.results.render(matrices, mouseX, mouseY, delta);
matrices.pop();
}
}
use of net.minecraft.text.Text in project Skyblocker by LifeIsAParadox.
the class SearchResultsWidget method render.
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
RenderSystem.disableDepthTest();
if (this.displayRecipes) {
String craftText = this.recipeResults.get(this.currentPage).text;
this.client.textRenderer.drawWithShadow(matrices, craftText, this.parentX + 11, this.parentY + 31, 0xffffffff);
Text resultText = this.recipeResults.get(this.currentPage).result.getName();
this.client.textRenderer.drawWithShadow(matrices, resultText, this.parentX + 11, this.parentY + 43, 0xffffffff);
this.client.textRenderer.drawWithShadow(matrices, "▶", this.parentX + 96, this.parentY + 90, 0xaaffffff);
}
for (ResultButtonWidget button : resultButtons) button.render(matrices, mouseX, mouseY, delta);
if (this.pageCount > 1) {
String string = (this.currentPage + 1) + "/" + this.pageCount;
int dx = this.client.textRenderer.getWidth(string) / 2;
this.client.textRenderer.draw(matrices, string, this.parentX - dx + 73, this.parentY + 141, -1);
}
if (this.prevPageButton.active)
this.prevPageButton.render(matrices, mouseX, mouseY, delta);
if (this.nextPageButton.active)
this.nextPageButton.render(matrices, mouseX, mouseY, delta);
RenderSystem.enableDepthTest();
}
Aggregations