From 93b59ed08ac0d0406774d351609d9e6841fee4ce Mon Sep 17 00:00:00 2001 From: Brendan Date: Sat, 13 Aug 2011 21:30:25 -0700 Subject: [PATCH] modified: src/content_craft.cpp modified: src/content_inventory.cpp modified: src/content_mapblock.cpp modified: src/content_mapnode.cpp modified: src/content_mapnode.h modified: src/mapgen.cpp modified: src/mineral.cpp modified: src/tile.cpp data/brightglass.png data/glowdust.png data/glowstone.png --- src/content_craft.cpp | 9 +++++ src/content_inventory.cpp | 6 ++- src/content_mapblock.cpp | 77 +++++++++++++++++++++++++++++++++++++++ src/content_mapnode.cpp | 27 +++++++++++++- src/content_mapnode.h | 4 +- src/mapgen.cpp | 31 ++++++++++++++++ src/mineral.cpp | 2 +- src/tile.cpp | 3 ++ 8 files changed, 155 insertions(+), 4 deletions(-) diff --git a/src/content_craft.cpp b/src/content_craft.cpp index 481ea1a63..9d96f853d 100644 --- a/src/content_craft.cpp +++ b/src/content_craft.cpp @@ -458,6 +458,13 @@ void craft_set_creative_inventory(Player *player) assert(r == NULL); } + + { + InventoryItem *item = new CraftItem("glowdust", 1); + void* r = player->inventory.addItem("main", item); + assert(r == NULL); + } + /* Give materials */ @@ -486,6 +493,8 @@ void craft_set_creative_inventory(Player *player) CONTENT_CHEST, CONTENT_FURNACE, CONTENT_SIGN_WALL, + CONTENT_BRIGHTGLASS, + CONTENT_GLOWSTONE, CONTENT_IGNORE }; diff --git a/src/content_inventory.cpp b/src/content_inventory.cpp index de8f8e397..122301097 100644 --- a/src/content_inventory.cpp +++ b/src/content_inventory.cpp @@ -71,6 +71,8 @@ std::string item_craft_get_image_name(const std::string &subname) return "scorched_stuff.png"; else if(subname == "firefly") return "firefly.png"; + else if(subname == "glowdust") + return "glowdust.png"; else return "cloud.png"; // just something } @@ -102,7 +104,7 @@ s16 item_craft_get_drop_count(const std::string &subname) bool item_craft_is_cookable(const std::string &subname) { - if(subname == "lump_of_iron" || subname == "lump_of_clay" || subname == "rat" || subname == "cooked_rat") + if(subname == "lump_of_iron" || subname == "lump_of_clay" || subname == "rat" || subname == "cooked_rat" || subname == "glowdust") return true; return false; @@ -118,6 +120,8 @@ InventoryItem* item_craft_create_cook_result(const std::string &subname) return new CraftItem("cooked_rat", 1); else if(subname == "cooked_rat") return new CraftItem("scorched_stuff", 1); + else if(subname == "glowdust") + return new MaterialItem(CONTENT_BRIGHTGLASS, 1); return NULL; } diff --git a/src/content_mapblock.cpp b/src/content_mapblock.cpp index ed2cd766a..d77ca153e 100644 --- a/src/content_mapblock.cpp +++ b/src/content_mapblock.cpp @@ -171,6 +171,17 @@ void mapblock_mesh_generate_special(MeshMakeData *data, g_texturesource->getTextureId("glass.png")); material_glass.setTexture(0, pa_glass.atlas); + + // BrightGlass material + video::SMaterial material_brightglass; + material_glass.setFlag(video::EMF_LIGHTING, false); + material_glass.setFlag(video::EMF_BILINEAR_FILTER, false); + material_glass.setFlag(video::EMF_FOG_ENABLE, true); + material_glass.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; + AtlasPointer pa_brightglass = g_texturesource->getTexture( + g_texturesource->getTextureId("brightglass.png")); + material_brightglass.setTexture(0, pa_brightglass.atlas); + // Wood material video::SMaterial material_wood; material_wood.setFlag(video::EMF_LIGHTING, false); @@ -778,6 +789,72 @@ void mapblock_mesh_generate_special(MeshMakeData *data, collector.append(material_glass, vertices, 4, indices, 6); } } + + /* + Add brightglass + */ + else if(n.getContent() == CONTENT_BRIGHTGLASS) + { + u8 l = decode_light(undiminish_light(n.getLightBlend(data->m_daynight_ratio))); + video::SColor c = MapBlock_LightColor(255, l); + + for(u32 j=0; j<6; j++) + { + video::S3DVertex vertices[4] = + { + video::S3DVertex(-BS/2,-BS/2,BS/2, 0,0,0, c, + pa_brightglass.x0(), pa_brightglass.y1()), + video::S3DVertex(BS/2,-BS/2,BS/2, 0,0,0, c, + pa_brightglass.x1(), pa_brightglass.y1()), + video::S3DVertex(BS/2,BS/2,BS/2, 0,0,0, c, + pa_brightglass.x1(), pa_brightglass.y0()), + video::S3DVertex(-BS/2,BS/2,BS/2, 0,0,0, c, + pa_brightglass.x0(), pa_brightglass.y0()), + }; + + if(j == 0) + { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateXZBy(0); + } + else if(j == 1) + { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateXZBy(180); + } + else if(j == 2) + { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateXZBy(-90); + } + else if(j == 3) + { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateXZBy(90); + } + else if(j == 4) + { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateYZBy(-90); + } + else if(j == 5) + { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateYZBy(90); + } + + for(u16 i=0; i<4; i++) + { + vertices[i].Pos += intToFloat(p + blockpos_nodes, BS); + } + + u16 indices[] = {0,1,2,2,3,0}; + // Add to mesh collector + collector.append(material_glass, vertices, 4, indices, 6); + } + } + + /* Add fence */ diff --git a/src/content_mapnode.cpp b/src/content_mapnode.cpp index b164033db..d1932a9ff 100644 --- a/src/content_mapnode.cpp +++ b/src/content_mapnode.cpp @@ -31,7 +31,7 @@ void setStoneLikeDiggingProperties(DiggingPropertiesList &list, float toughness) void setDirtLikeDiggingProperties(DiggingPropertiesList &list, float toughness); void setWoodLikeDiggingProperties(DiggingPropertiesList &list, float toughness); -content_t trans_table_19[21][2] = { +content_t trans_table_19[23][2] = { {CONTENT_GRASS, 1}, {CONTENT_TREE, 4}, {CONTENT_LEAVES, 5}, @@ -53,6 +53,8 @@ content_t trans_table_19[21][2] = { {CONTENT_CLAY, 27}, {CONTENT_PAPYRUS, 28}, {CONTENT_BOOKSHELF, 29}, + {CONTENT_BRIGHTGLASS, 30}, + {CONTENT_GLOWSTONE, 31}, }; MapNode mapnode_translate_from_internal(MapNode n_from, u8 version) @@ -488,6 +490,29 @@ void content_mapnode_init() f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1"; setStoneLikeDiggingProperties(f->digging_properties, 5.0); + i = CONTENT_BRIGHTGLASS; + f = &content_features(i); + f->setAllTextures("brightglass.png"); + f->light_propagates = true; + f->sunlight_propagates = true; + f->param_type = CPT_LIGHT; + f->is_ground_content = true; + f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1"; + f->solidness = 0; // drawn separately, makes no faces + f->setInventoryTextureCube("brightglass.png", "brightglass.png", "brightglass.png"); + setWoodLikeDiggingProperties(f->digging_properties, 0.15); + f->light_source = LIGHT_MAX-1; + + i = CONTENT_GLOWSTONE; + f = &content_features(i); + f->setAllTextures("glowstone.png"); +// f->setInventoryTextureCube("glowstone.png", "glowstone.png", "glowstone.png"); + f->param_type = CPT_MINERAL; + f->is_ground_content = true; + f->dug_item = std::string("CraftItem glowdust 1"); + setStoneLikeDiggingProperties(f->digging_properties, 1.0); + f->light_source = LIGHT_MAX-3; + i = CONTENT_NC; f = &content_features(i); f->param_type = CPT_FACEDIR_SIMPLE; diff --git a/src/content_mapnode.h b/src/content_mapnode.h index 9643db746..b5f910e22 100644 --- a/src/content_mapnode.h +++ b/src/content_mapnode.h @@ -24,7 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., void content_mapnode_init(); -extern content_t trans_table_19[21][2]; +extern content_t trans_table_19[23][2]; MapNode mapnode_translate_from_internal(MapNode n_from, u8 version); MapNode mapnode_translate_to_internal(MapNode n_from, u8 version); @@ -75,6 +75,8 @@ MapNode mapnode_translate_to_internal(MapNode n_from, u8 version); #define CONTENT_JUNGLEGRASS 0x816 #define CONTENT_NC 0x817 #define CONTENT_NC_RB 0x818 +#define CONTENT_BRIGHTGLASS 0x819 +#define CONTENT_GLOWSTONE 0x81a #endif diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 9effa8ac6..054dd064a 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -1760,6 +1760,37 @@ void make_block(BlockMakeData *data) } } } + + + /* + Add glowstone (gs) (modified from coal) + */ + //for(s16 i=0; i < MYMAX(0, 50 - abs(node_min.Y+8 - (-30))); i++) + //for(s16 i=0; i<50; i++) + u16 gs_amount = 30; + u16 gs_rareness = 60 / gs_amount; + if(gs_rareness == 0) + gs_rareness = 1; + if(mineralrandom.next()%gs_rareness == 0) + { + u16 a = mineralrandom.next() % 16; + u16 amount = gs_amount * a*a*a / 1000; + for(s16 i=0; i