use of net.minecraft.text.Text in project meteor-client by MeteorDevelopment.
the class BetterTab method getPlayerName.
public Text getPlayerName(PlayerListEntry playerListEntry) {
Text name;
Color color = null;
name = playerListEntry.getDisplayName();
if (name == null)
name = new LiteralText(playerListEntry.getProfile().getName());
if (playerListEntry.getProfile().getId().toString().equals(mc.player.getGameProfile().getId().toString()) && self.get()) {
color = selfColor.get();
} else if (friends.get() && Friends.get().get(playerListEntry.getProfile().getName()) != null) {
Friend friend = Friends.get().get(playerListEntry.getProfile().getName());
if (friend != null)
color = Friends.get().color;
}
if (color != null) {
String nameString = name.getString();
for (Formatting format : Formatting.values()) {
if (format.isColor())
nameString = nameString.replace(format.toString(), "");
}
name = new LiteralText(nameString).setStyle(name.getStyle().withColor(new TextColor(color.getPacked())));
}
return name;
}
use of net.minecraft.text.Text in project meteor-client by MeteorDevelopment.
the class Names method getSoundName.
public static String getSoundName(Identifier id) {
return soundNames.computeIfAbsent(id, identifier -> {
WeightedSoundSet soundSet = mc.getSoundManager().get(identifier);
if (soundSet == null)
return identifier.getPath();
Text text = soundSet.getSubtitle();
if (text == null)
return identifier.getPath();
return StringHelper.stripTextFormat(text.getString());
});
}
use of net.minecraft.text.Text in project FZMM-Mod by Zailer43.
the class GenericCallback method copyItemName.
private boolean copyItemName(boolean copyStyle) {
MinecraftClient mc = MinecraftClient.getInstance();
ItemStack stack = InventoryUtils.getFocusedSlot();
if (stack == null)
return true;
Text name = stack.hasCustomName() ? stack.getName() : stack.getItem().getName();
if (copyStyle) {
mc.keyboard.setClipboard(Text.Serializer.toJson(name));
} else {
mc.keyboard.setClipboard(name.getString());
}
return true;
}
use of net.minecraft.text.Text in project tweakermore by Fallen-Breath.
the class ContainerFiller method process.
@Override
public boolean process(ClientPlayerEntity player, ContainerScreen<?> containerScreen, List<Slot> allSlots, List<Slot> playerInvSlots, List<Slot> containerInvSlots) {
Slot bestSlot = null;
long maxCount = TweakerMoreConfigs.AUTO_FILL_CONTAINER_THRESHOLD.getIntegerValue() - 1;
for (Slot slot : playerInvSlots) if (slot.hasStack() && containerInvSlots.get(0).canInsert(slot.getStack())) {
long cnt = playerInvSlots.stream().filter(slt -> InventoryUtils.areStacksEqual(slot.getStack(), slt.getStack())).count();
if (cnt > maxCount) {
maxCount = cnt;
bestSlot = slot;
} else if (cnt == maxCount && bestSlot != null && !InventoryUtils.areStacksEqual(slot.getStack(), bestSlot.getStack())) {
bestSlot = null;
}
}
if (bestSlot != null && !allSlots.isEmpty()) {
Text stackName = bestSlot.getStack().getName();
InventoryUtils.tryMoveStacks(bestSlot, containerScreen, true, true, false);
long amount = containerInvSlots.stream().filter(Slot::hasStack).count(), total = containerInvSlots.size();
boolean isFull = Container.calculateComparatorOutput(containerInvSlots.get(0).inventory) >= 15;
String percentage = String.format("%s%d/%d%s", isFull ? Formatting.GREEN : Formatting.GOLD, amount, total, Formatting.RESET);
InfoUtils.printActionbarMessage("tweakermore.config.tweakmAutoFillContainer.container_filled", containerScreen.getTitle(), stackName, percentage);
return true;
} else {
InfoUtils.printActionbarMessage("tweakermore.config.tweakmAutoFillContainer.best_slot_not_found");
return false;
}
}
use of net.minecraft.text.Text in project tweakermore by Fallen-Breath.
the class SignTextCopier method copySignText.
public static boolean copySignText(KeyAction action, IKeybind key) {
MinecraftClient mc = MinecraftClient.getInstance();
if (mc.world != null && mc.crosshairTarget != null && mc.crosshairTarget.getType() == HitResult.Type.BLOCK) {
BlockPos blockPos = ((BlockHitResult) mc.crosshairTarget).getBlockPos();
BlockState blockState = mc.world.getBlockState(blockPos);
if (blockState.getBlock() instanceof AbstractSignBlock) {
BlockEntity blockEntity = mc.world.getBlockEntity(blockPos);
if (blockEntity instanceof SignBlockEntity) {
String text = Joiner.on("\n").join(Arrays.stream(((SignBlockEntity) blockEntity).text).map(Text::getString).collect(Collectors.toList()));
text = StringUtils.strip(text);
if (!text.isEmpty()) {
mc.keyboard.setClipboard(text);
InfoUtils.printActionbarMessage("tweakermore.config.copySignTextToClipBoard.sign_copied", blockState.getBlock().getName());
} else {
InfoUtils.printActionbarMessage("tweakermore.config.copySignTextToClipBoard.empty_sign", blockState.getBlock().getName());
}
return true;
}
}
}
InfoUtils.printActionbarMessage("tweakermore.config.copySignTextToClipBoard.no_sign");
return false;
}
Aggregations