Merge remote-tracking branch 'refs/remotes/origin/dedicated-rewrite' into dedicated-rewrite
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
#include "../../../../world/level/Level.h"
|
||||
#include "../../../../world/item/DyePowderItem.h"
|
||||
#include "../../../../world/item/crafting/Recipe.h"
|
||||
#include "network/RakNetInstance.h"
|
||||
#include "network/packet/WantCreatePacket.h"
|
||||
#include "platform/input/Keyboard.h"
|
||||
|
||||
static NinePatchLayer* guiPaneFrame = NULL;
|
||||
@@ -439,33 +441,38 @@ void PaneCraftingScreen::craftSelectedItem()
|
||||
ItemInstance resultItem = currentItem->item;
|
||||
|
||||
if (minecraft->player) {
|
||||
// Remove all items required for the recipe and ...
|
||||
for (unsigned int i = 0; i < currentItem->neededItems.size(); ++i) {
|
||||
CItem::ReqItem& req = currentItem->neededItems[i];
|
||||
if (minecraft->isOnline()) {
|
||||
WantCreatePacket packet(minecraft->player->entityId, resultItem.count, resultItem.getAuxValue(), resultItem.id);
|
||||
minecraft->raknetInstance->send(packet);
|
||||
} else {
|
||||
// Remove all items required for the recipe and ...
|
||||
for (unsigned int i = 0; i < currentItem->neededItems.size(); ++i) {
|
||||
CItem::ReqItem& req = currentItem->neededItems[i];
|
||||
|
||||
// If the recipe allows any aux-value as ingredients, first deplete
|
||||
// aux == 0 from inventory. Since I'm not sure if this always is
|
||||
// correct, let's only do it for ingredient sandstone for now.
|
||||
ItemInstance toRemove = req.item;
|
||||
// If the recipe allows any aux-value as ingredients, first deplete
|
||||
// aux == 0 from inventory. Since I'm not sure if this always is
|
||||
// correct, let's only do it for ingredient sandstone for now.
|
||||
ItemInstance toRemove = req.item;
|
||||
|
||||
if (Tile::sandStone->id == req.item.id
|
||||
&& Recipe::ANY_AUX_VALUE == req.item.getAuxValue()) {
|
||||
toRemove.setAuxValue(0);
|
||||
toRemove.count = minecraft->player->inventory->removeResource(toRemove, true);
|
||||
toRemove.setAuxValue(Recipe::ANY_AUX_VALUE);
|
||||
}
|
||||
if (Tile::sandStone->id == req.item.id
|
||||
&& Recipe::ANY_AUX_VALUE == req.item.getAuxValue()) {
|
||||
toRemove.setAuxValue(0);
|
||||
toRemove.count = minecraft->player->inventory->removeResource(toRemove, true);
|
||||
toRemove.setAuxValue(Recipe::ANY_AUX_VALUE);
|
||||
}
|
||||
|
||||
if (toRemove.count > 0) {
|
||||
minecraft->player->inventory->removeResource(toRemove);
|
||||
}
|
||||
if (toRemove.count > 0) {
|
||||
minecraft->player->inventory->removeResource(toRemove);
|
||||
}
|
||||
}
|
||||
// ... add the new one! (in this order, to fill empty slots better)
|
||||
// if it doesn't fit, throw it on the ground!
|
||||
if (!minecraft->player->inventory->add(&resultItem)) {
|
||||
minecraft->player->drop(new ItemInstance(resultItem), false);
|
||||
}
|
||||
|
||||
recheckRecipes();
|
||||
}
|
||||
// ... add the new one! (in this order, to fill empty slots better)
|
||||
// if it doesn't fit, throw it on the ground!
|
||||
if (!minecraft->player->inventory->add(&resultItem)) {
|
||||
minecraft->player->drop(new ItemInstance(resultItem), false);
|
||||
}
|
||||
|
||||
recheckRecipes();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user