Teleport
parent
74b9c4c130
commit
2945239b58
Binary file not shown.
After Width: | Height: | Size: 794 B |
|
@ -447,6 +447,24 @@ InventoryItem *craft_get_result(InventoryItem **items)
|
|||
}
|
||||
}
|
||||
|
||||
//j
|
||||
{
|
||||
ItemSpec specs[9];
|
||||
specs[0] = ItemSpec(ITEM_MATERIAL, CONTENT_STEEL);
|
||||
specs[1] = ItemSpec(ITEM_MATERIAL, CONTENT_STEEL);
|
||||
specs[2] = ItemSpec(ITEM_MATERIAL, CONTENT_STEEL);
|
||||
specs[3] = ItemSpec(ITEM_MATERIAL, CONTENT_STEEL);
|
||||
specs[4] = ItemSpec(ITEM_MATERIAL, CONTENT_MESE);
|
||||
specs[5] = ItemSpec(ITEM_MATERIAL, CONTENT_STEEL);
|
||||
specs[6] = ItemSpec(ITEM_MATERIAL, CONTENT_STEEL);
|
||||
specs[7] = ItemSpec(ITEM_MATERIAL, CONTENT_STEEL);
|
||||
specs[8] = ItemSpec(ITEM_MATERIAL, CONTENT_STEEL);
|
||||
if(checkItemCombination(items, specs))
|
||||
{
|
||||
return new MaterialItem(CONTENT_TELEPORT, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -506,6 +524,7 @@ void craft_set_creative_inventory(Player *player)
|
|||
CONTENT_SIGN_WALL,
|
||||
CONTENT_LAVASOURCE,
|
||||
CONTENT_BORDERSTONE,
|
||||
CONTENT_TELEPORT,
|
||||
CONTENT_IGNORE
|
||||
};
|
||||
|
||||
|
|
|
@ -325,6 +325,61 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
|||
// Add to mesh collector
|
||||
collector.append(material, vertices, 4, indices, 6);
|
||||
}
|
||||
/*
|
||||
Teleports
|
||||
*/
|
||||
else if(n.getContent() == CONTENT_TELEPORT)
|
||||
{
|
||||
u8 l = decode_light(n.getLightBlend(data->m_daynight_ratio));
|
||||
video::SColor c = MapBlock_LightColor(255, l);
|
||||
|
||||
float d = (float)BS/16;
|
||||
// Wall at X+ of node
|
||||
video::S3DVertex vertices[4] =
|
||||
{
|
||||
video::S3DVertex(BS/2-d,-BS/2,-BS/2, 0,0,0, c, 0,1),
|
||||
video::S3DVertex(BS/2-d,-BS/2,BS/2, 0,0,0, c, 1,1),
|
||||
video::S3DVertex(BS/2-d,BS/2,BS/2, 0,0,0, c, 1,0),
|
||||
video::S3DVertex(BS/2-d,BS/2,-BS/2, 0,0,0, c, 0,0),
|
||||
};
|
||||
|
||||
v3s16 dir = unpackDir(n.param2);
|
||||
|
||||
for(s32 i=0; i<4; i++)
|
||||
{
|
||||
if(dir == v3s16(1,0,0))
|
||||
vertices[i].Pos.rotateXZBy(0);
|
||||
if(dir == v3s16(-1,0,0))
|
||||
vertices[i].Pos.rotateXZBy(180);
|
||||
if(dir == v3s16(0,0,1))
|
||||
vertices[i].Pos.rotateXZBy(90);
|
||||
if(dir == v3s16(0,0,-1))
|
||||
vertices[i].Pos.rotateXZBy(-90);
|
||||
if(dir == v3s16(0,-1,0))
|
||||
vertices[i].Pos.rotateXYBy(-90);
|
||||
if(dir == v3s16(0,1,0))
|
||||
vertices[i].Pos.rotateXYBy(90);
|
||||
|
||||
vertices[i].Pos += intToFloat(p + blockpos_nodes, BS);
|
||||
}
|
||||
|
||||
// Set material
|
||||
video::SMaterial material;
|
||||
material.setFlag(video::EMF_LIGHTING, false);
|
||||
material.setFlag(video::EMF_BACK_FACE_CULLING, false);
|
||||
material.setFlag(video::EMF_BILINEAR_FILTER, false);
|
||||
material.setFlag(video::EMF_FOG_ENABLE, true);
|
||||
//material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
||||
material.MaterialType
|
||||
= video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
|
||||
|
||||
material.setTexture(0,
|
||||
g_texturesource->getTextureRaw("teleport.png"));
|
||||
|
||||
u16 indices[] = {0,1,2,2,3,0};
|
||||
// Add to mesh collector
|
||||
collector.append(material, vertices, 4, indices, 6);
|
||||
}
|
||||
/*
|
||||
Add flowing liquid to mesh
|
||||
*/
|
||||
|
|
|
@ -642,6 +642,23 @@ void content_mapnode_init()
|
|||
if(f->initial_metadata == NULL)
|
||||
f->initial_metadata = new SignNodeMetadata("Property of nobody");
|
||||
setStoneLikeDiggingProperties(f->digging_properties, 10.0);
|
||||
|
||||
i = CONTENT_TELEPORT;
|
||||
f = &content_features(i);
|
||||
f->setAllTextures("teleport.png");
|
||||
//f->setInventoryTexture("teleport.png");
|
||||
f->param_type = CPT_LIGHT;
|
||||
f->light_propagates = true;
|
||||
f->light_source = 3; //?
|
||||
f->sunlight_propagates = true;
|
||||
f->solidness = 0; // drawn separately, makes no faces
|
||||
f->walkable = false;
|
||||
f->wall_mounted = true;
|
||||
f->air_equivalent = true;
|
||||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||
if(f->initial_metadata == NULL)
|
||||
f->initial_metadata = new SignNodeMetadata("");
|
||||
f->digging_properties.set("", DiggingProperties(true, 0.5, 0));
|
||||
|
||||
// NOTE: Remember to add frequently used stuff to the texture atlas in tile.cpp
|
||||
|
||||
|
|
|
@ -56,6 +56,8 @@ MapNode mapnode_translate_to_internal(MapNode n_from, u8 version);
|
|||
#define CONTENT_LAVA 32
|
||||
#define CONTENT_LAVASOURCE 33
|
||||
|
||||
#define CONTENT_TELEPORT 34
|
||||
|
||||
// 0x800...0xfff (2048...4095): higher 4 bytes of param2 are not usable
|
||||
#define CONTENT_GRASS 0x800 //1
|
||||
#define CONTENT_TREE 0x801 //4
|
||||
|
@ -85,5 +87,6 @@ MapNode mapnode_translate_to_internal(MapNode n_from, u8 version);
|
|||
#define CONTENT_NC_RB 0x818
|
||||
#define CONTENT_BORDERSTONE 0x819
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
50
src/game.cpp
50
src/game.cpp
|
@ -570,6 +570,56 @@ void getPointedNode(Client *client, v3f player_position,
|
|||
}
|
||||
}
|
||||
|
||||
else if(n.getContent() == CONTENT_TELEPORT)
|
||||
{
|
||||
v3s16 dir = unpackDir(n.param2);
|
||||
v3f dir_f = v3f(dir.X, dir.Y, dir.Z);
|
||||
dir_f *= BS/2 - BS/6 - BS/20;
|
||||
v3f cpf = npf + dir_f;
|
||||
f32 distance = (cpf - camera_position).getLength();
|
||||
|
||||
v3f vertices[4] =
|
||||
{
|
||||
v3f(BS*0.42,-BS*0.4,-BS*0.4),
|
||||
v3f(BS*0.49, BS*0.4, BS*0.4),
|
||||
};
|
||||
|
||||
for(s32 i=0; i<2; i++)
|
||||
{
|
||||
if(dir == v3s16(1,0,0))
|
||||
vertices[i].rotateXZBy(0);
|
||||
if(dir == v3s16(-1,0,0))
|
||||
vertices[i].rotateXZBy(180);
|
||||
if(dir == v3s16(0,0,1))
|
||||
vertices[i].rotateXZBy(90);
|
||||
if(dir == v3s16(0,0,-1))
|
||||
vertices[i].rotateXZBy(-90);
|
||||
if(dir == v3s16(0,-1,0))
|
||||
vertices[i].rotateXYBy(-90);
|
||||
if(dir == v3s16(0,1,0))
|
||||
vertices[i].rotateXYBy(90);
|
||||
|
||||
vertices[i] += npf;
|
||||
}
|
||||
|
||||
core::aabbox3d<f32> box;
|
||||
|
||||
box = core::aabbox3d<f32>(vertices[0]);
|
||||
box.addInternalPoint(vertices[1]);
|
||||
|
||||
if(distance < mindistance)
|
||||
{
|
||||
if(box.intersectsWithLine(shootline))
|
||||
{
|
||||
nodefound = true;
|
||||
nodepos = np;
|
||||
neighbourpos = np;
|
||||
mindistance = distance;
|
||||
nodehilightbox = box;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if(n.getContent() == CONTENT_LADDER)
|
||||
{
|
||||
v3s16 dir = unpackDir(n.param2);
|
||||
|
|
|
@ -2261,6 +2261,31 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||
/*dout_server<<"Server::ProcessData(): Moved player "<<peer_id<<" to "
|
||||
<<"("<<position.X<<","<<position.Y<<","<<position.Z<<")"
|
||||
<<" pitch="<<pitch<<" yaw="<<yaw<<std::endl;*/
|
||||
|
||||
//j
|
||||
v3s16 pos = floatToInt(position, BS);
|
||||
MapNode n = m_env.getMap().getNodeNoEx(pos);
|
||||
if(n.getContent() == CONTENT_TELEPORT){
|
||||
SignNodeMetadata* meta = (SignNodeMetadata*)m_env.getMap().getNodeMetadata(pos);
|
||||
if(meta){
|
||||
v3f t;
|
||||
std::string text = meta->getText();
|
||||
str_replace_char(text,',',' ');
|
||||
std::istringstream is(text);
|
||||
is >> t.X >> t.Y >> t.Z;
|
||||
|
||||
//TODO: map limits!
|
||||
if( t.X > 32000 || t.X < -32000 ||
|
||||
t.Y > 32000 || t.Y < -32000 ||
|
||||
t.Z > 32000 || t.Z < -32000 ||
|
||||
(t.X == 0 && t.Y == 0 && t.Z == 0)
|
||||
) return;
|
||||
|
||||
dout_server << "Teleporting: " << text << std::endl;
|
||||
player->setPosition(t*BS);
|
||||
SendMovePlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(command == TOSERVER_GOTBLOCKS)
|
||||
{
|
||||
|
@ -3147,7 +3172,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||
//if(text.length()>1 && text[0]=='#'){
|
||||
if( node.getContent() == CONTENT_BORDERSTONE ){
|
||||
|
||||
//j: ustawiamy wlasciciela
|
||||
//j: set ownership
|
||||
|
||||
std::string groupName = text;
|
||||
|
||||
|
@ -3177,6 +3202,21 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||
block->setOwner(group);
|
||||
if(group) text = "Property of " + groupName;
|
||||
else text = "Property of nobody";
|
||||
} else if( node.getContent() == CONTENT_TELEPORT ){
|
||||
|
||||
//j teleport
|
||||
|
||||
//std::string st = text;
|
||||
//str_replace_char(st,',',' ');
|
||||
//float f[3];
|
||||
//std::istringstream is(st);
|
||||
//is >> f[0] >> f[1] >> f[2];
|
||||
|
||||
////TODO: map limits!
|
||||
//for(int i=0; i<3; i++)
|
||||
// if(f[i]>32000 || f[i]<-32000) f[i]=0;
|
||||
|
||||
//text = ftos(f[0]) + "," + ftos(f[1]) + "," + ftos(f[2]);
|
||||
}
|
||||
|
||||
SignNodeMetadata *signmeta = (SignNodeMetadata*)meta;
|
||||
|
|
Loading…
Reference in New Issue