Skip to content

Commit

Permalink
Fix enchantments when there are less than three options
Browse files Browse the repository at this point in the history
  • Loading branch information
Camotoy committed Jan 20, 2021
1 parent 5d4b368 commit 787e6fe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public EnchantingContainer(String title, int id, int size, PlayerInventory playe
geyserEnchantOptions = new GeyserEnchantOption[3];
for (int i = 0; i < geyserEnchantOptions.length; i++) {
geyserEnchantOptions[i] = new GeyserEnchantOption(i);
// Options cannot be null, so we build initial options
// GeyserSession can be safely null here because it's only needed for net IDs
enchantOptions[i] = geyserEnchantOptions[i].build(null);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,8 @@ public GeyserEnchantOption(int javaIndex) {
}

public EnchantOptionData build(GeyserSession session) {
if (enchantLevel == -1) {
// Should not be sent to the client, as it is supposed to be empty
return null;
}
return new EnchantOptionData(xpCost, javaIndex + 16, EMPTY,
Collections.singletonList(new EnchantData(bedrockEnchantIndex, enchantLevel)), EMPTY,
javaEnchantIndex == -1 ? "unknown" : ENCHANT_NAMES.get(javaEnchantIndex), session.getNextItemNetId());
enchantLevel == -1 ? EMPTY : Collections.singletonList(new EnchantData(bedrockEnchantIndex, enchantLevel)), EMPTY,
javaEnchantIndex == -1 ? "unknown" : ENCHANT_NAMES.get(javaEnchantIndex), enchantLevel == -1 ? 0 : session.getNextItemNetId());
}
}

0 comments on commit 787e6fe

Please sign in to comment.