forked from oerkki/voxelands
add a safe, and make some nodes safe from destructive mobs
This commit is contained in:
parent
e90e6969bc
commit
4a169b16c3
Binary file not shown.
After Width: | Height: | Size: 565 B |
Binary file not shown.
After Width: | Height: | Size: 506 B |
Binary file not shown.
After Width: | Height: | Size: 506 B |
|
@ -2257,6 +2257,7 @@ void content_mapnode_init(bool repeat)
|
||||||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||||
f->type = CMT_STONE;
|
f->type = CMT_STONE;
|
||||||
f->hardness = 5.0;
|
f->hardness = 5.0;
|
||||||
|
f->destructive_mob_safe = true;
|
||||||
crafting::setHardBlockRecipe(CONTENT_CRAFTITEM_STEEL_INGOT,CONTENT_STEEL);
|
crafting::setHardBlockRecipe(CONTENT_CRAFTITEM_STEEL_INGOT,CONTENT_STEEL);
|
||||||
crafting::setUncraftHardBlockRecipe(CONTENT_STEEL,CONTENT_CRAFTITEM_STEEL_INGOT);
|
crafting::setUncraftHardBlockRecipe(CONTENT_STEEL,CONTENT_CRAFTITEM_STEEL_INGOT);
|
||||||
lists::add("craftguide",i);
|
lists::add("craftguide",i);
|
||||||
|
@ -2280,6 +2281,7 @@ void content_mapnode_init(bool repeat)
|
||||||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||||
f->type = CMT_STONE;
|
f->type = CMT_STONE;
|
||||||
f->hardness = 5.0;
|
f->hardness = 5.0;
|
||||||
|
f->destructive_mob_safe = true;
|
||||||
crafting::setHardBlockRecipe(CONTENT_CRAFTITEM_COPPER_INGOT,CONTENT_COPPER);
|
crafting::setHardBlockRecipe(CONTENT_CRAFTITEM_COPPER_INGOT,CONTENT_COPPER);
|
||||||
crafting::setUncraftHardBlockRecipe(CONTENT_COPPER,CONTENT_CRAFTITEM_COPPER_INGOT);
|
crafting::setUncraftHardBlockRecipe(CONTENT_COPPER,CONTENT_CRAFTITEM_COPPER_INGOT);
|
||||||
lists::add("craftguide",i);
|
lists::add("craftguide",i);
|
||||||
|
@ -2296,6 +2298,7 @@ void content_mapnode_init(bool repeat)
|
||||||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||||
f->type = CMT_STONE;
|
f->type = CMT_STONE;
|
||||||
f->hardness = 5.0;
|
f->hardness = 5.0;
|
||||||
|
f->destructive_mob_safe = true;
|
||||||
crafting::setHardBlockRecipe(CONTENT_CRAFTITEM_GOLD_INGOT,CONTENT_GOLD);
|
crafting::setHardBlockRecipe(CONTENT_CRAFTITEM_GOLD_INGOT,CONTENT_GOLD);
|
||||||
crafting::setUncraftHardBlockRecipe(CONTENT_GOLD,CONTENT_CRAFTITEM_GOLD_INGOT);
|
crafting::setUncraftHardBlockRecipe(CONTENT_GOLD,CONTENT_CRAFTITEM_GOLD_INGOT);
|
||||||
lists::add("craftguide",i);
|
lists::add("craftguide",i);
|
||||||
|
@ -2312,6 +2315,7 @@ void content_mapnode_init(bool repeat)
|
||||||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||||
f->type = CMT_STONE;
|
f->type = CMT_STONE;
|
||||||
f->hardness = 5.0;
|
f->hardness = 5.0;
|
||||||
|
f->destructive_mob_safe = true;
|
||||||
crafting::setHardBlockRecipe(CONTENT_CRAFTITEM_SILVER_INGOT,CONTENT_SILVER);
|
crafting::setHardBlockRecipe(CONTENT_CRAFTITEM_SILVER_INGOT,CONTENT_SILVER);
|
||||||
crafting::setUncraftHardBlockRecipe(CONTENT_SILVER,CONTENT_CRAFTITEM_SILVER_INGOT);
|
crafting::setUncraftHardBlockRecipe(CONTENT_SILVER,CONTENT_CRAFTITEM_SILVER_INGOT);
|
||||||
lists::add("craftguide",i);
|
lists::add("craftguide",i);
|
||||||
|
@ -2328,6 +2332,7 @@ void content_mapnode_init(bool repeat)
|
||||||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||||
f->type = CMT_STONE;
|
f->type = CMT_STONE;
|
||||||
f->hardness = 5.0;
|
f->hardness = 5.0;
|
||||||
|
f->destructive_mob_safe = true;
|
||||||
crafting::setHardBlockRecipe(CONTENT_CRAFTITEM_TIN_INGOT,CONTENT_TIN);
|
crafting::setHardBlockRecipe(CONTENT_CRAFTITEM_TIN_INGOT,CONTENT_TIN);
|
||||||
crafting::setUncraftHardBlockRecipe(CONTENT_TIN,CONTENT_CRAFTITEM_TIN_INGOT);
|
crafting::setUncraftHardBlockRecipe(CONTENT_TIN,CONTENT_CRAFTITEM_TIN_INGOT);
|
||||||
lists::add("craftguide",i);
|
lists::add("craftguide",i);
|
||||||
|
@ -2344,6 +2349,7 @@ void content_mapnode_init(bool repeat)
|
||||||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||||
f->type = CMT_STONE;
|
f->type = CMT_STONE;
|
||||||
f->hardness = 5.0;
|
f->hardness = 5.0;
|
||||||
|
f->destructive_mob_safe = true;
|
||||||
crafting::setHardBlockRecipe(CONTENT_CRAFTITEM_QUARTZ,CONTENT_QUARTZ);
|
crafting::setHardBlockRecipe(CONTENT_CRAFTITEM_QUARTZ,CONTENT_QUARTZ);
|
||||||
crafting::setUncraftHardBlockRecipe(CONTENT_QUARTZ,CONTENT_CRAFTITEM_QUARTZ);
|
crafting::setUncraftHardBlockRecipe(CONTENT_QUARTZ,CONTENT_CRAFTITEM_QUARTZ);
|
||||||
lists::add("craftguide",i);
|
lists::add("craftguide",i);
|
||||||
|
|
|
@ -62,7 +62,8 @@ MapNode mapnode_translate_to_internal(MapNode n_from, u8 version);
|
||||||
#define CONTENT_TORCH 7
|
#define CONTENT_TORCH 7
|
||||||
#define CONTENT_TABLE 8
|
#define CONTENT_TABLE 8
|
||||||
#define CONTENT_WATERSOURCE 9
|
#define CONTENT_WATERSOURCE 9
|
||||||
// FREE 10-13
|
// FREE 10-12
|
||||||
|
#define CONTENT_SAFE 13
|
||||||
#define CONTENT_SIGN_WALL 14
|
#define CONTENT_SIGN_WALL 14
|
||||||
#define CONTENT_CHEST 15
|
#define CONTENT_CHEST 15
|
||||||
#define CONTENT_FURNACE 16
|
#define CONTENT_FURNACE 16
|
||||||
|
|
|
@ -82,6 +82,7 @@ void content_mapnode_special(bool repeat)
|
||||||
f->hardness = 0.75;
|
f->hardness = 0.75;
|
||||||
f->pressure_type = CST_SOLID;
|
f->pressure_type = CST_SOLID;
|
||||||
f->suffocation_per_second = 0;
|
f->suffocation_per_second = 0;
|
||||||
|
f->destructive_mob_safe = true;
|
||||||
content_nodebox_fence_inv(f);
|
content_nodebox_fence_inv(f);
|
||||||
content_nodebox_fence(f);
|
content_nodebox_fence(f);
|
||||||
f->setInventoryTextureNodeBox(i,"fence_steel.png","fence_steel_top.png","fence_steel.png");
|
f->setInventoryTextureNodeBox(i,"fence_steel.png","fence_steel_top.png","fence_steel.png");
|
||||||
|
@ -1253,6 +1254,28 @@ void content_mapnode_special(bool repeat)
|
||||||
lists::add("craftguide",i);
|
lists::add("craftguide",i);
|
||||||
lists::add("creative",i);
|
lists::add("creative",i);
|
||||||
|
|
||||||
|
i = CONTENT_SAFE;
|
||||||
|
f = &content_features(i);
|
||||||
|
f->description = wgettext("Safe");
|
||||||
|
f->param_type = CPT_FACEDIR_SIMPLE;
|
||||||
|
f->draw_type = CDT_CUBELIKE;
|
||||||
|
f->setAllTextures("safe_side.png");
|
||||||
|
f->setTexture(0, "safe_top.png");
|
||||||
|
f->setTexture(1, "safe_top.png");
|
||||||
|
f->setTexture(5, "safe_lock.png"); // Z-
|
||||||
|
f->setInventoryTexture("safe_lock.png");
|
||||||
|
f->setInventoryTextureCube("safe_top.png", "safe_lock.png", "safe_side.png");
|
||||||
|
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||||
|
if(f->initial_metadata == NULL)
|
||||||
|
f->initial_metadata = new SafeNodeMetadata();
|
||||||
|
f->type = CMT_WOOD;
|
||||||
|
f->hardness = 1.0;
|
||||||
|
f->pressure_type = CST_SOLID;
|
||||||
|
f->destructive_mob_safe = true;
|
||||||
|
crafting::setFilledRoundRecipe(CONTENT_CRAFTITEM_STEEL_INGOT,CONTENT_CRAFTITEM_COPPER_INGOT,CONTENT_LOCKABLE_CHEST);
|
||||||
|
lists::add("craftguide",i);
|
||||||
|
lists::add("creative",i);
|
||||||
|
|
||||||
i = CONTENT_FURNACE;
|
i = CONTENT_FURNACE;
|
||||||
f = &content_features(i);
|
f = &content_features(i);
|
||||||
f->description = wgettext("Furnace");
|
f->description = wgettext("Furnace");
|
||||||
|
|
|
@ -34,17 +34,16 @@ void content_nodedef_knob(content_t nodeid, content_t source_node, ContentMateri
|
||||||
features->type = CMT_STONE;
|
features->type = CMT_STONE;
|
||||||
features->hardness = 0.8;
|
features->hardness = 0.8;
|
||||||
features->climbable = true;
|
features->climbable = true;
|
||||||
if(material_type == CMT_WOOD)
|
features->suffocation_per_second = 0;
|
||||||
{
|
if (material_type == CMT_WOOD) {
|
||||||
content_t recipe[9] = {
|
content_t recipe[9] = {
|
||||||
CONTENT_IGNORE, CONTENT_IGNORE, CONTENT_IGNORE,
|
CONTENT_IGNORE, CONTENT_IGNORE, CONTENT_IGNORE,
|
||||||
source_node , source_node , CONTENT_IGNORE,
|
source_node , source_node , CONTENT_IGNORE,
|
||||||
CONTENT_IGNORE, CONTENT_IGNORE, CONTENT_IGNORE};
|
CONTENT_IGNORE, CONTENT_IGNORE, CONTENT_IGNORE
|
||||||
|
};
|
||||||
|
|
||||||
crafting::setRecipe(recipe, nodeid, 2);
|
crafting::setRecipe(recipe, nodeid, 2);
|
||||||
}
|
}else{
|
||||||
else
|
|
||||||
{
|
|
||||||
crafting::set1To4Recipe(source_node,nodeid);
|
crafting::set1To4Recipe(source_node,nodeid);
|
||||||
}
|
}
|
||||||
content_nodebox_knob(features);
|
content_nodebox_knob(features);
|
||||||
|
|
|
@ -320,7 +320,81 @@ bool LockingChestNodeMetadata::import(NodeMetadata *meta)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ChestNodeMetadata
|
SafeNodeMetadata
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Prototype
|
||||||
|
SafeNodeMetadata proto_SafeNodeMetadata;
|
||||||
|
|
||||||
|
SafeNodeMetadata::SafeNodeMetadata()
|
||||||
|
{
|
||||||
|
NodeMetadata::registerType(typeId(), create);
|
||||||
|
|
||||||
|
m_inventory = new Inventory();
|
||||||
|
m_inventory->addList("0", 8*4);
|
||||||
|
}
|
||||||
|
SafeNodeMetadata::~SafeNodeMetadata()
|
||||||
|
{
|
||||||
|
delete m_inventory;
|
||||||
|
}
|
||||||
|
u16 SafeNodeMetadata::typeId() const
|
||||||
|
{
|
||||||
|
return CONTENT_SAFE;
|
||||||
|
}
|
||||||
|
NodeMetadata* SafeNodeMetadata::create(std::istream &is)
|
||||||
|
{
|
||||||
|
SafeNodeMetadata *d = new SafeNodeMetadata();
|
||||||
|
d->setOwner(deSerializeString(is));
|
||||||
|
d->m_inventory->deSerialize(is);
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
NodeMetadata* SafeNodeMetadata::clone()
|
||||||
|
{
|
||||||
|
SafeNodeMetadata *d = new SafeNodeMetadata();
|
||||||
|
*d->m_inventory = *m_inventory;
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
void SafeNodeMetadata::serializeBody(std::ostream &os)
|
||||||
|
{
|
||||||
|
os<<serializeString(m_owner);
|
||||||
|
m_inventory->serialize(os);
|
||||||
|
}
|
||||||
|
std::wstring SafeNodeMetadata::infoText()
|
||||||
|
{
|
||||||
|
char buff[256];
|
||||||
|
snprintf(buff,256,gettext("Safe owned by '%s'"),m_owner.c_str());
|
||||||
|
return narrow_to_wide(buff);
|
||||||
|
}
|
||||||
|
bool SafeNodeMetadata::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 SafeNodeMetadata::getDrawSpecString()
|
||||||
|
{
|
||||||
|
return
|
||||||
|
"size[8,9]"
|
||||||
|
"list[current_name;0;0,0;8,4;]"
|
||||||
|
"list[current_player;main;0,5;8,4;]";
|
||||||
|
}
|
||||||
|
bool SafeNodeMetadata::import(NodeMetadata *meta)
|
||||||
|
{
|
||||||
|
if (meta->typeId() != CONTENT_CHEST)
|
||||||
|
return false;
|
||||||
|
ChestNodeMetadata *l = (ChestNodeMetadata*)meta;
|
||||||
|
*m_inventory = *l->getInventory();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
CreativeChestNodeMetadata
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Prototype
|
// Prototype
|
||||||
|
|
|
@ -155,6 +155,33 @@ private:
|
||||||
std::string m_owner;
|
std::string m_owner;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class SafeNodeMetadata : public NodeMetadata
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SafeNodeMetadata();
|
||||||
|
~SafeNodeMetadata();
|
||||||
|
|
||||||
|
virtual u16 typeId() const;
|
||||||
|
static NodeMetadata* create(std::istream &is);
|
||||||
|
virtual NodeMetadata* clone();
|
||||||
|
virtual void serializeBody(std::ostream &os);
|
||||||
|
virtual std::wstring infoText();
|
||||||
|
virtual Inventory* getInventory() {return m_inventory;}
|
||||||
|
virtual bool nodeRemovalDisabled();
|
||||||
|
virtual std::string getDrawSpecString();
|
||||||
|
|
||||||
|
virtual bool import(NodeMetadata *meta);
|
||||||
|
|
||||||
|
virtual std::string getOwner(){ return m_owner; }
|
||||||
|
virtual void setOwner(std::string t){ m_owner = t; }
|
||||||
|
virtual std::string getInventoryOwner(){ return m_owner; }
|
||||||
|
virtual void setInventoryOwner(std::string t){ m_owner = t; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
Inventory *m_inventory;
|
||||||
|
std::string m_owner;
|
||||||
|
};
|
||||||
|
|
||||||
class CreativeChestNodeMetadata : public NodeMetadata
|
class CreativeChestNodeMetadata : public NodeMetadata
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1196,7 +1196,7 @@ void MobSAO::explodeSquare(v3s16 p0, v3s16 size)
|
||||||
MapNode n = map->getNodeNoEx(p);
|
MapNode n = map->getNodeNoEx(p);
|
||||||
if (n.getContent() == CONTENT_IGNORE)
|
if (n.getContent() == CONTENT_IGNORE)
|
||||||
continue;
|
continue;
|
||||||
if (content_features(n).pressure_type == CST_SOLID && content_features(n).draw_type == CDT_CUBELIKE)
|
if (content_features(n).destructive_mob_safe)
|
||||||
continue;
|
continue;
|
||||||
map->removeNodeAndUpdate(p, modified_blocks);
|
map->removeNodeAndUpdate(p, modified_blocks);
|
||||||
}
|
}
|
||||||
|
|
|
@ -300,6 +300,8 @@ struct ContentFeatures
|
||||||
// Used for texture atlas creation.
|
// Used for texture atlas creation.
|
||||||
// Currently only enabled for CONTENT_STONE.
|
// Currently only enabled for CONTENT_STONE.
|
||||||
bool often_contains_mineral;
|
bool often_contains_mineral;
|
||||||
|
// Whether destructive mobs can destroy this node
|
||||||
|
bool destructive_mob_safe;
|
||||||
|
|
||||||
// Inventory item string as which the node appears in inventory when dug.
|
// Inventory item string as which the node appears in inventory when dug.
|
||||||
// Mineral overrides this.
|
// Mineral overrides this.
|
||||||
|
@ -412,6 +414,7 @@ struct ContentFeatures
|
||||||
liquid_type = LIQUID_NONE;
|
liquid_type = LIQUID_NONE;
|
||||||
air_equivalent = false;
|
air_equivalent = false;
|
||||||
often_contains_mineral = false;
|
often_contains_mineral = false;
|
||||||
|
destructive_mob_safe = false;
|
||||||
dug_item = "";
|
dug_item = "";
|
||||||
extra_dug_item = "";
|
extra_dug_item = "";
|
||||||
extra_dug_item_rarity = 2;
|
extra_dug_item_rarity = 2;
|
||||||
|
|
Loading…
Reference in New Issue