GameTest Framework - mojang-minecraft - Enchantment does not get added even though API reports that it does
Summary:
When adding or removing enchantments via the GameTest Framework -> mojang-minecraft API, nothing happens even though the API reports success and/or no errors.
Steps to Reproduce:
1. Create a simple js script (the example I used is screenshotted below) that creates an item, adds a valid enchantment to it, and then adds it to the player's inventory.
2. Load into any world seed.
3. Connect the Visual Studio Code debugger.
4. Put a breakpoint where the success of the adding enchantment API can be viewed.
5. In the game, do whatever is needed to cause the code to run (for my example code, simply right-click on any block).
6. Go back to VS Code and observe that the breakpoint has been hit.
7. Press F5 to leave the code and return to the game.
Observed Results:
The player has been given an unenchanted item, even though the API reported the enchantment was successfully added.
Expected Results:
The player has been given an enchanted item, because the API reported the enchantment was successfully added.
Notes:
Similarly, if using the removeEnchantment API on an item with an enchantment, it throws no errors (does not return anything as it is a void function) and the enchantment is not removed.
Created Issue:
GameTest Framework - mojang-minecraft - Enchantment does not get added even though API reports that it does
Summary:
When adding or removing enchantments via the GameTest Framework -> mojang-minecraft API, nothing happens even though the API reports success and/or no errors.Steps to Reproduce:
1. Create a simple js script (the example I used is screenshotted below) that creates an item, adds a valid enchantment to it, and then adds it to the player's inventory.
2. Load into any world seed.
3. Connect the Visual Studio Code debugger.
4. Put a breakpoint where the success of the adding enchantment API can be viewed.
5. In the game, do whatever is needed to cause the code to run (for my example code, simply right-click on any block).
6. Go back to VS Code and observe that the breakpoint has been hit.
7. Press F5 to leave the code and return to the game.Observed Results:
The player has been given an unenchanted item, even though the API reported the enchantment was successfully added.
Expected Results:
The player has been given an enchanted item, because the API reported the enchantment was successfully added.
Screenshots/Videos:
Notes:
Similarly, if using the removeEnchantment API on an item with an enchantment, it throws no errors (does not return anything as it is a void function) and the enchantment is not removed.
- Unresolved
- Open
- Unconfirmed
- Windows
- Windows 10
- 1.18.31
Summary:
When adding or removing enchantments via the GameTest Framework -> mojang-minecraft API, nothing happens even though the API reports success and/or no errors.Steps to Reproduce:
1. Create a simple js script (the example I used is screenshotted below) that creates an item, adds a valid enchantment to it, and then adds it to the player's inventory.
2. Load into any world seed.
3. Connect the Visual Studio Code debugger.
4. Put a breakpoint where the success of the adding enchantment API can be viewed.
5. In the game, do whatever is needed to cause the code to run (for my example code, simply right-click on any block).
6. Go back to VS Code and observe that the breakpoint has been hit.
7. Press F5 to leave the code and return to the game.Observed Results:
The player has been given an unenchanted item, even though the API reported the enchantment was successfully added.
Expected Results:
The player has been given an enchanted item, because the API reported the enchantment was successfully added.
Screenshots/Videos:
Notes:
Similarly, if using the removeEnchantment API on an item with an enchantment, it throws no errors (does not return anything as it is a void function) and the enchantment is not removed.Summary:
When adding or removing enchantments via the GameTest Framework -> mojang-minecraft API, nothing happens even though the API reports success and/or no errors.Steps to Reproduce:
1. Create a simple js script (the example I used is screenshotted below) that creates an item, adds a valid enchantment to it, and then adds it to the player's inventory.
2. Load into any world seed.
3. Connect the Visual Studio Code debugger.
4. Put a breakpoint where the success of the adding enchantment API can be viewed.
5. In the game, do whatever is needed to cause the code to run (for my example code, simply right-click on any block).
6. Go back to VS Code and observe that the breakpoint has been hit.
7. Press F5 to leave the code and return to the game.Observed Results:
The player has been given an unenchanted item, even though the API reported the enchantment was successfully added.
Expected Results:
The player has been given an enchanted item, because the API reported the enchantment was successfully added.
Notes:
Similarly, if using the removeEnchantment API on an item with an enchantment, it throws no errors (does not return anything as it is a void function) and the enchantment is not removed.
This is not an issue! Read above and see what @v-weszaj said. You have to apply the updated enchantmentList after you set or remove a new enchantment.


Tested on 1.19.0 and this is still an issue, updated the Affected Versions to reflect this.
Tested on 1.19.2 and this is still an issue, updated the Affected Versions to reflect this.
Tested on 1.19.10 and this is still an issue, updated the Affected Versions to reflect this.
Tested on 1.19.11 and this is still an issue, updated the Affected Versions to reflect this.
Tested on 1.19.20 and this is still an issue, updated the Affected Versions to reflect this.
This may be a little confusing but the general flow with using enchant api is as follows:
1. Obtain the list of enchantments - enchantments property from enchantment component
2. Edit the list of enchantments - using addEnchantment() method
3. Assign the modified enchantment list as the value of enchantments property from enchantment component
Here's a modified version of the code from the attached screenshot:
Please update your file and let us know if the issue is fixed.
Thanks for the info! Everything makes sense, but having to modify the list and then reassign back isn't quite as intuitive as simply updating the list on the item. But I understand if that is the desired implementation.
I updated my file to do this and it is indeed working as the item now has the enchantment, so this issue can be closed.
Closing as Cannot Reproduce per previous comment of the bug owner.