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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user