From b3feddfef372618c8a9d7a0abcaf18cfad866c18 Mon Sep 17 00:00:00 2001 From: daoge <3523206925@qq.com> Date: Tue, 3 Mar 2026 03:04:10 +0800 Subject: feat: TU19 (Dec 2014) Features & Content (#155) * try to resolve merge conflict * feat: TU19 (Dec 2014) Features & Content (#32) * December 2014 files * Working release build * Fix compilation issues * Add sound to Windows64Media * Add DLC content and force Tutorial DLC * Revert "Add DLC content and force Tutorial DLC" This reverts commit 97a43994725008e35fceb984d5549df9c8cea470. * Disable broken light packing * Disable breakpoint during DLC texture map load Allows DLC loading but the DLC textures are still broken * Fix post build not working * ... * fix vs2022 build * fix cmake build --------- Co-authored-by: Loki --- Minecraft.World/Level.h | 119 ++++++++++++++++++++++++++++-------------------- 1 file changed, 70 insertions(+), 49 deletions(-) (limited to 'Minecraft.World/Level.h') diff --git a/Minecraft.World/Level.h b/Minecraft.World/Level.h index 361a40e8..6e6b28cd 100644 --- a/Minecraft.World/Level.h +++ b/Minecraft.World/Level.h @@ -41,6 +41,11 @@ class LevelSettings; class Biome; class Villages; class VillageSiege; +class Tickable; +class Minecart; +class EntitySelector; +class Scoreboard; +class GameRules; class Level : public LevelSource { @@ -61,7 +66,7 @@ public: static const int MAX_LEVEL_SIZE = 30000000; static const int maxMovementHeight = 512; // 4J added - static const int minBuildHeight = 0; // 4J - brought forward from 1.2.3 + static const int minBuildHeight = 0; // 4J - brought forward from 1.2.3 static const int maxBuildHeight = 256; // 4J - brought forward from 1.2.3 static const int genDepthBits = 7; static const int genDepthBitsPlusFour = genDepthBits + 4; @@ -84,7 +89,7 @@ public: static bool getCacheTestEnabled(); static bool getInstaTick(); static void setInstaTick(bool enable); -// bool instaTick; // 4J - removed + // bool instaTick; // 4J - removed static const int MAX_BRIGHTNESS = 15; static const int TICKS_PER_DAY = 20 * 60 * 20; // ORG:20*60*20 @@ -124,16 +129,15 @@ public: protected: float oRainLevel, rainLevel; float oThunderLevel, thunderLevel; - int lightningTime; public: - int lightningBoltTime; - bool noNeighborUpdate; + int skyFlashTime; + int difficulty; Random *random; bool isNew; Dimension *dimension; - + protected: vector listeners; @@ -152,6 +156,13 @@ public: shared_ptr villages; VillageSiege *villageSiege; +private: + // 4J - Calendar is now static + // Calendar *calendar; + +protected: + Scoreboard *scoreboard; + public: Biome *getBiome(int x, int z); // 4J - brought forward from 1.2.3 virtual BiomeSource *getBiomeSource(); @@ -164,7 +175,6 @@ private: public: Level(shared_ptrlevelStorage, const wstring& name, Dimension *dimension, LevelSettings *levelSettings, bool doCreateChunkSource = true); - Level(Level *level, Dimension *dimension); Level(shared_ptrlevelStorage, const wstring& levelName, LevelSettings *levelSettings); Level(shared_ptrlevelStorage, const wstring& levelName, LevelSettings *levelSettings, Dimension *fixedDimension, bool doCreateChunkSource = true); @@ -187,6 +197,7 @@ public: bool isEmptyTile(int x, int y, int z); virtual bool isEntityTile(int x, int y, int z); int getTileRenderShape(int x, int y, int z); + int getTileRenderShape(int t); // 4J Added to slightly optimise and avoid getTile call if we already know the tile bool hasChunkAt(int x, int y, int z); bool hasChunksAt(int x, int y, int z, int r); bool hasChunksAt(int x0, int y0, int z0, int x1, int y1, int z1); @@ -201,36 +212,31 @@ public: public: LevelChunk *getChunkAt(int x, int z); LevelChunk *getChunk(int x, int z); - virtual bool setTileAndDataNoUpdate(int x, int y, int z, int tile, int data); - virtual bool setTileAndDataNoUpdate(int x, int y, int z, int tile, int data, bool informClients); - virtual bool setTileNoUpdate(int x, int y, int z, int tile); - bool setTileNoUpdateNoLightCheck(int x, int y, int z, int tile); // 4J added + virtual bool setTileAndData(int x, int y, int z, int tile, int data, int updateFlags); Material *getMaterial(int x, int y, int z); virtual int getData(int x, int y, int z); - void setData(int x, int y, int z, int data, bool forceUpdate=false); // 4J added forceUpdate - virtual bool setDataNoUpdate(int x, int y, int z, int data); - bool setTile(int x, int y, int z, int tile); - bool setTileAndData(int x, int y, int z, int tile, int data); - void sendTileUpdated(int x, int y, int z); + virtual bool setData(int x, int y, int z, int data, int updateFlags, bool forceUpdate =false); // 4J added forceUpdate + virtual bool removeTile(int x, int y, int z); + virtual bool destroyTile(int x, int y, int z, bool dropResources); + virtual bool setTileAndUpdate(int x, int y, int z, int tile); + virtual void sendTileUpdated(int x, int y, int z); public: virtual void tileUpdated(int x, int y, int z, int tile); void lightColumnChanged(int x, int z, int y0, int y1); void setTileDirty(int x, int y, int z); void setTilesDirty(int x0, int y0, int z0, int x1, int y1, int z1); - void swap(int x1, int y1, int z1, int x2, int y2, int z2); void updateNeighborsAt(int x, int y, int z, int tile); - -private: + void updateNeighborsAtExceptFromFacing(int x, int y, int z, int tile, int skipFacing); void neighborChanged(int x, int y, int z, int type); - -public: + virtual bool isTileToBeTickedAt(int x, int y, int z, int tileId); bool canSeeSky(int x, int y, int z); int getDaytimeRawBrightness(int x, int y, int z); int getRawBrightness(int x, int y, int z); int getRawBrightness(int x, int y, int z, bool propagate); bool isSkyLit(int x, int y, int z); int getHeightmap(int x, int z); + int getLowestHeightmap(int x, int z); void updateLightIfOtherThan(LightLayer::variety layer, int x, int y, int z, int expected); int getBrightnessPropagate(LightLayer::variety layer, int x, int y, int z, int tileId); // 4J added tileId void getNeighbourBrightnesses(int *brightnesses, LightLayer::variety layer, int x, int y, int z); // 4J added @@ -247,7 +253,8 @@ public: inline int getBrightnessCached(lightCache_t *cache, LightLayer::variety layer, int x, int y, int z); inline int getEmissionCached(lightCache_t *cache, int ct, int x, int y, int z); inline int getBlockingCached(lightCache_t *cache, LightLayer::variety layer, int *ct, int x, int y, int z); - void initCache(lightCache_t *cache); + void initCachePartial(lightCache_t *cache, int xc, int yc, int zc); + void initCacheComplete(lightCache_t *cache, int xc, int yc, int zc); void flushCache(lightCache_t *cache, __uint64 cacheUse, LightLayer::variety layer); bool cachewritten; @@ -278,10 +285,11 @@ public: HitResult *clip(Vec3 *a, Vec3 *b, bool liquid); HitResult *clip(Vec3 *a, Vec3 *b, bool liquid, bool solidOnly); - virtual void playSound(shared_ptr entity, int iSound, float volume, float pitch); + virtual void playEntitySound(shared_ptr entity, int iSound, float volume, float pitch); + virtual void playPlayerSound(shared_ptr entity, int iSound, float volume, float pitch); virtual void playSound(double x, double y, double z, int iSound, float volume, float pitch, float fClipSoundDist=16.0f); - virtual void playLocalSound(double x, double y, double z, int iSound, float volume, float pitch, float fClipSoundDist=16.0f); + virtual void playLocalSound(double x, double y, double z, int iSound, float volume, float pitch, bool distanceDelay, float fClipSoundDist=16.0f); void playStreamingMusic(const wstring& name, int x, int y, int z); void playMusic(double x, double y, double z, const wstring& string, float volume); @@ -305,13 +313,14 @@ private: AABBList boxes; public: - AABBList *getCubes(shared_ptr source, AABB *box, bool noEntities=false, bool blockAtEdge=false); // 4J - added noEntities & blockAtEdge parameters - AABBList *getTileCubes(AABB *box, bool blockAtEdge); // 4J Stu - Brought forward from 12w36 to fix #46282 - TU5: Gameplay: Exiting the minecart in a tight corridor damages the player + AABBList *getCubes(shared_ptr source, AABB *box, bool noEntities = false, bool blockAtEdge = false); // 4J: Added noEntities & blockAtEdge parameters + AABBList *getTileCubes(AABB *box, bool blockAtEdge = false); // 4J: Added noEntities & blockAtEdge parameters int getOldSkyDarken(float a); // 4J - change brought forward from 1.8.2 float getSkyDarken(float a); // 4J - change brought forward from 1.8.2 Vec3 *getSkyColor(shared_ptr source, float a); float getTimeOfDay(float a); - int getMoonPhase(float a); + int getMoonPhase(); + float getMoonBrightness(); float getSunAngle(float a); Vec3 *getCloudColor(float a); Vec3 *getFogColor(float a); @@ -322,7 +331,8 @@ public: int getLightDepth(int x, int z); float getStarBrightness(float a); virtual void addToTickNextTick(int x, int y, int z, int tileId, int tickDelay); - virtual void forceAddTileTick(int x, int y, int z, int tileId, int tickDelay); + virtual void addToTickNextTick(int x, int y, int z, int tileId, int tickDelay, int priorityTilt); + virtual void forceAddTileTick(int x, int y, int z, int tileId, int tickDelay, int prioTilt); virtual void tickEntities(); void addAllPendingTileEntities(vector< shared_ptr >& entities); void tick(shared_ptr e); @@ -350,7 +360,9 @@ public: virtual bool isSolidRenderTile(int x, int y, int z); virtual bool isSolidBlockingTile(int x, int y, int z); bool isSolidBlockingTileInLoadedChunk(int x, int y, int z, bool valueIfNotLoaded); + bool isFullAABBTile(int x, int y, int z); virtual bool isTopSolidBlocking(int x, int y, int z); // 4J - brought forward from 1.3.2 + bool isTopSolidBlocking(Tile *tile, int data); protected: bool spawnEnemies; @@ -386,7 +398,7 @@ protected: private: int delayUntilNextMoodSound; static const int CHUNK_POLL_RANGE = 9; - static const int CHUNK_TILE_TICK_COUNT = 80; + static const int CHUNK_TILE_TICK_COUNT = 80; static const int CHUNK_SECTION_TILE_TICK_COUNT = (CHUNK_TILE_TICK_COUNT / 8) + 1; protected: @@ -402,9 +414,8 @@ public: bool shouldSnow(int x, int y, int z); void checkLight(int x, int y, int z, bool force = false, bool rootOnlyEmissive = false); // 4J added force, rootOnlySource parameters private: - int *toCheckLevel; - int getExpectedSkyColor(lightCache_t *cache, int oc, int x, int y , int z, int ct, int block); - int getExpectedBlockColor(lightCache_t *cache, int oc, int x, int y, int z, int ct, int block, bool propagatedOnly); // 4J added parameter + int *toCheckLevel; + int getExpectedLight(lightCache_t *cache, int x, int y, int z, LightLayer::variety layer, bool propagatedOnly); public: void checkLight(LightLayer::variety layer, int xc, int yc, int zc, bool force = false, bool rootOnlyEmissive = false); // 4J added force, rootOnlySource parameters @@ -419,29 +430,34 @@ public: bool isClientSide; vector > *getEntities(shared_ptr except, AABB *bb); + vector > *getEntities(shared_ptr except, AABB *bb, const EntitySelector *selector); vector > *getEntitiesOfClass(const type_info& baseClass, AABB *bb); + vector > *getEntitiesOfClass(const type_info& baseClass, AABB *bb, const EntitySelector *selector); shared_ptr getClosestEntityOfClass(const type_info& baseClass, AABB *bb, shared_ptr source); + virtual shared_ptr getEntity(int entityId) = 0; vector > getAllEntities(); void tileEntityChanged(int x, int y, int z, shared_ptr te); -// unsigned int countInstanceOf(BaseObject::Class *clas); + // unsigned int countInstanceOf(BaseObject::Class *clas); unsigned int countInstanceOf(eINSTANCEOF clas, bool singleType, unsigned int *protectedCount = NULL, unsigned int *couldWanderCount = NULL); // 4J added unsigned int countInstanceOfInRange(eINSTANCEOF clas, bool singleType, int range, int x, int y, int z); // 4J Added void addEntities(vector > *list); virtual void removeEntities(vector > *list); - bool mayPlace(int tileId, int x, int y, int z, bool ignoreEntities, int face, shared_ptr ignoreEntity); + bool mayPlace(int tileId, int x, int y, int z, bool ignoreEntities, int face, shared_ptr ignoreEntity, shared_ptr item); int getSeaLevel(); Path *findPath(shared_ptr from, shared_ptr to, float maxDist, bool canPassDoors, bool canOpenDoors, bool avoidWater, bool canFloat); Path *findPath(shared_ptr from, int xBest, int yBest, int zBest, float maxDist, bool canPassDoors, bool canOpenDoors, bool avoidWater, bool canFloat); - bool getDirectSignal(int x, int y, int z, int dir); - bool hasDirectSignal(int x, int y, int z); - bool getSignal(int x, int y, int z, int dir); + int getDirectSignal(int x, int y, int z, int dir); + int getDirectSignalTo(int x, int y, int z); + bool hasSignal(int x, int y, int z, int dir); + int getSignal(int x, int y, int z, int dir); bool hasNeighborSignal(int x, int y, int z); + int getBestNeighborSignal(int x, int y, int z); // 4J Added maxYDist param shared_ptr getNearestPlayer(shared_ptr source, double maxDist, double maxYDist = -1); shared_ptr getNearestPlayer(double x, double y, double z, double maxDist, double maxYDist = -1); shared_ptr getNearestPlayer(double x, double z, double maxDist); - shared_ptr getNearestAttackablePlayer(shared_ptr source, double maxDist); - shared_ptr getNearestAttackablePlayer(double x, double y, double z, double maxDist); + shared_ptr getNearestAttackablePlayer(shared_ptr source, double maxDist); + shared_ptr getNearestAttackablePlayer(double x, double y, double z, double maxDist); shared_ptr getPlayerByName(const wstring& name); shared_ptr getPlayerByUUID(const wstring& name); // 4J Added @@ -449,10 +465,11 @@ public: void setBlocksAndData(int x, int y, int z, int xs, int ys, int zs, byteArray data, bool includeLighting = true); virtual void disconnect(bool sendDisconnect = true); void checkSession(); - void setTime(__int64 time); - void setOverrideTimeOfDay(__int64 time); // 4J Added so we can override timeOfDay without changing tick time + void setGameTime(__int64 time); __int64 getSeed(); - __int64 getTime(); + __int64 getGameTime(); + __int64 getDayTime(); + void setDayTime(__int64 newTime); Pos *getSharedSpawnPos(); void setSpawnPos(int x, int y, int z); void setSpawnPos(Pos *spawnPos); @@ -463,6 +480,7 @@ public: virtual void tileEvent(int x, int y, int z, int tile, int b0, int b1); LevelStorage *getLevelStorage(); LevelData *getLevelData(); + GameRules *getGameRules(); virtual void updateSleepingPlayerList(); bool useNewSeaLevel(); // 4J added bool getHasBeenInCreative(); // 4J Added @@ -479,25 +497,27 @@ public: void setSavedData(const wstring& id, shared_ptr data); shared_ptr getSavedData(const type_info& clazz, const wstring& id); int getFreeAuxValueFor(const wstring& id); + void globalLevelEvent(int type, int sourceX, int sourceY, int sourceZ, int data); void levelEvent(int type, int x, int y, int z, int data); void levelEvent(shared_ptr source, int type, int x, int y, int z, int data); int getMaxBuildHeight(); int getHeight(); + virtual Tickable *makeSoundUpdater(shared_ptr minecart); Random *getRandomFor(int x, int z, int blend); - bool updateLights(); virtual bool isAllEmpty(); double getHorizonHeight() ; void destroyTileProgress(int id, int x, int y, int z, int progress); - TilePos *findNearestMapFeature(const wstring& featureName, int x, int y, int z); + // Calendar *getCalendar(); // 4J - Calendar is now static + virtual void createFireworks(double x, double y, double z, double xd, double yd, double zd, CompoundTag *infoTag); + virtual Scoreboard *getScoreboard(); + virtual void updateNeighbourForOutputSignal(int x, int y, int z, int source); + virtual float getDifficulty(double x, double y, double z); + virtual float getDifficulty(int x, int y, int z); + TilePos *findNearestMapFeature(const wstring& featureName, int x, int y, int z); // 4J Added int getAuxValueForMap(PlayerUID xuid, int dimension, int centreXC, int centreZC, int scale); - // 4J added - - - __int64 m_timeOfDayOverride; - // 4J - optimisation - keep direct reference of underlying cache here LevelChunk **chunkSourceCache; int chunkSourceXZSize; @@ -531,6 +551,7 @@ public: { eSpawnType_Egg, eSpawnType_Breed, + eSpawnType_Portal, }; bool canCreateMore(eINSTANCEOF type, ESPAWN_TYPE spawnType); -- cgit v1.2.3