Powah! (Rearchitected)

Powah! (Rearchitected)

3M Downloads

Tooltip formatting problems.

geosskk opened this issue ยท 1 comments

commented

Version:

  • Minecraft: 1.20.1
  • Forge: 47.0.1
  • Fabric Loader: 0.14.21
  • Powah: 5.0.2

Issue description:

It seems as though some of the text formatting for item tooltips is not working correctly.

image

Possible Solution:

After taking a look at the source code I noticed that a lot of the localized Components were written as:
Component.literal(getGeneration()).append(Component.translatable("info.lollipop.fe.pet.tick")),
which appends the %s FE/t to 40k which results in 40k%s FE/t.

The issue was that instead of replacing %s in the localized string with a value, it appended the localized string to the end value.
It seems to work as expected by using Component.translatable() with the key and a replacement value:
Component.translatable("info.lollipop.fe.pet.tick", getGeneration()).

image
Thermo Generator with proper string interpolation.

There appears to be unnecessary spacing in the tooltips .

image

Possible Solution:

I'm not sure if this spacing is intentional or not but it seems to be easily removable.
All that has to be done is to remove tooltip.add(Component.empty()); from the ends of the appendHoverText() methods in AbstractEnergyBlock.java and BindingCardItem.java.

image
Thermo Generator without the spacing at the end of the tooltip.

There are no tooltips for the Energy Cells.

image

Possible Solution:

It seems that the class EnergyCellBlock returns EnergyCellItem in the method getBlockItem().
The EnergyCellItem class then overrides the getEnergyInfo() method and returns null.

The issue with returning null from getEnergyInfo() is that appendHoverText only applies tooltips if Energy.ifPresent returns a result.
Energy.ifPresent only returns a result when the provided ItemStack is an instance of IEnergyContainingItem and returns a non null value of IEnergyContainingItem.Info from getEnergyInfo().

All that is needed to fix this issue is to remove the

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

method from the EnergyCellItem class.

There doesn't seem to be any issues with removing the getEnergyInfo() override from the EnergyCellItem class, however I am not 100% certain about this.

image
The tooltips of the Energy Cell after these changes.

The wrench tooltip seems to intend on formatting the current mode text in yellow, but it does not apply.

image
The wrench tooltip is completely gray instead of gray and yellow.

image
The mod appends the ChatFormatting.YELLOW style right before the wrench mode, but it does not appear in game.

Possible Solution:

I was thinking that it would be better to separate the "Mode:" and wrench mode localization text.

Example:
image
I've managed to create a new "info.powah.wrench.mode" localization where the current wrench mode can be interpolated into the string.
With this method we can then use a separate Component.translatable() for the wrench mode with the .withStyle(ChatFormatting.YELLOW) style method.

image
What the wrench tooltip looks like with these changes.

Notes

I have managed to implement all these changes successfully on the 1.20 branch of this repo.
The changes I've made seem to fix the problems on both the Fabric and Forge versions of the mod.
If it sounds okay, I can submit a PR with all the changes that I've made.

commented

Sorry, I wasn't looking at issues too closely and missed this part:

If it sounds okay, I can submit a PR with all the changes that I've made.

Thankfully you went ahead with the PR. :)