f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
f->cookresult_item = "CraftItem lump_of_coal 1";
+ f->furnace_burntime = 30;
setWoodLikeMaterialProperties(f->material, 1.0);
i = CONTENT_JUNGLETREE;
f->setTexture(1, "jungletree_top.png");
f->param_type = CPT_MINERAL;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
+ f->furnace_burntime = 30;
setWoodLikeMaterialProperties(f->material, 1.0);
i = CONTENT_JUNGLEGRASS;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
f->walkable = false;
setLeavesLikeMaterialProperties(f->material, 1.0);
+ f->furnace_burntime = 2;
i = CONTENT_LEAVES;
f = nodemgr->getModifiable(i);
f->extra_dug_item_rarity = 20;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
setLeavesLikeMaterialProperties(f->material, 1.0);
+ f->furnace_burntime = 1.0;
i = CONTENT_CACTUS;
f = nodemgr->getModifiable(i);
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
setWoodLikeMaterialProperties(f->material, 0.75);
+ f->furnace_burntime = 15;
i = CONTENT_PAPYRUS;
f = nodemgr->getModifiable(i);
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
f->walkable = false;
setLeavesLikeMaterialProperties(f->material, 0.5);
+ f->furnace_burntime = 1;
i = CONTENT_BOOKSHELF;
f = nodemgr->getModifiable(i);
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
setWoodLikeMaterialProperties(f->material, 0.75);
+ f->furnace_burntime = 30;
i = CONTENT_GLASS;
f = nodemgr->getModifiable(i);
f->selection_box.type = NODEBOX_FIXED;
f->selection_box.fixed = core::aabbox3d<f32>(
-BS/7, -BS/2, -BS/7, BS/7, BS/2, BS/7);
+ f->furnace_burntime = 30/2;
setWoodLikeMaterialProperties(f->material, 0.75);
i = CONTENT_RAIL;
f->air_equivalent = true; // grass grows underneath
f->walkable = false;
f->selection_box.type = NODEBOX_FIXED;
+ f->furnace_burntime = 5;
setDirtLikeMaterialProperties(f->material, 0.75);
i = CONTENT_LADDER;
f->walkable = false;
f->climbable = true;
f->selection_box.type = NODEBOX_WALLMOUNTED;
+ f->furnace_burntime = 5;
setWoodLikeMaterialProperties(f->material, 0.5);
// Deprecated
f->setInventoryTextureCube("wood.png", "wood.png", "wood.png");
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
+ f->furnace_burntime = 30/4;
setWoodLikeMaterialProperties(f->material, 0.75);
i = CONTENT_MESE;
f->setInventoryTextureCube("mese.png", "mese.png", "mese.png");
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
+ f->furnace_burntime = 30;
setStoneLikeMaterialProperties(f->material, 0.5);
i = CONTENT_CLOUD;
f->post_effect_color = video::SColor(192, 255, 64, 0);
// New-style lava source material (mostly unused)
f->setSpecialMaterial(0, MaterialSpec("lava.png", false));
+ f->furnace_burntime = 60;
i = CONTENT_TORCH;
f = nodemgr->getModifiable(i);
f->selection_box.wall_side = core::aabbox3d<f32>(
-BS/2, -BS/3.333, -BS/10, -BS/2+BS/3.333, BS/3.333, BS/10);
setConstantMaterialProperties(f->material, 0.0);
+ f->furnace_burntime = 4;
i = CONTENT_SIGN_WALL;
f = nodemgr->getModifiable(i);
f->initial_metadata = new SignNodeMetadata(NULL, "Some sign");
setConstantMaterialProperties(f->material, 0.5);
f->selection_box.type = NODEBOX_WALLMOUNTED;
+ f->furnace_burntime = 10;
i = CONTENT_CHEST;
f = nodemgr->getModifiable(i);
if(f->initial_metadata == NULL)
f->initial_metadata = new ChestNodeMetadata(NULL);
setWoodLikeMaterialProperties(f->material, 1.0);
+ f->furnace_burntime = 30;
i = CONTENT_LOCKABLE_CHEST;
f = nodemgr->getModifiable(i);
if(f->initial_metadata == NULL)
f->initial_metadata = new LockingChestNodeMetadata(NULL);
setWoodLikeMaterialProperties(f->material, 1.0);
+ f->furnace_burntime = 30;
i = CONTENT_FURNACE;
f = nodemgr->getModifiable(i);
f->setInventoryTexture("nc_front.png");
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
setStoneLikeMaterialProperties(f->material, 3.0);
+ f->furnace_burntime = 1;
i = CONTENT_NC_RB;
f = nodemgr->getModifiable(i);
f->setInventoryTexture("nc_rb.png");
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
setStoneLikeMaterialProperties(f->material, 3.0);
+ f->furnace_burntime = 1;
i = CONTENT_SAPLING;
f = nodemgr->getModifiable(i);
f->air_equivalent = false;
f->walkable = false;
setConstantMaterialProperties(f->material, 0.0);
+ f->furnace_burntime = 10;
i = CONTENT_APPLE;
f = nodemgr->getModifiable(i);
f->air_equivalent = true;
f->dug_item = std::string("CraftItem apple 1");
setConstantMaterialProperties(f->material, 0.0);
+ f->furnace_burntime = 3;
}
// accomodate any result item
if(room_available)
{
- m_src_totaltime = 3;
+ m_src_totaltime = src_item->getCookTime();
}
else
{
assert(fuel_list);
const InventoryItem *fuel_item = fuel_list->getItem(0);
- if(ItemSpec(ITEM_MATERIAL, CONTENT_TREE).checkItem(fuel_item))
- {
- m_fuel_totaltime = 30;
- m_fuel_time = 0;
- fuel_list->decrementMaterials(1);
- changed = true;
- }
- else if(ItemSpec(ITEM_MATERIAL, CONTENT_JUNGLETREE).checkItem(fuel_item))
- {
- m_fuel_totaltime = 30;
- m_fuel_time = 0;
- fuel_list->decrementMaterials(1);
- changed = true;
- }
- else if(ItemSpec(ITEM_MATERIAL, CONTENT_FENCE).checkItem(fuel_item))
- {
- m_fuel_totaltime = 30/2;
- m_fuel_time = 0;
- fuel_list->decrementMaterials(1);
- changed = true;
- }
- else if(ItemSpec(ITEM_MATERIAL, CONTENT_WOOD).checkItem(fuel_item))
- {
- m_fuel_totaltime = 30/4;
- m_fuel_time = 0;
- fuel_list->decrementMaterials(1);
- changed = true;
- }
- else if(ItemSpec(ITEM_MATERIAL, CONTENT_BOOKSHELF).checkItem(fuel_item))
- {
- m_fuel_totaltime = 30/4;
- m_fuel_time = 0;
- fuel_list->decrementMaterials(1);
- changed = true;
- }
- else if(ItemSpec(ITEM_MATERIAL, CONTENT_LEAVES).checkItem(fuel_item))
- {
- m_fuel_totaltime = 30/16;
- m_fuel_time = 0;
- fuel_list->decrementMaterials(1);
- changed = true;
- }
- else if(ItemSpec(ITEM_MATERIAL, CONTENT_PAPYRUS).checkItem(fuel_item))
- {
- m_fuel_totaltime = 30/32;
- m_fuel_time = 0;
- fuel_list->decrementMaterials(1);
- changed = true;
- }
- else if(ItemSpec(ITEM_MATERIAL, CONTENT_JUNGLEGRASS).checkItem(fuel_item))
- {
- m_fuel_totaltime = 30/32;
- m_fuel_time = 0;
- fuel_list->decrementMaterials(1);
- changed = true;
- }
- else if(ItemSpec(ITEM_MATERIAL, CONTENT_CACTUS).checkItem(fuel_item))
- {
- m_fuel_totaltime = 30/4;
+ if(fuel_item && fuel_item->getBurnTime() >= 0){
+ m_fuel_totaltime = fuel_item->getBurnTime();
m_fuel_time = 0;
fuel_list->decrementMaterials(1);
changed = true;
- }
- else if(ItemSpec(ITEM_CRAFT, "Stick").checkItem(fuel_item))
- {
- m_fuel_totaltime = 30/4/4;
- m_fuel_time = 0;
- fuel_list->decrementMaterials(1);
- changed = true;
- }
- else if(ItemSpec(ITEM_CRAFT, "lump_of_coal").checkItem(fuel_item))
- {
- m_fuel_totaltime = 40;
- m_fuel_time = 0;
- fuel_list->decrementMaterials(1);
- changed = true;
- }
- else
- {
+ } else {
//infostream<<"No fuel found"<<std::endl;
// No fuel, stop loop.
m_step_accumulator = 0;
return InventoryItem::deSerialize(is, m_gamedef);
}
+float MaterialItem::getCookTime() const
+{
+ INodeDefManager *ndef = m_gamedef->ndef();
+ const ContentFeatures &f = ndef->get(m_content);
+ return f.furnace_cooktime;
+}
+
+float MaterialItem::getBurnTime() const
+{
+ INodeDefManager *ndef = m_gamedef->ndef();
+ const ContentFeatures &f = ndef->get(m_content);
+ return f.furnace_burntime;
+}
+
/*
ToolItem
*/
return item_craft_create_cook_result(m_subname, m_gamedef);
}
+float CraftItem::getCookTime() const
+{
+ return 3.0;
+}
+
+float CraftItem::getBurnTime() const
+{
+ if(m_subname == "lump_of_coal")
+ return 40;
+ return -1;
+}
+
bool CraftItem::use(ServerEnvironment *env, ServerActiveObject *user)
{
if(!item_craft_is_eatable(m_subname, m_gamedef))
// Whether it can be cooked
virtual bool isCookable() const {return false;}
- // Time of cooking
- virtual float getCookTime(){return 3.0;}
// Result of cooking (can randomize)
virtual InventoryItem *createCookResult() const {return NULL;}
+ // Time of cooking
+ virtual float getCookTime() const {return 3.0;}
+ // Whether it can be burned (<0 = cannot be burned)
+ virtual float getBurnTime() const {return -1;}
// Eat, press, activate, whatever.
// Called when item is right-clicked when lying on ground.
*/
bool isCookable() const;
InventoryItem *createCookResult() const;
+ float getCookTime() const;
+ float getBurnTime() const;
/*
Special methods
*/
bool isCookable() const;
InventoryItem *createCookResult() const;
+ float getCookTime() const;
+ float getBurnTime() const;
bool use(ServerEnvironment *env, ServerActiveObject *user);
writeF1000(os, crackiness);
writeF1000(os, crumbliness);
writeF1000(os, cuttability);
+ writeF1000(os, flammability);
}
void MaterialProperties::deSerialize(std::istream &is)
crackiness = readF1000(is);
crumbliness = readF1000(is);
cuttability = readF1000(is);
+ flammability = readF1000(is);
}
DiggingProperties getDiggingProperties(u16 content, ToolDiggingProperties *tp,
// Sword is best for cuttable light stuff.
float cuttability;
// If high, ignites easily
- //float flammability;
+ float flammability;
MaterialProperties():
diggability(DIGGABLE_NOT),
constant_time(0.5),
- weight(1),
- crackiness(1),
- crumbliness(1),
- cuttability(1)
+ weight(0),
+ crackiness(0),
+ crumbliness(0),
+ cuttability(0),
+ flammability(0)
{}
void serialize(std::ostream &os);
damage_per_second = 0;
selection_box = NodeBox();
material = MaterialProperties();
- cookresult_item = "";
+ cookresult_item = ""; // Cannot be cooked
+ furnace_cooktime = 3.0;
+ furnace_burntime = -1.0; // Cannot be burned
}
void ContentFeatures::serialize(std::ostream &os)
selection_box.serialize(os);
material.serialize(os);
os<<serializeString(cookresult_item);
+ writeF1000(os, furnace_cooktime);
+ writeF1000(os, furnace_burntime);
}
void ContentFeatures::deSerialize(std::istream &is, IGameDef *gamedef)
selection_box.deSerialize(is);
material.deSerialize(is);
cookresult_item = deSerializeString(is);
+ furnace_cooktime = readF1000(is);
+ furnace_burntime = readF1000(is);
}
void ContentFeatures::setTexture(u16 i, std::string name)
NodeBox selection_box;
MaterialProperties material;
std::string cookresult_item;
+ float furnace_cooktime;
+ float furnace_burntime;
/*
Methods
/*
TODO:
- Node definition
-- Random node triggers
+- Random node triggers (like grass growth)
+- Deterministic node triggers (like falling sand)
- Object visual client-side stuff
- Blink effect
- Spritesheets and animation
blockdef.on_inventory_modified
meta.set("owner", playername)
meta.get("owner")
-- Item definition
+- Item definition (actually, only CraftItem)
*/
static void stackDump(lua_State *L, std::ostream &o)