add bottles and drink support, fix some craft item inventory bugs

This commit is contained in:
darkrose 2015-06-04 19:15:22 +10:00
parent c94024cf6e
commit 53ab5b5f27
7 changed files with 50 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 300 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 B

View File

@ -610,7 +610,7 @@ void content_craftitem_init()
f->texture = "potato_starch.png";
f->name = "potato_starch";
f->description = wgettext("Potato Starch");
crafting::set1To2Recipe(CONTENT_CRAFTITEM_POTATO,CONTENT_CRAFTITEM_STARCH);
crafting::set2Any2Recipe(CONTENT_CRAFTITEM_POTATO,CONTENT_CRAFTITEM_POTATO,CONTENT_CRAFTITEM_STARCH);
lists::add("craftguide",i);
lists::add("creative",i);
@ -1243,4 +1243,36 @@ void content_craftitem_init()
crafting::set1Any2Recipe(CONTENT_CRAFTITEM_OERKKI_DUST,CONTENT_CRAFTITEM_DYE_BLACK,CONTENT_CRAFTITEM_OERKKI_DUST_BLACK);
lists::add("craftguide",i);
lists::add("creative",i);
i = CONTENT_CRAFTITEM_GLASS_BOTTLE;
f = &g_content_craftitem_features[i];
f->content = i;
f->texture = "glass_bottle.png";
f->name = "glass_bottle";
f->description = wgettext("Glass Bottle");
f->drop_count = 1;
{
u16 r[9] = {
CONTENT_GLASS, CONTENT_IGNORE, CONTENT_GLASS,
CONTENT_GLASS, CONTENT_IGNORE, CONTENT_GLASS,
CONTENT_IGNORE, CONTENT_GLASS, CONTENT_IGNORE
};
crafting::setRecipe(r,CONTENT_CRAFTITEM_GLASS_BOTTLE,5);
}
lists::add("craftguide",i);
lists::add("creative",i);
i = CONTENT_CRAFTITEM_GRAPE_JUICE;
f = &g_content_craftitem_features[i];
f->content = i;
f->texture = "drink_grape.png^glass_bottle.png";
f->name = "glass_bottle";
f->description = wgettext("Grape Juice");
f->stackable = false;
f->drop_count = 1;
f->edible = 2;
f->onuse_replace_item = CONTENT_CRAFTITEM_GLASS_BOTTLE;
crafting::set1over1Recipe(CONTENT_CRAFTITEM_GRAPE,CONTENT_CRAFTITEM_GLASS_BOTTLE,CONTENT_CRAFTITEM_GRAPE_JUICE);
lists::add("craftguide",i);
lists::add("creative",i);
}

View File

@ -63,7 +63,7 @@ struct CraftItemFeatures {
description(L""),
cook_result(""),
fuel_time(0.0),
stackable(false),
stackable(true),
edible(0),
drop_count(-1),
teleports(-2),
@ -189,5 +189,7 @@ CraftItemFeatures & content_craftitem_features(std::string subname);
#define CONTENT_CRAFTITEM_OERKKI_DUST_RED (CONTENT_CRAFTITEM_MASK | 0x72)
#define CONTENT_CRAFTITEM_OERKKI_DUST_YELLOW (CONTENT_CRAFTITEM_MASK | 0x73)
#define CONTENT_CRAFTITEM_OERKKI_DUST_BLACK (CONTENT_CRAFTITEM_MASK | 0x74)
#define CONTENT_CRAFTITEM_GLASS_BOTTLE (CONTENT_CRAFTITEM_MASK | 0x75)
#define CONTENT_CRAFTITEM_GRAPE_JUICE (CONTENT_CRAFTITEM_MASK | 0x76)
#endif

View File

@ -291,6 +291,8 @@ public:
}
u16 freeSpace() const
{
if (!content_craftitem_features(m_content).stackable)
return 0;
if (m_count > QUANTITY_ITEM_MAX_COUNT)
return 0;
return QUANTITY_ITEM_MAX_COUNT - m_count;

View File

@ -4094,7 +4094,18 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
/*
Create the object
*/
ServerActiveObject *obj = item->createSAO(&m_env, 0, pos);
ServerActiveObject *obj = NULL;
/* createSAO will drop all craft items, we may not want that */
if (
wielded_craft_features.content == wieldcontent
&& wielded_craft_features.drop_item == CONTENT_IGNORE
) {
InventoryItem *ditem = InventoryItem::create(wieldcontent,item->getDropCount());
obj = ditem->createSAO(&m_env, 0, pos);
delete ditem;
}else{
obj = item->createSAO(&m_env, 0, pos);
}
if (obj == NULL) {
infostream<<"WARNING: item resulted in NULL object, "