Skip to content

Commit

Permalink
[1.20] Fixes for the tooltips of Powah's items. (#114)
Browse files Browse the repository at this point in the history
* Fixed the string interpolation used for the localization in the power receive, extract, io, and generation tooltips.

* Removed the extra blank line from the items tooltips.

* Removed getEnergyInfo() from EnergyCellItem to show the tooltips for the Energy Cell items.

* Fix the wrench item's tooltips to make the current mode text yellow.
  • Loading branch information
geosskk authored Nov 9, 2023
1 parent b69c221 commit e28c64a
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockSt
@Override
public void additionalEnergyInfo(ItemStack stack, Energy.Item energy, List<Component> tooltip) {
tooltip.add(Component.translatable("info.powah.generation.factor").withStyle(ChatFormatting.GRAY).append(Text.COLON)
.append(Component.literal(Util.numFormat(getConfig().getGeneration(this.variant)))
.append(Component.translatable("info.lollipop.fe.pet.tick")).withStyle(ChatFormatting.DARK_GRAY)));
.append(Component.translatable("info.lollipop.fe.pet.tick", Util.numFormat(getConfig().getGeneration(this.variant)))
.withStyle(ChatFormatting.DARK_GRAY)));
}

@Override
Expand Down
2 changes: 0 additions & 2 deletions common/src/main/java/owmii/powah/item/BindingCardItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,9 @@ public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List<Compo
CompoundTag nbt = stack.getTag();
if (nbt == null) {
tooltip.add(Component.translatable("info.powah.click.to.bind").withStyle(ChatFormatting.DARK_GRAY));
tooltip.add(Component.empty());
} else if (nbt.hasUUID("bound_player_id")) {
tooltip.add(Component.translatable("info.lollipop.owner", ChatFormatting.YELLOW + nbt.getString("bound_player_name"))
.withStyle(ChatFormatting.GRAY));
tooltip.add(Component.empty());
}
}

Expand Down
5 changes: 0 additions & 5 deletions common/src/main/java/owmii/powah/item/EnergyCellItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ public EnergyCellItem(EnergyCellBlock block, Properties properties, @Nullable Re
super(block, properties, group);
}

@Override
public Info getEnergyInfo() {
return null;
}

@Override
public Rarity getRarity(ItemStack stack) {
if (getVariant().equals(Tier.CREATIVE)) {
Expand Down
15 changes: 9 additions & 6 deletions common/src/main/java/owmii/powah/item/WrenchItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ public InteractionResultHolder<ItemStack> use(Level worldIn, Player playerIn, In
if (playerIn.isShiftKeyDown()) {
nextWrenchMode(stack);
playerIn.displayClientMessage(
Component.translatable("info.powah.wrench.mode." + getWrenchMode(stack).name().toLowerCase(), ChatFormatting.YELLOW)
.withStyle(ChatFormatting.GRAY),
Component.translatable("info.powah.wrench.mode",
Component.translatable("info.powah.wrench.mode." + getWrenchMode(stack).name().toLowerCase())
.withStyle(ChatFormatting.YELLOW)),
true);
return InteractionResultHolder.success(stack);
}
Expand All @@ -129,17 +130,19 @@ public InteractionResultHolder<ItemStack> use(Level worldIn, Player playerIn, In

@Override
public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List<Component> tooltip, TooltipFlag flagIn) {
tooltip.add(Component.translatable("info.powah.wrench.mode." + getWrenchMode(stack).name().toLowerCase(), ChatFormatting.YELLOW)
.withStyle(ChatFormatting.GRAY));
tooltip.add(Component.translatable("info.powah.wrench.mode",
Component.translatable("info.powah.wrench.mode." + getWrenchMode(stack).name().toLowerCase())
.withStyle(ChatFormatting.YELLOW)));
}

@Override
public void inventoryTick(ItemStack stack, Level worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
if (entityIn instanceof Player) {
Player player = (Player) entityIn;
oneTimeInfo(player, stack,
Component.translatable("info.powah.wrench.mode." + getWrenchMode(stack).name().toLowerCase(), ChatFormatting.YELLOW)
.withStyle(ChatFormatting.GRAY));
Component.translatable("info.powah.wrench.mode",
Component.translatable("info.powah.wrench.mode." + getWrenchMode(stack).name().toLowerCase())
.withStyle(ChatFormatting.YELLOW)));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ public void appendHoverText(ItemStack stack, @Nullable BlockGetter worldIn, List
addEnergyInfo(stack, energy, tooltip);
addEnergyTransferInfo(stack, energy, tooltip);
additionalEnergyInfo(stack, energy, tooltip);
tooltip.add(Component.empty());
});
}

Expand All @@ -109,16 +108,16 @@ public void addEnergyTransferInfo(ItemStack stack, Energy.Item storage, List<Com
if (ext + re > 0) {
if (ext == re) {
tooltip.add(Component.translatable("info.lollipop.max.io").withStyle(ChatFormatting.GRAY).append(Text.COLON)
.append(Component.literal(Util.numFormat(ext)).append(Component.translatable("info.lollipop.fe.pet.tick"))
.append(Component.translatable("info.lollipop.fe.pet.tick", Util.numFormat(ext))
.withStyle(ChatFormatting.DARK_GRAY)));
} else {
if (ext > 0)
tooltip.add(Component.translatable("info.lollipop.max.extract").withStyle(ChatFormatting.GRAY).append(Text.COLON)
.append(Component.literal(Util.numFormat(ext)).append(Component.translatable("info.lollipop.fe.pet.tick"))
.append(Component.translatable("info.lollipop.fe.pet.tick", Util.numFormat(ext))
.withStyle(ChatFormatting.DARK_GRAY)));
if (re > 0)
tooltip.add(Component.translatable("info.lollipop.max.receive").withStyle(ChatFormatting.GRAY).append(Text.COLON)
.append(Component.literal(Util.numFormat(re)).append(Component.translatable("info.lollipop.fe.pet.tick"))
.append(Component.translatable("info.lollipop.fe.pet.tick", Util.numFormat(re))
.withStyle(ChatFormatting.DARK_GRAY)));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public AbstractGeneratorBlock(Properties properties, Tier variant) {
@Override
public void additionalEnergyInfo(ItemStack stack, Energy.Item energy, List<Component> tooltip) {
tooltip.add(Component.translatable("info.lollipop.generates").withStyle(ChatFormatting.GRAY).append(Text.COLON)
.append(Component.literal(Util.numFormat(getConfig().getGeneration(this.variant)))
.append(Component.translatable("info.lollipop.fe.pet.tick")).withStyle(ChatFormatting.DARK_GRAY)));
.append(Component.translatable("info.lollipop.fe.pet.tick", Util.numFormat(getConfig().getGeneration(this.variant)))
.withStyle(ChatFormatting.DARK_GRAY)));
}

@Override
Expand Down
1 change: 0 additions & 1 deletion common/src/main/java/owmii/powah/lib/item/EnergyItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List<Compo
.withStyle(ChatFormatting.DARK_GRAY)));
tooltip.add(Component.translatable("info.lollipop.max.io").withStyle(ChatFormatting.GRAY).append(Text.COLON).append(Component
.translatable("info.lollipop.fe.pet.tick", Util.numFormat(energy.getMaxExtract())).withStyle(ChatFormatting.DARK_GRAY)));
tooltip.add(Component.empty());
}
});
}
Expand Down
7 changes: 4 additions & 3 deletions common/src/main/resources/assets/powah/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,10 @@
"info.powah.shift.to.apply": "[SHIFT + CLICK] to apply.",
"info.powah.solid.coolant": "Solid Coolant",
"info.powah.unlimited": "Unlimited Powah!!!",
"info.powah.wrench.mode.config": "Mode: %sConfig",
"info.powah.wrench.mode.link": "Mode: %sLink",
"info.powah.wrench.mode.rotate": "Mode: %sRotate",
"info.powah.wrench.mode": "Mode: %s",
"info.powah.wrench.mode.config": "Config",
"info.powah.wrench.mode.link": "Link",
"info.powah.wrench.mode.rotate": "Rotate",
"item.powah.aerial_pearl": "Aerial Pearl",
"item.powah.battery_basic": "Battery (Basic)",
"item.powah.battery_blazing": "Battery (Blazing)",
Expand Down
7 changes: 4 additions & 3 deletions common/src/main/resources/assets/powah/lang/fr_fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@
"info.powah.shift.to.apply": "[MAJ + CLIC] pour appliquer.",
"info.powah.solid.coolant": "Liquide de refroidissement solide",
"info.powah.unlimited": "Unlimited Powah!!!",
"info.powah.wrench.mode.config": "Mode : %sConfiguration",
"info.powah.wrench.mode.link": "Mode : %sLiaison",
"info.powah.wrench.mode.rotate": "Mode : %sRotation",
"info.powah.wrench.mode": "Mode : %s",
"info.powah.wrench.mode.config": "Configuration",
"info.powah.wrench.mode.link": "Liaison",
"info.powah.wrench.mode.rotate": "Rotation",
"item.powah.aerial_pearl": "Perle aérienne",
"item.powah.battery_basic": "Pile (Basique)",
"item.powah.battery_blazing": "Pile (Flamboyante)",
Expand Down
7 changes: 4 additions & 3 deletions common/src/main/resources/assets/powah/lang/pt_br.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@
"info.powah.shift.to.apply": "[SHIFT + CLICK] para aplicar.",
"info.powah.solid.coolant": "Refrigerante Sólido",
"info.powah.unlimited": "Powah Ilimitado!!!",
"info.powah.wrench.mode.config": "Modo: %sConfiguração",
"info.powah.wrench.mode.link": "Modo: %sLink",
"info.powah.wrench.mode.rotate": "Modo: %sGirar",
"info.powah.wrench.mode": "Modo: %s",
"info.powah.wrench.mode.config": "Configuração",
"info.powah.wrench.mode.link": "Link",
"info.powah.wrench.mode.rotate": "Girar",
"item.powah.aerial_pearl": "Pérola Aérea",
"item.powah.battery_basic": "Bateria (Básico)",
"item.powah.battery_blazing": "Bateria (Flamejante)",
Expand Down
7 changes: 4 additions & 3 deletions common/src/main/resources/assets/powah/lang/ru_ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@
"info.powah.shift.to.apply": "SHIFT + ЛКМ для применения",
"info.powah.solid.coolant": "Твёрдый хладагент",
"info.powah.unlimited": "Безграничная мощь!!!",
"info.powah.wrench.mode.config": "Режим %sнастройки",
"info.powah.wrench.mode.link": "Режим %sпривязки",
"info.powah.wrench.mode.rotate": "Режим %sвращения",
"info.powah.wrench.mode": "Режим %s",
"info.powah.wrench.mode.config": "настройки",
"info.powah.wrench.mode.link": "привязки",
"info.powah.wrench.mode.rotate": "вращения",
"item.powah.aerial_pearl": "Эфирная жемчужина",
"item.powah.battery_basic": "Аккумулятор (Основной)",
"item.powah.battery_blazing": "Аккумулятор (Пламенный)",
Expand Down
7 changes: 4 additions & 3 deletions common/src/main/resources/assets/powah/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@
"info.powah.shift.to.apply": "按下 Shift 单击以应用。",
"info.powah.solid.coolant": "固体冷却剂",
"info.powah.unlimited": "无限的能量!!!",
"info.powah.wrench.mode.config": "模式:%s配置",
"info.powah.wrench.mode.link": "模式:%s链接",
"info.powah.wrench.mode.rotate": "模式:%s旋转",
"info.powah.wrench.mode": "模式:%s",
"info.powah.wrench.mode.config": "配置",
"info.powah.wrench.mode.link": "链接",
"info.powah.wrench.mode.rotate": "旋转",
"item.powah.aerial_pearl": "天线珍珠",
"item.powah.battery_basic": "电池(基础)",
"item.powah.battery_blazing": "电池(烈焰)",
Expand Down
7 changes: 4 additions & 3 deletions common/src/main/resources/assets/powah/lang/zh_tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@
"info.powah.shift.to.apply": "[SHIFT + 左鍵] 來應用",
"info.powah.solid.coolant": "固體冷卻劑",
"info.powah.unlimited": "終極能量!!!",
"info.powah.wrench.mode.config": "模式: %s配置",
"info.powah.wrench.mode.link": "模式: %s連接",
"info.powah.wrench.mode.rotate": "模式: %s旋轉",
"info.powah.wrench.mode": "模式: %s",
"info.powah.wrench.mode.config": "配置",
"info.powah.wrench.mode.link": "連接",
"info.powah.wrench.mode.rotate": "旋轉",
"item.powah.aerial_pearl": "天線珍珠",
"item.powah.battery_basic": "電池 (基礎)",
"item.powah.battery_blazing": "電池 (烈焰)",
Expand Down

0 comments on commit e28c64a

Please sign in to comment.