Browse Source

breakBlock fix

opengl-renderer-broken
Martin Dørum 4 years ago
parent
commit
4c88962ccc
1 changed files with 11 additions and 2 deletions
  1. 11
    2
      libswan/src/WorldPlane.cc

+ 11
- 2
libswan/src/WorldPlane.cc View File

@@ -104,9 +104,18 @@ Entity &WorldPlane::spawnPlayer() {
}

void WorldPlane::breakBlock(TilePos pos) {
Tile &t = getTile(pos);
setTile(pos, "core::air");

// If the block is already air, do nothing
Tile::ID id = getTileID(pos);
Tile::ID air = world_->getTileID("core::air");
if (id == air)
return;

// Change the block to air...
setTileID(pos, air);

// Then spawn an item stack entity.
Tile &t = world_->getTileByID(id);
if (t.dropped_item_ != std::nullopt) {
spawnEntity("core::item-stack", SRFArray{
new SRFFloatArray{ (float)pos.x, (float)pos.y },

Loading…
Cancel
Save