forked from oerkki/voxelands
new creeping grass growth
This commit is contained in:
parent
25ab63591a
commit
4e43de05ec
Binary file not shown.
Before Width: | Height: | Size: 661 B After Width: | Height: | Size: 656 B |
Binary file not shown.
After Width: | Height: | Size: 828 B |
Binary file not shown.
Before Width: | Height: | Size: 731 B After Width: | Height: | Size: 772 B |
|
@ -402,6 +402,21 @@ void content_mapnode_init(bool repeat)
|
|||
f->farm_ploughable = true;
|
||||
lists::add("decrafting",i);
|
||||
|
||||
i = CONTENT_GROWING_GRASS;
|
||||
f = &content_features(i);
|
||||
f->description = wgettext("Growing Grass");
|
||||
f->setAllTextures("mud.png");
|
||||
f->setTexture(0, "grass_growing.png");
|
||||
f->setInventoryTextureCube("grass.png","mud.png","mud.png");
|
||||
f->draw_type = CDT_CUBELIKE;
|
||||
f->param2_type = CPT_PLANTGROWTH;
|
||||
f->is_ground_content = true;
|
||||
f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_MUD)+" 1";
|
||||
f->special_alternate_node = CONTENT_GRASS;
|
||||
f->type = CMT_DIRT;
|
||||
f->hardness = 1.0;
|
||||
f->farm_ploughable = true;
|
||||
|
||||
i = CONTENT_GRASS_FOOTSTEPS;
|
||||
f = &content_features(i);
|
||||
f->description = wgettext("Grass");
|
||||
|
|
|
@ -90,7 +90,8 @@ MapNode mapnode_translate_to_internal(MapNode n_from, u8 version);
|
|||
#define CONTENT_COBBLE_WALL 0x029
|
||||
// FREE 2A-0x7C
|
||||
// 0x7D-0x7F reserved values, air, ignore, etc
|
||||
// FREE 0x80-0x7FF
|
||||
// FREE 0x80-0x7FE
|
||||
#define CONTENT_GROWING_GRASS 0x7FF
|
||||
#define CONTENT_GRASS 0x800
|
||||
#define CONTENT_TREE 0x801
|
||||
#define CONTENT_LEAVES 0x802
|
||||
|
|
|
@ -991,21 +991,32 @@ void ServerEnvironment::step(float dtime)
|
|||
*/
|
||||
case CONTENT_MUD:
|
||||
{
|
||||
if (n.envticks > 3) {
|
||||
MapNode n_top = m_map->getNodeNoEx(p+v3s16(0,1,0));
|
||||
if (content_features(n_top).air_equivalent) {
|
||||
if (p.Y > 50 && p.Y < 1024) {
|
||||
n.setContent(CONTENT_MUDSNOW);
|
||||
m_map->addNodeWithEvent(p, n);
|
||||
}else if (n_top.getLightBlend(getDayNightRatio()) >= 13) {
|
||||
n.setContent(CONTENT_GRASS);
|
||||
m_map->addNodeWithEvent(p, n);
|
||||
}
|
||||
MapNode n_top = m_map->getNodeNoEx(p+v3s16(0,1,0));
|
||||
if (content_features(n_top).air_equivalent) {
|
||||
if (p.Y > 50 && p.Y < 1024) {
|
||||
n.setContent(CONTENT_MUDSNOW);
|
||||
m_map->addNodeWithEvent(p, n);
|
||||
}else if (n_top.getLightBlend(getDayNightRatio()) >= 13) {
|
||||
n.setContent(CONTENT_GROWING_GRASS);
|
||||
n.param2 = 0;
|
||||
m_map->addNodeWithEvent(p, n);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case CONTENT_GROWING_GRASS:
|
||||
{
|
||||
MapNode n_top = m_map->getNodeNoEx(p+v3s16(0,1,0));
|
||||
if (content_features(n_top).air_equivalent) {
|
||||
plantgrowth_grass(this,p);
|
||||
}else{
|
||||
n.setContent(CONTENT_MUD);
|
||||
m_map->addNodeWithEvent(p,n);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case CONTENT_WATER:
|
||||
case CONTENT_WATERSOURCE:
|
||||
{
|
||||
|
|
|
@ -199,6 +199,63 @@ TileSpec getNodeTile(MapNode mn, v3s16 p, v3s16 face_dir, NodeModMap &temp_mods,
|
|||
// Get new texture
|
||||
u32 new_id = g_texturesource->getTextureId(texture_name);
|
||||
spec.texture = g_texturesource->getTexture(new_id);
|
||||
}else if (f->draw_type == CDT_CUBELIKE && f->param2_type == CPT_PLANTGROWTH && face_dir.Y == 1) {
|
||||
TileSpec bspec = spec;
|
||||
spec = mn.getTile(v3s16(0,-1,0),false);
|
||||
if (mn.param2) {
|
||||
u8 p = mn.param2&0xF0;
|
||||
u8 g = mn.param2&0x0F;
|
||||
if (g < 15) {
|
||||
u32 orig_id = bspec.texture.id;
|
||||
std::string blit_name = g_texturesource->getTextureName(orig_id);
|
||||
std::string orig_name = g_texturesource->getTextureName(spec.texture.id);
|
||||
std::string texture_name = orig_name;
|
||||
if (p == 0) {
|
||||
float v = (float)(g+1)*0.03125;
|
||||
texture_name += "^[blit:";
|
||||
texture_name += ftos(0.5-v);
|
||||
texture_name += ",";
|
||||
texture_name += ftos(0.5-v);
|
||||
texture_name += ",";
|
||||
texture_name += ftos(0.5+v);
|
||||
texture_name += ",";
|
||||
texture_name += ftos(0.5+v);
|
||||
texture_name += ",";
|
||||
texture_name += blit_name;
|
||||
}else{
|
||||
float v = (float)g*0.0625;
|
||||
if ((p&(1<<7)) != 0) { // -Z
|
||||
texture_name += "^[blit:0,";
|
||||
texture_name += ftos(1.0-v);
|
||||
texture_name += ",1,1,";
|
||||
texture_name += blit_name;
|
||||
}
|
||||
if ((p&(1<<6)) != 0) { // +Z
|
||||
texture_name += "^[blit:0,0,1,";
|
||||
texture_name += ftos(v);
|
||||
texture_name += ",";
|
||||
texture_name += blit_name;
|
||||
}
|
||||
if ((p&(1<<5)) != 0) { // -X
|
||||
texture_name += "^[blit:0,0,";
|
||||
texture_name += ftos(v);
|
||||
texture_name += ",1,";
|
||||
texture_name += blit_name;
|
||||
}
|
||||
if ((p&(1<<4)) != 0) { // +X
|
||||
texture_name += "^[blit:";
|
||||
texture_name += ftos(1.0-v);
|
||||
texture_name += ",0,1,1,";
|
||||
texture_name += blit_name;
|
||||
}
|
||||
}
|
||||
// Get new texture
|
||||
u32 new_id = g_texturesource->getTextureId(texture_name);
|
||||
spec.texture = g_texturesource->getTexture(new_id);
|
||||
}else{
|
||||
spec = bspec;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string rot = mn.getTileRotationString(face_dir);
|
||||
|
@ -235,20 +292,6 @@ TileSpec getNodeTile(MapNode mn, v3s16 p, v3s16 face_dir, NodeModMap &temp_mods,
|
|||
// Get new texture
|
||||
u32 new_id = g_texturesource->getTextureId(os.str());
|
||||
|
||||
spec.texture = g_texturesource->getTexture(new_id);
|
||||
}
|
||||
if (mod == NODEMOD_SELECTION) {
|
||||
// Get original texture name
|
||||
u32 orig_id = spec.texture.id;
|
||||
std::string orig_name = g_texturesource->getTextureName(orig_id);
|
||||
|
||||
// Create new texture name
|
||||
std::ostringstream os;
|
||||
os<<orig_name<<"^[forcesingle";
|
||||
|
||||
// Get new texture
|
||||
u32 new_id = g_texturesource->getTextureId(os.str());
|
||||
|
||||
spec.texture = g_texturesource->getTexture(new_id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -480,3 +480,51 @@ void plantgrowth_plant(ServerEnvironment *env, v3s16 p0, s16 height)
|
|||
}
|
||||
env->getMap().addNodeWithEvent(p0,n);
|
||||
}
|
||||
|
||||
void plantgrowth_grass(ServerEnvironment *env, v3s16 p0)
|
||||
{
|
||||
u32 tod = env->getTimeOfDay();
|
||||
MapNode n = env->getMap().getNodeNoEx(p0);
|
||||
u8 light = n.getLightBlend(env->getDayNightRatio());
|
||||
content_t c = content_features(n.getContent()).special_alternate_node;
|
||||
if (c == CONTENT_IGNORE)
|
||||
return;
|
||||
bool add = false;
|
||||
{
|
||||
u8 p = 0;
|
||||
MapNode nn = env->getMap().getNodeNoEx(p0+v3s16(0,0,-1));
|
||||
if (nn.getContent() == c)
|
||||
p |= 1<<7;
|
||||
nn = env->getMap().getNodeNoEx(p0+v3s16(0,0,1));
|
||||
if (nn.getContent() == c)
|
||||
p |= 1<<6;
|
||||
nn = env->getMap().getNodeNoEx(p0+v3s16(-1,0,0));
|
||||
if (nn.getContent() == c)
|
||||
p |= 1<<5;
|
||||
nn = env->getMap().getNodeNoEx(p0+v3s16(1,0,0));
|
||||
if (nn.getContent() == c)
|
||||
p |= 1<<4;
|
||||
if (!n.param2 && p == 0 && myrand_range(0,20) != 0)
|
||||
return;
|
||||
if (!n.param2 || p != (n.param2&0xF0)) {
|
||||
n.param2 &= 0x0F;
|
||||
n.param2 |= p;
|
||||
add = true;
|
||||
}
|
||||
}
|
||||
// only grow during the day or with good light
|
||||
if (light > LIGHT_MAX-4 || (tod > 6000 && tod < 18000)) {
|
||||
u8 p = n.param2&0xF0;
|
||||
u8 g = n.param2&0x0F;
|
||||
g++;
|
||||
if (g > 15) {
|
||||
n.setContent(c);
|
||||
}else{
|
||||
n.param2 = (p|g);
|
||||
}
|
||||
add = true;
|
||||
}
|
||||
|
||||
if (add)
|
||||
env->getMap().addNodeWithEvent(p0,n);
|
||||
}
|
||||
|
|
|
@ -30,5 +30,6 @@ void plantgrowth_largetree(ServerEnvironment *env, v3s16 p0);
|
|||
void plantgrowth_jungletree(ServerEnvironment *env, v3s16 p0);
|
||||
void plantgrowth_seed(ServerEnvironment *env, v3s16 p0);
|
||||
void plantgrowth_plant(ServerEnvironment *env, v3s16 p0, s16 height=0);
|
||||
void plantgrowth_grass(ServerEnvironment *env, v3s16 p0);
|
||||
|
||||
#endif
|
||||
|
|
16
src/tile.cpp
16
src/tile.cpp
|
@ -1829,10 +1829,22 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
|||
// Position to copy the blitted from in the blitted image
|
||||
core::position2d<s32> pos_from((float)idim.Width*x,(float)idim.Height*y);
|
||||
// Blit
|
||||
image->copyToWithAlpha(baseimg, pos_to,
|
||||
if (image->getBitsPerPixel() == 32) {
|
||||
image->copyToWithAlpha(
|
||||
baseimg,
|
||||
pos_to,
|
||||
core::rect<s32>(pos_from, dim),
|
||||
video::SColor(255,255,255,255),
|
||||
NULL);
|
||||
NULL
|
||||
);
|
||||
}else{
|
||||
image->copyTo(
|
||||
baseimg,
|
||||
pos_to,
|
||||
core::rect<s32>(pos_from, dim),
|
||||
NULL
|
||||
);
|
||||
}
|
||||
// Drop image
|
||||
image->drop();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue