/
Chunk.php
399 lines (328 loc) · 8.11 KB
/
Chunk.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\level\format;
use pocketmine\entity\Entity;
use pocketmine\level\format\generic\SubChunk;
use pocketmine\tile\Tile;
interface Chunk{
const MAX_SUBCHUNKS = 16;
const DATA_ORDER_XZY = 0;
const DATA_ORDER_YZX = 1;
/**
* @return int
*/
public function getX() : int;
/**
* @return int
*/
public function getZ() : int;
public function setX(int $x);
public function setZ(int $z);
/**
* @return LevelProvider|null
*/
public function getProvider();
/**
* @param LevelProvider $provider
*/
public function setProvider(LevelProvider $provider);
/**
* Returns the chunk height in subchunks
*
* @return int
*/
public function getHeight() : int;
/**
* Gets block and meta in one go
*
* @param int $x 0-15
* @param int $y 0-15
* @param int $z 0-15
*
* @return int bitmap, (id << 4) | data
*/
public function getFullBlock(int $x, int $y, int $z) : int;
/**
* @param int $x 0-15
* @param int $y 0-255
* @param int $z 0-15
* @param int $blockId , if null, do not change
* @param int $meta 0-15, if null, do not change
*
* @return bool
*/
public function setBlock(int $x, int $y, int $z, $blockId = null, $meta = null) : bool;
/**
* @param int $x 0-15
* @param int $y 0-255
* @param int $z 0-15
*
* @return int 0-255
*/
public function getBlockId(int $x, int $y, int $z) : int;
/**
* @param int $x 0-15
* @param int $y 0-255
* @param int $z 0-15
* @param int $id 0-255
*/
public function setBlockId(int $x, int $y, int $z, int $id);
/**
* @param int $x 0-15
* @param int $y 0-255
* @param int $z 0-15
*
* @return int 0-15
*/
public function getBlockData(int $x, int $y, int $z) : int;
/**
* @param int $x 0-15
* @param int $y 0-255
* @param int $z 0-15
* @param int $data 0-15
*/
public function setBlockData(int $x, int $y, int $z, int $data);
/**
* @param int $x 0-15
* @param int $y 0-255
* @param int $z 0-15
*
* @return int (16-bit)
*/
public function getBlockExtraData(int $x, int $y, int $z) : int;
/**
* @param int $x 0-15
* @param int $y 0-255
* @param int $z 0-15
* @param int $data (16-bit)
*/
public function setBlockExtraData(int $x, int $y, int $z, int $data);
/**
* @param int $x 0-15
* @param int $y 0-255
* @param int $z 0-15
*
* @return int 0-15
*/
public function getBlockSkyLight(int $x, int $y, int $z) : int;
/**
* @param int $x 0-15
* @param int $y 0-255
* @param int $z 0-15
* @param int $level 0-15
*/
public function setBlockSkyLight(int $x, int $y, int $z, int $level);
/**
* @param int $x 0-15
* @param int $y 0-255
* @param int $z 0-15
*
* @return int 0-15
*/
public function getBlockLight(int $x, int $y, int $z) : int;
/**
* @param int $x 0-15
* @param int $y 0-255
* @param int $z 0-15
* @param int $level 0-15
*/
public function setBlockLight(int $x, int $y, int $z, int $level);
/**
* @param int $x 0-15
* @param int $z 0-15
*
* @return int 0-255
*/
public function getHighestBlockAt(int $x, int $z) : int;
/**
* @param int $x 0-15
* @param int $z 0-15
*
* @return int 0-255
*/
public function getHeightMap(int $x, int $z) : int;
/**
* @param int $x 0-15
* @param int $z 0-15
* @param $value 0-255
*/
public function setHeightMap(int $x, int $z, int $value);
public function recalculateHeightMap();
public function populateSkyLight();
/**
* @param int $x 0-15
* @param int $z 0-15
*
* @return int 0-255
*/
public function getBiomeId(int $x, int $z) : int;
/**
* @param int $x 0-15
* @param int $z 0-15
* @param int $biomeId 0-255
*/
public function setBiomeId(int $x, int $z, int $biomeId);
public function getBlockIdColumn(int $x, int $z) : string;
public function getBlockDataColumn(int $x, int $z) : string;
public function getBlockSkyLightColumn(int $x, int $z) : string;
public function getBlockLightColumn(int $x, int $z) : string;
public function isLightPopulated() : bool;
public function setLightPopulated(bool $value = true);
public function isPopulated() : bool;
public function setPopulated(bool $value = true);
public function isGenerated() : bool;
public function setGenerated(bool $value = true);
/**
* @param Entity $entity
*/
public function addEntity(Entity $entity);
/**
* @param Entity $entity
*/
public function removeEntity(Entity $entity);
/**
* @param Tile $tile
*/
public function addTile(Tile $tile);
/**
* @param Tile $tile
*/
public function removeTile(Tile $tile);
/**
* @return Entity[]
*/
public function getEntities() : array;
/**
* @return Tile[]
*/
public function getTiles() : array;
/**
* @param int $x 0-15
* @param int $y 0-255
* @param int $z 0-15
*/
public function getTile(int $x, int $y, int $z);
/**
* @return bool
*/
public function isLoaded() : bool;
/**
* Loads the chunk
*
* @param bool $generate If the chunk does not exist, generate it
*
* @return bool
*/
public function load(bool $generate = true) : bool;
/**
* @param bool $save
* @param bool $safe If false, unload the chunk even if players are nearby
*
* @return bool
*/
public function unload(bool $save = true, bool $safe = true) : bool;
public function initChunk();
/**
* @return string
*/
public function getBiomeIdArray() : string;
/**
* @return int[]
*/
public function getHeightMapArray() : array;
public function getBlockIdArray() : string;
public function getBlockDataArray() : string;
public function getBlockExtraDataArray() : array;
public function getBlockSkyLightArray() : string;
public function getBlockLightArray() : string;
/**
* @return bool
*/
public function hasChanged() : bool;
/**
* @param bool $changed
*/
public function setChanged(bool $changed = true);
/**
* @param int $fY 0-15
* @param bool $generateNew will set and return a modifiable subchunk
*
* @return SubChunk
*/
public function getSubChunk(int $fY, bool $generateNew = false) : SubChunk;
/**
* @param int $fY 0-15
* @param SubChunk $subChunk
*
* @return bool
*/
public function setSubChunk(int $fY, SubChunk $subChunk = null, bool $allowEmpty = false) : bool;
/**
* @return SubChunk[]
*/
public function getSubChunks() : array;
/**
* Returns the index of the highest non-empty subchunk
*
* @return bool
*/
public function getHighestSubChunkIndex() : int;
/**
* Returns the number of subchunks that need sending
*
* @return int
*/
public function getSubChunkSendCount() : int;
/**
* Disposes of empty subchunks
*/
public function pruneEmptySubChunks();
/**
* Serializes the chunk to network data
*
* @return string
*/
public function networkSerialize() : string;
/**
* Serializes a chunk without compression for use in AsyncTasks.
*
* @return string
*/
public static function fastSerialize(Chunk $chunk) : string;
/**
* Deserializes a chunk from fast serialization
*
* @param string $data
* @param LevelProvider $provider
*
* @return Chunk|null
*/
public static function fastDeserialize(string $data, LevelProvider $provider = null);
/**
* Creates and returns an empty chunk
*
* @param int $chunkX
* @param int $chunkZ
* @param LevelProvider $provider
*
* @return Chunk
*/
public static function getEmptyChunk(int $chunkX, int $chunkZ, LevelProvider $provider = null) : Chunk;
}