use of net.minecraft.text.LiteralText in project nbt-crafting by Siphalor.
the class MixinAnvilContainer method updateResult.
@Inject(method = "updateResult", at = @At("HEAD"), cancellable = true)
public void updateResult(CallbackInfo callbackInfo) {
recipe = player.world.getRecipeManager().getFirstMatch(NbtCrafting.ANVIL_RECIPE_TYPE, inventory, player.world).orElse(null);
if (recipe != null) {
ItemStack resultStack = recipe.craft(inventory);
repairItemUsage = 1;
if (userChangedName) {
if (!StringUtils.isBlank(newItemName) && !newItemName.equals(resultStack.getName().getString())) {
resultStack.setCustomName(new LiteralText(newItemName));
}
userChangedName = false;
} else {
newItemName = resultStack.getName().getString();
if (player instanceof ServerPlayerEntity) {
if (NbtCrafting.hasClientMod((ServerPlayerEntity) player)) {
PacketByteBuf packetByteBuf = new PacketByteBuf(Unpooled.buffer());
packetByteBuf.writeString(newItemName);
ServerSidePacketRegistry.INSTANCE.sendToPlayer(player, NbtCrafting.UPDATE_ANVIL_TEXT_S2C_PACKET_ID, packetByteBuf);
}
}
}
result.setInvStack(0, resultStack);
levelCost.set(recipe.getLevels());
sendContentUpdates();
callbackInfo.cancel();
}
}
use of net.minecraft.text.LiteralText in project reeses-sodium-options by FlashyReese.
the class SodiumVideoOptionsScreen method parentFrameBuilder.
protected BasicFrame.Builder parentFrameBuilder() {
BasicFrame.Builder basicFrameBuilder;
Dim2i basicFrameDim = new Dim2i(0, 0, this.width, this.height);
Dim2i tabFrameDim = new Dim2i(basicFrameDim.width() / 20 / 2, basicFrameDim.height() / 4 / 2, basicFrameDim.width() - (basicFrameDim.width() / 20), basicFrameDim.height() / 4 * 3);
Dim2i undoButtonDim = new Dim2i(tabFrameDim.getLimitX() - 203, tabFrameDim.getLimitY() + 5, 65, 20);
Dim2i applyButtonDim = new Dim2i(tabFrameDim.getLimitX() - 134, tabFrameDim.getLimitY() + 5, 65, 20);
Dim2i closeButtonDim = new Dim2i(tabFrameDim.getLimitX() - 65, tabFrameDim.getLimitY() + 5, 65, 20);
Dim2i donateButtonDim = new Dim2i(tabFrameDim.getLimitX() - 122, tabFrameDim.y() - 26, 100, 20);
Dim2i hideDonateButtonDim = new Dim2i(tabFrameDim.getLimitX() - 20, tabFrameDim.y() - 26, 20, 20);
this.undoButton = new FlatButtonWidget(undoButtonDim, new TranslatableText("sodium.options.buttons.undo"), this::undoChanges);
this.applyButton = new FlatButtonWidget(applyButtonDim, new TranslatableText("sodium.options.buttons.apply"), this::applyChanges);
this.closeButton = new FlatButtonWidget(closeButtonDim, new TranslatableText("gui.done"), this::close);
this.donateButton = new FlatButtonWidget(donateButtonDim, new TranslatableText("sodium.options.buttons.donate"), this::openDonationPage);
this.hideDonateButton = new FlatButtonWidget(hideDonateButtonDim, new LiteralText("x"), this::hideDonationButton);
if (SodiumClientMod.options().notifications.hideDonationButton) {
this.setDonationButtonVisibility(false);
}
basicFrameBuilder = this.parentBasicFrameBuilder(basicFrameDim, tabFrameDim);
if (FabricLoader.getInstance().isModLoaded("iris")) {
int size = this.client.textRenderer.getWidth(new TranslatableText(IrisApi.getInstance().getMainScreenLanguageKey()));
Dim2i shaderPackButtonDim;
if (!SodiumClientMod.options().notifications.hideDonationButton) {
shaderPackButtonDim = new Dim2i(tabFrameDim.getLimitX() - 134 - size, tabFrameDim.y() - 26, 10 + size, 20);
} else {
shaderPackButtonDim = new Dim2i(tabFrameDim.getLimitX() - size - 10, tabFrameDim.y() - 26, 10 + size, 20);
}
FlatButtonWidget shaderPackButton = new FlatButtonWidget(shaderPackButtonDim, new TranslatableText(IrisApi.getInstance().getMainScreenLanguageKey()), () -> this.client.setScreen((Screen) IrisApi.getInstance().openMainIrisScreenObj(this)));
basicFrameBuilder.addChild(dim -> shaderPackButton);
}
return basicFrameBuilder;
}
use of net.minecraft.text.LiteralText in project SpeedRunIGT by RedLime.
the class SpeedRunIGTInfoScreen method render.
@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
this.renderBackground(matrices);
matrices.push();
matrices.scale(1.5F, 1.5F, 1.5F);
this.drawCenteredText(matrices, this.textRenderer, this.title, this.width / 3, 15, 16777215);
matrices.pop();
this.drawCenteredText(matrices, this.textRenderer, new LiteralText("Made by RedLime"), this.width / 2, 50, 16777215);
this.drawCenteredText(matrices, this.textRenderer, new LiteralText("Discord : RedLime#0817"), this.width / 2, 62, 16777215);
this.drawCenteredText(matrices, this.textRenderer, new LiteralText("Version : " + SpeedRunIGT.MOD_VERSION.split("\\+")[0]), this.width / 2, 78, 16777215);
if (UPDATE_STATUS != UpdateStatus.NONE) {
if (UPDATE_STATUS == UpdateStatus.OUTDATED) {
update.active = true;
this.drawCenteredText(matrices, this.textRenderer, new LiteralText("Updated Version : " + UPDATE_VERSION).formatted(Formatting.YELLOW), this.width / 2, 88, 16777215);
}
this.drawCenteredText(matrices, this.textRenderer, new TranslatableText("speedrunigt.message.update." + UPDATE_STATUS.name().toLowerCase(Locale.ROOT)), this.width / 2, 116, 16777215);
}
super.render(matrices, mouseX, mouseY, delta);
}
use of net.minecraft.text.LiteralText in project SpeedRunIGT by RedLime.
the class TimerCustomizeScreen method render.
@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
saveButton.active = changed;
this.renderBackground(matrices);
drawer.draw();
this.drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 15, 16777215);
if (!hide) {
if (!igtButton.active || !rtaButton.active) {
if (drawer.isLocked()) {
drawCenteredText(matrices, this.textRenderer, new TranslatableText("speedrunigt.option.timer_position.description.lock"), this.width / 2, this.height / 2 - 80, 16777215);
} else {
drawCenteredText(matrices, this.textRenderer, new TranslatableText("speedrunigt.option.timer_position.description"), this.width / 2, this.height / 2 - 80, 16777215);
drawCenteredText(matrices, this.textRenderer, new TranslatableText("speedrunigt.option.timer_position.description.move"), this.width / 2, this.height / 2 - 69, 16777215);
}
}
if (!fontButton.active && client != null) {
int c = fontPage * 3;
FontManagerAccessor fontManager = (FontManagerAccessor) ((MinecraftClientAccessor) client).getFontManager();
for (int i = 0; i < fontSelectButtons.size(); i++) {
if (c + i < availableFonts.size()) {
Identifier fontIdentifier = availableFonts.get(c + i);
LiteralText text = new LiteralText(fontIdentifier.getPath());
if (client != null && fontManager.getFontStorages().containsKey(fontIdentifier)) {
text.setStyle(text.getStyle().withFont(fontIdentifier));
} else {
text.append(new LiteralText(" (Unavailable)")).formatted(Formatting.RED);
}
if (fontIdentifier.toString().equals(drawer.getTimerFont().toString())) {
text.append(" [Selected]").formatted(Formatting.ITALIC);
}
drawCenteredText(matrices, this.textRenderer, text, this.width / 2 - 30, this.height / 2 - 11 + (i * 22), 16777215);
}
}
}
}
super.render(matrices, mouseX, mouseY, delta);
}
use of net.minecraft.text.LiteralText in project fabric-name-history-lookup by Woolyenough.
the class ClientCommands method names.
private static int names(CommandContext<FabricClientCommandSource> context) {
CompletableFuture.runAsync(() -> {
String name = context.getInput().split(" ")[1];
String[] playerNameAndUUID = get_player_name_and_uuid(name);
String username = playerNameAndUUID[0];
String uuid = playerNameAndUUID[1];
if (Objects.equals(username, "None")) {
context.getSource().sendError(new LiteralText("No account exists by that name .-."));
} else {
context.getSource().sendFeedback(new LiteralText("§7[Hover] §eView name history of " + username).styled(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://namemc.com/profile/" + username)).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, get_player_name_history(username, uuid).append(new LiteralText("\n\n§7§oClick to open in NameMC!"))))));
}
});
return 0;
}
Aggregations