Skip to content

Commit

Permalink
[BlockCursor] No longer possible to replace blocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
Unarelith committed Feb 17, 2020
1 parent 494f56f commit bb5819e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions client/source/hud/BlockCursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,18 @@ void BlockCursor::onEvent(const SDL_Event &event, const Hotbar &hotbar) {
if(face == 2) z++;
if(face == 5) z--;

m_world.setBlock(x, y, z, hotbar.currentItem());
u32 blockId = m_world.getBlock(x, y, z);
const Block &block = Registry::getInstance().getBlock(blockId);
if (!blockId || block.drawType() == BlockDrawType::Liquid) {
m_world.setBlock(x, y, z, hotbar.currentItem());

m_client.sendPlayerPlaceBlock(x, y, z, hotbar.currentItem());
m_client.sendPlayerPlaceBlock(x, y, z, hotbar.currentItem());

const ItemStack &currentStack = m_player.inventory().getStack(hotbar.cursorPos(), 0);
m_player.inventory().setStack(hotbar.cursorPos(), 0, currentStack.amount() > 1 ? currentStack.item().name() : "", currentStack.amount() - 1);
const ItemStack &currentStack = m_player.inventory().getStack(hotbar.cursorPos(), 0);
m_player.inventory().setStack(hotbar.cursorPos(), 0, currentStack.amount() > 1 ? currentStack.item().name() : "", currentStack.amount() - 1);

m_client.sendPlayerInvUpdate();
m_client.sendPlayerInvUpdate();
}
}
}
}
Expand Down

0 comments on commit bb5819e

Please sign in to comment.