fogleman / Craft

A simple Minecraft clone written in C using modern OpenGL (shaders).
http://www.michaelfogleman.com/craft/
MIT License
10.39k stars 1.39k forks source link

Fix placing blocks on plants or other non-obstacles (simple fix) #181

Open satoshinm opened 7 years ago

satoshinm commented 7 years ago

Right-clicking on a non-obstacle block (such as a plant) used to do nothing. I originally suspected it was an issue in hit testing, but turns out to be an easy fix: if the hit target is not an obstacle, then create the new block on the clicked block. This matches the commonly expected behavior e.g. in Minecraft.

Before:

screen shot 2017-05-07 at 7 52 07 pm

After right-click, without this pull request: nothing happens

screen shot 2017-05-07 at 7 52 07 pm

After right-click, with this pull request:

screen shot 2017-05-07 at 7 52 14 pm