1
0
Fork 0

initial chest metadata

mutilcraft-mt53
Perttu Ahola 2011-04-04 11:18:14 +03:00
parent a9f89fb3fb
commit 9e683fff50
7 changed files with 123 additions and 53 deletions

View File

@ -200,41 +200,13 @@ FIXME: Server sometimes goes into some infinite PeerNotFoundException loop
* Make a small history check to transformLiquids to detect and log
continuous oscillations, in such detail that they can be fixed.
TODO: When player dies, throw items on map
TODO: Player health points
- When player dies, throw items on map
Objects:
--------
TODO: There has to be some better way to handle static objects than to
send them all the time. This affects signs and item objects.
SUGG: Signs could be done in the same way as torches. For this, blocks
need an additional metadata field for the texts
- This is also needed for item container chests
Block object server side:
- A "near blocks" buffer, in which some nearby blocks are stored.
- For all blocks in the buffer, objects are stepped(). This
means they are active.
- A global active buffer is needed for the server
- A timestamp to blocks
- All blocks going in and out of the buffer are recorded.
- For outgoing blocks, timestamp is written.
- For incoming blocks, time difference is calculated and
objects are stepped according to it.
- When an active object goes far from a player, either delete
it or store it statically.
- When a statically stored active object comes near a player,
recreate the active object
* Continue making the scripting system:
* Make updateNodeMesh for a less verbose mesh update on add/removenode
* Switch to using a safe way for the self and env pointers
* Make some global environment hooks, like node placed and general
on_step()
* Add a global Lua spawn handler and such
* Get rid of MapBlockObjects
* Other players could be sent to clients as LuaCAOs
TODO: Get rid of MapBlockObjects
Map:
----

View File

@ -288,14 +288,6 @@ void init_mapnode()
f->wall_mounted = true;
f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
i = CONTENT_FURNACE;
f = &g_content_features[i];
f->setAllTextures("furnace_side.png");
f->setTexture(2, "furnace_front.png");
f->setInventoryTexture("furnace_front.png");
f->param_type = CPT_NONE;
f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
i = CONTENT_SIGN_WALL;
f = &g_content_features[i];
f->setInventoryTexture("sign_wall.png");
@ -309,10 +301,57 @@ void init_mapnode()
if(f->initial_metadata == NULL)
f->initial_metadata = new SignNodeMetadata("Some sign");
i = CONTENT_CHEST;
f = &g_content_features[i];
f->param_type = CPT_FACEDIR_SIMPLE;
f->setAllTextures("chest_side.png");
f->setTexture(0, "chest_top.png");
f->setTexture(1, "chest_top.png");
f->setTexture(5, "chest_front.png"); // Z-
f->setInventoryTexture("chest_top.png");
//f->setInventoryTextureCube("chest_top.png", "chest_side.png", "chest_side.png");
f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
if(f->initial_metadata == NULL)
f->initial_metadata = new ChestNodeMetadata();
i = CONTENT_FURNACE;
f = &g_content_features[i];
f->param_type = CPT_FACEDIR_SIMPLE;
f->setAllTextures("furnace_side.png");
f->setTexture(5, "furnace_front.png"); // Z-
f->setInventoryTexture("furnace_front.png");
f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
}
v3s16 facedir_rotate(u8 facedir, v3s16 dir)
{
/*
Face 2 (normally Z-) direction:
facedir=0: Z-
facedir=1: X-
facedir=2: Z+
facedir=3: X+
*/
v3s16 newdir;
if(facedir==0) // Same
newdir = v3s16(dir.X, dir.Y, dir.Z);
else if(facedir == 1) // Face is taken from rotXZccv(-90)
newdir = v3s16(-dir.Z, dir.Y, dir.X);
else if(facedir == 2) // Face is taken from rotXZccv(180)
newdir = v3s16(-dir.X, dir.Y, -dir.Z);
else if(facedir == 3) // Face is taken from rotXZccv(90)
newdir = v3s16(dir.Z, dir.Y, -dir.X);
else
newdir = dir;
return newdir;
}
TileSpec MapNode::getTile(v3s16 dir)
{
if(content_features(d).param_type == CPT_FACEDIR_SIMPLE)
dir = facedir_rotate(param1, dir);
TileSpec spec;
s32 dir_i = -1;

View File

@ -95,8 +95,9 @@ void init_content_inventory_texture_paths();
#define CONTENT_COALSTONE 11
#define CONTENT_WOOD 12
#define CONTENT_SAND 13
#define CONTENT_FURNACE 14
#define CONTENT_SIGN_WALL 15
#define CONTENT_SIGN_WALL 14
#define CONTENT_CHEST 15
#define CONTENT_FURNACE 16
/*
Content feature list
@ -106,7 +107,9 @@ enum ContentParamType
{
CPT_NONE,
CPT_LIGHT,
CPT_MINERAL
CPT_MINERAL,
// Direction for chests and furnaces and such
CPT_FACEDIR_SIMPLE
};
enum LiquidType
@ -136,13 +139,9 @@ struct ContentFeatures
*/
TileSpec tiles[6];
// TODO: Somehow specify inventory image
//std::string inventory_image_path;
//TextureSpec inventory_texture;
//u32 inventory_texture_id;
video::ITexture *inventory_texture;
bool is_ground_content; //TODO: Remove, use walkable instead
bool is_ground_content;
bool light_propagates;
bool sunlight_propagates;
u8 solidness; // Used when choosing which face is drawn
@ -409,6 +408,13 @@ inline v3s16 unpackDir(u8 b)
return d;
}
/*
facedir: CPT_FACEDIR_SIMPLE param1 value
dir: The face for which stuff is wanted
return value: The face from which the stuff is actually found
*/
v3s16 facedir_rotate(u8 facedir, v3s16 dir);
enum LightBank
{
LIGHTBANK_DAY,
@ -431,14 +437,18 @@ struct MapNode
Sunlight is LIGHT_SUN, which is LIGHT_MAX+1.
- Contains 2 values, day- and night lighting. Each takes 4 bits.
*/
s8 param;
union
{
/*
The second parameter. Initialized to 0.
Direction for torches and flowing water.
*/
s8 param;
u8 param1;
};
/*
The second parameter. Initialized to 0.
E.g. direction for torches and flowing water.
*/
union
{
u8 param2;
u8 dir;
};

View File

@ -60,8 +60,14 @@ void initializeMaterialProperties()
g_material_properties[CONTENT_SAND].setDiggingProperties("",
DiggingProperties(true, 0.4, 0));
g_material_properties[CONTENT_CHEST].setDiggingProperties("",
DiggingProperties(true, 1.0, 0));
setStoneLikeDiggingProperties(CONTENT_FURNACE, 1.0);
g_material_properties[CONTENT_SIGN_WALL].setDiggingProperties("",
DiggingProperties(true, 0.0, 0));
/*
Add MesePick to everything
*/

View File

@ -104,6 +104,34 @@ std::string SignNodeMetadata::infoText()
return std::string("\"")+m_text+"\"";
}
/*
ChestNodeMetadata
*/
ChestNodeMetadata::ChestNodeMetadata()
{
NodeMetadata::registerType(typeId(), create);
}
u16 ChestNodeMetadata::typeId() const
{
return CONTENT_CHEST;
}
NodeMetadata* ChestNodeMetadata::create(std::istream &is)
{
return new ChestNodeMetadata();
}
NodeMetadata* ChestNodeMetadata::clone()
{
return new ChestNodeMetadata();
}
void ChestNodeMetadata::serializeBody(std::ostream &os)
{
}
std::string ChestNodeMetadata::infoText()
{
return "Chest";
}
/*
NodeMetadatalist
*/

View File

@ -79,6 +79,20 @@ private:
std::string m_text;
};
class ChestNodeMetadata : public NodeMetadata
{
public:
ChestNodeMetadata();
virtual u16 typeId() const;
static NodeMetadata* create(std::istream &is);
virtual NodeMetadata* clone();
virtual void serializeBody(std::ostream &os);
virtual std::string infoText();
private:
};
class NodeMetadataList
{
public:

View File

@ -3387,6 +3387,7 @@ void setCreativeInventory(Player *player)
CONTENT_MESE,
CONTENT_WATERSOURCE,
CONTENT_CLOUD,
CONTENT_CHEST,
CONTENT_FURNACE,
CONTENT_SIGN_WALL,
CONTENT_IGNORE