Skip to content

Some fixes for potion items#5555

Open
BUGTeas wants to merge 12 commits into
GeyserMC:masterfrom
BUGTeas:fix-potion-component
Open

Some fixes for potion items#5555
BUGTeas wants to merge 12 commits into
GeyserMC:masterfrom
BUGTeas:fix-potion-component

Conversation

@BUGTeas
Copy link
Copy Markdown
Contributor

@BUGTeas BUGTeas commented May 17, 2025

// Make custom effect information visible when shown in tooltip
if (potionContents != null && tooltip.showInTooltip(DataComponentTypes.POTION_CONTENTS)) {
customName += getPotionEffectInfo(potionContents, session.locale()); // TODO should this be done with lore instead?
if (javaItem instanceof PotionItem || javaItem instanceof ArrowItem) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for adding this instanceof check? Geyser tries to match Java behaviour, and Java shows the potion effect tooltip on all items with a potion_contents component, not just these specific items, so it's probably good to do the same.

Also, given the above, I'm not sure if Geyser should show the effect in the HUD name tooltip, since Java doesn't. However, that seems up to debate to me.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason for show the effects in the HUD name tooltip

Bedrock always show effects in the HUD name tooltip, and show "No Effects" when it haven't any effects. If use lore to show these custom effects, Bedrock player will only saw effects or "No Effects" by vanilla potion ID.

/give @s potion[custom_name="Test",potion_contents={custom_effects:[{id:hero_of_the_village,duration:-1},{id:unluck,amplifier:1,duration:658980}]}]
image
image

/give @s potion[custom_name="Test 2",potion_contents={custom_effects:[{id:hero_of_the_village,duration:-1},{id:unluck,amplifier:1,duration:658980}],potion:leaping}]
image
image

But wrapping line in name can resolve this problem well:

image
image

At least, It reduce some misunderstandings of players, even if it looks a little wried.

Copy link
Copy Markdown
Contributor Author

@BUGTeas BUGTeas May 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, is the instanceof check before getting potion name in the getPotionName method used to use the custom_name of the potion_contents component only on tipped arrow & potion to match the Java behavior? I understand now.

For show custom effects on next line of the name, I think it have a better method to implement this. I'll take a look at it later.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bedrock always show effects in the HUD name tooltip, and show "No Effects" when it haven't any effects. If use lore to show these custom effects, Bedrock player will only saw effects or "No Effects" by vanilla potion ID.

Ah okay, thanks for clarifying! In that case, this makes sense to me. It might be good to document this in comments near the code as well, for future reference.

Comment thread core/src/main/java/org/geysermc/geyser/translator/item/ItemTranslator.java Outdated
@BUGTeas BUGTeas marked this pull request as ready for review May 23, 2025 16:59
@BUGTeas BUGTeas marked this pull request as draft May 24, 2025 12:54
@onebeastchris
Copy link
Copy Markdown
Member

Heya, what's the holdup here? 😄

@BUGTeas
Copy link
Copy Markdown
Contributor Author

BUGTeas commented Jul 6, 2025

Heya, what's the holdup here? 😄

I deeply apologize, but I don't have time to continue this work for the time being. I will add some commit directly when I come back in future.

@BUGTeas BUGTeas marked this pull request as ready for review August 5, 2025 14:59
@BUGTeas
Copy link
Copy Markdown
Contributor Author

BUGTeas commented Aug 5, 2025

Sorry I took too long. Now it can be review.

Copy link
Copy Markdown
Member

@onebeastchris onebeastchris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the wait, I forgot about this PR 😬


Set<Item> javaOnlyItems = new ObjectOpenHashSet<>();
Collections.addAll(javaOnlyItems, Items.SPECTRAL_ARROW, Items.DEBUG_STICK,
Items.KNOWLEDGE_BOOK, Items.TIPPED_ARROW);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To my knowledge, this item still doesn't exist - at least not the base tipped arrow. Can we account for that?

// Make a name when has custom effects
String potionName = potion == null ? "empty" : potion.toString().toLowerCase(Locale.ROOT);
return MessageTranslator.convertMessage(Component.translatable(mapping.getJavaItem().translationKey() + ".effect." + potionName), language);
// because the custom effect information is display from the second line of the name.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// because the custom effect information is display from the second line of the name.
// The custom effect information is displayed in the second line of the name.

String potionName = potion == null ? "empty" : potion.toString().toLowerCase(Locale.ROOT);
return MessageTranslator.convertMessage(Component.translatable(mapping.getJavaItem().translationKey() + ".effect." + potionName), language);
// because the custom effect information is display from the second line of the name.
// if name is not set, the custom effect information will not be displayed.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// if name is not set, the custom effect information will not be displayed.
// If a name is not set, the custom effect information will not be displayed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants