Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better Tooltips, Inventory Tweaks language support #5024

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.gui.screen.ingame.ScreenHandlerProvider;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
Expand Down Expand Up @@ -74,17 +75,21 @@ private void onInit(CallbackInfo info) {
InventoryTweaks invTweaks = Modules.get().get(InventoryTweaks.class);

if (invTweaks.isActive() && invTweaks.showButtons() && invTweaks.canSteal(getScreenHandler())) {

String steal = I18n.translate("modules.meteor-client.inventory-tweaks.steal");
String dump = I18n.translate("modules.meteor-client.inventory-tweaks.dump");

addDrawableChild(
new ButtonWidget.Builder(Text.literal("Steal"), button -> invTweaks.steal(getScreenHandler()))
new ButtonWidget.Builder(Text.literal(steal), button -> invTweaks.steal(getScreenHandler()))
.position(x, y - 22)
.size(40, 20)
.size(steal.length() * 10, 20)
.build()
);

addDrawableChild(
new ButtonWidget.Builder(Text.literal("Dump"), button -> invTweaks.dump(getScreenHandler()))
.position(x + 42, y - 22)
.size(40, 20)
new ButtonWidget.Builder(Text.literal(dump), button -> invTweaks.dump(getScreenHandler()))
.position(x + steal.length() * 10 + 2, y - 22)
.size(dump.length() * 10, 20)
.build()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import meteordevelopment.meteorclient.utils.tooltip.*;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.block.entity.BeehiveBlockEntity;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.*;
import net.minecraft.component.type.SuspiciousStewEffectsComponent.StewEffect;
Expand Down Expand Up @@ -295,12 +296,12 @@ private void appendTooltip(ItemStackTooltipEvent event) {
BlockStateComponent blockStateComponent = event.itemStack().get(DataComponentTypes.BLOCK_STATE);
if (blockStateComponent != null) {
String level = blockStateComponent.properties().get("honey_level");
event.appendStart(Text.literal(String.format("%sHoney level: %s%s%s.", Formatting.GRAY, Formatting.YELLOW, level, Formatting.GRAY)));
event.appendStart(Text.literal(I18n.translate("modules.meteor-client.better-tooltips.beehive.honey-level", level)));
}

List<BeehiveBlockEntity.BeeData> bees = event.itemStack().get(DataComponentTypes.BEES);
if (bees != null) {
event.appendStart(Text.literal(String.format("%sBees: %s%d%s.", Formatting.GRAY, Formatting.YELLOW, bees.size(), Formatting.GRAY)));
event.appendStart(Text.literal(I18n.translate("modules.meteor-client.better-tooltips.beehive.bees", bees.size())));
}
}
}
Expand All @@ -315,12 +316,12 @@ private void appendTooltip(ItemStackTooltipEvent event) {

ByteCountDataOutput.INSTANCE.reset();

if (byteCount >= 1024) count = String.format("%.2f kb", byteCount / (float) 1024);
else count = String.format("%d bytes", byteCount);
if (byteCount >= 1024) count = I18n.translate("modules.meteor-client.better-tooltips.kilobytes", byteCount / (float) 1024);
else count = I18n.translate("modules.meteor-client.better-tooltips.bytes", byteCount);

event.appendEnd(Text.literal(count).formatted(Formatting.GRAY));
event.appendEnd(Text.literal(count));
} catch (Exception e) {
event.appendEnd(Text.literal("Error getting bytes.").formatted(Formatting.RED));
event.appendEnd(Text.literal(I18n.translate("modules.meteor-client.better-tooltips.error-getting-bytes")));
}
}

Expand All @@ -340,7 +341,7 @@ private void getTooltipData(TooltipDataEvent event) {
else if (event.itemStack.getItem() == Items.ENDER_CHEST && previewEChest()) {
event.tooltipData = EChestMemory.isKnown()
? new ContainerTooltipComponent(EChestMemory.ITEMS.toArray(new ItemStack[27]), ECHEST_COLOR)
: new TextTooltipComponent(Text.literal("Unknown inventory.").formatted(Formatting.DARK_RED));
: new TextTooltipComponent(Text.literal(I18n.translate("modules.meteor-client.better-tooltips.unknown-inventory")));
}

// Map preview
Expand Down Expand Up @@ -426,7 +427,7 @@ private void appendPreviewTooltipText(ItemStackTooltipEvent event, boolean space
)) {
// we don't want to add the spacer if the tooltip is hidden
if (spacer) event.appendEnd(Text.literal(""));
event.appendEnd(Text.literal("Hold " + Formatting.YELLOW + keybind + Formatting.RESET + " to preview"));
event.appendEnd(Text.literal(I18n.translate("modules.meteor-client.better-tooltips.hold-to-preview", keybind)));
}
}

Expand Down
16 changes: 15 additions & 1 deletion src/main/resources/assets/meteor-client/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
{
"key.meteor-client.open-gui": "Open GUI",
"key.meteor-client.open-commands": "Open Commands"
"key.meteor-client.open-commands": "Open Commands",

"modules.meteor-client.better-tooltips.beehive.honey-level": "§7Honey level: §e%s§7.",
"modules.meteor-client.better-tooltips.beehive.bees": "§7Bees: §e%d§7.",

"modules.meteor-client.better-tooltips.kilobytes": "§7%.2f kb",
"modules.meteor-client.better-tooltips.bytes": "§7%d bytes",
"modules.meteor-client.better-tooltips.error-getting-bytes": "§cError getting bytes.",

"modules.meteor-client.better-tooltips.unknown-inventory": "§4Unknown inventory",

"modules.meteor-client.better-tooltips.hold-to-preview": "Hold §e%s§r to preview",

"modules.meteor-client.inventory-tweaks.dump": "Dump",
"modules.meteor-client.inventory-tweaks.steal": "Steal"
}
18 changes: 18 additions & 0 deletions src/main/resources/assets/meteor-client/lang/ru_ru.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"key.meteor-client.open-gui": "Открыть меню",
"key.meteor-client.open-commands": "Открыть команды",

"modules.meteor-client.better-tooltips.beehive.honey-level": "§7Уровень мёда: §e%s§7.",
"modules.meteor-client.better-tooltips.beehive.bees": "§7Пчел: §e%d§7.",

"modules.meteor-client.better-tooltips.kilobytes": "§7%.2f кб",
"modules.meteor-client.better-tooltips.bytes": "§7%d байт",
"modules.meteor-client.better-tooltips.error-getting-bytes": "§cОшибка при получении байтов.",

"modules.meteor-client.better-tooltips.unknown-inventory": "§4Неизвестный инвентарь",

"modules.meteor-client.better-tooltips.hold-to-preview": "Удерживайте §e%s§r для предпросмотра",

"modules.meteor-client.inventory-tweaks.dump": "Сложить",
"modules.meteor-client.inventory-tweaks.steal": "Взять"
}
Loading