fix: enchanting

fixes:
fishing rod crashing in enchantment table
updated more swfs that were not updated in a recent merge
sort costs in ascending order
randomise enchantment seeds for new players
This commit is contained in:
SevenToaster509
2026-04-17 08:26:13 +01:00
parent add784b259
commit 2b5a46a4fa
7 changed files with 36 additions and 9 deletions
+23 -7
View File
@@ -103,6 +103,16 @@ void EnchantmentMenu::slotsChanged(int a) // 4J used to take a shared_ptr<Contai
if (item == nullptr || !item->isEnchantable())
{
if (!level->isClientSide)
{
ByteArrayOutputStream baos;
DataOutputStream dos(&baos);
//send reset signal
dos.writeInt(-4);
PlayerList* playerList = MinecraftServer::getInstance()->getPlayers();
playerList->broadcastAll(std::make_shared<CustomPayloadPacket>(CustomPayloadPacket::ENCHANTMENT_LIST_PACKET, baos.toByteArray()));
}
for (int i = 0; i < 3; i++)
{
tempCosts[i] = costs[i];
@@ -166,6 +176,7 @@ void EnchantmentMenu::slotsChanged(int a) // 4J used to take a shared_ptr<Contai
{
costs[i] = EnchantmentHelper::getEnchantmentCost(&random, i, bookcases, item);
}
std::sort(costs, costs + 3);
if (!alreadyRan) {
en = false;
for (int i = 0; i < 3; i++)
@@ -180,13 +191,18 @@ void EnchantmentMenu::slotsChanged(int a) // 4J used to take a shared_ptr<Contai
for (int a = 0; a < 3; a++) {
vector<EnchantmentInstance*>* newEnchantment = cachedEnchantments[a];
for (int index = 0; index < newEnchantment->size(); index++)
{
EnchantmentInstance* e = newEnchantment->at(index);
dos.writeInt(e->enchantment->id);
dos.writeInt(e->level);
//delete e;
if (newEnchantment != nullptr) {
for (int index = 0; index < newEnchantment->size(); index++)
{
EnchantmentInstance* e = newEnchantment->at(index);
dos.writeInt(e->enchantment->id);
dos.writeInt(e->level);
//delete e;
}
}
else {
dos.writeInt(-3);
dos.writeInt(-3);
}
dos.writeInt(-1);
}