Some fixes for potion items#5555
Conversation
…on name, fix potion name in tipped arrows (refs GeyserMC#5255 GeyserMC#5176)
… potion components
…etting potion name in the getPotionName method?
| // 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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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}]}]


/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}]


But wrapping line in name can resolve this problem well:
At least, It reduce some misunderstandings of players, even if it looks a little wried.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
…, like getting potion name in the getPotionName method?" This reverts commit c002361.
…ame when potion tooltip is hidden
…potion-component
|
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. |
|
Sorry I took too long. Now it can be review. |
onebeastchris
left a comment
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
| // 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. |
There was a problem hiding this comment.
| // 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. |


- Feature:Make custom effect information visible & Support for customizing item name via 'custom_name' tag in 'potion_contents' component (new feature since 1.21.2) #5176
- Fix
item_namecomponent not work; Improve display of custom effects and shulker box tooltips for item names #5255Example:
/give @s potion[potion_contents={potion:long_leaping,custom_effects:[{id:luck}]}]Example:
/give @s minecraft:tipped_arrow[potion_contents={potion:leaping}]Example:
/give @s minecraft:shulker_box[container=[{slot:0,item:{id:tipped_arrow,count:1,components:{potion_contents:{potion:leaping}}}}]]potion effectscustom potion effects innormal arrow itemall items just like Java EditionExample:
/give @s apple[potion_contents={custom_effects:[{id:luck}]}]minecraft:potion_duration_scalecomponent support (new feature since 1.21.5)