[Registry] Small fix.
This commit is contained in:
parent
7cb8a51c3f
commit
6b986b7de5
@ -138,25 +138,28 @@ void BlockCursor::update(const Hotbar &hotbar, bool useDepthBuffer) {
|
||||
m_animationStart = (m_animationStart) ? gk::GameClock::getTicks() : 0;
|
||||
|
||||
const ItemStack ¤tStack = m_player.inventory().getStack(hotbar.cursorPos(), 0);
|
||||
float timeToBreak = m_currentBlock->timeToBreak(currentStack.item().harvestCapability(), currentStack.item().miningSpeed());
|
||||
if (m_animationStart && gk::GameClock::getTicks() > m_animationStart + timeToBreak * 1000) {
|
||||
ItemStack itemDrop = m_currentBlock->getItemDrop();
|
||||
m_player.inventory().addStack(itemDrop.item().name(), itemDrop.amount());
|
||||
m_world.setBlock(m_selectedBlock.x, m_selectedBlock.y, m_selectedBlock.z, 0);
|
||||
m_animationStart = gk::GameClock::getTicks();
|
||||
float timeToBreak = 0;
|
||||
if (m_animationStart) {
|
||||
timeToBreak = m_currentBlock->timeToBreak(currentStack.item().harvestCapability(), currentStack.item().miningSpeed());
|
||||
if (gk::GameClock::getTicks() > m_animationStart + timeToBreak * 1000) {
|
||||
ItemStack itemDrop = m_currentBlock->getItemDrop();
|
||||
m_player.inventory().addStack(itemDrop.item().name(), itemDrop.amount());
|
||||
m_world.setBlock(m_selectedBlock.x, m_selectedBlock.y, m_selectedBlock.z, 0);
|
||||
m_animationStart = gk::GameClock::getTicks();
|
||||
|
||||
sf::Packet packet;
|
||||
packet << Network::Command::PlayerDigBlock
|
||||
<< s32(m_selectedBlock.x)
|
||||
<< s32(m_selectedBlock.y)
|
||||
<< s32(m_selectedBlock.z);
|
||||
m_client.send(packet);
|
||||
sf::Packet packet;
|
||||
packet << Network::Command::PlayerDigBlock
|
||||
<< s32(m_selectedBlock.x)
|
||||
<< s32(m_selectedBlock.y)
|
||||
<< s32(m_selectedBlock.z);
|
||||
m_client.send(packet);
|
||||
|
||||
// FIXME
|
||||
sf::Packet invPacket;
|
||||
invPacket << Network::Command::PlayerInvUpdate;
|
||||
m_player.serialize(invPacket);
|
||||
m_client.send(invPacket);
|
||||
// FIXME
|
||||
sf::Packet invPacket;
|
||||
invPacket << Network::Command::PlayerInvUpdate;
|
||||
m_player.serialize(invPacket);
|
||||
m_client.send(invPacket);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_selectedBlock.w != -1)
|
||||
|
@ -81,9 +81,9 @@ void Registry::deserialize(sf::Packet &packet) {
|
||||
>> harvestRequirements >> itemDrop;
|
||||
|
||||
auto &block = registerBlock<Block>(textureID, name, label);
|
||||
block.setHarvestRequirements(harvestRequirements);
|
||||
block.setHardness(hardness);
|
||||
block.setDrawType(BlockDrawType(drawType));
|
||||
block.setHardness(hardness);
|
||||
block.setHarvestRequirements(harvestRequirements);
|
||||
block.setItemDrop(itemDrop.item().name(), itemDrop.amount());
|
||||
}
|
||||
else if (type == u8(DataType::Item)) {
|
||||
@ -95,10 +95,11 @@ void Registry::deserialize(sf::Packet &packet) {
|
||||
>> burnTime >> miningSpeed >> harvestCapability;
|
||||
|
||||
auto &item = registerItem(textureID, name, label);
|
||||
item.setIsFuel(isFuel);
|
||||
item.setIsBlock(isBlock);
|
||||
item.setMiningSpeed(miningSpeed);
|
||||
item.setIsFuel(isFuel);
|
||||
item.setBurnTime(burnTime);
|
||||
item.setMiningSpeed(miningSpeed);
|
||||
item.setHarvestCapability(harvestCapability);
|
||||
}
|
||||
else if (type == u8(DataType::CraftingRecipe)) {
|
||||
registerRecipe<CraftingRecipe>()->deserialize(packet);
|
||||
|
@ -42,10 +42,14 @@ void InventoryWidget::onMouseEvent(const SDL_Event &event, MouseItemWidget &mous
|
||||
}
|
||||
else if (event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_LEFT && m_currentItemWidget) {
|
||||
mouseItemWidget.swapItems(*m_currentItemWidget, isReadOnly);
|
||||
|
||||
// TODO: Send inventory update packet
|
||||
}
|
||||
else if (event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_RIGHT && m_currentItemWidget) {
|
||||
if (!isReadOnly) {
|
||||
mouseItemWidget.putItem(*m_currentItemWidget);
|
||||
|
||||
// TODO: Send inventory update packet
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user