campfire pt2

This commit is contained in:
darkrose 2017-02-08 04:29:13 +10:00
parent bdb7493ccc
commit b3416add93
4 changed files with 47 additions and 18 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 414 B

View File

@ -6369,13 +6369,15 @@ void meshgen_campfirelike(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNode
{
TileSpec stone_tiles[6];
TileSpec wood_tiles[6];
TileSpec ember_tile;
TileSpec fire_tile;
ContentFeatures *f;
std::vector<NodeBox> boxes;
f = &content_features(n.getContent());
fire_tile = f->tiles[2];
ember_tile = f->tiles[2];
fire_tile = f->tiles[3];
for (u16 i=0; i<6; i++) {
stone_tiles[i] = f->tiles[0];
@ -6430,6 +6432,39 @@ void meshgen_campfirelike(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNode
v3f pos = intToFloat(p,BS);
video::S3DVertex end_vertices[6] = {
video::S3DVertex(data->m_BS*0.25 ,data->m_BS*-0.4375,0 , 0,0,0, video::SColor(255,255,255,255), 0.5, 0.),
video::S3DVertex(data->m_BS*0.25 ,data->m_BS*-0.4375,data->m_BS*0.0625, 0,0,0, video::SColor(255,255,255,255), 0.625, 0.),
video::S3DVertex(data->m_BS*0.175,data->m_BS*-0.4375,data->m_BS*0.175, 0,0,0, video::SColor(255,255,255,255), 0.875, 0.125),
video::S3DVertex(data->m_BS*0.0625,data->m_BS*-0.4375,data->m_BS*0.25 , 0,0,0, video::SColor(255,255,255,255), 1.0, 0.375),
video::S3DVertex(0 ,data->m_BS*-0.4375,data->m_BS*0.25 , 0,0,0, video::SColor(255,255,255,255), 1.0, 0.5),
video::S3DVertex(0 ,data->m_BS*-0.4375,0 , 0,0,0, video::SColor(255,255,255,255), 0.5, 0.5)
};
u16 end_indices[12] = {5,1,0,5,2,1,5,3,2,5,4,3};
u16 rots[4] = {0,90,180,270};
for (u16 j=0; j<4; j++) {
video::S3DVertex v[6];
for (u16 i=0; i<6; i++) {
v[i] = end_vertices[i];
v[i].Pos.rotateXZBy(rots[j]);
v[i].TCoords *= ember_tile.texture.size;
v[i].TCoords += ember_tile.texture.pos;
}
std::vector<u32> colours;
if (selected.is_coloured) {
meshgen_selected_lights(colours,255,6);
}else{
meshgen_lights(data,n,p,colours,255,v3s16(0,1,0),6,v);
}
for (int k=0; k<6; k++) {
v[k].Pos += pos;
}
data->append(ember_tile, v, 6, end_indices, 12, colours);
}
for (u32 j=0; j<2; j++) {
video::S3DVertex vertices[4] = {
video::S3DVertex(-0.5*BS,-0.5*BS,0., 0,0,0, video::SColor(255,255,255,255), 0.,1.),

View File

@ -1479,16 +1479,16 @@ void content_mapnode_special(bool repeat)
f->sunlight_propagates = true;
f->walkable = false;
f->fuel_time = 1.0;
f->light_source = LIGHT_MAX-1;
f->light_source = LIGHT_MAX-3;
f->damage_per_second = 40;
f->setAllTextures("campfire_stones.png");
f->setTexture(0, "campfire_stones.png");
f->setTexture(1, "campfire_logs.png");
f->setTexture(2, "campfire_embers.png");
#ifndef SERVER
f->animation_length = 1.0;
f->setTextureFlags(2, MATERIAL_FLAG_ANIMATION_VERTICAL_FRAMES);
f->setTextureFlags(3, MATERIAL_FLAG_ANIMATION_VERTICAL_FRAMES);
#endif
f->setTexture(2, "campfire_flame.png");
f->setTexture(3, "campfire_flame.png");
content_nodebox_roofcollide(f);
f->setInventoryTexture("campfire_inv.png");
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
@ -1499,9 +1499,9 @@ void content_mapnode_special(bool repeat)
f->pressure_type = CST_CRUSHED;
{
u16 r[9] = {
CONTENT_ROCK, CONTENT_WOOD, CONTENT_ROCK,
CONTENT_WOOD, CONTENT_IGNORE, CONTENT_WOOD,
CONTENT_ROCK, CONTENT_WOOD, CONTENT_ROCK
CONTENT_ROCK, CONTENT_CRAFTITEM_STICK, CONTENT_ROCK,
CONTENT_CRAFTITEM_STICK, CONTENT_IGNORE, CONTENT_CRAFTITEM_STICK,
CONTENT_ROCK, CONTENT_CRAFTITEM_STICK, CONTENT_ROCK
};
crafting::setRecipe(r,CONTENT_CAMPFIRE,1);
}

View File

@ -1398,7 +1398,7 @@ CampFireNodeMetadata::CampFireNodeMetadata()
m_inventory = new Inventory();
m_inventory->addList("fuel", 1);
m_inventory->addList("src", 1);
m_inventory->addList("dst", 4);
m_inventory->addList("dst", 1);
m_step_accumulator = 0;
m_fuel_totaltime = 0;
@ -1605,15 +1605,9 @@ bool CampFireNodeMetadata::step(float dtime, v3s16 pos, ServerEnvironment *env)
std::string CampFireNodeMetadata::getDrawSpecString(Player *player)
{
std::string spec("size[8,9]");
spec += "list[current_name;fuel;2,3;1,1;]";
spec += "ring[2,3;1;#FF0000;";
float v = 0;
if (m_fuel_totaltime > 0.0)
v = 100.0-((100.0/m_fuel_totaltime)*m_fuel_time);
spec += itos((int)v);
spec += "]";
spec += "list[current_name;src;2,1;1,1;]";
spec += "list[current_name;dst;5,1;2,2;]";
spec += "list[current_name;fuel;2,2;1,1;]";
spec += "list[current_name;src;5,1;1,1;]";
spec += "list[current_name;dst;5,3;1,1;]";
spec += "list[current_player;main;0,5;8,4;]";
return spec;
}