#include "irrlichttypes.h"
#include "mapnode.h"
-#include "content_nodemeta.h"
#include "nodedef.h"
#include "utility.h"
#include "nameidmapping.h"
f.wall_mounted = true;
f.air_equivalent = true;
f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
- if(f.initial_metadata == NULL)
- f.initial_metadata = new SignNodeMetadata(NULL, "Some sign");
+ f.metadata_name = "sign";
setConstantMaterialProperties(f.material, 0.5);
f.selection_box.type = NODEBOX_WALLMOUNTED;
f.furnace_burntime = 10;
f.setInventoryTexture("chest_top.png");
//f.setInventoryTextureCube("chest_top.png", "chest_side.png", "chest_side.png");
f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
- if(f.initial_metadata == NULL)
- f.initial_metadata = new ChestNodeMetadata(NULL);
+ f.metadata_name = "chest";
setWoodLikeMaterialProperties(f.material, 1.0);
f.furnace_burntime = 30;
nodemgr->set(i, f);
f.setInventoryTexture("chest_lock.png");
//f.setInventoryTextureCube("chest_top.png", "chest_side.png", "chest_side.png");
f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
- if(f.initial_metadata == NULL)
- f.initial_metadata = new LockingChestNodeMetadata(NULL);
+ f.metadata_name = "locked_chest";
setWoodLikeMaterialProperties(f.material, 1.0);
f.furnace_burntime = 30;
nodemgr->set(i, f);
f.setInventoryTexture("furnace_front.png");
//f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
f.dug_item = std::string("MaterialItem2 ")+itos(CONTENT_COBBLE)+" 6";
- if(f.initial_metadata == NULL)
- f.initial_metadata = new FurnaceNodeMetadata(NULL);
+ f.metadata_name = "furnace";
setStoneLikeMaterialProperties(f.material, 3.0);
nodemgr->set(i, f);
/*
Add intial metadata
*/
-
- NodeMetadata *meta_proto = nodemgr->get(n).initial_metadata;
- if(meta_proto)
- {
- NodeMetadata *meta = meta_proto->clone(m_gamedef);
+
+ std::string metadata_name = nodemgr->get(n).metadata_name;
+ if(metadata_name != ""){
+ NodeMetadata *meta = NodeMetadata::create(metadata_name, m_gamedef);
meta->setOwner(player_name);
setNodeMetadata(p, meta);
}
ContentFeatures::~ContentFeatures()
{
- delete initial_metadata;
#ifndef SERVER
for(u16 j=0; j<CF_SPECIAL_COUNT; j++){
delete special_materials[j];
dug_item = "";
extra_dug_item = "";
extra_dug_item_rarity = 2;
- initial_metadata = NULL;
+ metadata_name = "";
liquid_type = LIQUID_NONE;
liquid_alternative_flowing = CONTENT_IGNORE;
liquid_alternative_source = CONTENT_IGNORE;
os<<serializeString(dug_item);
os<<serializeString(extra_dug_item);
writeS32(os, extra_dug_item_rarity);
- if(initial_metadata){
- writeU8(os, true);
- initial_metadata->serialize(os);
- } else {
- writeU8(os, false);
- }
+ os<<serializeString(metadata_name);
writeU8(os, liquid_type);
writeU16(os, liquid_alternative_flowing);
writeU16(os, liquid_alternative_source);
dug_item = deSerializeString(is);
extra_dug_item = deSerializeString(is);
extra_dug_item_rarity = readS32(is);
- if(readU8(is)){
- initial_metadata = NodeMetadata::deSerialize(is, gamedef);
- } else {
- initial_metadata = NULL;
- }
+ metadata_name = deSerializeString(is);
liquid_type = (enum LiquidType)readU8(is);
liquid_alternative_flowing = readU16(is);
liquid_alternative_source = readU16(is);
std::string extra_dug_item;
// Usual get interval for extra dug item
s32 extra_dug_item_rarity;
- // Initial metadata is cloned from this
- NodeMetadata *initial_metadata;
+ // Metadata name of node (eg. "furnace")
+ std::string metadata_name;
// Whether the node is non-liquid, source liquid or flowing liquid
enum LiquidType liquid_type;
// If the content is liquid, this is the flowing version of the liquid.
getstringfield(L, table0, "extra_dug_item", f.extra_dug_item);
// Usual get interval for extra dug item
getintfield(L, table0, "extra_dug_item_rarity", f.extra_dug_item_rarity);
- // Initial metadata is cloned from this
- // TODO: As metadata name
- // NodeMetadata *initial_metadata;
+ // Metadata name of node (eg. "furnace")
+ getstringfield(L, table0, "metadata_name", f.metadata_name);
// Whether the node is non-liquid, source liquid or flowing liquid
// TODO: Enum read
// enum LiquidType liquid_type;
if(meta)
meta->inventoryModified();
- MapBlock *block = m_env.getMap().getBlockNoCreateNoEx(blockpos);
+ MapBlock *block = m_env->getMap().getBlockNoCreateNoEx(blockpos);
if(block)
block->raiseModified(MOD_STATE_WRITE_NEEDED);