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);
}
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);
}
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);
}
}
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());
}
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();
}
Aggregations