use of net.minecraft.text.TranslatableText in project Rug by RubixDev.
the class MaxEffectCommand method register.
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
LiteralArgumentBuilder<ServerCommandSource> command = literal("maxeffect").requires((player) -> SettingsManager.canUseCommand(player, RugSettings.commandMaxEffect)).then(argument("effect", StatusEffectArgumentType.statusEffect()).executes(context -> {
ServerCommandSource source = context.getSource();
ServerPlayerEntity player = source.getPlayer();
StatusEffect effect = StatusEffectArgumentType.getStatusEffect(context, "effect");
boolean success = false;
if (player instanceof LivingEntity) {
StatusEffectInstance statusEffectInstance = new StatusEffectInstance(effect, effect.isInstant() ? 999999 : (999999 * 20), 255, false, false);
success = (player).addStatusEffect(statusEffectInstance, source.getEntity());
}
if (!success) {
throw new SimpleCommandExceptionType(new TranslatableText("commands.effect.give.failed")).create();
}
source.sendFeedback(new TranslatableText("commands.effect.give.success.single", effect.getName(), player.getDisplayName(), 999999), true);
return 1;
}));
dispatcher.register(command);
}
use of net.minecraft.text.TranslatableText in project Primeval by devs-immortal.
the class ClayMoldItem method appendTooltip.
@Environment(EnvType.CLIENT)
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context) {
NbtCompound nbt = stack.getOrCreateNbt();
NbtCompound fluidNbt = nbt.getCompound("Fluid");
int fluidAmount = fluidNbt.getInt("Amount");
if (fluidAmount > 0) {
tooltip.add((new TranslatableText("text.primeval.fluid.contains", fluidAmount, new TranslatableText("block." + fluidNbt.getString("fluid").replace(':', '.')))).formatted(Formatting.GRAY));
}
tooltip.add((new TranslatableText("⚖ ").append(this.weight.getText()).append(" ⤧ ").append(this.size.getText())).formatted(Formatting.GRAY));
}
use of net.minecraft.text.TranslatableText in project MiniMap by pl3xgaming.
the class AboutCategory method renderContent.
@Override
public void renderContent(MatrixStack matrixStack, float mouseX, float mouseY, float delta) {
float x = (Monitor.width() + baseX()) / 2F;
float y = baseY() + 80F;
Texture.ICON.tint(matrixStack, x - 32 + 4F, y + 4F, 64, 64, 0x88000000);
Texture.ICON.draw(matrixStack, x - 32, y, 64, 64);
Font.GOODDOG.drawCentered(matrixStack, Lang.TITLE, x + 3F, y + 85F + 3F, 0x88000000);
Font.GOODDOG.drawCentered(matrixStack, Lang.TITLE, x, y + 85F, 0xFFFFFFFF);
Font.NOTOSANS.drawCentered(matrixStack, "Copyright (c) 2020-2022", x + 1F, y + 140 + 1F, 0x88000000);
Font.NOTOSANS.drawCentered(matrixStack, "Copyright (c) 2020-2022", x, y + 140, 0xFFFFFFFF);
Font.NOTOSANS.drawCentered(matrixStack, "William Blake Galbreath", x + 1F, y + 160 + 1F, 0x88000000);
Font.NOTOSANS.drawCentered(matrixStack, "William Blake Galbreath", x, y + 160, 0xFFFFFFFF);
String mc = UpdateChecker.INSTANCE.getMinecraftVersion();
int current = UpdateChecker.INSTANCE.getCurrentVersion();
int latest = UpdateChecker.INSTANCE.getLatestVersion();
// todo cache this component somewhere
Text currentVersion = new TranslatableText("Current Version: " + mc + (current < 0 ? " SNAPSHOT" : " build " + current));
Font.NOTOSANS.drawCentered(matrixStack, currentVersion, x + 1F, y + 230 + 1F, 0x88000000);
Font.NOTOSANS.drawCentered(matrixStack, currentVersion, x, y + 230, 0xFFFFFFFF);
// todo cache this component somewhere
Text text;
if (latest > 0) {
text = new TranslatableText("Latest Version: " + mc + " build " + latest);
} else if (latest == UpdateChecker.Status.CHECKING) {
text = new TranslatableText("Checking for updates...").formatted(Formatting.LIGHT_PURPLE);
} else if (latest == UpdateChecker.Status.ERROR) {
text = new TranslatableText("Error checking for updates!").formatted(Formatting.RED);
} else if (latest == current) {
text = new TranslatableText("Up to date!").formatted(Formatting.GREEN);
} else {
text = new TranslatableText("Unknown").formatted(Formatting.GOLD);
}
Font.NOTOSANS.drawCentered(matrixStack, text.copy().formatted(Formatting.RESET), x + 1F, y + 260 + 1F, 0x88000000);
Font.NOTOSANS.drawCentered(matrixStack, text, x, y + 260, 0xFFFFFFFF);
if (UpdateChecker.INSTANCE.hasUpdate()) {
Font.ROBOTO.drawCentered(matrixStack, "Updates Available!", x + 1F, y + 280 + 1F, 0x88880000);
Font.ROBOTO.drawCentered(matrixStack, "Updates Available!", x, y + 280, 0xFFFF5555);
}
}
use of net.minecraft.text.TranslatableText in project BlockMeter by ModProg.
the class ColorButton method init.
@Override
protected void init() {
ModConfig config = BlockMeterClient.getConfigManager().getConfig();
// Create Color Selector
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 4; ++j) {
final int colorIndex = i * 4 + j;
this.addDrawableChild(new ColorButton(this.width / 2 - 44 + j * 22, this.height / 2 - 88 + i * 22, 20, 20, null, DyeColor.byId(colorIndex).getColorComponents(), config.colorIndex == colorIndex, false, button -> {
ClientMeasureBox.setColorIndex(colorIndex);
final ClientMeasureBox currentBox = BlockMeterClient.getInstance().getCurrentBox();
if (currentBox != null)
currentBox.setColor(DyeColor.byId(colorIndex));
MinecraftClient.getInstance().setScreen((Screen) null);
}));
}
}
this.addDrawableChild(new ButtonWidget(this.width / 2 - BUTTONWIDTH / 2, this.height / 2 + 10, BUTTONWIDTH, 20, new TranslatableText("blockmeter.keepColor", new Object[] { new TranslatableText(config.incrementColor ? "options.off" : "options.on") }), button -> {
config.incrementColor = !config.incrementColor;
MinecraftClient.getInstance().setScreen((Screen) null);
// Todo find a way to increment to a new Color if a box was created while
// incrementColor was disabled
BlockMeterClient.getConfigManager().save();
}));
this.addDrawableChild(new ButtonWidget(this.width / 2 - BUTTONWIDTH / 2, this.height / 2 + 32, BUTTONWIDTH, 20, new TranslatableText("blockmeter.diagonal", new Object[] { new TranslatableText(config.innerDiagonal ? "options.on" : "options.off") }), button -> {
System.err.println("IDK WHAT YOU ARE DOING");
config.innerDiagonal = !config.innerDiagonal;
MinecraftClient.getInstance().setScreen((Screen) null);
BlockMeterClient.getConfigManager().save();
}));
this.addDrawableChild(new ButtonWidget(this.width / 2 - BUTTONWIDTH / 2, this.height / 2 + 54, BUTTONWIDTH, 20, new TranslatableText("blockmeter.showOthers", new Object[] { new TranslatableText(config.showOtherUsersBoxes ? "options.on" : "options.off") }), button -> {
System.err.println("IDK WHAT YOU ARE DOING");
config.showOtherUsersBoxes = !config.showOtherUsersBoxes;
MinecraftClient.getInstance().setScreen((Screen) null);
BlockMeterClient.getConfigManager().save();
}));
}
use of net.minecraft.text.TranslatableText in project BlockMeter by ModProg.
the class SelectBoxGui method init.
@Override
protected void init() {
final int uiHeight = (boxes.length + 1) * (BUTTONHEIGHT + PADDING);
for (int i = 0; i < boxes.length; i++) {
final ClientMeasureBox box = boxes[i];
final TranslatableText text = new TranslatableText("blockmeter.boxToString", new Object[] { box.getBlockStart().getX(), box.getBlockStart().getY(), box.getBlockStart().getZ(), box.getBlockEnd().getX(), box.getBlockEnd().getY(), box.getBlockEnd().getZ() });
// text.setStyle(text.getStyle().withColor(TextColor.fromRgb(box.getColor().getSignColor())));
this.addDrawableChild(new ColorButton(this.width / 2 - (BUTTONWIDTH) / 2, this.height / 2 - uiHeight / 2 + i * (BUTTONHEIGHT + PADDING), BUTTONWIDTH, BUTTONHEIGHT, text, box.getColor().getColorComponents(), false, true, button -> {
box.loosenCorner(block);
MinecraftClient.getInstance().setScreen((Screen) null);
}));
}
this.addDrawableChild(new ButtonWidget(this.width / 2 - BUTTONWIDTH / 2, this.height / 2 - uiHeight / 2 + boxes.length * (BUTTONHEIGHT + PADDING) + PADDING, BUTTONWIDTH, BUTTONHEIGHT, new TranslatableText("gui.cancel"), button -> {
MinecraftClient.getInstance().setScreen((Screen) null);
}));
}
Aggregations