Skip to content

Commit 8dbfcf2

Browse files
committed
Client: Restore temporary hack to be able to mine forcefields
1 parent 92f2c68 commit 8dbfcf2

4 files changed

Lines changed: 18 additions & 5 deletions

File tree

include/ClientLib/ClientBlockLibrary.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ namespace tsom
3434
inline const std::shared_ptr<Nz::GpuBuffer>& GetGlobalBlockBuffer() const;
3535
inline const std::shared_ptr<Nz::TextureAsset>& GetPreviewTexture(BlockIndex blockIndex) const;
3636

37+
bool LoadFromString(std::string_view content, bool merge = false) override;
38+
3739
private:
3840
std::shared_ptr<Nz::GpuBuffer> m_globalBlockBuffer;
3941
std::vector<std::shared_ptr<Nz::TextureAsset>> m_previewTextures;

include/ClientLib/ClientBlockLibrary.inl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ namespace tsom
88
m_applicationBase(applicationBase),
99
m_globalBlockBufferPtr(nullptr)
1010
{
11-
// HAAAAAAAAAAAAAAAAAAAAX
12-
// Re-enable collisions for forcefield to allow clients to remove them (player collisions are only handled on the server for now)
13-
if (BlockIndex idx = GetBlockIndex("forcefield"); idx != InvalidBlockIndex)
14-
m_blocks[idx].hasCollisions = true;
1511
}
1612

1713
inline const std::shared_ptr<Nz::TextureAsset>& ClientBlockLibrary::GetBlockTexture(CookedBlockRegistry::TextureType textureType) const

include/CommonLib/BlockLibrary.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace tsom
4040
inline bool IsValidBlock(BlockIndex blockIndex) const;
4141
inline bool IsValidLayer(std::size_t layerIndex) const;
4242

43-
bool LoadFromString(std::string_view content, bool merge = false);
43+
virtual bool LoadFromString(std::string_view content, bool merge = false);
4444

4545
BlockIndex RegisterBlock(std::string name, BlockInfo blockInfo);
4646
std::size_t RegisterLayer(std::string name, LayerInfo layerInfo);

src/ClientLib/ClientBlockLibrary.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,4 +240,19 @@ namespace tsom
240240
m_previewTextures[blockIndex] = Nz::TextureAsset::CreateView(m_blockTextures[previewTextures[blockIndex].first], slotTexView);
241241
}
242242
}
243+
244+
bool ClientBlockLibrary::LoadFromString(std::string_view content, bool merge)
245+
{
246+
if (!BlockLibrary::LoadFromString(content, merge))
247+
return false;
248+
249+
// Re-enable collisions on the client to allow clients to remove them (player collisions are only handled on the server for now)
250+
// FIXME: Handle this with collisions layers
251+
for (BlockData& blockData : m_blocks)
252+
blockData.hasCollisions = true;
253+
254+
m_blocks[EmptyBlockIndex].hasCollisions = false; //< Except for the empty block
255+
256+
return true;
257+
}
243258
}

0 commit comments

Comments
 (0)