diff --git a/Minecraft.Client/ClientConnection.cpp b/Minecraft.Client/ClientConnection.cpp index a485210b..515eefed 100644 --- a/Minecraft.Client/ClientConnection.cpp +++ b/Minecraft.Client/ClientConnection.cpp @@ -4015,6 +4015,12 @@ void ClientConnection::handleCustomPayload(shared_ptr custo else if (a == -2) { done = true; } + else if (a == -4) { + for (int i = 0; i < 3; i++) { + minecraft->localplayers[m_userIndex]->enchantmentEntries[i].id = -3; + } + done = true; + } else { if (firstInGroup) { temp.id = a; diff --git a/Minecraft.Client/Common/Media/MediaWindows64/skinHDGraphicsInGame.swf b/Minecraft.Client/Common/Media/MediaWindows64/skinHDGraphicsInGame.swf index d014d317..77111b40 100644 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/skinHDGraphicsInGame.swf and b/Minecraft.Client/Common/Media/MediaWindows64/skinHDGraphicsInGame.swf differ diff --git a/Minecraft.Client/Common/Media/MediaWindows64/skinHDInGame.swf b/Minecraft.Client/Common/Media/MediaWindows64/skinHDInGame.swf index b9aaa068..da56df72 100644 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/skinHDInGame.swf and b/Minecraft.Client/Common/Media/MediaWindows64/skinHDInGame.swf differ diff --git a/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp index 2084305e..1c08827b 100644 --- a/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp @@ -275,10 +275,13 @@ void IUIScene_AbstractContainerMenu::handleEnchantButton(int slot, int iPad) { EnchantmentMenu* menu = new EnchantmentMenu(Minecraft::GetInstance()->player->inventory, dynamic_cast(Minecraft::GetInstance()->level), 0, 0, 0); if (0 == 0) { //uhh don't worry that is temporary int lapisCost = slot + 1; // slot 0 = 1 lapis, slot 1 = 2, slot 2 = 3 - + Minecraft* pMinecraft = Minecraft::GetInstance(); auto player = pMinecraft->player; + if (player->enchantmentEntries[slot].id == -3) return; + EnchantmentMenu* menu = dynamic_cast(player->containerMenu); + HtmlString title = HtmlString( wstring(app.GetString(Enchantment::enchantments[player->enchantmentEntries[slot].id]->getDescriptionId())) + L" " + diff --git a/Minecraft.Client/PlayerList.cpp b/Minecraft.Client/PlayerList.cpp index d32bb948..4c0f6bf7 100644 --- a/Minecraft.Client/PlayerList.cpp +++ b/Minecraft.Client/PlayerList.cpp @@ -216,6 +216,8 @@ bool PlayerList::placeNewPlayer(Connection *connection, shared_ptr #endif // 4J Added - Give every player a map the first time they join a server player->inventory->setItem( 9, std::make_shared(Item::emptyMap_Id, 1, level->getAuxValueForMap(player->getXuid(), 0, centreXC, centreZC, mapScale))); + Random* r = new Random(); + player->enchantmentSeed = r->nextInt(1000000); //Randomise enchantment seed upon joining server if(app.getGameRuleDefinitions() != nullptr) { app.getGameRuleDefinitions()->postProcessPlayer(player); diff --git a/Minecraft.World/EnchantmentMenu.cpp b/Minecraft.World/EnchantmentMenu.cpp index a1b12096..1536bc31 100644 --- a/Minecraft.World/EnchantmentMenu.cpp +++ b/Minecraft.World/EnchantmentMenu.cpp @@ -103,6 +103,16 @@ void EnchantmentMenu::slotsChanged(int a) // 4J used to take a shared_ptrisEnchantable()) { + 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::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* 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); } diff --git a/Minecraft.World/Player.h b/Minecraft.World/Player.h index 97552f98..84249bde 100644 --- a/Minecraft.World/Player.h +++ b/Minecraft.World/Player.h @@ -34,7 +34,7 @@ class GameType; class Scoreboard; struct EnchantmentEntry { int level; - int id; + int id = -3; };