new jungle ground cover

This commit is contained in:
darkrose 2016-01-08 20:47:26 +10:00
parent 208ee1dafc
commit 4e630b1cff
11 changed files with 136 additions and 50 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 642 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 784 B

View File

@ -1050,6 +1050,7 @@ void meshgen_dirtlike(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNode &sel
* 1 - spring grass
* 2 - autumn grass
* 4 - snow
* 8 - jungle grass
*
* param2:
* plantgrowth, only valid if param1 bottom nibble is 1 or 2
@ -1109,6 +1110,35 @@ void meshgen_dirtlike(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNode &sel
std::string btex = g_texturesource->getTextureName(basetile.texture.id);
std::string tex = btex;
switch (overlay) {
case 8:
if (n.param2 == 0) {
tex = "grass_jungle.png";
if (data->mesh_detail > 1) {
for (int i=0; i<6; i++) {
o_faces[i] = faces[i];
}
}
}else{
tex = getGrassTile(n.param2,btex,"grass_growing_jungle.png");
if (data->mesh_detail > 1) {
u8 pg = n.param2&0xF0;
if ((pg&(1<<7)) != 0) { // -Z
o_faces[5] = faces[5];
}
if ((pg&(1<<6)) != 0) { // +Z
o_faces[4] = faces[4];
}
if ((pg&(1<<5)) != 0) { // -X
o_faces[3] = faces[3];
}
if ((pg&(1<<4)) != 0) { // +X
o_faces[2] = faces[2];
}
}
}
sidetile.texture = g_texturesource->getTexture("grass_side_jungle.png");
upstile.texture = g_texturesource->getTexture("grass_corner_jungle.png");
break;
case 4:
tex = "snow.png";
if (data->mesh_detail > 1) {
@ -2028,7 +2058,7 @@ void meshgen_plantlike(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNode &se
unf = &content_features(unc);
}
if (unf->draw_type == CDT_CUBELIKE && unc != CONTENT_FARM_DIRT) {
if ((unf->draw_type == CDT_CUBELIKE || unf->draw_type == CDT_DIRTLIKE) && unc != CONTENT_FARM_DIRT) {
if (up.X%2) {
pos_inner.Z = -0.1*data->m_BS;
}else{
@ -2158,6 +2188,7 @@ void meshgen_plantlike_fern(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNod
ContentFeatures *f = &content_features(n);
TileSpec tile = getNodeTile(n,p,v3s16(0,-1,0),selected);
v3f offset(0,0,0);
s16 rot = 0;
bool is_dropped = false;
if (data->m_vmanip.getNodeRO(data->m_blockpos_nodes + p + v3s16(0,-1,0)).getContent() == CONTENT_FLOWER_POT) {
offset = v3f(0,-0.25*data->m_BS,0);
@ -2175,23 +2206,29 @@ void meshgen_plantlike_fern(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNod
unf = &content_features(unc);
}
if (unf->draw_type == CDT_CUBELIKE && unc != CONTENT_FARM_DIRT) {
if ((unf->draw_type == CDT_CUBELIKE || unf->draw_type == CDT_DIRTLIKE) && unc != CONTENT_FARM_DIRT) {
if (up.X%2) {
pos_inner.Z = -0.1*data->m_BS;
rot = 20;
}else{
pos_inner.Z = 0.1*data->m_BS;
rot = -20;
}
if (up.Z%2) {
pos_inner.X = -0.1*data->m_BS;
rot += 10;
}else{
pos_inner.X = 0.1*data->m_BS;
rot += -10;
}
if (up.Y%2) {
pos_inner.X += 0.05*data->m_BS;
pos_inner.Z -= 0.05*data->m_BS;
rot += 5;
}else{
pos_inner.X -= 0.05*data->m_BS;
pos_inner.Z += 0.05*data->m_BS;
rot += -5;
}
}
}
@ -2217,14 +2254,14 @@ void meshgen_plantlike_fern(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNod
video::S3DVertex( 0.5*data->m_BS, 0.28125*data->m_BS,1.5*data->m_BS, 0,0,0, video::SColor(255,255,255,255), 1.,0.)
};
s16 angle[8] = {
45,
-45,
135,
-135,
90,
0,
180,
-90
45+rot,
-45+rot,
135+rot,
-135+rot,
90+rot,
0+rot,
180+rot,
-90+rot
};
float vo[8] = {
0.0,

View File

@ -1145,9 +1145,27 @@ void ServerEnvironment::step(float dtime)
}
switch(n.getContent()) {
/*
Convert mud under proper lighting to grass
*/
/*
* param1:
* top nibble:
* 0 - no effect
* 1 - footsteps
* 2 - salt
* bottom nibble:
* 0 - no overlay
* 1 - spring grass
* 2 - autumn grass
* 4 - snow
* 8 - jungle grass
*
* param2:
* plantgrowth, only valid if param1 bottom nibble is 1 or 2
* top nibble:
* bitwise OR direction of growth
* bottom nibble:
* 0 - fully grown
* 1-15 - growth stages
*/
case CONTENT_MUD:
case CONTENT_CLAY:
{
@ -1164,7 +1182,7 @@ void ServerEnvironment::step(float dtime)
m_map->addNodeWithEvent(p, n);
}
// footsteps fade out
}else if ((n.param1&0xF0) == 0x10 && n.envticks > 3) {
}else if ((n.param1&0x10) == 0x10 && n.envticks > 3) {
n.param1 &= ~0x10;
m_map->addNodeWithEvent(p,n);
// autumn grass in autumn/winter
@ -1221,34 +1239,7 @@ void ServerEnvironment::step(float dtime)
(n.param1&0x0F) != 0x04
&& n_top.getLightBlend(getDayNightRatio()) >= 13
) {
if ((n.param1&0x0F) != 0x00 && (n.param2&0x0F) == 0x0) {
int f = (700-(p.Y*2))+10;
if (p.Y > 1 && myrand()%f == 0) {
if (
n_top.getContent() == CONTENT_AIR
&& n_top.getLightBlend(getDayNightRatio()) >= 13
) {
v3f pp = intToFloat(p,BS);
Player *nearest = getNearestConnectedPlayer(pp);
if (nearest == NULL || nearest->getPosition().getDistanceFrom(pp)/BS > 20.0) {
std::vector<content_t> search;
search.push_back(CONTENT_WILDGRASS_SHORT);
if (season != ENV_SEASON_SPRING)
search.push_back(CONTENT_WILDGRASS_LONG);
search.push_back(CONTENT_FLOWER_STEM);
search.push_back(CONTENT_FLOWER_ROSE);
search.push_back(CONTENT_FLOWER_TULIP);
search.push_back(CONTENT_FLOWER_DAFFODIL);
if (!searchNear(p,v3s16(1,1,1),search,NULL)) {
n_top.setContent(CONTENT_WILDGRASS_SHORT);
m_map->addNodeWithEvent(p+v3s16(0,1,0), n_top);
}
}
}
}
}else{
plantgrowth_grass(this,p);
}
plantgrowth_grass(this,p);
}
}else{
if (n.param1 == 0x01) {

View File

@ -1854,6 +1854,12 @@ void make_block(BlockMakeData *data)
}else if (current_depth==0 && !water_detected && y >= WATER_LEVEL && air_detected) {
if (y > 50 || (y > 45 && myrand()%5 == 0)) {
vmanip.m_data[i] = MapNode(CONTENT_MUD,0x04);
}else if (is_jungle) {
if (noisebuf_ground_wetness.get(x,y,z) > 1.0) {
vmanip.m_data[i] = MapNode(CONTENT_CLAY,0x08);
}else{
vmanip.m_data[i] = MapNode(CONTENT_MUD,0x08);
}
}else if (noisebuf_ground_wetness.get(x,y,z) > 1.0) {
vmanip.m_data[i] = MapNode(CONTENT_CLAY,0x01);
}else{
@ -1881,8 +1887,13 @@ void make_block(BlockMakeData *data)
}
// Amount of trees
u32 tree_count = block_area_nodes * tree_amount_2d(data->seed, p2d_center);
if (is_jungle)
tree_count *= 5;
if (is_jungle) {
if (!tree_count) {
tree_count = 20;
}else{
tree_count *= 5;
}
}
/*
Add trees

View File

@ -512,18 +512,65 @@ void plantgrowth_grass(ServerEnvironment *env, v3s16 p0)
u8 p1mask = (n.param1&0x0F);
bool add = false;
if ((n.param1&0x20) == 0x20)
return;
if (p1mask == 0) {
u8 season = env->getSeason();
if (season == ENV_SEASON_WINTER)
return;
if (season == ENV_SEASON_AUTUMN) {
p1mask = 0x02;
bool is_jungle = false;
v3s16 near[4] = {
v3s16(0,0,-1),
v3s16(0,0,1),
v3s16(-1,0,0),
v3s16(1,0,0)
};
for (int i=0; !is_jungle && i<4; i++) {
MapNode nn = env->getMap().getNodeNoEx(p0+near[i]);
if (content_features(nn.getContent()).draw_type == CDT_DIRTLIKE && (nn.param1&0x0F) == 0x08)
is_jungle = true;
}
if (is_jungle) {
p1mask = 0x08;
}else{
p1mask = 0x01;
u8 season = env->getSeason();
if (season == ENV_SEASON_WINTER)
return;
if (season == ENV_SEASON_AUTUMN) {
p1mask = 0x02;
}else{
p1mask = 0x01;
}
}
n.param1 |= p1mask;
n.param2 = 0;
}else if (n.param2 == 0) {
int f = (700-(p0.Y*2))+10;
if (p0.Y > 1 && myrand()%f == 0) {
MapNode n_top = env->getMap().getNodeNoEx(p0+v3s16(0,1,0));
if (
n_top.getContent() == CONTENT_AIR
&& n_top.getLightBlend(env->getDayNightRatio()) >= 13
) {
v3f pp = intToFloat(p0,BS);
Player *nearest = env->getNearestConnectedPlayer(pp);
if (nearest == NULL || nearest->getPosition().getDistanceFrom(pp)/BS > 20.0) {
std::vector<content_t> search;
search.push_back(CONTENT_WILDGRASS_SHORT);
u8 season = env->getSeason();
if (season != ENV_SEASON_SPRING)
search.push_back(CONTENT_WILDGRASS_LONG);
search.push_back(CONTENT_FLOWER_STEM);
search.push_back(CONTENT_FLOWER_ROSE);
search.push_back(CONTENT_FLOWER_TULIP);
search.push_back(CONTENT_FLOWER_DAFFODIL);
if (!env->searchNear(p0,v3s16(1,1,1),search,NULL)) {
n_top.setContent(CONTENT_WILDGRASS_SHORT);
env->getMap().addNodeWithEvent(p0+v3s16(0,1,0), n_top);
}
}
}
}
return;
}