diff options
| author | qwasdrizzel <145519042+qwasdrizzel@users.noreply.github.com> | 2026-03-05 22:18:36 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-05 22:18:36 -0600 |
| commit | cffe636e359441e1c667784d40bd71d111c281de (patch) | |
| tree | 11144e082d516ba05a66aa3564875f5879a45f7c /Minecraft.Client/PlayerConnection.cpp | |
| parent | d1eb09a4b97f38476a538f7a7de06a0a620a1a65 (diff) | |
| parent | 5cbdf27b46e4ac23e441489c524b1f1aba88c269 (diff) | |
Merge branch 'smartcmd:main' into main
Diffstat (limited to 'Minecraft.Client/PlayerConnection.cpp')
| -rw-r--r-- | Minecraft.Client/PlayerConnection.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/Minecraft.Client/PlayerConnection.cpp b/Minecraft.Client/PlayerConnection.cpp index 266cae36..ab8ae20b 100644 --- a/Minecraft.Client/PlayerConnection.cpp +++ b/Minecraft.Client/PlayerConnection.cpp @@ -1093,6 +1093,10 @@ void PlayerConnection::handleContainerClose(shared_ptr<ContainerClosePacket> pac #ifndef _CONTENT_PACKAGE void PlayerConnection::handleContainerSetSlot(shared_ptr<ContainerSetSlotPacket> packet) { + if(player->gameMode->isSurvival()){ // Still allow creative players to change slots manually with packets(?) -- might want this different. + server->warn(L"Player " + player->getName() + L" just tried to set a slot in a container in survival mode"); + return; + } if (packet->containerId == AbstractContainerMenu::CONTAINER_ID_CARRIED ) { player->inventory->setCarried(packet->item); @@ -1589,6 +1593,10 @@ void PlayerConnection::handleCraftItem(shared_ptr<CraftItemPacket> packet) Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); shared_ptr<ItemInstance> pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr); + size_t recipeCount = Recipes::getInstance()->getRecipies()->size(); + if (iRecipe < 0 || iRecipe >= (int)recipeCount) + return; + if(app.DebugSettingsOn() && (player->GetDebugOptions()&(1L<<eDebugSetting_CraftAnything))) { pTempItemInst->onCraftedBy(player->level, dynamic_pointer_cast<Player>( player->shared_from_this() ), pTempItemInst->count ); @@ -1607,9 +1615,21 @@ void PlayerConnection::handleCraftItem(shared_ptr<CraftItemPacket> packet) { - // TODO 4J Stu - Assume at the moment that the client can work this out for us... - //if(pRecipeIngredientsRequired[iRecipe].bCanMake) - //{ + Recipy::INGREDIENTS_REQUIRED &req = pRecipeIngredientsRequired[iRecipe]; + if (req.iType == RECIPE_TYPE_3x3 && dynamic_cast<CraftingMenu *>(player->containerMenu) == NULL) + { + server->warn(L"Player " + player->getName() + L" tried to craft a 3x3 recipe without a crafting bench"); + return; + } + for (int i = 0; i < req.iIngC; i++){ + int need = req.iIngValA[i]; + int have = player->inventory->countResource(req.iIngIDA[i], req.iIngAuxValA[i]); + if (have < need){ + server->warn(L"Player " + player->getName() + L" just tried to craft item " + to_wstring(pTempItemInst->id) + L" with insufficient ingredients"); + return; + } + } + pTempItemInst->onCraftedBy(player->level, dynamic_pointer_cast<Player>( player->shared_from_this() ), pTempItemInst->count ); // and remove those resources from your inventory |
