forked from oerkki/voxelands
some cleanups to getPointedNode and collision
This commit is contained in:
parent
77050197b1
commit
2de19e596c
|
@ -244,17 +244,12 @@ collisionMoveResult collisionMoveSimple(Map *map,
|
|||
continue;
|
||||
|
||||
std::vector<aabb3f> nodeboxes = f.getNodeBoxes(n);
|
||||
if (
|
||||
f.draw_type == CDT_WALLLIKE
|
||||
|| f.draw_type == CDT_FENCELIKE
|
||||
|| n.getContent() == CONTENT_WOOD_GATE
|
||||
|| n.getContent() == CONTENT_STEEL_GATE
|
||||
) {
|
||||
if (f.jumpable == false)
|
||||
nodeboxes.push_back(core::aabbox3d<f32>(
|
||||
-0.5*BS,0.5*BS,-0.5*BS,
|
||||
0.5*BS,1.0*BS,0.5*BS
|
||||
));
|
||||
}
|
||||
|
||||
for(std::vector<aabb3f>::iterator
|
||||
i = nodeboxes.begin();
|
||||
i != nodeboxes.end(); i++)
|
||||
|
|
|
@ -1949,6 +1949,7 @@ void content_mapnode_init()
|
|||
f->param_type = CPT_LIGHT;
|
||||
f->draw_type = CDT_FENCELIKE;
|
||||
f->is_ground_content = true;
|
||||
f->jumpable = false;
|
||||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||
f->solidness = 0; // drawn separately, makes no faces
|
||||
f->air_equivalent = true; // grass grows underneath
|
||||
|
@ -2141,6 +2142,7 @@ void content_mapnode_init()
|
|||
f->is_ground_content = true;
|
||||
f->light_propagates = true;
|
||||
f->buildable_to = true;
|
||||
f->material_pointable = false;
|
||||
f->sunlight_propagates = true;
|
||||
f->solidness = 0; // drawn separately, makes no faces
|
||||
f->dug_item = std::string("CraftItem snow_ball 1");
|
||||
|
@ -4769,6 +4771,7 @@ void content_mapnode_init()
|
|||
f->rotate_tile_with_nodebox = true;
|
||||
f->setInventoryTexture("gate_wood_inv.png");
|
||||
f->wield_nodebox = false;
|
||||
f->jumpable = false;
|
||||
f->param_type = CPT_LIGHT;
|
||||
f->light_propagates = true;
|
||||
f->sunlight_propagates = true;
|
||||
|
@ -4791,6 +4794,7 @@ void content_mapnode_init()
|
|||
f->rotate_tile_with_nodebox = true;
|
||||
f->setInventoryTexture("gate_steel_inv.png");
|
||||
f->wield_nodebox = false;
|
||||
f->jumpable = false;
|
||||
f->param_type = CPT_LIGHT;
|
||||
f->light_propagates = true;
|
||||
f->sunlight_propagates = true;
|
||||
|
@ -4949,6 +4953,7 @@ void content_mapnode_init()
|
|||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||
f->solidness = 0; // drawn separately, makes no faces
|
||||
f->walkable = false;
|
||||
f->material_pointable = false;
|
||||
f->flammable = 1; // can be replaced by fire if the node under it is set on fire
|
||||
f->fuel_time = 30/32;
|
||||
//f->pointable = false;
|
||||
|
@ -4969,6 +4974,7 @@ void content_mapnode_init()
|
|||
f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_WILDGRASS_SHORT)+" 1";
|
||||
f->solidness = 0; // drawn separately, makes no faces
|
||||
f->walkable = false;
|
||||
f->material_pointable = false;
|
||||
f->flammable = 1; // can be replaced by fire if the node under it is set on fire
|
||||
f->fuel_time = 30/32;
|
||||
f->buildable_to = true;
|
||||
|
@ -4987,6 +4993,7 @@ void content_mapnode_init()
|
|||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||
f->solidness = 0; // drawn separately, makes no faces
|
||||
f->walkable = false;
|
||||
f->material_pointable = false;
|
||||
f->flammable = 1; // can be replaced by fire if the node under it is set on fire
|
||||
f->fuel_time = 30/32;
|
||||
f->buildable_to = true;
|
||||
|
@ -5005,6 +5012,7 @@ void content_mapnode_init()
|
|||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||
f->solidness = 0; // drawn separately, makes no faces
|
||||
f->walkable = false;
|
||||
f->material_pointable = false;
|
||||
f->flammable = 1; // can be replaced by fire if the node under it is set on fire
|
||||
f->fuel_time = 30/32;
|
||||
f->buildable_to = true;
|
||||
|
@ -5023,6 +5031,7 @@ void content_mapnode_init()
|
|||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||
f->solidness = 0; // drawn separately, makes no faces
|
||||
f->walkable = false;
|
||||
f->material_pointable = false;
|
||||
f->flammable = 1; // can be replaced by fire if the node under it is set on fire
|
||||
f->fuel_time = 30/32;
|
||||
f->buildable_to = true;
|
||||
|
@ -5041,6 +5050,7 @@ void content_mapnode_init()
|
|||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||
f->solidness = 0; // drawn separately, makes no faces
|
||||
f->walkable = false;
|
||||
f->material_pointable = false;
|
||||
f->flammable = 1; // can be replaced by fire if the node under it is set on fire
|
||||
f->fuel_time = 30/32;
|
||||
f->buildable_to = true;
|
||||
|
@ -5059,6 +5069,7 @@ void content_mapnode_init()
|
|||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||
f->solidness = 0; // drawn separately, makes no faces
|
||||
f->walkable = false;
|
||||
f->material_pointable = false;
|
||||
f->flammable = 1; // can be replaced by fire if the node under it is set on fire
|
||||
f->fuel_time = 30/32;
|
||||
f->buildable_to = true;
|
||||
|
@ -5197,6 +5208,7 @@ void content_mapnode_init()
|
|||
f->description = std::string("Rough Stone Wall");
|
||||
f->setAllTextures("roughstone.png");
|
||||
f->light_propagates = true;
|
||||
f->jumpable = false;
|
||||
f->param_type = CPT_LIGHT;
|
||||
f->draw_type = CDT_WALLLIKE;
|
||||
f->is_ground_content = true;
|
||||
|
@ -5212,6 +5224,7 @@ void content_mapnode_init()
|
|||
f->description = std::string("Mossy Cobblestone Wall");
|
||||
f->setAllTextures("mossycobble.png");
|
||||
f->light_propagates = true;
|
||||
f->jumpable = false;
|
||||
f->param_type = CPT_LIGHT;
|
||||
f->draw_type = CDT_WALLLIKE;
|
||||
f->is_ground_content = true;
|
||||
|
@ -5227,6 +5240,7 @@ void content_mapnode_init()
|
|||
f->description = std::string("Stone Wall");
|
||||
f->setAllTextures("stone.png");
|
||||
f->light_propagates = true;
|
||||
f->jumpable = false;
|
||||
f->param_type = CPT_LIGHT;
|
||||
f->draw_type = CDT_WALLLIKE;
|
||||
f->is_ground_content = true;
|
||||
|
@ -5242,6 +5256,7 @@ void content_mapnode_init()
|
|||
f->description = std::string("Sand Stone Wall");
|
||||
f->setAllTextures("sandstone.png");
|
||||
f->light_propagates = true;
|
||||
f->jumpable = false;
|
||||
f->param_type = CPT_LIGHT;
|
||||
f->draw_type = CDT_WALLLIKE;
|
||||
f->is_ground_content = true;
|
||||
|
|
|
@ -174,6 +174,7 @@ void content_toolitem_init()
|
|||
f->texture = "tool_woodbucket.png";
|
||||
f->name = "WBucket";
|
||||
f->gui_name = "Wooden Bucket";
|
||||
f->liquids_pointable = true;
|
||||
crafting::setURecipe(CONTENT_CRAFTITEM_STICK,CONTENT_TOOLITEM_WBUCKET);
|
||||
|
||||
i = CONTENT_TOOLITEM_TINBUCKET;
|
||||
|
@ -182,6 +183,7 @@ void content_toolitem_init()
|
|||
f->texture = "tool_tinbucket.png";
|
||||
f->name = "TinBucket";
|
||||
f->gui_name = "Tin Bucket";
|
||||
f->liquids_pointable = true;
|
||||
crafting::setURecipe(CONTENT_CRAFTITEM_TIN_INGOT,CONTENT_TOOLITEM_TINBUCKET);
|
||||
|
||||
i = CONTENT_TOOLITEM_WBUCKET_WATER;
|
||||
|
@ -204,6 +206,7 @@ void content_toolitem_init()
|
|||
f->texture = "tool_steelbucket.png";
|
||||
f->name = "SteelBucket";
|
||||
f->gui_name = "Steel Bucket";
|
||||
f->liquids_pointable = true;
|
||||
crafting::setURecipe(CONTENT_CRAFTITEM_STEEL_INGOT,CONTENT_TOOLITEM_STEELBUCKET);
|
||||
|
||||
i = CONTENT_TOOLITEM_STEELBUCKET_WATER;
|
||||
|
|
|
@ -20,6 +20,8 @@ struct ToolItemFeatures {
|
|||
s16 edible;
|
||||
// the number dropped on right click, -1 for all
|
||||
s16 drop_count;
|
||||
// whether this tool can point at liquid nodes
|
||||
bool liquids_pointable;
|
||||
|
||||
ToolItemFeatures():
|
||||
content(CONTENT_IGNORE),
|
||||
|
@ -29,7 +31,8 @@ struct ToolItemFeatures {
|
|||
cook_result(""),
|
||||
fuel_time(0.0),
|
||||
edible(0),
|
||||
drop_count(-1)
|
||||
drop_count(-1),
|
||||
liquids_pointable(false)
|
||||
{}
|
||||
};
|
||||
|
||||
|
|
31
src/game.cpp
31
src/game.cpp
|
@ -313,6 +313,11 @@ void getPointedNode(Client *client, v3f player_position,
|
|||
s16 yend = pos_i.Y + 1 + (camera_direction.Y>0 ? a : 1);
|
||||
s16 zend = pos_i.Z + (camera_direction.Z>0 ? a : 1);
|
||||
s16 xend = pos_i.X + (camera_direction.X>0 ? a : 1);
|
||||
InventoryItem *wield = (InventoryItem*)client->getLocalPlayer()->getWieldItem();
|
||||
bool wield_is_hand = (wield == NULL);
|
||||
bool wield_is_tool = (wield && wield->getContent()&CONTENT_TOOLITEM_MASK);
|
||||
bool wield_is_craft = (wield && wield->getContent()&CONTENT_CRAFTITEM_MASK);
|
||||
bool wield_is_material = (!wield_is_hand && !wield_is_tool && !wield_is_craft);
|
||||
|
||||
for(s16 y = ystart; y <= yend; y++)
|
||||
for(s16 z = zstart; z <= zend; z++)
|
||||
|
@ -322,31 +327,13 @@ void getPointedNode(Client *client, v3f player_position,
|
|||
try
|
||||
{
|
||||
n = client->getNode(v3s16(x,y,z));
|
||||
if (content_pointable(n.getContent()) == false) {
|
||||
if (content_liquid_source(n.getContent()) == false)
|
||||
if (content_features(n.getContent()).pointable == false) {
|
||||
if (content_features(n.getContent()).liquid_type != LIQUID_SOURCE)
|
||||
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")
|
||||
&& wieldname != std::string("TinBucket")
|
||||
)
|
||||
) {
|
||||
if (!wield || content_toolitem_features(wield->getContent()).liquids_pointable == false)
|
||||
continue;
|
||||
}
|
||||
}else if ((n.getContent() >= CONTENT_PLANTS_MIN && n.getContent() <= CONTENT_PLANTS_MAX) || n.getContent() == CONTENT_SNOW) {
|
||||
const InventoryItem *wield = client->getLocalPlayer()->getWieldItem();
|
||||
if (
|
||||
wield
|
||||
&& wield->getName() == std::string("MaterialItem")
|
||||
) {
|
||||
}else if (content_features(n.getContent()).material_pointable == false && wield_is_material) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(InvalidPositionException &e)
|
||||
|
|
|
@ -173,6 +173,8 @@ struct ContentFeatures
|
|||
bool walkable;
|
||||
// Player can point to these
|
||||
bool pointable;
|
||||
// Player can point to these while holding a material (node)
|
||||
bool material_pointable;
|
||||
// Player can dig these
|
||||
bool diggable;
|
||||
// Player can climb these
|
||||
|
@ -181,6 +183,8 @@ struct ContentFeatures
|
|||
bool buildable_to;
|
||||
// Whether fire can be started on top of it
|
||||
u8 flammable;
|
||||
// Whether a player or mob can jump over this node
|
||||
bool jumpable;
|
||||
// Whether the node has no liquid, source liquid or flowing liquid
|
||||
enum LiquidType liquid_type;
|
||||
// If true, param2 is set to direction when placed. Used for torches.
|
||||
|
@ -266,10 +270,12 @@ struct ContentFeatures
|
|||
visual_solidness = 0;
|
||||
walkable = true;
|
||||
pointable = true;
|
||||
material_pointable = true;
|
||||
diggable = true;
|
||||
climbable = false;
|
||||
buildable_to = false;
|
||||
flammable = 0;
|
||||
jumpable = true;
|
||||
liquid_type = LIQUID_NONE;
|
||||
wall_mounted = false;
|
||||
air_equivalent = false;
|
||||
|
|
Loading…
Reference in New Issue