+ clay and associated items
authorNils Dagsson Moskopp <nils@dieweltistgarnichtso.net>
Wed, 1 Jun 2011 02:57:46 +0000 (04:57 +0200)
committerNils Dagsson Moskopp <nils@dieweltistgarnichtso.net>
Wed, 1 Jun 2011 02:57:46 +0000 (04:57 +0200)
data/clay.png [new file with mode: 0644]
data/clay_brick.png [new file with mode: 0644]
data/lump_of_clay.png [new file with mode: 0644]
src/inventory.cpp
src/map.cpp
src/mapnode.cpp
src/mapnode.h
src/materials.cpp
src/server.cpp
src/tile.cpp

diff --git a/data/clay.png b/data/clay.png
new file mode 100644 (file)
index 0000000..3557429
Binary files /dev/null and b/data/clay.png differ
diff --git a/data/clay_brick.png b/data/clay_brick.png
new file mode 100644 (file)
index 0000000..e36648e
Binary files /dev/null and b/data/clay_brick.png differ
diff --git a/data/lump_of_clay.png b/data/lump_of_clay.png
new file mode 100644 (file)
index 0000000..be0bab9
Binary files /dev/null and b/data/lump_of_clay.png differ
index 47a8d4de90503ed9580bc2724094d08c792d171a..3f83c74192caf9a7c79e281abb21c474162dd53d 100644 (file)
@@ -160,8 +160,12 @@ video::ITexture * CraftItem::getImage()
                name = "lump_of_coal.png";
        else if(m_subname == "lump_of_iron")
                name = "lump_of_iron.png";
+       else if(m_subname == "lump_of_clay")
+               name = "lump_of_clay.png";
        else if(m_subname == "steel_ingot")
                name = "steel_ingot.png";
+       else if(m_subname == "clay_brick")
+               name = "clay_brick.png";
        else if(m_subname == "rat")
                name = "rat.png";
        else
@@ -199,7 +203,7 @@ u16 CraftItem::getDropCount()
 
 bool CraftItem::isCookable()
 {
-       if(m_subname == "lump_of_iron")
+       if(m_subname == "lump_of_iron" || m_subname == "lump_of_clay")
        {
                return true;
        }
@@ -212,6 +216,8 @@ InventoryItem *CraftItem::createCookResult()
        {
                return new CraftItem("steel_ingot", 1);
        }
+       else if(m_subname == "lump_of_clay")
+               return new CraftItem("clay_brick", 1);
        return NULL;
 }
 
index c48599d475ba5e419e22d2d027db94905dabea3c..bf9f38c877598d4a39af4975d2cd33fc937b89a3 100644 (file)
@@ -3141,6 +3141,13 @@ void makeChunk(ChunkMakeData *data)
                if(have_sand == false)
                        continue;
 
+               // Determine whether to have clay in the sand here
+               double claynoise = noise2d_perlin(
+                               0.5+(float)p2d.X/500, 0.5+(float)p2d.Y/500,
+                               data->seed+4321, 8, 0.95);
+
+               bool have_clay = have_sand && (claynoise > 0.95);
+
                // Find ground level
                s16 surface_y = find_ground_level_clever(data->vmanip, p2d);
                
@@ -3157,7 +3164,10 @@ void makeChunk(ChunkMakeData *data)
                                MapNode *n = &data->vmanip.m_data[i];
                                if(n->d == CONTENT_MUD || n->d == CONTENT_GRASS)
                                {
-                                       n->d = CONTENT_SAND;
+                                       if(have_clay && (surface_y == WATER_LEVEL))
+                                               n->d = CONTENT_CLAY;
+                                       else
+                                               n->d = CONTENT_SAND;
                                }
                                else
                                {
index 72cd762c67edb228ab6b6afebf99718f18781b5a..cef9bbf03674481dbb64d60e770cff7334187c24 100644 (file)
@@ -189,13 +189,21 @@ void init_mapnode()
        f->is_ground_content = true;
        f->dug_item = std::string("MaterialItem ")+itos(CONTENT_SAND)+" 1";
        
+       i = CONTENT_CLAY;
+       f = &g_content_features[i];
+       f->setAllTextures("clay.png");
+       f->setInventoryTextureCube("clay.png", "clay.png", "clay.png");
+       f->param_type = CPT_MINERAL;
+       f->is_ground_content = true;
+       f->dug_item = std::string("CraftItem lump_of_clay 4");
+       
        i = CONTENT_BRICK;
        f = &g_content_features[i];
        f->setAllTextures("brick.png");
        f->setInventoryTextureCube("brick.png", "brick.png", "brick.png");
        f->param_type = CPT_MINERAL;
        f->is_ground_content = true;
-       f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
+       f->dug_item = std::string("CraftItem clay_brick 4");
        
        i = CONTENT_TREE;
        f = &g_content_features[i];
index 5022031de4fdfd941911b3316f16c4a75805d58a..e8cc0ab513fcdb0d47699f76b6b582e6eb558b2d 100644 (file)
@@ -104,6 +104,7 @@ void init_content_inventory_texture_paths();
 #define CONTENT_SANDSTONE 22
 #define CONTENT_CACTUS 23
 #define CONTENT_BRICK 24
+#define CONTENT_CLAY 25
 
 /*
        Content feature list
index 0c744af9f0c0c33e32f629e45ddbf1f6ad04d162..8c23056f241a2cb6d518defbd981659e719ef9f0 100644 (file)
@@ -71,6 +71,7 @@ void initializeMaterialProperties()
        setDirtLikeDiggingProperties(CONTENT_GRASS, 1.0);
        setDirtLikeDiggingProperties(CONTENT_GRASS_FOOTSTEPS, 1.0);
        setDirtLikeDiggingProperties(CONTENT_SAND, 1.0);
+       setDirtLikeDiggingProperties(CONTENT_CLAY, 1.0);
        
        setWoodLikeDiggingProperties(CONTENT_TREE, 1.0);
        setWoodLikeDiggingProperties(CONTENT_LEAVES, 0.15);
index dfc05f7d3b4275d6b280a71df6c6e7fe4effea52..17850c5fad65cad1b14bc9ca2d2a9bd335674134 100644 (file)
@@ -3987,6 +3987,36 @@ void Server::UpdateCrafting(u16 peer_id)
                                        found = true;
                                }
                        }
+
+                       // Clay
+                       if(!found)
+                       {
+                               ItemSpec specs[9];
+                               specs[3] = ItemSpec(ITEM_CRAFT, "lump_of_clay");
+                               specs[4] = ItemSpec(ITEM_CRAFT, "lump_of_clay");
+                               specs[6] = ItemSpec(ITEM_CRAFT, "lump_of_clay");
+                               specs[7] = ItemSpec(ITEM_CRAFT, "lump_of_clay");
+                               if(checkItemCombination(items, specs))
+                               {
+                                       rlist->addItem(new MaterialItem(CONTENT_CLAY, 1));
+                                       found = true;
+                               }
+                       }
+
+                       // Brick
+                       if(!found)
+                       {
+                               ItemSpec specs[9];
+                               specs[3] = ItemSpec(ITEM_CRAFT, "clay_brick");
+                               specs[4] = ItemSpec(ITEM_CRAFT, "clay_brick");
+                               specs[6] = ItemSpec(ITEM_CRAFT, "clay_brick");
+                               specs[7] = ItemSpec(ITEM_CRAFT, "clay_brick");
+                               if(checkItemCombination(items, specs))
+                               {
+                                       rlist->addItem(new MaterialItem(CONTENT_BRICK, 1));
+                                       found = true;
+                               }
+                       }
                }
        
        } // if creative_mode == false
@@ -4076,6 +4106,7 @@ void setCreativeInventory(Player *player)
                CONTENT_STONE,
                CONTENT_SAND,
                CONTENT_SANDSTONE,
+               CONTENT_CLAY,
                CONTENT_BRICK,
                CONTENT_TREE,
                CONTENT_LEAVES,
index 361de704cce344eca36e599bdb554b92ca9d541a..71e0c9638a15b9778206a587601cfeed0de6ab21 100644 (file)
@@ -507,6 +507,7 @@ void TextureSource::buildMainAtlas()
        sourcelist.push_back("mud.png");
        sourcelist.push_back("sand.png");
        sourcelist.push_back("sandstone.png");
+       sourcelist.push_back("clay.png");
        sourcelist.push_back("brick.png");
        sourcelist.push_back("grass.png");
        sourcelist.push_back("grass_footsteps.png");