From 1ecb48c7857cb8d4f2da514a5b1050908e9729c6 Mon Sep 17 00:00:00 2001 From: CobaltXII Date: Wed, 2 Jan 2019 21:46:37 -0500 Subject: [PATCH] Can only place id_dandelion and id_rose on id_grass --- src/main.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 1cb2047..d616179 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -681,9 +681,29 @@ int main(int argc, char** argv) hitbox(floor(px), floor(py), floor(pz), 1.0f, 1.0f, 1.0f); } - the_accessor->set_id_safe(px, py, pz, id_cobblestone_slab); + // Check if the hitbox of the block that is going + // to be placed does not intersect with the + // player. - block_timer = 10; + if (!hitbox_intersect(player_hitbox, new_block)) + { + // The player is not inside the block that is + // going to be placed, so place the block. + + block_id place_id = id_reeds; + + if (place_id == id_dandelion || place_id == id_rose) + { + // Can only place id_dandelion and id_rose + // on id_grass. + + if (the_world->get_id_safe(px, py + 1, pz) == id_grass) + { + the_accessor->set_id_safe(px, py, pz, place_id); + + block_timer = 10; + } + } break; }