Search in sources :

Example 96 with TranslatableText

use of net.minecraft.text.TranslatableText in project bewitchment by MoriyaShiine.

the class SearchBlocksRitualFunction method start.

@Override
public void start(ServerWorld world, BlockPos glyphPos, BlockPos effectivePos, Inventory inventory, boolean catFamiliar) {
    PlayerEntity closestPlayer = world.getClosestPlayer(glyphPos.getX() + 0.5, glyphPos.getY() + 0.5, glyphPos.getZ() + 0.5, 8, false);
    if (closestPlayer != null) {
        Block block = world.getBlockState(glyphPos.down(2)).getBlock();
        int blocks = BWUtil.getBlockPoses(effectivePos, catFamiliar ? 48 : 16, currentPos -> world.getBlockState(currentPos).getBlock() == block).size();
        closestPlayer.sendMessage(new TranslatableText(Bewitchment.MODID + ".message.found_block" + (blocks == 1 ? "" : "s"), blocks, block.getName()), true);
    }
    super.start(world, glyphPos, effectivePos, inventory, catFamiliar);
}
Also used : Block(net.minecraft.block.Block) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ParticleType(net.minecraft.particle.ParticleType) LivingEntity(net.minecraft.entity.LivingEntity) Predicate(java.util.function.Predicate) ServerWorld(net.minecraft.server.world.ServerWorld) RitualFunction(moriyashiine.bewitchment.api.registry.RitualFunction) TranslatableText(net.minecraft.text.TranslatableText) BWUtil(moriyashiine.bewitchment.common.misc.BWUtil) Inventory(net.minecraft.inventory.Inventory) BlockPos(net.minecraft.util.math.BlockPos) Bewitchment(moriyashiine.bewitchment.common.Bewitchment) TranslatableText(net.minecraft.text.TranslatableText) Block(net.minecraft.block.Block) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 97 with TranslatableText

use of net.minecraft.text.TranslatableText in project ThonkUtil by LimeAppleBoat.

the class TranslationUtil method translateNumeric.

public static Text translateNumeric(String key, int[]... args) {
    Object[] realArgs = new Object[args.length];
    for (int i = 0; i < args.length; i++) {
        NumberFormat nf = NumberFormat.getInstance();
        if (args[i].length == 1) {
            realArgs[i] = nf.format(args[i][0]);
        } else {
            assert args[i].length == 2;
            realArgs[i] = nf.format(args[i][0]) + "/" + nf.format(args[i][1]);
        }
    }
    int[] override = new int[args.length];
    Arrays.fill(override, -1);
    for (int i = 0; i < args.length; i++) {
        int[] arg = args[i];
        if (arg == null) {
            throw new NullPointerException("args[" + i + "]");
        }
        if (arg.length == 1) {
            override[i] = arg[0];
        }
    }
    String lastKey = key;
    for (int flags = (1 << args.length) - 1; flags >= 0; flags--) {
        StringBuilder fullKey = new StringBuilder(key);
        for (int i = 0; i < args.length; i++) {
            fullKey.append('.');
            if (((flags & (1 << i)) != 0) && override[i] != -1) {
                fullKey.append(override[i]);
            } else {
                fullKey.append('n');
            }
        }
        lastKey = fullKey.toString();
        if (I18n.hasTranslation(lastKey)) {
            return new TranslatableText(lastKey, realArgs);
        }
    }
    return new TranslatableText(lastKey, realArgs);
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) NumberFormat(java.text.NumberFormat)

Example 98 with TranslatableText

use of net.minecraft.text.TranslatableText in project reeses-sodium-options by FlashyReese.

the class OptionPageScrollFrame method renderOptionTooltip.

private void renderOptionTooltip(MatrixStack matrixStack, int mouseX, int mouseY, ControlElement<?> element) {
    if (this.lastTime + 500 > System.currentTimeMillis())
        return;
    Dim2i dim = element.getDimensions();
    int textPadding = 3;
    int boxPadding = 3;
    int boxWidth = dim.width();
    // Offset based on mouse position, width and height of content and width and height of the window
    int boxY = dim.getLimitY();
    int boxX = dim.x();
    Option<?> option = element.getOption();
    List<OrderedText> tooltip = new ArrayList<>(MinecraftClient.getInstance().textRenderer.wrapLines(option.getTooltip(), boxWidth - (textPadding * 2)));
    OptionImpact impact = option.getImpact();
    if (impact != null) {
        tooltip.add(Language.getInstance().reorder(new TranslatableText("sodium.options.performance_impact_string", impact.getLocalizedName()).formatted(Formatting.GRAY)));
    }
    int boxHeight = (tooltip.size() * 12) + boxPadding;
    int boxYLimit = boxY + boxHeight;
    int boxYCutoff = this.dim.getLimitY();
    // If the box is going to be cutoff on the Y-axis, move it back up the difference
    if (boxYLimit > boxYCutoff) {
        boxY -= boxHeight + dim.height();
    }
    if (boxY < 0) {
        boxY = dim.getLimitY();
    }
    this.drawRect(boxX, boxY, boxX + boxWidth, boxY + boxHeight, 0xE0000000);
    this.drawRectOutline(boxX, boxY, boxX + boxWidth, boxY + boxHeight, 0xFF94E4D3);
    for (int i = 0; i < tooltip.size(); i++) {
        MinecraftClient.getInstance().textRenderer.draw(matrixStack, tooltip.get(i), boxX + textPadding, boxY + textPadding + (i * 12), 0xFFFFFFFF);
    }
}
Also used : Dim2i(me.jellysquid.mods.sodium.client.util.Dim2i) TranslatableText(net.minecraft.text.TranslatableText) OptionImpact(me.jellysquid.mods.sodium.client.gui.options.OptionImpact) OrderedText(net.minecraft.text.OrderedText) ArrayList(java.util.ArrayList)

Example 99 with TranslatableText

use of net.minecraft.text.TranslatableText in project ThonkUtil by LimeAppleBoat.

the class ThonkUtil method showMessage.

@SubscribeEvent
@Environment(EnvType.CLIENT)
public static void showMessage(TitleScreenRenderEvent event) {
    if (state.equals(State.RELEASE))
        return;
    Text text = new LiteralText("").append(new TranslatableText("thonkutil.warning.1").formatted(Formatting.RED)).append(new TranslatableText("thonkutil." + state).formatted(state.formatting)).append(new TranslatableText("thonkutil.warning.1.1").formatted(Formatting.RED));
    DrawableHelper.drawCenteredText(event.matrices(), MinecraftClient.getInstance().textRenderer, text, event.screen().width / 2, 4 + (0 * (MinecraftClient.getInstance().textRenderer.fontHeight + 1)), 0xFFFFFF | event.alpha());
    text = new TranslatableText(state.translationKeyDesc);
    DrawableHelper.drawCenteredText(event.matrices(), MinecraftClient.getInstance().textRenderer, text, event.screen().width / 2, 4 + (1 * (MinecraftClient.getInstance().textRenderer.fontHeight + 1)), 0xFFFFFF | event.alpha());
    text = new TranslatableText("thonkutil.warning.3");
    DrawableHelper.drawCenteredText(event.matrices(), MinecraftClient.getInstance().textRenderer, text, event.screen().width / 2, 4 + (2 * (MinecraftClient.getInstance().textRenderer.fontHeight + 1)), 0xFFFFFF | event.alpha());
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) LiteralText(net.minecraft.text.LiteralText) TranslatableText(net.minecraft.text.TranslatableText) Text(net.minecraft.text.Text) LiteralText(net.minecraft.text.LiteralText) SubscribeEvent(com.jab125.thonkutil.api.annotations.SubscribeEvent)

Example 100 with TranslatableText

use of net.minecraft.text.TranslatableText in project ThonkUtil by LimeAppleBoat.

the class TemperatureCommand method execute.

private static int execute(ServerCommandSource source, Collection<? extends Entity> targets, boolean alt) {
    Iterator<? extends Entity> var2 = targets.iterator();
    List<Float> a = new ArrayList<>();
    while (var2.hasNext()) {
        Entity entity = var2.next();
        a.add(!alt ? TemperatureUtil.getTemperature(entity) : TemperatureUtil.getTemperatureAlt(entity));
    }
    var b = a.iterator();
    if (targets.size() == 1) {
    // source.sendFeedback(new TranslatableText("commands.temperature.success.single", ((Entity)targets.iterator().next()).getDisplayName(), a.iterator().next()), true);
    } else {
    // source.sendFeedback(new TranslatableText("commands.temperature.success.multiple", targets.size(), a.iterator().next()), true);
    }
    int x = 0;
    for (Entity target : targets) {
        if (x > 10)
            return 10;
        source.sendFeedback(new TranslatableText("commands.temperature.success.single", target.getDisplayName(), b.next()), true);
        x++;
    }
    return targets.size();
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) Entity(net.minecraft.entity.Entity) ArrayList(java.util.ArrayList)

Aggregations

TranslatableText (net.minecraft.text.TranslatableText)161 LiteralText (net.minecraft.text.LiteralText)30 Text (net.minecraft.text.Text)19 ItemStack (net.minecraft.item.ItemStack)16 ArrayList (java.util.ArrayList)15 ButtonWidget (net.minecraft.client.gui.widget.ButtonWidget)14 List (java.util.List)12 MinecraftClient (net.minecraft.client.MinecraftClient)12 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)12 SPEInterface (eu.pb4.armorstandeditor.helpers.SPEInterface)9 LivingEntity (net.minecraft.entity.LivingEntity)9 PlayerEntity (net.minecraft.entity.player.PlayerEntity)8 ListTag (net.minecraft.nbt.ListTag)8 Formatting (net.minecraft.util.Formatting)8 BlockPos (net.minecraft.util.math.BlockPos)8 Environment (net.fabricmc.api.Environment)7 AbstractButtonWidget (net.minecraft.client.gui.widget.AbstractButtonWidget)7 Entity (net.minecraft.entity.Entity)7 Collection (java.util.Collection)6 ArmorStandPreset (eu.pb4.armorstandeditor.config.ArmorStandPreset)5