the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 558 lines 23 kB view raw
1#pragma once 2using namespace std; 3#include "LevelSource.h" 4#include "LightLayer.h" 5#include "ChunkPos.h" 6#include "TickNextTickData.h" 7#include "SavedData.h" 8#include "Definitions.h" 9#include "ParticleTypes.h" 10#include "biome.h" 11#include "C4JThread.h" 12 13#ifdef __PSVITA__ 14#include "..\Minecraft.Client\PSVita\PSVitaExtras\CustomSet.h" 15#endif 16 17// 4J Stu - This value should be big enough that we don't get any crashes causes by memory overwrites, 18// however it does seem way too large for what is actually needed. Needs further investigation 19#define LEVEL_CHUNKS_TO_UPDATE_MAX (19*19*8) 20 21class Vec3; 22class ChunkSource; 23class LevelListener; 24class Explosion; 25class Dimension; 26class Material; 27class TileEntity; 28class AABB; 29class Entity; 30class SavedData; 31class Pos; 32class Player; 33class LevelData; 34class ProgressListener; 35class Random; 36class LevelStorage; 37class SavedDataStorage; 38class HitResult; 39class Path; 40class LevelSettings; 41class Biome; 42class Villages; 43class VillageSiege; 44class Tickable; 45class Minecart; 46class EntitySelector; 47class Scoreboard; 48class GameRules; 49 50class Level : public LevelSource 51{ 52public: 53 static const int MAX_TICK_TILES_PER_TICK = 1000; 54 55 // 4J Added 56 static const int MAX_GRASS_TICKS = 100; 57 static const int MAX_LAVA_TICKS = 100; 58 59 60public: 61 static const int MAX_XBOX_BOATS = 40; // Max number of boats 62 static const int MAX_CONSOLE_MINECARTS = 40; 63 static const int MAX_DISPENSABLE_FIREBALLS = 200; 64 static const int MAX_DISPENSABLE_PROJECTILES = 300; 65 66 static const int MAX_LEVEL_SIZE = 30000000; 67 static const int maxMovementHeight = 512; // 4J added 68 69 static const int minBuildHeight = 0; // 4J - brought forward from 1.2.3 70 static const int maxBuildHeight = 256; // 4J - brought forward from 1.2.3 71 static const int genDepthBits = 7; 72 static const int genDepthBitsPlusFour = genDepthBits + 4; 73 static const int genDepth = 1 << genDepthBits; 74 static const int genDepthMinusOne = genDepth - 1; 75 static const int constSeaLevel = genDepth / 2 - 1; 76 77 static const int CHUNK_TILE_COUNT = maxBuildHeight * 16 * 16; 78 static const int HALF_CHUNK_TILE_COUNT = CHUNK_TILE_COUNT/2; 79 static const int COMPRESSED_CHUNK_SECTION_HEIGHT = 128; 80 static const int COMPRESSED_CHUNK_SECTION_TILES = COMPRESSED_CHUNK_SECTION_HEIGHT * 16 * 16; // 4J Stu - Fixed size 81 82 int seaLevel; 83 84 // 4J - added, making instaTick flag use TLS so we can set it in the chunk rebuilding thread without upsetting the main game thread 85 static DWORD tlsIdx; 86 static DWORD tlsIdxLightCache; 87 static void enableLightingCache(); 88 static void destroyLightingCache(); 89 static bool getCacheTestEnabled(); 90 static bool getInstaTick(); 91 static void setInstaTick(bool enable); 92 // bool instaTick; // 4J - removed 93 94 static const int MAX_BRIGHTNESS = 15; 95 static const int TICKS_PER_DAY = 20 * 60 * 20; // ORG:20*60*20 96 97public: 98 CRITICAL_SECTION m_entitiesCS; // 4J added 99 100 vector<shared_ptr<Entity> > entities; 101 102protected: 103 vector<shared_ptr<Entity> > entitiesToRemove; 104public: 105 bool hasEntitiesToRemove(); // 4J added 106 bool m_bDisableAddNewTileEntities; // 4J Added 107 CRITICAL_SECTION m_tileEntityListCS; // 4J added 108 vector<shared_ptr<TileEntity> > tileEntityList; 109private: 110 vector<shared_ptr<TileEntity> > pendingTileEntities; 111 vector<shared_ptr<TileEntity> > tileEntitiesToUnload; 112 bool updatingTileEntities; 113public: 114 vector<shared_ptr<Player> > players; 115 vector<shared_ptr<Entity> > globalEntities; 116 117private: 118 int cloudColor; 119 120public: 121 int skyDarken; 122 123protected: 124 int randValue; 125 126public: 127 int addend; 128 129protected: 130 float oRainLevel, rainLevel; 131 float oThunderLevel, thunderLevel; 132 133public: 134 int skyFlashTime; 135 136 int difficulty; 137 Random *random; 138 bool isNew; 139 Dimension *dimension; 140 141protected: 142 vector<LevelListener *> listeners; 143 144public: 145 ChunkSource *chunkSource; // 4J - changed to public 146protected: 147 // This is the only shared_ptr ref to levelStorage - we need to keep this as long as at least one Level references it, 148 // to be able to cope with moving from dimension to dimension where the Level(Level *level, Dimension *dimension) ctor is used 149 shared_ptr<LevelStorage> levelStorage; 150 151 LevelData *levelData; 152 153public: 154 bool isFindingSpawn; 155 SavedDataStorage *savedDataStorage; 156 shared_ptr<Villages> villages; 157 VillageSiege *villageSiege; 158 159private: 160 // 4J - Calendar is now static 161 // Calendar *calendar; 162 163protected: 164 Scoreboard *scoreboard; 165 166public: 167 Biome *getBiome(int x, int z); // 4J - brought forward from 1.2.3 168 virtual BiomeSource *getBiomeSource(); 169 170private: 171 172 // 4J Stu - Added these ctors to handle init of member variables 173 void _init(); 174 void _init(shared_ptr<LevelStorage>levelStorage, const wstring& levelName, LevelSettings *levelSettings, Dimension *fixedDimension, bool doCreateChunkSource = true); 175 176public: 177 Level(shared_ptr<LevelStorage>levelStorage, const wstring& name, Dimension *dimension, LevelSettings *levelSettings, bool doCreateChunkSource = true); 178 Level(shared_ptr<LevelStorage>levelStorage, const wstring& levelName, LevelSettings *levelSettings); 179 Level(shared_ptr<LevelStorage>levelStorage, const wstring& levelName, LevelSettings *levelSettings, Dimension *fixedDimension, bool doCreateChunkSource = true); 180 181 virtual ~Level(); 182 183protected: 184 virtual ChunkSource *createChunkSource() = 0; 185 186 virtual void initializeLevel(LevelSettings *settings); 187 188public: 189 virtual bool AllPlayersAreSleeping() { return false; } // 4J Added 190 191 virtual void validateSpawn(); 192 int getTopTile(int x, int z); 193 194public: 195 virtual int getTile(int x, int y, int z); 196 virtual int getTileLightBlock(int x, int y, int z); 197 bool isEmptyTile(int x, int y, int z); 198 virtual bool isEntityTile(int x, int y, int z); 199 int getTileRenderShape(int x, int y, int z); 200 int getTileRenderShape(int t); // 4J Added to slightly optimise and avoid getTile call if we already know the tile 201 bool hasChunkAt(int x, int y, int z); 202 bool hasChunksAt(int x, int y, int z, int r); 203 bool hasChunksAt(int x0, int y0, int z0, int x1, int y1, int z1); 204 bool reallyHasChunkAt(int x, int y, int z); // 4J added 205 bool reallyHasChunksAt(int x, int y, int z, int r); // 4J added 206 bool reallyHasChunksAt(int x0, int y0, int z0, int x1, int y1, int z1); // 4J added 207 208public: 209 bool hasChunk(int x, int z); 210 bool reallyHasChunk(int x, int z ); // 4J added 211 212public: 213 LevelChunk *getChunkAt(int x, int z); 214 LevelChunk *getChunk(int x, int z); 215 virtual bool setTileAndData(int x, int y, int z, int tile, int data, int updateFlags); 216 Material *getMaterial(int x, int y, int z); 217 virtual int getData(int x, int y, int z); 218 virtual bool setData(int x, int y, int z, int data, int updateFlags, bool forceUpdate =false); // 4J added forceUpdate 219 virtual bool removeTile(int x, int y, int z); 220 virtual bool destroyTile(int x, int y, int z, bool dropResources); 221 virtual bool setTileAndUpdate(int x, int y, int z, int tile); 222 virtual void sendTileUpdated(int x, int y, int z); 223 224public: 225 virtual void tileUpdated(int x, int y, int z, int tile); 226 void lightColumnChanged(int x, int z, int y0, int y1); 227 void setTileDirty(int x, int y, int z); 228 void setTilesDirty(int x0, int y0, int z0, int x1, int y1, int z1); 229 void updateNeighborsAt(int x, int y, int z, int tile); 230 void updateNeighborsAtExceptFromFacing(int x, int y, int z, int tile, int skipFacing); 231 void neighborChanged(int x, int y, int z, int type); 232 virtual bool isTileToBeTickedAt(int x, int y, int z, int tileId); 233 bool canSeeSky(int x, int y, int z); 234 int getDaytimeRawBrightness(int x, int y, int z); 235 int getRawBrightness(int x, int y, int z); 236 int getRawBrightness(int x, int y, int z, bool propagate); 237 bool isSkyLit(int x, int y, int z); 238 int getHeightmap(int x, int z); 239 int getLowestHeightmap(int x, int z); 240 void updateLightIfOtherThan(LightLayer::variety layer, int x, int y, int z, int expected); 241 int getBrightnessPropagate(LightLayer::variety layer, int x, int y, int z, int tileId); // 4J added tileId 242 void getNeighbourBrightnesses(int *brightnesses, LightLayer::variety layer, int x, int y, int z); // 4J added 243 int getBrightness(LightLayer::variety layer, int x, int y, int z); 244 void setBrightness(LightLayer::variety layer, int x, int y, int z, int brightness, bool noUpdateOnClient=false); // 4J added noUpdateOnClient 245 void setBrightnessNoUpdateOnClient(LightLayer::variety layer, int x, int y, int z, int brightness); // 4J added 246 247#ifdef _LARGE_WORLDS 248 typedef __uint64 lightCache_t; 249#else 250 typedef unsigned int lightCache_t; 251#endif 252 inline void setBrightnessCached(lightCache_t *cache, __uint64 *cacheUse, LightLayer::variety layer, int x, int y, int z, int brightness); 253 inline int getBrightnessCached(lightCache_t *cache, LightLayer::variety layer, int x, int y, int z); 254 inline int getEmissionCached(lightCache_t *cache, int ct, int x, int y, int z); 255 inline int getBlockingCached(lightCache_t *cache, LightLayer::variety layer, int *ct, int x, int y, int z); 256 void initCachePartial(lightCache_t *cache, int xc, int yc, int zc); 257 void initCacheComplete(lightCache_t *cache, int xc, int yc, int zc); 258 void flushCache(lightCache_t *cache, __uint64 cacheUse, LightLayer::variety layer); 259 260 bool cachewritten; 261 static const int LIGHTING_SHIFT = 24; 262 static const int BLOCKING_SHIFT = 20; 263 static const int EMISSION_SHIFT = 16; 264#ifdef _LARGE_WORLDS 265 static const __int64 LIGHTING_WRITEBACK = 0x80000000LL; 266 static const __int64 EMISSION_VALID = 0x40000000LL; 267 static const __int64 BLOCKING_VALID = 0x20000000LL; 268 static const __int64 LIGHTING_VALID = 0x10000000LL; 269 static const lightCache_t POSITION_MASK = 0xffffffff0000ffffLL; 270#else 271 static const int LIGHTING_WRITEBACK = 0x80000000; 272 static const int EMISSION_VALID = 0x40000000; 273 static const int BLOCKING_VALID = 0x20000000; 274 static const int LIGHTING_VALID = 0x10000000; 275 static const lightCache_t POSITION_MASK = 0x0000ffff; 276#endif 277 278 int cacheminx, cachemaxx, cacheminy, cachemaxy, cacheminz, cachemaxz; 279 void setTileBrightnessChanged(int x, int y, int z); 280 virtual int getLightColor(int x, int y, int z, int emitt, int tileId = -1); // 4J - brought forward from 1.8.2 281 virtual float getBrightness(int x, int y, int z, int emitt); 282 virtual float getBrightness(int x, int y, int z); 283 bool isDay(); 284 HitResult *clip(Vec3 *a, Vec3 *b); 285 HitResult *clip(Vec3 *a, Vec3 *b, bool liquid); 286 HitResult *clip(Vec3 *a, Vec3 *b, bool liquid, bool solidOnly); 287 288 virtual void playEntitySound(shared_ptr<Entity> entity, int iSound, float volume, float pitch); 289 virtual void playPlayerSound(shared_ptr<Player> entity, int iSound, float volume, float pitch); 290 virtual void playSound(double x, double y, double z, int iSound, float volume, float pitch, float fClipSoundDist=16.0f); 291 292 virtual void playLocalSound(double x, double y, double z, int iSound, float volume, float pitch, bool distanceDelay, float fClipSoundDist=16.0f); 293 294 void playStreamingMusic(const wstring& name, int x, int y, int z); 295 void playMusic(double x, double y, double z, const wstring& string, float volume); 296 // 4J removed - void addParticle(const wstring& id, double x, double y, double z, double xd, double yd, double zd); 297 void addParticle(ePARTICLE_TYPE id, double x, double y, double z, double xd, double yd, double zd); // 4J added 298 virtual bool addGlobalEntity(shared_ptr<Entity> e); 299 virtual bool addEntity(shared_ptr<Entity> e); 300 301protected: 302 virtual void entityAdded(shared_ptr<Entity> e); 303 virtual void entityRemoved(shared_ptr<Entity> e); 304 virtual void playerRemoved(shared_ptr<Entity> e); // 4J added 305 306public: 307 virtual void removeEntity(shared_ptr<Entity> e); 308 void removeEntityImmediately(shared_ptr<Entity> e); 309 void addListener(LevelListener *listener); 310 void removeListener(LevelListener *listener); 311 312private: 313 AABBList boxes; 314 315public: 316 AABBList *getCubes(shared_ptr<Entity> source, AABB *box, bool noEntities = false, bool blockAtEdge = false); // 4J: Added noEntities & blockAtEdge parameters 317 AABBList *getTileCubes(AABB *box, bool blockAtEdge = false); // 4J: Added noEntities & blockAtEdge parameters 318 int getOldSkyDarken(float a); // 4J - change brought forward from 1.8.2 319 float getSkyDarken(float a); // 4J - change brought forward from 1.8.2 320 Vec3 *getSkyColor(shared_ptr<Entity> source, float a); 321 float getTimeOfDay(float a); 322 int getMoonPhase(); 323 float getMoonBrightness(); 324 float getSunAngle(float a); 325 Vec3 *getCloudColor(float a); 326 Vec3 *getFogColor(float a); 327 int getTopRainBlock(int x, int z); 328 int getTopSolidBlock(int x, int z); 329 bool biomeHasRain(int x, int z); // 4J added 330 bool biomeHasSnow(int x, int z); // 4J added 331 int getLightDepth(int x, int z); 332 float getStarBrightness(float a); 333 virtual void addToTickNextTick(int x, int y, int z, int tileId, int tickDelay); 334 virtual void addToTickNextTick(int x, int y, int z, int tileId, int tickDelay, int priorityTilt); 335 virtual void forceAddTileTick(int x, int y, int z, int tileId, int tickDelay, int prioTilt); 336 virtual void tickEntities(); 337 void addAllPendingTileEntities(vector< shared_ptr<TileEntity> >& entities); 338 void tick(shared_ptr<Entity> e); 339 virtual void tick(shared_ptr<Entity> e, bool actual); 340 bool isUnobstructed(AABB *aabb); 341 bool isUnobstructed(AABB *aabb, shared_ptr<Entity> ignore); 342 bool containsAnyBlocks(AABB *box); 343 bool containsAnyLiquid(AABB *box); 344 bool containsAnyLiquid_NoLoad(AABB *box); // 4J added 345 bool containsFireTile(AABB *box); 346 bool checkAndHandleWater(AABB *box, Material *material, shared_ptr<Entity> e); 347 bool containsMaterial(AABB *box, Material *material); 348 bool containsLiquid(AABB *box, Material *material); 349 // 4J Stu - destroyBlocks param brought forward as part of fix for tnt cannons 350 shared_ptr<Explosion> explode(shared_ptr<Entity> source, double x, double y, double z, float r, bool destroyBlocks); 351 virtual shared_ptr<Explosion> explode(shared_ptr<Entity> source, double x, double y, double z, float r, bool fire, bool destroyBlocks); 352 float getSeenPercent(Vec3 *center, AABB *bb); 353 bool extinguishFire(shared_ptr<Player> player, int x, int y, int z, int face); 354 wstring gatherStats(); 355 wstring gatherChunkSourceStats(); 356 virtual shared_ptr<TileEntity> getTileEntity(int x, int y, int z); 357 void setTileEntity(int x, int y, int z, shared_ptr<TileEntity> tileEntity); 358 void removeTileEntity(int x, int y, int z); 359 void markForRemoval(shared_ptr<TileEntity> entity); 360 virtual bool isSolidRenderTile(int x, int y, int z); 361 virtual bool isSolidBlockingTile(int x, int y, int z); 362 bool isSolidBlockingTileInLoadedChunk(int x, int y, int z, bool valueIfNotLoaded); 363 bool isFullAABBTile(int x, int y, int z); 364 virtual bool isTopSolidBlocking(int x, int y, int z); // 4J - brought forward from 1.3.2 365 bool isTopSolidBlocking(Tile *tile, int data); 366 367protected: 368 bool spawnEnemies; 369 bool spawnFriendlies; 370 371public: 372 // int xxo, yyo, zzo; 373 374 void updateSkyBrightness(); 375 void setSpawnSettings(bool spawnEnemies, bool spawnFriendlies); 376 virtual void tick(); 377 378private: 379 void prepareWeather(); 380 381protected: 382 virtual void tickWeather(); 383 384private: 385 void stopWeather(); 386 387public: 388 void toggleDownfall(); 389 390protected: 391#ifdef __PSVITA__ 392 // AP - See CustomSet.h for an explanation of this 393 CustomSet chunksToPoll; 394#else 395 unordered_set<ChunkPos,ChunkPosKeyHash,ChunkPosKeyEq> chunksToPoll; 396#endif 397 398private: 399 int delayUntilNextMoodSound; 400 static const int CHUNK_POLL_RANGE = 9; 401 static const int CHUNK_TILE_TICK_COUNT = 80; 402 static const int CHUNK_SECTION_TILE_TICK_COUNT = (CHUNK_TILE_TICK_COUNT / 8) + 1; 403 404protected: 405 virtual void buildAndPrepareChunksToPoll(); 406 virtual void tickClientSideTiles(int xo, int zo, LevelChunk *lc); 407 virtual void tickTiles(); 408 409 // 4J - snow & ice checks brought forward from 1.2.3 410public: 411 bool shouldFreezeIgnoreNeighbors(int x, int y, int z); 412 bool shouldFreeze(int x, int y, int z); 413 bool shouldFreeze(int x, int y, int z, bool checkNeighbors); 414 bool shouldSnow(int x, int y, int z); 415 void checkLight(int x, int y, int z, bool force = false, bool rootOnlyEmissive = false); // 4J added force, rootOnlySource parameters 416private: 417 int *toCheckLevel; 418 int getExpectedLight(lightCache_t *cache, int x, int y, int z, LightLayer::variety layer, bool propagatedOnly); 419public: 420 void checkLight(LightLayer::variety layer, int xc, int yc, int zc, bool force = false, bool rootOnlyEmissive = false); // 4J added force, rootOnlySource parameters 421 422public: 423 virtual bool tickPendingTicks(bool force); 424 virtual vector<TickNextTickData> *fetchTicksInChunk(LevelChunk *chunk, bool remove); 425 426private: 427 vector<shared_ptr<Entity> > es; 428 429public: 430 bool isClientSide; 431 432 vector<shared_ptr<Entity> > *getEntities(shared_ptr<Entity> except, AABB *bb); 433 vector<shared_ptr<Entity> > *getEntities(shared_ptr<Entity> except, AABB *bb, const EntitySelector *selector); 434 vector<shared_ptr<Entity> > *getEntitiesOfClass(const type_info& baseClass, AABB *bb); 435 vector<shared_ptr<Entity> > *getEntitiesOfClass(const type_info& baseClass, AABB *bb, const EntitySelector *selector); 436 shared_ptr<Entity> getClosestEntityOfClass(const type_info& baseClass, AABB *bb, shared_ptr<Entity> source); 437 virtual shared_ptr<Entity> getEntity(int entityId) = 0; 438 vector<shared_ptr<Entity> > getAllEntities(); 439 void tileEntityChanged(int x, int y, int z, shared_ptr<TileEntity> te); 440 // unsigned int countInstanceOf(BaseObject::Class *clas); 441 unsigned int countInstanceOf(eINSTANCEOF clas, bool singleType, unsigned int *protectedCount = NULL, unsigned int *couldWanderCount = NULL); // 4J added 442 unsigned int countInstanceOfInRange(eINSTANCEOF clas, bool singleType, int range, int x, int y, int z); // 4J Added 443 void addEntities(vector<shared_ptr<Entity> > *list); 444 virtual void removeEntities(vector<shared_ptr<Entity> > *list); 445 bool mayPlace(int tileId, int x, int y, int z, bool ignoreEntities, int face, shared_ptr<Entity> ignoreEntity, shared_ptr<ItemInstance> item); 446 int getSeaLevel(); 447 Path *findPath(shared_ptr<Entity> from, shared_ptr<Entity> to, float maxDist, bool canPassDoors, bool canOpenDoors, bool avoidWater, bool canFloat); 448 Path *findPath(shared_ptr<Entity> from, int xBest, int yBest, int zBest, float maxDist, bool canPassDoors, bool canOpenDoors, bool avoidWater, bool canFloat); 449 int getDirectSignal(int x, int y, int z, int dir); 450 int getDirectSignalTo(int x, int y, int z); 451 bool hasSignal(int x, int y, int z, int dir); 452 int getSignal(int x, int y, int z, int dir); 453 bool hasNeighborSignal(int x, int y, int z); 454 int getBestNeighborSignal(int x, int y, int z); 455 // 4J Added maxYDist param 456 shared_ptr<Player> getNearestPlayer(shared_ptr<Entity> source, double maxDist, double maxYDist = -1); 457 shared_ptr<Player> getNearestPlayer(double x, double y, double z, double maxDist, double maxYDist = -1); 458 shared_ptr<Player> getNearestPlayer(double x, double z, double maxDist); 459 shared_ptr<Player> getNearestAttackablePlayer(shared_ptr<Entity> source, double maxDist); 460 shared_ptr<Player> getNearestAttackablePlayer(double x, double y, double z, double maxDist); 461 462 shared_ptr<Player> getPlayerByName(const wstring& name); 463 shared_ptr<Player> getPlayerByUUID(const wstring& name); // 4J Added 464 byteArray getBlocksAndData(int x, int y, int z, int xs, int ys, int zs, bool includeLighting = true); 465 void setBlocksAndData(int x, int y, int z, int xs, int ys, int zs, byteArray data, bool includeLighting = true); 466 virtual void disconnect(bool sendDisconnect = true); 467 void checkSession(); 468 void setGameTime(__int64 time); 469 __int64 getSeed(); 470 __int64 getGameTime(); 471 __int64 getDayTime(); 472 void setDayTime(__int64 newTime); 473 Pos *getSharedSpawnPos(); 474 void setSpawnPos(int x, int y, int z); 475 void setSpawnPos(Pos *spawnPos); 476 void ensureAdded(shared_ptr<Entity> entity); 477 virtual bool mayInteract(shared_ptr<Player> player, int xt, int yt, int zt, int content); 478 virtual void broadcastEntityEvent(shared_ptr<Entity> e, byte event); 479 ChunkSource *getChunkSource(); 480 virtual void tileEvent(int x, int y, int z, int tile, int b0, int b1); 481 LevelStorage *getLevelStorage(); 482 LevelData *getLevelData(); 483 GameRules *getGameRules(); 484 virtual void updateSleepingPlayerList(); 485 bool useNewSeaLevel(); // 4J added 486 bool getHasBeenInCreative(); // 4J Added 487 bool isGenerateMapFeatures(); // 4J Added 488 int getSaveVersion(); 489 int getOriginalSaveVersion(); 490 float getThunderLevel(float a); 491 float getRainLevel(float a); 492 void setRainLevel(float rainLevel); 493 bool isThundering(); 494 bool isRaining(); 495 bool isRainingAt(int x, int y, int z); 496 bool isHumidAt(int x, int y, int z); 497 void setSavedData(const wstring& id, shared_ptr<SavedData> data); 498 shared_ptr<SavedData> getSavedData(const type_info& clazz, const wstring& id); 499 int getFreeAuxValueFor(const wstring& id); 500 void globalLevelEvent(int type, int sourceX, int sourceY, int sourceZ, int data); 501 void levelEvent(int type, int x, int y, int z, int data); 502 void levelEvent(shared_ptr<Player> source, int type, int x, int y, int z, int data); 503 int getMaxBuildHeight(); 504 int getHeight(); 505 virtual Tickable *makeSoundUpdater(shared_ptr<Minecart> minecart); 506 Random *getRandomFor(int x, int z, int blend); 507 virtual bool isAllEmpty(); 508 double getHorizonHeight() ; 509 void destroyTileProgress(int id, int x, int y, int z, int progress); 510 // Calendar *getCalendar(); // 4J - Calendar is now static 511 virtual void createFireworks(double x, double y, double z, double xd, double yd, double zd, CompoundTag *infoTag); 512 virtual Scoreboard *getScoreboard(); 513 virtual void updateNeighbourForOutputSignal(int x, int y, int z, int source); 514 virtual float getDifficulty(double x, double y, double z); 515 virtual float getDifficulty(int x, int y, int z); 516 TilePos *findNearestMapFeature(const wstring& featureName, int x, int y, int z); 517 518 // 4J Added 519 int getAuxValueForMap(PlayerUID xuid, int dimension, int centreXC, int centreZC, int scale); 520 521 // 4J - optimisation - keep direct reference of underlying cache here 522 LevelChunk **chunkSourceCache; 523 int chunkSourceXZSize; 524 525 // 4J - added for implementation of finite limit to number of item entities, tnt and falling block entities 526public: 527 virtual bool newPrimedTntAllowed() { return true; } 528 virtual bool newFallingTileAllowed() { return true; } 529 530 // 4J - added for new lighting from 1.8.2 531 CRITICAL_SECTION m_checkLightCS; 532 533private: 534 int m_iHighestY; // 4J-PB - for the end portal in The End 535public: 536 int GetHighestY() { return m_iHighestY;} 537 void SetHighestY(int iVal) { m_iHighestY=iVal;} 538 539 bool isChunkFinalised(int x, int z); // 4J added 540 bool isChunkPostPostProcessed(int x, int z); // 4J added 541 542private: 543 int m_unsavedChunkCount; 544 545public: 546 int getUnsavedChunkCount(); 547 void incrementUnsavedChunkCount(); // 4J Added 548 void decrementUnsavedChunkCount(); // 4J Added 549 550 enum ESPAWN_TYPE 551 { 552 eSpawnType_Egg, 553 eSpawnType_Breed, 554 eSpawnType_Portal, 555 }; 556 557 bool canCreateMore(eINSTANCEOF type, ESPAWN_TYPE spawnType); 558};