clay vessel pt 1

master
darkrose 2017-08-01 14:54:15 +10:00
parent 22e0d8595d
commit 46ea46d2ab
32 changed files with 383 additions and 146 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 459 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 461 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 473 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 505 B

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 323 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 736 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 392 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 708 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 736 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 802 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 559 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 630 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 317 B

After

Width:  |  Height:  |  Size: 551 B

View File

@ -343,8 +343,8 @@ void content_mapnode_init(bool repeat)
i = CONTENT_STONEBRICK;
f = &content_features(i);
f->description = gettext("Stone Brick");
f->setAllTextures("stonebrick.png");
f->setInventoryTextureCube("stonebrick.png", "stonebrick.png", "stonebrick.png");
f->setAllTextures("stone.png^overlay_brick.png");
f->setInventoryTextureCube("stone.png^overlay_brick.png", "stone.png^overlay_brick.png", "stone.png^overlay_brick.png");
f->draw_type = CDT_CUBELIKE;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
@ -357,8 +357,8 @@ void content_mapnode_init(bool repeat)
i = CONTENT_STONEBLOCK;
f = &content_features(i);
f->description = gettext("Stone Block");
f->setAllTextures("stoneblock.png");
f->setInventoryTextureCube("stoneblock.png", "stoneblock.png", "stoneblock.png");
f->setAllTextures("stone.png^overlay_block.png");
f->setInventoryTextureCube("stone.png^overlay_block.png", "stone.png^overlay_block.png", "stone.png^overlay_block.png");
f->draw_type = CDT_CUBELIKE;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
@ -371,8 +371,8 @@ void content_mapnode_init(bool repeat)
i = CONTENT_ROUGHSTONEBRICK;
f = &content_features(i);
f->description = gettext("Rough Stone Brick");
f->setAllTextures("roughstone_brick.png");
f->setInventoryTextureCube("roughstone_brick.png", "roughstone_brick.png", "roughstone_brick.png");
f->setAllTextures("roughstone.png^overlay_brick.png");
f->setInventoryTextureCube("roughstone.png^overlay_brick.png", "roughstone.png^overlay_brick.png", "roughstone.png^overlay_brick.png");
f->draw_type = CDT_CUBELIKE;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
@ -389,8 +389,8 @@ void content_mapnode_init(bool repeat)
i = CONTENT_ROUGHSTONEBLOCK;
f = &content_features(i);
f->description = gettext("Rough Stone Block");
f->setAllTextures("roughstone_block.png");
f->setInventoryTextureCube("roughstone_block.png", "roughstone_block.png", "roughstone_block.png");
f->setAllTextures("roughstone.png^overlay_block.png");
f->setInventoryTextureCube("roughstone.png^overlay_block.png", "roughstone.png^overlay_block.png", "roughstone.png^overlay_block.png");
f->draw_type = CDT_CUBELIKE;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
@ -825,8 +825,8 @@ void content_mapnode_init(bool repeat)
i = CONTENT_TERRACOTTA_BRICK;
f = &content_features(i);
f->description = gettext("Terracotta Brick");
f->setAllTextures("terracotta_brick.png");
f->setInventoryTextureCube("terracotta_brick.png", "terracotta_brick.png", "terracotta_brick.png");
f->setAllTextures("terracotta.png^overlay_brick.png");
f->setInventoryTextureCube("terracotta.png^overlay_brick.png", "terracotta.png^overlay_brick.png", "terracotta.png^overlay_brick.png");
f->draw_type = CDT_CUBELIKE;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
@ -839,8 +839,8 @@ void content_mapnode_init(bool repeat)
i = CONTENT_TERRACOTTA_BLOCK;
f = &content_features(i);
f->description = gettext("Terracotta Block");
f->setAllTextures("terracotta_block.png");
f->setInventoryTextureCube("terracotta_block.png", "terracotta_block.png", "terracotta_block.png");
f->setAllTextures("terracotta.png^overlay_block.png");
f->setInventoryTextureCube("terracotta.png^overlay_block.png", "terracotta.png^overlay_block.png", "terracotta.png^overlay_block.png");
f->draw_type = CDT_CUBELIKE;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
@ -853,7 +853,7 @@ void content_mapnode_init(bool repeat)
i = CONTENT_TERRACOTTA_TILE;
f = &content_features(i);
f->description = gettext("Terracotta Tile");
f->setAllTextures("terracotta_tile.png");
f->setAllTextures("terracotta.png^overlay_tile.png");
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
f->type = CMT_STONE;
f->dig_time = 1.0;
@ -864,7 +864,7 @@ void content_mapnode_init(bool repeat)
f->sunlight_propagates = true;
f->suffocation_per_second = 0;
content_nodebox_carpet(f);
f->setInventoryTextureNodeBox(i,"terracotta_tile.png", "terracotta_tile.png", "terracotta_tile.png");
f->setInventoryTextureNodeBox(i,"terracotta.png^overlay_tile.png", "terracotta.png^overlay_tile.png", "terracotta.png^overlay_tile.png");
crafting::setTileRecipe(CONTENT_TERRACOTTA,CONTENT_TERRACOTTA_TILE);
content_list_add("craftguide",i,1,0);
content_list_add("creative",i,1,0);
@ -2356,7 +2356,7 @@ void content_mapnode_init(bool repeat)
i = CONTENT_STONE_TILE;
f = &content_features(i);
f->description = gettext("Stone Tiles");
f->setAllTextures("stone_tile.png");
f->setAllTextures("stone.png^overlay_oddtile.png");
f->param_type = CPT_LIGHT;
f->draw_type = CDT_NODEBOX;
f->is_ground_content = true;
@ -2364,7 +2364,7 @@ void content_mapnode_init(bool repeat)
f->sunlight_propagates = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
content_nodebox_carpet(f);
f->setInventoryTextureNodeBox(i,"stone_tile.png", "stone_tile.png", "stone_tile.png");
f->setInventoryTextureNodeBox(i,"stone.png^overlay_oddtile.png", "stone.png^overlay_oddtile.png", "stone.png^overlay_oddtile.png");
f->type = CMT_STONE;
f->dig_time = 0.5;
f->pressure_type = CST_CRUSHABLE;

View File

@ -128,7 +128,9 @@ MapNode mapnode_translate_to_internal(MapNode n_from, u8 version);
#define CONTENT_APPLEWOOD_BARREL_SEALED 0x047
#define CONTENT_JUNGLEWOOD_BARREL_SEALED 0x048
#define CONTENT_PINE_BARREL_SEALED 0x049
// FREE 0x04A-0x07C
#define CONTENT_CLAY_VESSEL 0x04A
#define CONTENT_CLAY_VESSEL_RAW 0x04B
// FREE 0x04C-0x07C
// 0x7D-0x7F reserved values, air, ignore, etc
#define CONTENT_CHAIR_CENTRE 0x080
#define CONTENT_CHAIR_ENDL 0x081
@ -213,8 +215,7 @@ MapNode mapnode_translate_to_internal(MapNode n_from, u8 version);
#define CONTENT_TREE 0x801
#define CONTENT_LEAVES 0x802
#define CONTENT_FARM_DIRT 0x803
// MESE is deprecated, but leave it here for the moment
#define CONTENT_MESE 0x804
// FREE 0x804
#define CONTENT_MUD 0x805
#define CONTENT_COTTON 0x806
#define CONTENT_BORDERSTONE 0x807

View File

@ -225,7 +225,7 @@ void content_mapnode_special(bool repeat)
i = CONTENT_ROOFTILE_TERRACOTTA;
f = &content_features(i);
f->description = gettext("Terracotta Roof Tile");
f->setAllTextures("rooftile_terracotta.png");
f->setAllTextures("terracotta.png^overlay_rooftile.png");
f->setAllTextureFlags(0);
f->draw_type = CDT_ROOFLIKE;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
@ -281,7 +281,7 @@ void content_mapnode_special(bool repeat)
i = CONTENT_ROOFTILE_STONE;
f = &content_features(i);
f->description = gettext("Stone Roof Tile");
f->setAllTextures("rooftile_stone.png");
f->setAllTextures("stone.png^overlay_rooftile.png");
f->setAllTextureFlags(0);
f->draw_type = CDT_ROOFLIKE;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
@ -1681,39 +1681,40 @@ void content_mapnode_special(bool repeat)
i = CONTENT_FLOWER_POT_RAW;
f = &content_features(i);
f->param_type = CPT_LIGHT;
f->description = gettext("Unbaked Flower Pot");
f->setAllTextures("flower_pot_raw.png");
f->setTexture(0,"flower_pot_raw_top.png");
f->setTexture(1,"flower_pot_raw_bottom.png");
f->description = gettext("Unfired Flower Pot");
f->setAllTextures("clay.png");
f->setTexture(0,"clay.png^flower_pot_top.png");
f->draw_type = CDT_NODEBOX;
f->light_propagates = true;
f->sunlight_propagates = true;
f->air_equivalent = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
f->cook_result = std::string("MaterialItem2 ")+itos(CONTENT_FLOWER_POT)+" 1";
f->type = CMT_STONE;
f->dig_time = 0.75;
f->pressure_type = CST_CRUSHABLE;
content_nodebox_flower_pot(f);
f->setInventoryTextureNodeBox(i,"flower_pot_raw_top.png","flower_pot_raw.png","flower_pot_raw.png");
f->setInventoryTextureNodeBox(i,"clay.png^flower_pot_top.png","clay.png","clay.png");
crafting::setVRecipe(CONTENT_CRAFTITEM_CLAY,CONTENT_FLOWER_POT_RAW);
content_list_add("craftguide",i,1,0);
content_list_add("cooking",i,1,0);
content_list_add("creative",i,1,0);
i = CONTENT_FLOWER_POT;
f = &content_features(i);
f->param_type = CPT_LIGHT;
f->description = gettext("Flower Pot");
f->setAllTextures("flower_pot.png");
f->setTexture(0,"flower_pot_top.png");
f->setTexture(1,"flower_pot_bottom.png");
f->setAllTextures("terracotta.png");
f->setTexture(0,"terracotta.png^flower_pot_top.png");
f->draw_type = CDT_NODEBOX;
f->light_propagates = true;
f->sunlight_propagates = true;
f->air_equivalent = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
f->type = CMT_STONE;
f->dig_time = 0.75;
content_nodebox_flower_pot(f);
f->setInventoryTextureNodeBox(i,"flower_pot_top.png","flower_pot.png","flower_pot.png");
f->setInventoryTextureNodeBox(i,"terracotta.png^flower_pot_top.png","terracotta.png","terracotta.png");
content_list_add("creative",i,1,0);
// walls
@ -2298,4 +2299,49 @@ void content_mapnode_special(bool repeat)
content_list_add("cooking",i,1,0);
content_list_add("craftguide",i,1,0);
content_list_add("creative",i,1,0);
i = CONTENT_CLAY_VESSEL_RAW;
f = &content_features(i);
f->description = gettext("Unfired Clay Vessel");
f->setAllTextures("clay.png");
f->draw_type = CDT_NODEBOX;
f->param_type = CPT_LIGHT;
f->light_propagates = true;
f->sunlight_propagates = true;
f->air_equivalent = true;
f->type = CMT_DIRT;
f->dig_time = 0.1;
f->suffocation_per_second = 0;
f->pressure_type = CST_SOLID;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
f->cook_result = std::string("MaterialItem2 ")+itos(CONTENT_CLAY_VESSEL)+" 1";
content_nodebox_clay_vessel(f);
f->setInventoryTextureNodeBox(i,"clay.png", "clay.png", "clay.png");
crafting::setURecipe(CONTENT_CRAFTITEM_CLAY,CONTENT_CLAY_VESSEL);
content_list_add("craftguide",i,1,0);
content_list_add("cooking",i,1,0);
content_list_add("creative",i,1,0);
i = CONTENT_CLAY_VESSEL;
f = &content_features(i);
f->description = gettext("Clay Vessel");
f->setAllTextures("terracotta.png");
f->setAllMetaTextures("terracotta.png");
f->draw_type = CDT_NODEBOX_META;
f->param_type = CPT_LIGHT;
f->light_propagates = true;
f->sunlight_propagates = true;
f->air_equivalent = true;
f->type = CMT_DIRT;
f->dig_time = 0.1;
f->suffocation_per_second = 0;
f->pressure_type = CST_SOLID;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
content_nodebox_clay_vessel(f);
f->setInventoryTextureNodeBox(i,"terracotta.png", "terracotta.png", "terracotta.png");
if (f->initial_metadata == NULL)
f->initial_metadata = new ClayVesselNodeMetadata();
crafting::setURecipe(CONTENT_CRAFTITEM_CLAY,CONTENT_CLAY_VESSEL);
content_list_add("craftguide",i,1,0);
content_list_add("creative",i,1,0);
}

View File

@ -2263,5 +2263,36 @@ void content_nodebox_barrel_sealed(ContentFeatures *f)
f->addNodeBox(NodeBox(
-0.3125*BS,0.3125*BS,-0.3125*BS,0.3125*BS,0.375*BS,0.3125*BS
));
}
void content_nodebox_clay_vessel(ContentFeatures *f)
{
f->setNodeBox(NodeBox(
-0.25*BS,-0.4375*BS,-0.25*BS,0.25*BS,-0.375*BS,0.25*BS
));
f->addNodeBox(NodeBox(
0.25*BS,-0.4375*BS,-0.25*BS,0.3125*BS,0.25*BS,0.25*BS
));
f->addNodeBox(NodeBox(
-0.3125*BS,-0.4375*BS,-0.25*BS,-0.25*BS,0.25*BS,0.25*BS
));
f->addNodeBox(NodeBox(
-0.3125*BS,-0.4375*BS,-0.3125*BS,0.3125*BS,0.25*BS,-0.25*BS
));
f->addNodeBox(NodeBox(
-0.3125*BS,-0.4375*BS,0.25*BS,0.3125*BS,0.25*BS,0.3125*BS
));
f->addNodeBox(NodeBox(
-0.3125*BS,-0.5*BS,-0.3125*BS,-0.0625*BS,-0.4375*BS,-0.0625*BS
));
f->addNodeBox(NodeBox(
-0.3125*BS,-0.5*BS,0.0625*BS,-0.0625*BS,-0.4375*BS,0.3125*BS
));
f->addNodeBox(NodeBox(
0.0625*BS,-0.5*BS,-0.3125*BS,0.3125*BS,-0.4375*BS,-0.0625*BS
));
f->addNodeBox(NodeBox(
0.0625*BS,-0.5*BS,0.0625*BS,0.3125*BS,-0.4375*BS,0.3125*BS
));
}

View File

@ -104,5 +104,6 @@ void content_nodebox_glass_pane(ContentFeatures *f);
void content_nodebox_snowman(ContentFeatures *f);
void content_nodebox_barrel(ContentFeatures *f);
void content_nodebox_barrel_sealed(ContentFeatures *f);
void content_nodebox_clay_vessel(ContentFeatures *f);
#endif

View File

@ -184,6 +184,27 @@ private:
uint16_t m_expanded_slot_id;
};
class ClayVesselNodeMetadata : public NodeMetadata
{
public:
ClayVesselNodeMetadata();
~ClayVesselNodeMetadata();
virtual u16 typeId() const;
static NodeMetadata* create(std::istream &is);
virtual NodeMetadata* clone();
virtual void serializeBody(std::ostream &os);
virtual Inventory* getInventory() {return m_inventory;}
virtual bool nodeRemovalDisabled();
virtual std::string getDrawSpecString(Player *player);
virtual bool receiveFields(std::string formname, std::map<std::string, std::string> fields, Player *player);
virtual std::vector<NodeBox> getNodeBoxes(MapNode &n);
private:
Inventory *m_inventory;
bool is_sealed;
};
class DeprecatedChestNodeMetadata : public NodeMetadata
{
public:

View File

@ -2160,20 +2160,6 @@ void ServerEnvironment::step(float dtime)
break;
}
// MESE is dead
case CONTENT_MESE:
{
if (p.Y > 0) {
n.setContent(CONTENT_MITHRIL_BLOCK);
m_map->addNodeWithEvent(p, n);
}else{
n.setContent(CONTENT_STONE);
n.param1 = MINERAL_MITHRIL;
m_map->addNodeWithEvent(p, n);
}
break;
}
// cobble becomes mossy underwater
case CONTENT_COBBLE:
{

View File

@ -545,7 +545,12 @@ void GUIFormSpecMenu::drawList(const ListDrawSpec &s, int phase)
driver->draw2DRectangle(GUI_INV_BG, brect, &AbsoluteClippingRect);
if (m_selected_item != NULL && m_selected_item->listname == s.listname && m_selected_item->i == i) {
if (
m_selected_item != NULL
&& s.inventoryloc.type == m_selected_item->inventoryloc.type
&& m_selected_item->i == i
&& m_selected_item->listname == s.listname
) {
driver->draw2DRectangleOutline(brect, GUI_INV_HIGHLIGHT);
}else{

View File

@ -12,7 +12,7 @@
#define GUI_BG_TT video::SColor(200,70,130,30)
#define GUI_TT_TEXT video::SColor(255,255,255,255)
#define GUI_INV_BORDER video::SColor(128,60,60,60)
#define GUI_INV_BORDER video::SColor(128,150,150,150)
#define GUI_INV_HIGHLIGHT video::SColor(240,170,30,30)
#define GUI_INV_BG video::SColor(128,60,60,60)

View File

@ -886,8 +886,6 @@ void InventoryList::deSerialize(std::istream &is)
m_items[item_i] = NULL;
continue;
}
if (c == CONTENT_MESE)
c = CONTENT_CRAFTITEM_MITHRIL_UNBOUND;
u16 wc = readU16(is);
u16 d = readU16(is);
if (m_items[item_i] != NULL) {

View File

@ -29,104 +29,6 @@
#include "content_mapnode.h"
#include "environment.h"
/*
BookShelfNodeMetadata
*/
// Prototype
BookShelfNodeMetadata proto_BookShelfNodeMetadata;
BookShelfNodeMetadata::BookShelfNodeMetadata()
{
NodeMetadata::registerType(typeId(), create);
m_inventory = new Inventory();
m_inventory->addList("0", 14);
InventoryList *l = m_inventory->getList("0");
l->setStackable(false);
l->addAllowed(CONTENT_BOOK);
l->addAllowed(CONTENT_COOK_BOOK);
l->addAllowed(CONTENT_DECRAFT_BOOK);
l->addAllowed(CONTENT_DIARY_BOOK);
l->addAllowed(CONTENT_CRAFT_BOOK);
l->addAllowed(CONTENT_RCRAFT_BOOK);
}
BookShelfNodeMetadata::~BookShelfNodeMetadata()
{
delete m_inventory;
}
u16 BookShelfNodeMetadata::typeId() const
{
return CONTENT_BOOKSHELF;
}
NodeMetadata* BookShelfNodeMetadata::create(std::istream &is)
{
BookShelfNodeMetadata *d = new BookShelfNodeMetadata();
d->m_inventory->deSerialize(is);
return d;
}
NodeMetadata* BookShelfNodeMetadata::clone()
{
BookShelfNodeMetadata *d = new BookShelfNodeMetadata();
*d->m_inventory = *m_inventory;
return d;
}
void BookShelfNodeMetadata::serializeBody(std::ostream &os)
{
m_inventory->serialize(os);
}
bool BookShelfNodeMetadata::nodeRemovalDisabled()
{
/*
Disable removal if chest contains something
*/
InventoryList *list = m_inventory->getList("0");
if(list == NULL)
return false;
if(list->getUsedSlots() == 0)
return false;
return true;
}
std::string BookShelfNodeMetadata::getDrawSpecString(Player *player)
{
return
"size[8,7]"
"list[current_name;0;0.5,0;7,2;]"
"list[current_player;main;0,3;8,4;]";
}
std::vector<NodeBox> BookShelfNodeMetadata::getNodeBoxes(MapNode &n)
{
std::vector<NodeBox> boxes;
boxes.clear();
InventoryList *list = m_inventory->getList("0");
if(list == NULL)
return boxes;
if(list->getUsedSlots() == 0)
return boxes;
f32 x = 0;
f32 y = 0;
f32 h = 0;
for (s16 i=0; i<14; i++) {
if (list->getItem(i) == NULL)
continue;
x = (i%7)*0.125;
y = (i/7)*-0.5;
h = ((i%7)%2)*0.0625;
boxes.push_back(NodeBox(
(-0.4375+x)*BS,(0.0625+y)*BS,-0.4375*BS,(-0.3125+x)*BS,(0.375+y+h)*BS,-0.0625*BS
));
boxes.push_back(NodeBox(
(0.3125-x)*BS,(0.0625+y)*BS,0.0625*BS,(0.4375-x)*BS,(0.375+y+h)*BS,0.4375*BS
));
}
return transformNodeBox(n,boxes);
}
/*
ClockNodeMetadata
*/

View File

@ -32,6 +32,104 @@
#include "player.h"
/*
BookShelfNodeMetadata
*/
// Prototype
BookShelfNodeMetadata proto_BookShelfNodeMetadata;
BookShelfNodeMetadata::BookShelfNodeMetadata()
{
NodeMetadata::registerType(typeId(), create);
m_inventory = new Inventory();
m_inventory->addList("0", 14);
InventoryList *l = m_inventory->getList("0");
l->setStackable(false);
l->addAllowed(CONTENT_BOOK);
l->addAllowed(CONTENT_COOK_BOOK);
l->addAllowed(CONTENT_DECRAFT_BOOK);
l->addAllowed(CONTENT_DIARY_BOOK);
l->addAllowed(CONTENT_CRAFT_BOOK);
l->addAllowed(CONTENT_RCRAFT_BOOK);
}
BookShelfNodeMetadata::~BookShelfNodeMetadata()
{
delete m_inventory;
}
u16 BookShelfNodeMetadata::typeId() const
{
return CONTENT_BOOKSHELF;
}
NodeMetadata* BookShelfNodeMetadata::create(std::istream &is)
{
BookShelfNodeMetadata *d = new BookShelfNodeMetadata();
d->m_inventory->deSerialize(is);
return d;
}
NodeMetadata* BookShelfNodeMetadata::clone()
{
BookShelfNodeMetadata *d = new BookShelfNodeMetadata();
*d->m_inventory = *m_inventory;
return d;
}
void BookShelfNodeMetadata::serializeBody(std::ostream &os)
{
m_inventory->serialize(os);
}
bool BookShelfNodeMetadata::nodeRemovalDisabled()
{
/*
Disable removal if chest contains something
*/
InventoryList *list = m_inventory->getList("0");
if(list == NULL)
return false;
if(list->getUsedSlots() == 0)
return false;
return true;
}
std::string BookShelfNodeMetadata::getDrawSpecString(Player *player)
{
return
"size[8,7]"
"list[current_name;0;0.5,0;7,2;]"
"list[current_player;main;0,3;8,4;]";
}
std::vector<NodeBox> BookShelfNodeMetadata::getNodeBoxes(MapNode &n)
{
std::vector<NodeBox> boxes;
boxes.clear();
InventoryList *list = m_inventory->getList("0");
if(list == NULL)
return boxes;
if(list->getUsedSlots() == 0)
return boxes;
f32 x = 0;
f32 y = 0;
f32 h = 0;
for (s16 i=0; i<14; i++) {
if (list->getItem(i) == NULL)
continue;
x = (i%7)*0.125;
y = (i/7)*-0.5;
h = ((i%7)%2)*0.0625;
boxes.push_back(NodeBox(
(-0.4375+x)*BS,(0.0625+y)*BS,-0.4375*BS,(-0.3125+x)*BS,(0.375+y+h)*BS,-0.0625*BS
));
boxes.push_back(NodeBox(
(0.3125-x)*BS,(0.0625+y)*BS,0.0625*BS,(0.4375-x)*BS,(0.375+y+h)*BS,0.4375*BS
));
}
return transformNodeBox(n,boxes);
}
/*
ChestNodeMetadata
*/
@ -475,3 +573,151 @@ bool SealedBarrelNodeMetadata::import(NodeMetadata *meta)
m_water_level = l->m_water_level;
return true;
}
/*
ClayVesselNodeMetadata
*/
// Prototype
ClayVesselNodeMetadata proto_ClayVesselNodeMetadata;
ClayVesselNodeMetadata::ClayVesselNodeMetadata()
{
NodeMetadata::registerType(typeId(), create);
m_inventory = new Inventory();
m_inventory->addList("main", 9);
is_sealed = false;
InventoryList *l = m_inventory->getList("main");
l->addAllowed(CONTENT_CRAFTITEM_APPLE);
l->addAllowed(CONTENT_CRAFTITEM_APPLE_BLOSSOM);
l->addAllowed(CONTENT_CRAFTITEM_APPLE_IRON);
l->addAllowed(CONTENT_CRAFTITEM_APPLE_JUICE);
l->addAllowed(CONTENT_CRAFTITEM_APPLE_PIE_SLICE);
l->addAllowed(CONTENT_CRAFTITEM_BEETROOT);
l->addAllowed(CONTENT_CRAFTITEM_BLUEBERRY);
l->addAllowed(CONTENT_CRAFTITEM_BREAD);
l->addAllowed(CONTENT_CRAFTITEM_CACTUS_FRUIT);
l->addAllowed(CONTENT_CRAFTITEM_CARROT);
l->addAllowed(CONTENT_CRAFTITEM_CARROT_CAKE);
l->addAllowed(CONTENT_CRAFTITEM_CARROT_CAKE_RAW);
l->addAllowed(CONTENT_CRAFTITEM_COFFEE);
l->addAllowed(CONTENT_CRAFTITEM_COFFEE_BEANS);
l->addAllowed(CONTENT_CRAFTITEM_COOKED_FISH);
l->addAllowed(CONTENT_CRAFTITEM_COOKED_MEAT);
l->addAllowed(CONTENT_CRAFTITEM_COOKED_RAT);
l->addAllowed(CONTENT_CRAFTITEM_DOUGH);
l->addAllowed(CONTENT_CRAFTITEM_FISH);
l->addAllowed(CONTENT_CRAFTITEM_FLOUR);
l->addAllowed(CONTENT_CRAFTITEM_GLASS_BOTTLE_WATER);
l->addAllowed(CONTENT_CRAFTITEM_GRAPE);
l->addAllowed(CONTENT_CRAFTITEM_GRAPE_JUICE);
l->addAllowed(CONTENT_CRAFTITEM_IRON_BOTTLE_WATER);
l->addAllowed(CONTENT_CRAFTITEM_MEAT);
l->addAllowed(CONTENT_CRAFTITEM_MELONSLICE);
l->addAllowed(CONTENT_CRAFTITEM_MUSH);
l->addAllowed(CONTENT_CRAFTITEM_POTATO);
l->addAllowed(CONTENT_CRAFTITEM_PUMPKINSLICE);
l->addAllowed(CONTENT_CRAFTITEM_PUMPKIN_PIE_SLICE);
l->addAllowed(CONTENT_CRAFTITEM_RASPBERRY);
l->addAllowed(CONTENT_CRAFTITEM_ROASTPOTATO);
l->addAllowed(CONTENT_CRAFTITEM_TEA);
l->addAllowed(CONTENT_CRAFTITEM_TEA_LEAVES);
l->addAllowed(CONTENT_CRAFTITEM_WHEAT);
}
ClayVesselNodeMetadata::~ClayVesselNodeMetadata()
{
delete m_inventory;
}
u16 ClayVesselNodeMetadata::typeId() const
{
return CONTENT_CLAY_VESSEL;
}
NodeMetadata* ClayVesselNodeMetadata::create(std::istream &is)
{
std::string s;
ClayVesselNodeMetadata *d = new ClayVesselNodeMetadata();
d->m_inventory->deSerialize(is);
s = deSerializeString(is);
d->is_sealed = !!mystoi(s);
return d;
}
NodeMetadata* ClayVesselNodeMetadata::clone()
{
ClayVesselNodeMetadata *d = new ClayVesselNodeMetadata();
*d->m_inventory = *m_inventory;
d->is_sealed = is_sealed;
return d;
}
void ClayVesselNodeMetadata::serializeBody(std::ostream &os)
{
m_inventory->serialize(os);
os<<serializeString(itos(is_sealed ? 1 : 0));
}
bool ClayVesselNodeMetadata::nodeRemovalDisabled()
{
/*
Disable removal if chest contains something
*/
InventoryList *list = m_inventory->getList("main");
if (list == NULL)
return false;
if (list->getUsedSlots() == 0)
return false;
return true;
}
std::string ClayVesselNodeMetadata::getDrawSpecString(Player *player)
{
std::string spec("size[8,8]");
if (is_sealed) {
spec += "button[0.5,2;3,1;unseal;";
spec += gettext("Unseal Vessel");
spec += "]";
}else{
spec += "button[0.5,2;3,1;seal;";
spec += gettext("Seal Vessel");
spec += "]";
spec += "list[current_name;main;3.5,0.5;3,3;]";
}
spec += "list[current_player;main;0,3.8;8,1;0,8;]";
spec += "list[current_player;main;0,5;8,3;8,-1;]";
return spec;
}
bool ClayVesselNodeMetadata::receiveFields(std::string formname, std::map<std::string, std::string> fields, Player *player)
{
if (fields["seal"] != "") {
if (is_sealed)
return false;
is_sealed = true;
return true;
}else if (fields["unseal"] != "") {
if (!is_sealed)
return false;
is_sealed = false;
return true;
}
return false;
}
std::vector<NodeBox> ClayVesselNodeMetadata::getNodeBoxes(MapNode &n)
{
std::vector<NodeBox> boxes;
if (is_sealed) {
boxes.push_back(NodeBox(
-0.34375*BS,0.1875*BS,-0.34375*BS,0.34375*BS,0.3125*BS,0.34375*BS
));
boxes.push_back(NodeBox(
-0.125*BS,0.3125*BS,-0.125*BS,0.125*BS,0.375*BS,0.125*BS
));
}
return boxes;
}