Skip to content

Commit

Permalink
Allow building on non-obstacle blocks to overwrite them. Closes GH-34
Browse files Browse the repository at this point in the history
For example, if you right-click to place a block on a plant, then
instead of doing nothing, it replaces the plant. Builds over it, instead
of on it. Obstacles are still built on, as before.

fogleman/Craft#181
  • Loading branch information
satoshinm committed May 8, 2017
1 parent 2829226 commit 8c690fe
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2203,7 +2203,11 @@ void on_build() {
State *s = &g->players->state;
int hx, hy, hz;
int hw = hit_test(1, s->x, s->y, s->z, s->rx, s->ry, &hx, &hy, &hz);
if (hy > 0 && hy < 256 && is_obstacle(hw)) {
if (hy > 0 && hy < 256) {
if (!is_obstacle(hw)) {
hw = hit_test(0, s->x, s->y, s->z, s->rx, s->ry, &hx, &hy, &hz);
}

if (!player_intersects_block(2, s->x, s->y, s->z, hx, hy, hz)) {
set_block(hx, hy, hz, items[g->item_index]);
record_block(hx, hy, hz, items[g->item_index]);
Expand Down

0 comments on commit 8c690fe

Please sign in to comment.