From ee7c6d72abd50b84f27f77e99f7af48d9b15f4ae Mon Sep 17 00:00:00 2001 From: darkrose Date: Sun, 13 Oct 2013 18:51:55 +1000 Subject: [PATCH] buckets --- data/textures/tool_steelbucket.png | Bin 0 -> 329 bytes data/textures/tool_steelbucket_lava.png | Bin 0 -> 363 bytes data/textures/tool_steelbucket_water.png | Bin 0 -> 369 bytes data/textures/tool_woodbucket.png | Bin 854 -> 461 bytes data/textures/tool_woodbucket_water.png | Bin 0 -> 445 bytes src/collision.cpp | 1 + src/content_craft.cpp | 13 ++- src/content_mapnode.cpp | 17 ++- src/defaultsettings.cpp | 1 + src/game.cpp | 19 ++- src/inventory.h | 49 +++++--- src/server.cpp | 143 ++++++++++++++++++++++- src/tile.cpp | 22 ++++ 13 files changed, 243 insertions(+), 22 deletions(-) create mode 100644 data/textures/tool_steelbucket.png create mode 100644 data/textures/tool_steelbucket_lava.png create mode 100644 data/textures/tool_steelbucket_water.png create mode 100644 data/textures/tool_woodbucket_water.png diff --git a/data/textures/tool_steelbucket.png b/data/textures/tool_steelbucket.png new file mode 100644 index 0000000000000000000000000000000000000000..f165fd209e9dc30282c963ee27dcd34eeb84b115 GIT binary patch literal 329 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgg)Zdra)<*XK-XFws@%#er@=ltB< z)VvZPmw~~#C^fMpHASI3vm`^o-P1Q9MK6^dD89hc#WBR<^x2@3yhjvxwuHYtv`E5h zA=7sU_7DfnDTkPM_B~-WI_NU-+eT~s6r0B%89!t{P^;Vb^g-W=Gnd`HPCj`!_sp3K zQO4fZ&$kH7Vv@c0+jYT|O*c`o^Za=JJUMpDMelNy3 P732v|S3j3^P6QL70(Y)*K0-AbW|YuPgg)Zdray@#n4E9dnI@*Z;FalP;AGr??^ zsSzu$bV2fkSxtf(XJsTCRfAlvZ)(!?Sma&Q=pmBua>?YU|Nrj)`tbVGuwUCmA75)I z(_FsdvT}EE@rJAND)*PGxaKKHHaX8^eqOtJ)yh?0vv>?v$MYKqZWL%*8dh$(Y*}W9 zAyWZ!-}Q!$lk$+n(bncyXCpI3FShQL70(Y)*K0-AbW|YuPgg)ZdrZ{;h&$K*nvW_nIRD+&iT2y zsd*(pE(3#eQEFmIYKlU6W=V#EyQgnJie4&6;R#O{#}JFtXD8Y69Wvl)jn~Q(Y_&{( zajVsMgXVIz}ew22cvdq8QG3!Ig zx5?eVw`#vS60;_Hf7hR?GU2r=5~ueV6>h9iQ&Lm%OXF!MeI2=d9^;0s(|Qf(sNbGy zFt@nFaM@ky>9^&s-AeNG?Mvy2w0ZHnE~Z_;!A1DbvL{l>EmMRT7EC$x@xuzU(nNy* z9@Qr-n!i^aT(sG1rC|MOh2Hy?@7<@x))=2+su!1Ud+XlZe8h1c$g`fVelF{r5}E)& CZi&JG literal 0 HcmV?d00001 diff --git a/data/textures/tool_woodbucket.png b/data/textures/tool_woodbucket.png index f05949d71bdde09f5a66b51efeeae872bdeb9b55..414ab27a407592989cad67f17d3a30ec1ea55373 100644 GIT binary patch delta 411 zcmV;M0c8Hx2F(MIB#}cKf87cV2p9^sb4Ahs0013nR9JLFZ*6U5Zgc_CX>@2HM@dakWG-a~0003)NkllOjQ^sLOw5hxSmnq%{P-%g)hVM^3cDE3NCBba;RPN-e*j+wou9a0SmXKS32g<&Sl-`ipe=DI@f^$6-gy(}w8p$FU7)nW zXp8T=q;*9SIy{g;y8f>{umBs&(*$vZ9|mOf2lZ4@y?>;5dfmo39Sm)`Tp{rU(s8LP zi|@JQa!F4`YNS}28$oN0QJSbP;_&RYXM>-rEckc&1hU&_5du91mFxfj002ovPDHLk FV1oFtxq$!x delta 804 zcmV+<1Ka$~1J(wRBpd;AQb$4nuFf3k00006VoOIv0RI600RN!9r<0K(9)H^j8xb)$ z&7OkD0008kNkl6xkOs;=@NUVTo#5Adkhp4-Zc zRiyJh+GIq7cbTeE#HjEYrhit*F|yGZ))5A_z!Zr=j>vRt#FMj{Qh`*0Upoo~*(AJE z2$9K9Krm0iyz2%73HZd-GX-x^v3d zW^@XOcT@xhMF6cRhL*`zLo>E)ZqJxq+Gb-m<>CDUuJ65w0KEIw^W6UW2Pz%8^2m_? z>zl8>!wS6g#!cGA3TY-&++xA&uUw@~!ngZ(h!N@n`TzrUPBnM{z_c;k+`9o%0nm(w z$fcdD9R78mEES_-z<=JWC6HM!&&esF>8Qj&7RIB7V&gI*3g1QCVud_$V~a z^(0jiGc?mjiLoaHPw;_3DQE%TE+}ftpe)(B_5%9KoGpN{YkBMcd2&F#APvr*nb0=)MqA*pcEKm*laAJ zk1X4cbx1VRDb3K*{rOuZckgEZ;rlNWLO|z8AqFW7gUJ-5ffz`AVzF?{PtVCIGpa4S zPhIDu{a-tIM=8^S9p8G|oz7cUD^D#MTNR)TF7*F8X-1PFAtqAHxTQlWrR2+;d!(|tr%KM*9B&?O_bKys^t4mzpw!Mzd`1Q2S}mFg`w*_k^*sg z#>vqECr8Jm{XE z)7O>#E*CF{q$V#v>qDTBY-UJAiF1B#Zfaf$kjuc}T$GwvlA5AWo>`Ki;O^-gkfN8$ z&cMKE?CIhdVsZNHBz+I&M2YtK@Bh6qdoCgDk}H-PIr+9jO4{Q3PfZB|GBaES-o6&w z7{!yFZqU)8q0>=lrhDw{?z`pd9VNF{&d&aI?EB-Nwdc9*f4mN4{$`}Ln5}VY?Dppm zw}kaQ4Y8l2zr%Uz{QOh4YowOQii*7Tc$Jb@FYHGK5eq` zjL5$KsjtdS>UO(+-EnVm{@443_0{eRn4NSj`g)(UPf^=enJG16+vjY4mW1@=&LQj$gkgd^w@b>H6&A%S=pX=hB;light_propagates = true; f->walkable = false; f->pointable = false; - f->diggable = false; + //f->diggable = false; f->buildable_to = true; f->liquid_type = LIQUID_SOURCE; f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1"; @@ -1106,6 +1107,7 @@ void content_mapnode_init() f->special_atlas = pa_water1; } #endif + setWaterLikeDiggingProperties(f->digging_properties, 0.5); i = CONTENT_LAVA; f = &content_features(i); @@ -1182,7 +1184,7 @@ void content_mapnode_init() f->light_source = LIGHT_MAX-1; f->walkable = false; f->pointable = false; - f->diggable = false; + //f->diggable = false; f->buildable_to = true; f->liquid_type = LIQUID_SOURCE; f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1"; @@ -1209,6 +1211,7 @@ void content_mapnode_init() f->special_atlas = pa_lava1; } #endif + setWaterLikeDiggingProperties(f->digging_properties, 0.5); i = CONTENT_TORCH; f = &content_features(i); @@ -2766,4 +2769,14 @@ void setLeafLikeDiggingProperties(DiggingPropertiesList &list, float toughness) DiggingProperties(true, 0.5*toughness, 65535./333.*toughness)); } +void setWaterLikeDiggingProperties(DiggingPropertiesList &list, float toughness) +{ + list.set("", + DiggingProperties(true, 150000.0*toughness, 0)); + list.set("WBucket", + DiggingProperties(true, 0.0, 65535./30.*toughness)); + + list.set("SteelBucket", + DiggingProperties(true, 0.0, 65535./80.*toughness)); +} diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 18e699d..fd3e40f 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -113,5 +113,6 @@ void set_default_settings(Settings *settings) settings->setDefault("server_map_save_interval", "1.238"); settings->setDefault("full_block_send_enable_min_time_from_building", "2.0"); settings->setDefault("enable_experimental", "false"); + settings->setDefault("enable_lavabuckets", "false"); } diff --git a/src/game.cpp b/src/game.cpp index 70cefef..216bea1 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -322,8 +322,23 @@ void getPointedNode(Client *client, v3f player_position, try { n = client->getNode(v3s16(x,y,z)); - if(content_pointable(n.getContent()) == false) - continue; + if(content_pointable(n.getContent()) == false) { + if (content_liquid_source(n.getContent()) == false) + continue; + const InventoryItem *wield = client->getLocalPlayer()->getWieldItem(); + std::string wieldname; + if ( + !wield + || wield->getName() != std::string("ToolItem") + || (wieldname = ((ToolItem*)wield)->getToolName()) == std::string("") + || ( + wieldname != std::string("SteelBucket") + && wieldname != std::string("WBucket") + ) + ) { + continue; + } + } } catch(InvalidPositionException &e) { diff --git a/src/inventory.h b/src/inventory.h index d53c608..2a5b7dd 100644 --- a/src/inventory.h +++ b/src/inventory.h @@ -316,38 +316,47 @@ public: } #ifndef SERVER std::string getBasename() const { - if(m_toolname == "WPick") + if (m_toolname == "WPick") { return "tool_woodpick.png"; - else if(m_toolname == "STPick") + }else if (m_toolname == "STPick") { return "tool_stonepick.png"; - else if(m_toolname == "SteelPick") + }else if (m_toolname == "SteelPick") { return "tool_steelpick.png"; - else if(m_toolname == "MesePick") + }else if (m_toolname == "MesePick") { return "tool_mesepick.png"; - else if(m_toolname == "WShovel") + }else if (m_toolname == "WShovel") { return "tool_woodshovel.png"; - else if(m_toolname == "STShovel") + }else if (m_toolname == "STShovel") { return "tool_stoneshovel.png"; - else if(m_toolname == "SteelShovel") + }else if (m_toolname == "SteelShovel") { return "tool_steelshovel.png"; - else if(m_toolname == "WAxe") + }else if (m_toolname == "WAxe") { return "tool_woodaxe.png"; - else if(m_toolname == "STAxe") + }else if (m_toolname == "STAxe") { return "tool_stoneaxe.png"; - else if(m_toolname == "SteelAxe") + }else if (m_toolname == "SteelAxe") { return "tool_steelaxe.png"; - else if(m_toolname == "WSword") + }else if (m_toolname == "WSword") { return "tool_woodsword.png"; - else if(m_toolname == "STSword") + }else if (m_toolname == "STSword") { return "tool_stonesword.png"; - else if(m_toolname == "SteelSword") + }else if (m_toolname == "SteelSword") { return "tool_steelsword.png"; - else if(m_toolname == "Shears") + }else if (m_toolname == "Shears") { return "tool_shears.png"; - else if(m_toolname == "WBucket") + }else if (m_toolname == "WBucket") { return "tool_woodbucket.png"; - else + }else if (m_toolname == "WBucket_water") { + return "tool_woodbucket_water.png"; + }else if(m_toolname == "SteelBucket") { + return "tool_steelbucket.png"; + }else if(m_toolname == "SteelBucket_water") { + return "tool_steelbucket_water.png"; + }else if(m_toolname == "SteelBucket_lava") { + return "tool_steelbucket_lava.png"; + }else{ return "cotton.png"; + } } video::ITexture * getImage() const @@ -410,6 +419,14 @@ public: return "Shears"; }else if(m_toolname == "WBucket") { return "Wooden Bucket"; + }else if(m_toolname == "WBucket_water") { + return "Wooden Bucket of Water"; + }else if(m_toolname == "SteelBucket") { + return "Steel Bucket"; + }else if(m_toolname == "SteelBucket_water") { + return "Steel Bucket of Water"; + }else if(m_toolname == "SteelBucket_lava") { + return "Steel Bucket of Lava"; } return ""; diff --git a/src/server.cpp b/src/server.cpp index 20103d5..6c83138 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2582,7 +2582,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) } wield = player->getWieldItem(); - std::string wieldname; + std::string wieldname(""); bool is_farm_swap = false; // This is pretty much the entirety of farming if ( @@ -2751,6 +2751,45 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) std::string dug_s = std::string("MaterialItem2 ")+itos(CONTENT_TRIMMED_LEAVES)+" 1";; std::istringstream is(dug_s, std::ios::binary); item = InventoryItem::deSerialize(is); + }else if ( + material == CONTENT_WATERSOURCE + && wield + && wield->getName() == std::string("ToolItem") + && (wieldname = ((ToolItem*)wield)->getToolName()) != std::string("") + && ( + wieldname == std::string("WBucket") + || wieldname == std::string("SteelBucket") + ) + ) { + std::string dug_s = std::string("ToolItem ") + wieldname + "_water 1"; + std::istringstream is(dug_s, std::ios::binary); + item = InventoryItem::deSerialize(is); + mlist->changeItem(item_i,item); + item = NULL; + UpdateCrafting(player->peer_id); + SendInventory(player->peer_id); + }else if ( + material == CONTENT_LAVASOURCE + && wield + && wield->getName() == std::string("ToolItem") + && (wieldname = ((ToolItem*)wield)->getToolName()) != std::string("") + && ( + wieldname == std::string("WBucket") + || wieldname == std::string("SteelBucket") + ) + ) { + if (g_settings->getBool("enable_lavabuckets") == false || wieldname == std::string("WBucket")) { + mlist->deleteItem(item_i); + HandlePlayerHP(player,4); + }else{ + std::string dug_s = std::string("ToolItem ") + wieldname + "_lava 1"; + std::istringstream is(dug_s, std::ios::binary); + item = InventoryItem::deSerialize(is); + mlist->changeItem(item_i,item); + item = NULL; + } + UpdateCrafting(player->peer_id); + SendInventory(player->peer_id); }else{ std::string &dug_s = content_features(material).dug_item; if(dug_s != "") @@ -3076,6 +3115,108 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) } }*/ + }else if ( + item->getName() == std::string("ToolItem") + && ( + ((ToolItem*)item)->getToolName() == std::string("WBucket_water") + || ((ToolItem*)item)->getToolName() == std::string("SteelBucket_water") + || ((ToolItem*)item)->getToolName() == std::string("SteelBucket_lava") + ) + ) { + MapNode n = m_env.getMap().getNodeNoEx(p_over); + std::string wieldname = ((ToolItem*)item)->getToolName(); + if ( + wieldname == std::string("WBucket_water") + || wieldname == std::string("SteelBucket_water") + ) { + if (ilist != NULL) { + std::string dug_s = std::string("ToolItem "); + if (wieldname == std::string("WBucket_water")) { + dug_s += "WBucket 1"; + }else{ + dug_s += "SteelBucket 1"; + } + std::istringstream is(dug_s, std::ios::binary); + InventoryItem *item = InventoryItem::deSerialize(is); + ilist->changeItem(item_i,item); + UpdateCrafting(player->peer_id); + SendInventory(player->peer_id); + n.setContent(CONTENT_WATERSOURCE); + core::list far_players; + sendAddNode(p_over, n, 0, &far_players, 30); + + /* + Add node. + + This takes some time so it is done after the quick stuff + */ + core::map modified_blocks; + { + MapEditEventIgnorer ign(&m_ignore_map_edit_events); + + std::string p_name = std::string(player->getName()); + m_env.getMap().addNodeAndUpdate(p_over, n, modified_blocks, p_name); + } + /* + Set blocks not sent to far players + */ + for(core::list::Iterator + i = far_players.begin(); + i != far_players.end(); i++) + { + u16 peer_id = *i; + RemoteClient *client = getClient(peer_id); + if(client==NULL) + continue; + client->SetBlocksNotSent(modified_blocks); + } + } + }else if (wieldname == std::string("SteelBucket_lava")) { + if (ilist != NULL) { + if (g_settings->getBool("enable_lavabuckets")) { + std::string dug_s = std::string("ToolItem SteelBucket 1"); + std::istringstream is(dug_s, std::ios::binary); + InventoryItem *item = InventoryItem::deSerialize(is); + ilist->changeItem(item_i,item); + UpdateCrafting(player->peer_id); + SendInventory(player->peer_id); + n.setContent(CONTENT_LAVASOURCE); + core::list far_players; + sendAddNode(p_over, n, 0, &far_players, 30); + + /* + Add node. + + This takes some time so it is done after the quick stuff + */ + core::map modified_blocks; + { + MapEditEventIgnorer ign(&m_ignore_map_edit_events); + + std::string p_name = std::string(player->getName()); + m_env.getMap().addNodeAndUpdate(p_over, n, modified_blocks, p_name); + } + /* + Set blocks not sent to far players + */ + for(core::list::Iterator + i = far_players.begin(); + i != far_players.end(); i++) + { + u16 peer_id = *i; + RemoteClient *client = getClient(peer_id); + if(client==NULL) + continue; + client->SetBlocksNotSent(modified_blocks); + } + }else{ + ilist->deleteItem(item_i); + HandlePlayerHP(player,4); + UpdateCrafting(player->peer_id); + SendInventory(player->peer_id); + } + } + } } /* Place other item (not a block) diff --git a/src/tile.cpp b/src/tile.cpp index 9db21fb..d52bb2e 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -117,6 +117,17 @@ std::string getTexturePath(const std::string &filename) return fullpath; std::string rel_path = std::string("textures")+DIR_DELIM+filename; + + /* + Check from user data directory + */ + if(fullpath == "") + { + std::string testpath = porting::path_userdata + DIR_DELIM + rel_path; + // Check all filename extensions. Returns "" if not found. + fullpath = getImagePath(testpath); + } + /* Check from data_path /textures */ @@ -166,6 +177,17 @@ std::string getModelPath(const std::string &filename) return fullpath; std::string rel_path = std::string("models")+DIR_DELIM+filename; + + /* + Check from user data directory + */ + if(fullpath == "") + { + std::string testpath = porting::path_userdata + DIR_DELIM + rel_path; + // Check all filename extensions. Returns "" if not found. + fullpath = getImagePath(testpath); + } + /* Check from data_path /models */