mojira.dev
MC-36937

Unavailable enchants are not greyed out when enchanting fishing rods, cost XP & Lapis when used

This report only describes that an enchantment is shown which is not available. See MC-30730, which describes the general behavior that an enchantment table may provide less than three enchantments.


The bug

When enchanting fishing rods, you are not able to apply low level enchants; the bug here is that these enchants still appear as if they could be selected. They should be greyed out.

See attached

[media]

: The first slot, which the mouse is hovering over, does not display any promised enchant in the tooltip and clicking it does nothing, yet it's not greyed out like the middle slot.

Example

Here is an example in video:

[media]

Bug analysis

@unknown has done a detailed analysis of when the bug occurs and possible solutions in this comment.

Code analysis

The following is based on decompiled version of Minecraft 1.9 using MCP 9.24 beta. All method and class names are the names used in the decompiled version.

The reason why this happens is because the enchantment level returned by the method net.minecraft.enchantment.EnchantmentHelper.calcItemStackEnchantability(Random, int, int, ItemStack) is used. This method always returns at least 1 for the first enchantment (0 meaning no enchantment available). I am not sure if this can be fixed in this method, however what can be done is having the method net.minecraft.inventory.ContainerEnchantment.onCraftMatrixChanged(IInventory) set 0 as enchantment level if no enchantments are available.
This might not be the best solution and is only a suggestion.

Linked issues

Attachments

Comments

Tokes

Confirmed for 14w11b. First I've heard of it but it was so quick to playtest I thought "why not check".

Deleted account

Is this still a concern in the current Minecraft version 14w20b / Launcher version 1.3.11 or later? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.

branza

Confirmed for 14w27b.

Jared VDB

Still happening in 1.9.2 please fix it Thanks 🙂

marcono1234

Please link to this comment in the description

The following is based on decompiled version of Minecraft 1.9 using MCP 9.24 beta. All method and class names are the names used in the decompiled version.

The reason why this happens is because the enchantment level returned by the method net.minecraft.enchantment.EnchantmentHelper.calcItemStackEnchantability(Random, int, int, ItemStack) is used. This method always returns at least 1 for the first enchantment (0 meaning no enchantment available). I am not sure if this can be fixed in this method, however what can be done is having the method net.minecraft.inventory.ContainerEnchantment.onCraftMatrixChanged(IInventory) set 0 as enchantment level if no enchantments are available.
This might not be the best solution and is only a suggestion.

Matthew Scarlett

Any news on this? Been over a year now and still happening in 1.10.2.

Michael Brocaglia

This is still happening in 1.12.1, what's going on with this? (In case you were wondering, on 1.12.1, it doesn't take your lapis or XP, it also won't preview the enchant. I do not have any bookshelves surrounding my table, either.)

Adam Preston

Confirmed for 1.13 Pre-2. Encountered this today ans was wondering what was up. It won't preview the enchant. and clicking it does nothing,

Dennis Ewell

Still happening on 1.13 Pre 2. The "ancient language" shows up, but cursor does not provide an English translation of the enchantment. Would think that if "ancient language" shows up an enchantment is available.

Prototype421

the bug occurs not only on fishing rods it also sometimes occur on other tools and books if there are no bookshelfs around

[media]

Kraif

Confirmed for 1.13.1.

Sebastian Ceballos
[media]

I cant enchant.

gaspoweredpick

Confirmed for 19w09a

ZeNico13

Confirmed in 1.14 Pre-Release 2

[media]
ZeNico13

Still in 1.14 pre-3, 1.14 pre-4 and 1.14 pre-5

ZeNico13

Still in 1.14 Release

ZeNico13

Still in 1.14.1 Release

ZeNico13

Still in 1.14.2 Pre-Release 1 and 1.14.2 Pre-Release 2

Shourin

Have same bug in 1.14.4

soyouzpanda

Have same bug in 1.15 but works only with Unbreaking

Maxence MENIF

Still in the 1.16 snapshot 20w11a. Under level 4 enchants, displayed enchantments will issue the same problems as mentioned above.

BobbitWormJoe

Can confirm this bug is still present in Java 1.16.1; tested in Survival.

pulpetti

Affects 20w27a

user-c84db

Blocked by [MC-218626]

Steve W

After confirming that this bug still exists in 1.18.1, I investigated and discovered what was happening:

TL;DR For Fishing Rods specifically, it is possible for the enchanting table to be in a state where it has a required XP level but no enchantments.

When generating enchantments, first a required XP level is randomly generated based on bookshelf count and player enchantment seed, then a modified level is generated from that XP level for gathering possible enchantments. See this page for info on what modified levels can get you what enchantment levels (the page says that the data is from 1.14.4, but the relevant Fishing Rod enchantments are still correct for 1.18.1).

The bug occurs when the required XP level is more than 0 but the modified level is not enough to reach the above mentioned enchantment levels, leaving the enchanting table without any enchantments. This bug affects Fishing Rods specifically because they have no enchantments that can apply below a modified level of 5 (the cutoff for Unbreaking I), whereas all other enchantable items have at least one enchantment with a minimum level of 1.

To test this, I made a Fabric mod to show enchanting table info in the GUI. As can be seen in three of the four attached pictures, the required XP level is more than 0, but no enchantments are generated (shown as "-1 -1"). Even with 15 bookshelves, bad enough RNG rolls can give you a required XP level as low as 2 or 3 (both of which have this issue every time). A required XP level of 4 will usually generate an enchantment (always Unbreaking I), but it can also have this issue depending on the exact RNG rolls.

The GUI mostly doesn't check for this inconsistency between having a required XP level yet no enchantment. The only place it does check is when rendering tooltips for the enchantment hint.

Possible fixes (either or both can be implemented):
1. Lower the minimum modified enchantment level for either Fishing Rod enchantment to 1 (Lure would be the more likely candidate for this as Luck of the Sea uses the same Java class as Fortune).
2. Reset the required XP level to 0 for that slot if no enchantments are generated.

[media]

[media]

[media]

[media]

MacchuPicchu

Present in 1.19-pre1.

MacchuPicchu

Present in 1.19-pre2.

MacchuPicchu

Present in 1.19-pre3.

MacchuPicchu

Present in 1.19-pre4.

MacchuPicchu

Present in 1.19-pre5.

MacchuPicchu

Present in 1.19-rc1.

MacchuPicchu

Present in 1.19-rc2.

MacchuPicchu

Present in 22w24a.

MacchuPicchu

Present in 1.19.2.

MacchuPicchu

Present in 1.19.4.

Seacraft Gaming

Also present in 1.21-rc1 and affects the mace

Jarl-Penguin

Please create a separate ticket regarding maces.
Edit: MC-273234

Dawoox

Present in the 1.21 release

BlackedIRL

Present in 1.21.4

[Mod] redstonehelper

(Unassigned)

Confirmed

Platform

Normal

Items, UI

enchanting, fishing_rod

Minecraft 1.7.1, Minecraft 1.7.2, Minecraft 13w47e, Minecraft 13w48a, Minecraft 13w48b, ..., 24w18a, 1.21, 1.21 Release Candidate 1, 1.21.4, 25w04a

Retrieved