use of net.minecraft.text.MutableText in project meteor-rejects by AntiCope.
the class SoundLocator method printSound.
private void printSound(SoundInstance sound) {
WeightedSoundSet soundSet = mc.getSoundManager().get(sound.getId());
MutableText text = soundSet.getSubtitle().copy();
text.append(String.format("%s at ", Formatting.RESET));
Vec3d pos = new Vec3d(sound.getX(), sound.getY(), sound.getZ());
text.append(ChatUtils.formatCoords(pos));
text.append(String.format("%s.", Formatting.RESET));
info(text);
}
use of net.minecraft.text.MutableText in project artifality by PinkGoosik.
the class LunarEnchantment method getName.
@Override
public Text getName(int level) {
MutableText text = new TranslatableText(this.getTranslationKey());
text.formatted(Formatting.BLUE);
if (level != 1 || this.getMaxLevel() != 1) {
text.append(" ").append(new TranslatableText("enchantment.level." + level));
}
return text;
}
use of net.minecraft.text.MutableText in project Client by MatHax.
the class BindsCommand method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.executes(context -> {
// Modules
List<Module> modules = Modules.get().getAll().stream().filter(module -> module.keybind.isSet()).collect(Collectors.toList());
info("--- Bound Modules ((highlight)%d(default)) ---", modules.size());
for (Module module : modules) {
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, getTooltip(module));
MutableText text = new LiteralText(module.title).formatted(Formatting.WHITE);
text.setStyle(text.getStyle().withHoverEvent(hoverEvent));
MutableText sep = new LiteralText(" - ");
sep.setStyle(sep.getStyle().withHoverEvent(hoverEvent));
text.append(sep.formatted(Formatting.GRAY));
MutableText key = new LiteralText(module.keybind.toString());
key.setStyle(key.getStyle().withHoverEvent(hoverEvent));
text.append(key.formatted(Formatting.GRAY));
ChatUtils.sendMsg(text);
}
return SINGLE_SUCCESS;
});
}
use of net.minecraft.text.MutableText in project EarthMCEssentials by EarthMC-Stats.
the class ModUtils method getNearbyLongestElement.
public static int getNearbyLongestElement(JsonArray nearbyResidents) {
if (nearbyResidents.size() == 0)
return 0;
int longestElement = 0;
for (int i = 0; i < nearbyResidents.size(); i++) {
JsonObject currentObj = nearbyResidents.get(i).getAsJsonObject();
if (currentObj.get("name") == null || currentObj.get("x") == null || currentObj.get("z") == null)
continue;
if (EarthMCEssentials.instance().getClientResident() != null && currentObj.get("name").getAsString().equals(EarthMCEssentials.instance().getClientResident().getName()))
continue;
int distance = Math.abs(currentObj.get("x").getAsInt() - Objects.requireNonNull(getInstance().player).getBlockX()) + Math.abs(currentObj.get("z").getAsInt() - getInstance().player.getBlockZ());
String prefix = "";
if (EarthMCEssentials.instance().getConfig().nearby.showRank) {
if (!currentObj.has("town"))
prefix = "(Townless) ";
else
prefix = "(" + currentObj.get("rank").getAsString() + ") ";
}
MutableText nearbyText = new TranslatableText(prefix + currentObj.get("name").getAsString() + ": " + distance + "m");
longestElement = Math.max(getTextWidth(nearbyText), longestElement);
}
return longestElement;
}
use of net.minecraft.text.MutableText in project Essential-Commands by John-Paul-R.
the class RealNameCommand method run.
@Override
public int run(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
String nicknameStr = StringArgumentType.getString(context, "player_nickname");
List<PlayerData> nicknamePlayers = PlayerDataManager.getInstance().getPlayerDataMatchingNickname(nicknameStr);
MutableText responseText = new LiteralText("");
// If no players matched the provided nickname
if (nicknamePlayers.size() == 0) {
responseText.append(ECText.getInstance().getText("cmd.realname.feedback.none_match").setStyle(CONFIG.FORMATTING_DEFAULT.getValue())).append(new LiteralText(nicknameStr).setStyle(CONFIG.FORMATTING_ACCENT.getValue())).append(ECText.getInstance().getText("generic.quote_fullstop").setStyle(CONFIG.FORMATTING_DEFAULT.getValue()));
} else {
responseText.append(ECText.getInstance().getText("cmd.realname.feedback.matching.1").setStyle(CONFIG.FORMATTING_DEFAULT.getValue())).append(new LiteralText(nicknameStr).setStyle(CONFIG.FORMATTING_ACCENT.getValue())).append(ECText.getInstance().getText("cmd.realname.feedback.matching.2").setStyle(CONFIG.FORMATTING_DEFAULT.getValue()));
for (PlayerData nicknamePlayer : nicknamePlayers) {
responseText.append("\n ");
responseText.append(nicknamePlayer.getPlayer().getGameProfile().getName());
}
}
context.getSource().sendFeedback(responseText, CONFIG.BROADCAST_TO_OPS.getValue());
return 0;
}
Aggregations