Botcraft 1.21.4
Loading...
Searching...
No Matches
World.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <atomic>
4#include <memory>
5#include <optional>
6#include <shared_mutex>
7#include <unordered_map>
8
14
16
17namespace std
18{
19 template<>
20 struct hash<pair<int, int>>
21 {
22 inline size_t operator()(const pair<int, int>& p) const
23 {
24 hash<int> hasher;
25 size_t value = hasher(p.first);
26 value ^= hasher(p.second) + 0x9e3779b9 + (value << 6) + (value >> 2);
27 return value;
28 }
29 };
30}
31
32namespace Botcraft
33{
34 class Biome;
35
37 {
38 public:
39 /// @brief
40 /// @param is_shared_ If true, this world can be shared by multiple bot
41 /// instances (assuming they all are and stay in the **same dimension**)
42 World(const bool is_shared_);
43
44 ~World();
45
46 /// @brief Check if a position is in a loaded chunk. Thread-safe
47 /// @param pos Block position
48 /// @return True if the chunk is loaded, false otherwise
49 bool IsLoaded(const Position& pos) const;
50
51 /// @brief is_shared getter
52 /// @return True if world is a shared one, false otherwise
53 bool IsShared() const;
54
55 /// @brief Get height of the current dimension
56 /// @return 256 for versions prior to 1.18, current dimension height otherwise
57 int GetHeight() const;
58
59 /// @brief Get min_y of the current dimension
60 /// @return 0 for versions prior to 1.18, current dimension min_y otherwise
61 int GetMinY() const;
62
63 /// @brief Check if current dimension is Ultrawarm
64 /// @return True if ultrawarm, false otherwise
65 bool IsInUltraWarmDimension() const;
66
67 /// @brief Check if a chunk modification flag is set. Thread-safe
68 /// @param x Chunk X coordinate
69 /// @param z Chunk Z coordinate
70 /// @return True if chunk flag is set, false otherwise
71 bool HasChunkBeenModified(const int x, const int z);
72
73 /// @brief Reset a chunk modification state. Thread-safe
74 /// @param x Chunk X coordinate
75 /// @param z Chunk Z coordinate
76 /// @return A copy of the chunk, or nothing if chunk is not loaded
77 std::optional<Chunk> ResetChunkModificationState(const int x, const int z);
78
79#if PROTOCOL_VERSION < 719 /* < 1.16 */
80 /// @brief Add a chunk at given coordinates. If already exists in another dimension, will be erased first. Thread-safe
81 /// @param x X chunk coordinate
82 /// @param z Z chunk coordinate
83 /// @param dim Dimension in which the chunk is added
84 /// @param loader_id Id of the loader of this chunk (used for shared worlds), default: current thread id
85 void LoadChunk(const int x, const int z, const Dimension dim, const std::thread::id& loader_id = std::this_thread::get_id());
86#else
87 /// @brief Add a chunk at given coordinates. If already exists in another dimension, will be erased first. Thread-safe
88 /// @param x X chunk coordinate
89 /// @param z Z chunk coordinate
90 /// @param dim Dimension in which the chunk is added
91 /// @param loader_id Id of the loader of this chunk (used for shared worlds), default: current thread id
92 void LoadChunk(const int x, const int z, const std::string& dim, const std::thread::id& loader_id = std::this_thread::get_id());
93#endif
94 /// @brief Remove a chunk at given coordinates. Thread-safe
95 /// @param x X chunk coordinate
96 /// @param z Z chunk coordinate
97 /// @param loader_id Id of the loader of this chunk (used for shared worlds), default: current thread id
98 void UnloadChunk(const int x, const int z, const std::thread::id& loader_id = std::this_thread::get_id());
99
100 /// @brief Remove all chunks from memory
101 /// @param loader_id Id of the loader of this chunk (used for shared worlds), default: current thread id
102 void UnloadAllChunks(const std::thread::id& loader_id = std::this_thread::get_id());
103
104
105 /// @brief Set block at given pos. Does nothing if pos is not loaded. Thread-safe
106 /// @param pos Position of the block to set
107 /// @param id Id of the desired block
108 void SetBlock(const Position& pos, const BlockstateId id);
109
110 /// @brief Get the blockstate at a given position. Thread-safe
111 /// @param pos Position of the block
112 /// @return A const pointer to the blockstate at position, nullptr if not loaded
113 const Blockstate* GetBlock(const Position& pos) const;
114
115 /// @brief Get blockstates for a set of positions. More efficient than calling multiple times GetBlock. Thread-safe
116 /// @param pos Positions of the blocks
117 /// @return A vector of const pointer to the blockstate at each position, nullptr if not loaded
118 std::vector<const Blockstate*> GetBlocks(const std::vector<Position>& pos) const;
119
120 /// @brief Get all colliders that could collide with a given AABB. Thread-safe
121 /// @param aabb AABB of the blocks to search for
122 /// @param movement Optional movement vector that will be added to the AABB
123 /// @return A vector of solid colliders
124 std::vector<AABB> GetColliders(const AABB& aabb, const Vector3<double>& movement = Vector3<double>(0.0)) const;
125
126 /// @brief Get the flow of fluid at a given position
127 /// @param pos Block position
128 /// @return A Vector3 of fluid flow
129 Vector3<double> GetFlow(const Position& pos);
130
131 /// @brief Get a read-only locked version of all the loaded chunks
132 /// @return Basically an object you can use as a std::unordered_map<std::pair<int, int>, Chunk>*.
133 /// **ALL WORLD UPDATE WILL BE BLOCKED WHILE THIS OBJECT IS ALIVE**, make sure it goes out of scope
134 /// as soon as you don't need it.
136
137#if PROTOCOL_VERSION < 358 /* < 1.13 */
138 /// @brief Set biome of given block column. Does nothing if not loaded. Thread-safe
139 /// @param x Column X coordinate
140 /// @param z Column Z coordinate
141 /// @param biome Id of the desired biome
142 void SetBiome(const int x, const int z, const unsigned char biome);
143#elif PROTOCOL_VERSION < 552 /* < 1.15 */
144 /// @brief Set biome of given block column. Does nothing if not loaded. Thread-safe
145 /// @param x Column X coordinate
146 /// @param z Column Z coordinate
147 /// @param biome Id of the desired biome
148 void SetBiome(const int x, const int z, const int biome);
149#else
150 /// @brief Set biome of given block. Does nothing if not loaded. Thread-safe
151 /// @param x X coordinate
152 /// @param y Y coordinate
153 /// @param z Z coordinate
154 /// @param biome Id of the desired biome
155 void SetBiome(const int x, const int y, const int z, const int biome);
156#endif
157 /// @brief Get the biome at a given position. Thread-safe
158 /// @param pos Block position
159 /// @return A pointer to the biome, nullptr if not loaded
160 const Biome* GetBiome(const Position& pos) const;
161
162 /// @brief Set sky light value. Thread-safe
163 /// @param pos Block position
164 /// @param skylight Desired sky light value
165 void SetSkyLight(const Position& pos, const unsigned char skylight);
166 /// @brief Set block light value. Thread-safe
167 /// @param pos Block position
168 /// @param blocklight Desired block light value
169 void SetBlockLight(const Position& pos, const unsigned char blocklight);
170
171 /// @brief Get sky light value. Thread-safe
172 /// @param pos Block position
173 /// @return Sky light value at pos, 0 if not loaded or in dimension with no sky light
174 unsigned char GetSkyLight(const Position& pos) const;
175 /// @brief Get block light value. Thread-safe
176 /// @param pos Block position
177 /// @return Block light value at pos, 0 if not loaded
178 unsigned char GetBlockLight(const Position& pos) const;
179
180 /// @brief Set block entity data at pos. Thread-safe
181 /// @param pos Position of the block entity
182 /// @param data Data to set
183 void SetBlockEntityData(const Position& pos, const ProtocolCraft::NBT::Value& data);
184
185 /// @brief Get the block entity data at a given position. Thread-safe
186 /// @param pos Position of the block entity
187 /// @return Copy of the data at pos
189
190#if PROTOCOL_VERSION < 719 /* < 1.16 */
191 /// @brief Get dimension of chunk at given coordinates. Thread-safe
192 /// @param x X chunk coordinate
193 /// @param z Z chunk coordinate
194 /// @return Dimension of the chunk, Dimension::None if chunk is not loaded
195 Dimension GetDimension(const int x, const int z) const;
196#else
197 /// @brief Get dimension of chunk at given coordinates. Thread-safe
198 /// @param x X chunk coordinate
199 /// @param z Z chunk coordinate
200 /// @return Dimension of the chunk, empty if chunk is not loaded
201 std::string GetDimension(const int x, const int z) const;
202#endif
203
204#if PROTOCOL_VERSION < 719 /* < 1.16 */
205 /// @brief Get current world dimension. Thread-safe
206 /// @return Current world dimension
207 Dimension GetCurrentDimension() const;
208#else
209 /// @brief Get current world dimension. Thread-safe
210 /// @return Current world dimension
211 std::string GetCurrentDimension() const;
212#endif
213
214#if PROTOCOL_VERSION < 719 /* < 1.16 */
215 /// @brief Set current world dimension. Thread-safe
216 /// @param dimension Dimension to set
217 void SetCurrentDimension(const Dimension dimension);
218#else
219 /// @brief Set current world dimension. Thread-safe
220 /// @param dimension Dimension to set
221 void SetCurrentDimension(const std::string& dimension);
222#endif
223
224#if PROTOCOL_VERSION > 756 /* > 1.17.1 */
225 /// @brief Set total height for given dimension. Thread-safe
226 /// @param dimension Dimension to set height for
227 /// @param height Total height of dimension
228 void SetDimensionHeight(const std::string& dimension, const int height);
229 /// @brief Set min block for given dimension. Thread-safe
230 /// @param dimension Dimension to set min_y for
231 /// @param min_y Min block of dimension
232 void SetDimensionMinY(const std::string& dimension, const int min_y);
233#endif
234#if PROTOCOL_VERSION > 718 /* > 1.15.2 */
235 /// @brief Set ultrawarm bool for given dimension. Thread-safe
236 /// @param dimension Dimension to set ultrawarm for
237 /// @param ultrawarm Whether the dimension is ultrawam (no water, lava flows faster etc...)
238 void SetDimensionUltrawarm(const std::string& dimension, const bool ultrawarm);
239#endif
240
241 /// @brief Perform a raycast in the voxel world and return position, normal and blockstate which are hit. Thread-safe
242 /// @param origin origin the origin of the ray
243 /// @param direction direction the direction of the ray
244 /// @param max_radius max_radius maximum distance of the search, must be > 0
245 /// @param out_pos out_pos the position of the block hit
246 /// @param out_normal out_normal the normal of the face hit
247 /// @return a pointer to the blockstate of the hit cube (nullptr if not hit)
248 const Blockstate* Raycast(const Vector3<double>& origin, const Vector3<double>& direction,
249 const float max_radius, Position& out_pos, Position& out_normal);
250
251#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
252 /// @brief Get a unique id used for server interactions. Thread-safe
253 /// @return Unique id
255#endif
256
257 /// @brief Check if an AABB collides in the world
258 /// @param aabb AABB to check against the world
259 /// @param fluid_collide if true, will count fluids as collision
260 /// @return True if collision false otherwise
261 bool IsFree(const AABB& aabb, const bool fluid_collide) const;
262
263 /// @brief Get the block position supporting an aabb
264 /// @param aabb The entity AABB
265 /// @return The block position the AABB is on, or empty if no block is found
266 std::optional<Position> GetSupportingBlockPos(const AABB& aabb) const;
267
268 protected:
269 virtual void Handle(ProtocolCraft::ClientboundLoginPacket& msg) override;
270 virtual void Handle(ProtocolCraft::ClientboundRespawnPacket& msg) override;
271 virtual void Handle(ProtocolCraft::ClientboundBlockUpdatePacket& msg) override;
274#if PROTOCOL_VERSION < 757 /* < 1.18 */
275 virtual void Handle(ProtocolCraft::ClientboundLevelChunkPacket& msg) override;
276#else
278#endif
279#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
280 virtual void Handle(ProtocolCraft::ClientboundLightUpdatePacket& msg) override;
281#endif
283#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
284 virtual void Handle(ProtocolCraft::ClientboundChunksBiomesPacket& msg) override;
285#endif
286#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
287 virtual void Handle(ProtocolCraft::ClientboundRegistryDataPacket& msg) override;
288#endif
289
290 private:
291#if PROTOCOL_VERSION < 719 /* < 1.16 */
292 void LoadChunkImpl(const int x, const int z, const Dimension dim, const std::thread::id& loader_id);
293#else
294 void LoadChunkImpl(const int x, const int z, const std::string& dim, const std::thread::id& loader_id);
295#endif
296 void UnloadChunkImpl(const int x, const int z, const std::thread::id& loader_id);
297
298 void SetBlockImpl(const Position& pos, const BlockstateId id);
299 const Blockstate* GetBlockImpl(const Position& pos) const;
300
301#if PROTOCOL_VERSION < 719 /* < 1.16 */
302 void SetCurrentDimensionImpl(const Dimension dimension);
303#else
304 void SetCurrentDimensionImpl(const std::string& dimension);
305#endif
306
307 int GetHeightImpl() const;
308 int GetMinYImpl() const;
309
310#if PROTOCOL_VERSION < 358 /* < 1.13 */
311 void SetBiomeImpl(const int x, const int z, const unsigned char biome);
312#elif PROTOCOL_VERSION < 552 /* < 1.15 */
313 void SetBiomeImpl(const int x, const int z, const int biome);
314#else
315 void SetBiomeImpl(const int x, const int y, const int z, const int biome);
316#endif
317
318 /// @brief Progagate chunk update at pos to neighbouring chunks
319 /// @param chunk_x Chunk X
320 /// @param chunk_z Chunk Z
321 /// @param pos World coordinates of updated block
322 void UpdateChunk(const int chunk_x, const int chunk_z, const Position& pos);
323
324 /// @brief Progagate whole chunk update to neighbouring chunks
325 /// @param chunk_x Chunk X
326 /// @param chunk_z Chunk Z
327 void UpdateChunk(const int chunk_x, const int chunk_z);
328
329 /// @brief Get a pointer to a chunk. Not thread-safe
330 /// @param x Chunk X
331 /// @param z Chunk Z
332 /// @return Pointer to the chunk, or nullptr if not loaded
333 Chunk* GetChunk(const int x, const int z);
334
335#if PROTOCOL_VERSION < 552 /* < 1.15 */
336 void LoadDataInChunk(const int x, const int z, const std::vector<unsigned char>& data,
337 const int primary_bit_mask, const bool ground_up_continuous);
338#elif PROTOCOL_VERSION < 755 /* < 1.17 */
339 void LoadDataInChunk(const int x, const int z, const std::vector<unsigned char>& data,
340 const int primary_bit_mask);
341#elif PROTOCOL_VERSION < 757 /* < 1.18 */
342 void LoadDataInChunk(const int x, const int z, const std::vector<unsigned char>& data,
343 const std::vector<unsigned long long int>& primary_bit_mask);
344#else
345 void LoadDataInChunk(const int x, const int z, const std::vector<unsigned char>& data);
346#endif
347
348#if PROTOCOL_VERSION < 757 /* < 1.18 */
349 void LoadBlockEntityDataInChunk(const int x, const int z, const std::vector<ProtocolCraft::NBT::Value>& block_entities);
350#else
351 void LoadBlockEntityDataInChunk(const int x, const int z, const std::vector<ProtocolCraft::BlockEntityInfo>& block_entities);
352#endif
353
354#if PROTOCOL_VERSION > 551 /* > 1.14.4 */ && PROTOCOL_VERSION < 757 /* < 1.18 */
355 void LoadBiomesInChunk(const int x, const int z, const std::vector<int>& biomes);
356#endif
357
358#if PROTOCOL_VERSION > 404 /* > 1.13.2 */ && PROTOCOL_VERSION < 719 /* < 1.16 */
359 void UpdateChunkLight(const int x, const int z, const Dimension dim, const int light_mask, const int empty_light_mask, const std::vector<std::vector<char> >& data, const bool sky);
360#elif PROTOCOL_VERSION > 718 /* > 1.15.2 */ && PROTOCOL_VERSION < 755 /* < 1.17 */
361 void UpdateChunkLight(const int x, const int z, const std::string& dim, const int light_mask, const int empty_light_mask, const std::vector<std::vector<char> >& data, const bool sky);
362#elif PROTOCOL_VERSION > 754 /* > 1.16.5 */
363 void UpdateChunkLight(const int x, const int z, const std::string& dim,
364 const std::vector<unsigned long long int>& light_mask, const std::vector<unsigned long long int>& empty_light_mask,
365 const std::vector<std::vector<char> >& data, const bool sky);
366#endif
367
368#if PROTOCOL_VERSION < 719 /* < 1.16 */
369 size_t GetDimIndex(const Dimension dim);
370#else
371 size_t GetDimIndex(const std::string& dim);
372#endif
373
374 private:
375 std::unordered_map<std::pair<int, int>, Chunk> terrain;
376 mutable std::shared_mutex world_mutex;
377
378#if PROTOCOL_VERSION > 404 /* > 1.13.2 */ && PROTOCOL_VERSION < 757 /* < 1.18 */
379 std::unordered_map<std::pair<int, int>, ProtocolCraft::ClientboundLightUpdatePacket> delayed_light_updates;
380#endif
381
382 const bool is_shared;
383#if PROTOCOL_VERSION < 719 /* < 1.16 */
384 Dimension current_dimension;
385 std::unordered_map<Dimension, size_t> dimension_index_map;
386 std::unordered_map<size_t, Dimension> index_dimension_map;
387#else
388 std::string current_dimension;
389 std::unordered_map<std::string, size_t> dimension_index_map;
390 std::unordered_map<size_t, std::string> index_dimension_map;
391#endif
392
393#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
395#endif
396
397#if PROTOCOL_VERSION > 756 /* > 1.17.1 */
398 /// @brief Height of the chunks in a given dimension
399 std::unordered_map<std::string, unsigned int> dimension_height;
400 /// @brief Height of the lowest block in a given dimension
401 std::unordered_map<std::string, int> dimension_min_y;
402#endif
403#if PROTOCOL_VERSION > 718 /* > 1.15.2 */
404 std::unordered_map<std::string, bool> dimension_ultrawarm;
405#endif
406 };
407} // Botcraft
Mutex protected reference, will be locked until destroyed.
void SetBlockEntityData(const Position &pos, const ProtocolCraft::NBT::Value &data)
Set block entity data at pos.
Definition World.cpp:375
Vector3< double > GetFlow(const Position &pos)
Get the flow of fluid at a given position.
Definition World.cpp:192
void UnloadChunkImpl(const int x, const int z, const std::thread::id &loader_id)
Definition World.cpp:1020
void SetSkyLight(const Position &pos, const unsigned char skylight)
Set sky light value.
Definition World.cpp:309
std::unordered_map< std::pair< int, int >, Chunk > terrain
Definition World.hpp:375
void UnloadChunk(const int x, const int z, const std::thread::id &loader_id=std::this_thread::get_id())
Remove a chunk at given coordinates.
Definition World.cpp:113
unsigned char GetBlockLight(const Position &pos) const
Get block light value.
Definition World.cpp:358
const Blockstate * GetBlock(const Position &pos) const
Get the blockstate at a given position.
Definition World.cpp:142
bool IsFree(const AABB &aabb, const bool fluid_collide) const
Check if an AABB collides in the world.
Definition World.cpp:613
std::optional< Chunk > ResetChunkModificationState(const int x, const int z)
Reset a chunk modification state.
Definition World.cpp:87
void SetDimensionMinY(const std::string &dimension, const int min_y)
Set min block for given dimension.
Definition World.cpp:472
void SetDimensionUltrawarm(const std::string &dimension, const bool ultrawarm)
Set ultrawarm bool for given dimension.
Definition World.cpp:480
void LoadDataInChunk(const int x, const int z, const std::vector< unsigned char > &data)
Definition World.cpp:1275
void SetCurrentDimensionImpl(const std::string &dimension)
Definition World.cpp:1099
Chunk * GetChunk(const int x, const int z)
Get a pointer to a chunk.
Definition World.cpp:1255
void UpdateChunkLight(const int x, const int z, const std::string &dim, const std::vector< unsigned long long int > &light_mask, const std::vector< unsigned long long int > &empty_light_mask, const std::vector< std::vector< char > > &data, const bool sky)
Definition World.cpp:1326
int GetNextWorldInteractionSequenceId()
Get a unique id used for server interactions.
Definition World.cpp:607
void LoadChunk(const int x, const int z, const std::string &dim, const std::thread::id &loader_id=std::this_thread::get_id())
Add a chunk at given coordinates.
Definition World.cpp:106
std::unordered_map< std::string, size_t > dimension_index_map
Definition World.hpp:389
int GetMinYImpl() const
Definition World.cpp:1117
std::string current_dimension
Definition World.hpp:388
std::unordered_map< size_t, std::string > index_dimension_map
Definition World.hpp:390
bool HasChunkBeenModified(const int x, const int z)
Check if a chunk modification flag is set.
Definition World.cpp:72
bool IsInUltraWarmDimension() const
Check if current dimension is Ultrawarm.
Definition World.cpp:62
void UpdateChunk(const int chunk_x, const int chunk_z, const Position &pos)
Progagate chunk update at pos to neighbouring chunks.
Definition World.cpp:1149
void SetDimensionHeight(const std::string &dimension, const int height)
Set total height for given dimension.
Definition World.cpp:466
int GetHeight() const
Get height of the current dimension.
Definition World.cpp:42
std::unordered_map< std::string, unsigned int > dimension_height
Height of the chunks in a given dimension.
Definition World.hpp:399
const Biome * GetBiome(const Position &pos) const
Get the biome at a given position.
Definition World.cpp:287
const Blockstate * GetBlockImpl(const Position &pos) const
Definition World.cpp:1063
void SetCurrentDimension(const std::string &dimension)
Set current world dimension.
Definition World.cpp:458
void SetBlock(const Position &pos, const BlockstateId id)
Set block at given pos.
Definition World.cpp:136
void SetBlockImpl(const Position &pos, const BlockstateId id)
Definition World.cpp:1036
bool IsLoaded(const Position &pos) const
Check if a position is in a loaded chunk.
Definition World.cpp:27
ProtocolCraft::NBT::Value GetBlockEntityData(const Position &pos) const
Get the block entity data at a given position.
Definition World.cpp:403
std::atomic< int > world_interaction_sequence_id
Definition World.hpp:394
void UnloadAllChunks(const std::thread::id &loader_id=std::this_thread::get_id())
Remove all chunks from memory.
Definition World.cpp:119
int GetHeightImpl() const
Definition World.cpp:1108
virtual void Handle(ProtocolCraft::ClientboundLoginPacket &msg) override
Definition World.cpp:708
void SetBiomeImpl(const int x, const int y, const int z, const int biome)
Definition World.cpp:1131
std::vector< AABB > GetColliders(const AABB &aabb, const Vector3< double > &movement=Vector3< double >(0.0)) const
Get all colliders that could collide with a given AABB.
Definition World.cpp:160
void SetBlockLight(const Position &pos, const unsigned char blocklight)
Set block light value.
Definition World.cpp:325
std::unordered_map< std::string, bool > dimension_ultrawarm
Definition World.hpp:404
std::unordered_map< std::string, int > dimension_min_y
Height of the lowest block in a given dimension.
Definition World.hpp:401
const Blockstate * Raycast(const Vector3< double > &origin, const Vector3< double > &direction, const float max_radius, Position &out_pos, Position &out_normal)
Perform a raycast in the voxel world and return position, normal and blockstate which are hit.
Definition World.cpp:487
void SetBiome(const int x, const int y, const int z, const int biome)
Set biome of given block.
Definition World.cpp:276
void LoadBlockEntityDataInChunk(const int x, const int z, const std::vector< ProtocolCraft::BlockEntityInfo > &block_entities)
Definition World.cpp:1297
unsigned char GetSkyLight(const Position &pos) const
Get sky light value.
Definition World.cpp:341
const bool is_shared
Definition World.hpp:382
size_t GetDimIndex(const std::string &dim)
Definition World.cpp:1429
bool IsShared() const
is_shared getter
Definition World.cpp:37
std::optional< Position > GetSupportingBlockPos(const AABB &aabb) const
Get the block position supporting an aabb.
Definition World.cpp:663
void LoadChunkImpl(const int x, const int z, const std::string &dim, const std::thread::id &loader_id)
Definition World.cpp:977
int GetMinY() const
Get min_y of the current dimension.
Definition World.cpp:52
std::shared_mutex world_mutex
Definition World.hpp:376
std::vector< const Blockstate * > GetBlocks(const std::vector< Position > &pos) const
Get blockstates for a set of positions.
Definition World.cpp:148
Utilities::ScopeLockedWrapper< const std::unordered_map< std::pair< int, int >, Chunk >, std::shared_mutex, std::shared_lock > GetChunks() const
Get a read-only locked version of all the loaded chunks.
Definition World.cpp:266
std::string GetCurrentDimension() const
Get current world dimension.
Definition World.cpp:448
std::string GetDimension(const int x, const int z) const
Get dimension of chunk at given coordinates.
Definition World.cpp:428
unsigned int BlockstateId
STL namespace.
size_t operator()(const pair< int, int > &p) const
Definition World.hpp:22