aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/LevelChunk.h
diff options
context:
space:
mode:
authordaoge <3523206925@qq.com>2026-03-03 03:04:10 +0800
committerGitHub <noreply@github.com>2026-03-03 03:04:10 +0800
commitb3feddfef372618c8a9d7a0abcaf18cfad866c18 (patch)
tree267761c3bb39241ba5c347bfbe2254d06686e287 /Minecraft.World/LevelChunk.h
parent84c31a2331f7a0ec85b9d438992e244f60e5020f (diff)
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 <lokirautio@gmail.com>
Diffstat (limited to 'Minecraft.World/LevelChunk.h')
-rw-r--r--Minecraft.World/LevelChunk.h118
1 files changed, 62 insertions, 56 deletions
diff --git a/Minecraft.World/LevelChunk.h b/Minecraft.World/LevelChunk.h
index e9510ad5..bc45016b 100644
--- a/Minecraft.World/LevelChunk.h
+++ b/Minecraft.World/LevelChunk.h
@@ -5,6 +5,8 @@ class DataLayer;
class TileEntity;
class Random;
class ChunkSource;
+class EntitySelector;
+
#include "SparseLightStorage.h"
#include "CompressedTileStorage.h"
#include "SparseDataStorage.h"
@@ -31,7 +33,7 @@ public:
const int ENTITY_BLOCKS_LENGTH;
static const int BLOCKS_LENGTH = Level::CHUNK_TILE_COUNT; // 4J added
- static bool touchedSky;
+ static bool touchedSky;
enum EColumnFlag
{
@@ -41,7 +43,7 @@ public:
eColumnFlag_biomeHasRain = 8,
};
-// byteArray blocks;
+ // byteArray blocks;
// 4J - actual storage for blocks is now private with public methods to access it
private:
CompressedTileStorage *lowerBlocks; // 0 - 127
@@ -52,10 +54,10 @@ public:
void getBlockData(byteArray data); // Sets data in passed in array of size 32768, from the block data in this chunk
int getBlocksAllocatedSize(int *count0, int *count1, int *count2, int *count4, int *count8);
- bool loaded;
+ bool loaded;
unsigned char rainHeights[16*16]; // 4J - optimisation brought forward from 1.8.2 (was int arrayb in java though)
unsigned char columnFlags[16*8]; // 4J - lighting update brought forward from 1.8.2, was a bool array but now mixed with other flags in our version, and stored in nybbles
- Level *level;
+ Level *level;
// 4J - actual storage for data is now private with public methods to access it
private:
@@ -65,7 +67,7 @@ public:
void setDataData(byteArray data); // Set data to that passed in in the input array of size 32768
void getDataData(byteArray data); // Sets data in passed in array of size 16384, from the data in this chunk
-// DataLayer *data;
+ // DataLayer *data;
private:
// 4J - actual storage for sky & block lights is now private with new methods to be able to access it.
@@ -93,16 +95,16 @@ public:
void readCompressedSkyLightData(DataInputStream *dis);
void readCompressedBlockLightData(DataInputStream *dis);
- byteArray heightmap;
- int minHeight;
- int x, z;
+ byteArray heightmap;
+ int minHeight;
+ int x, z;
private:
bool hasGapsToCheck;
public:
- unordered_map<TilePos, shared_ptr<TileEntity>, TilePosKeyHash, TilePosKeyEq> tileEntities;
- vector<shared_ptr<Entity> > **entityBlocks;
-
+ unordered_map<TilePos, shared_ptr<TileEntity>, TilePosKeyHash, TilePosKeyEq> tileEntities;
+ vector<shared_ptr<Entity> > **entityBlocks;
+
static const int sTerrainPopulatedFromHere = 2;
static const int sTerrainPopulatedFromW = 4;
static const int sTerrainPopulatedFromS = 8;
@@ -116,17 +118,17 @@ public:
static const int sTerrainPopulatedAllNeighbours = 1022; // The post-processing passes of all neighbours to this chunk are complete
static const int sTerrainPostPostProcessed = 1024; // This chunk has been post-post-processed, which is only done when all neighbours have been post-processed
- short terrainPopulated; // 4J - changed from bool to bitfield within short
+ short terrainPopulated; // 4J - changed from bool to bitfield within short
short *serverTerrainPopulated; // 4J added
void setUnsaved(bool unsaved); // 4J added
protected:
// 4J Stu - Stopped this being private so we can add some more logic to it
- bool m_unsaved;
+ bool m_unsaved;
public:
- bool dontSave;
- bool lastSaveHadEntities;
+ bool dontSave;
+ bool lastSaveHadEntities;
#ifdef SHARING_ENABLED
bool sharingTilesAndData; // 4J added
#endif
@@ -135,8 +137,10 @@ public:
virtual void reSyncLighting(); // 4J added
void startSharingTilesAndData(int forceMs = 0); // 4J added
__int64 lastUnsharedTime; // 4J added
- __int64 lastSaveTime;
+ __int64 lastSaveTime;
bool seenByPlayer;
+ int lowestHeightmap;
+ __int64 inhabitedTime;
#ifdef _LARGE_WORLDS
bool m_bUnloaded;
@@ -149,73 +153,74 @@ private:
public:
virtual void init(Level *level, int x, int z);
- LevelChunk(Level *level, int x, int z);
- LevelChunk(Level *level, byteArray blocks, int x, int z);
+ LevelChunk(Level *level, int x, int z);
+ LevelChunk(Level *level, byteArray blocks, int x, int z);
LevelChunk(Level *level, int x, int z, LevelChunk *lc);
~LevelChunk();
- virtual bool isAt(int x, int z);
+ virtual bool isAt(int x, int z);
- virtual int getHeightmap(int x, int z);
+ virtual int getHeightmap(int x, int z);
int getHighestSectionPosition();
- virtual void recalcBlockLights();
+ virtual void recalcBlockLights();
- virtual void recalcHeightmapOnly();
+ virtual void recalcHeightmapOnly();
- virtual void recalcHeightmap();
+ virtual void recalcHeightmap();
- virtual void lightLava();
+ virtual void lightLava();
private:
- void lightGaps(int x, int z);
+ void lightGaps(int x, int z);
// 4J - changes for lighting brought forward from 1.8.2
public:
void recheckGaps(bool bForce = false); // 4J - added parameter, made public
private:
- void lightGap(int x, int z, int source);
+ void lightGap(int x, int z, int source);
void lightGap(int x, int z, int y1, int y2);
- void recalcHeight(int x, int yStart, int z);
+ void recalcHeight(int x, int yStart, int z);
public:
virtual int getTileLightBlock(int x, int y, int z);
- virtual int getTile(int x, int y, int z);
- virtual bool setTileAndData(int x, int y, int z, int _tile, int _data);
- virtual bool setTile(int x, int y, int z, int _tile);
- virtual int getData(int x, int y, int z);
- virtual bool setData(int x, int y, int z, int val, int mask, bool *maskedBitsChanged); // 4J added mask
- virtual int getBrightness(LightLayer::variety layer, int x, int y, int z);
+ virtual int getTile(int x, int y, int z);
+ virtual bool setTileAndData(int x, int y, int z, int _tile, int _data);
+ virtual bool setTile(int x, int y, int z, int _tile);
+ virtual int getData(int x, int y, int z);
+ virtual bool setData(int x, int y, int z, int val, int mask, bool *maskedBitsChanged); // 4J added mask
+ virtual int getBrightness(LightLayer::variety layer, int x, int y, int z);
virtual void getNeighbourBrightnesses(int *brightnesses, LightLayer::variety layer, int x, int y, int z); // 4J added
- virtual void setBrightness(LightLayer::variety layer, int x, int y, int z, int brightness);
- virtual int getRawBrightness(int x, int y, int z, int skyDampen);
- virtual void addEntity(shared_ptr<Entity> e);
- virtual void removeEntity(shared_ptr<Entity> e);
- virtual void removeEntity(shared_ptr<Entity> e, int yc);
- virtual bool isSkyLit(int x, int y, int z);
- virtual void skyBrightnessChanged();
- virtual shared_ptr<TileEntity> getTileEntity(int x, int y, int z);
- virtual void addTileEntity(shared_ptr<TileEntity> te);
- virtual void setTileEntity(int x, int y, int z, shared_ptr<TileEntity> tileEntity);
- virtual void removeTileEntity(int x, int y, int z);
- virtual void load();
- virtual void unload(bool unloadTileEntities) ; // 4J - added parameter
+ virtual void setBrightness(LightLayer::variety layer, int x, int y, int z, int brightness);
+ virtual int getRawBrightness(int x, int y, int z, int skyDampen);
+ virtual void addEntity(shared_ptr<Entity> e);
+ virtual void removeEntity(shared_ptr<Entity> e);
+ virtual void removeEntity(shared_ptr<Entity> e, int yc);
+ virtual bool isSkyLit(int x, int y, int z);
+ virtual void skyBrightnessChanged();
+ virtual shared_ptr<TileEntity> getTileEntity(int x, int y, int z);
+ virtual void addTileEntity(shared_ptr<TileEntity> te);
+ virtual void setTileEntity(int x, int y, int z, shared_ptr<TileEntity> tileEntity);
+ virtual void removeTileEntity(int x, int y, int z);
+ virtual void load();
+ virtual void unload(bool unloadTileEntities) ; // 4J - added parameter
+ virtual bool containsPlayer(); // 4J - added
#ifdef _LARGE_WORLDS
virtual bool isUnloaded();
#endif
- virtual void markUnsaved();
- virtual void getEntities(shared_ptr<Entity> except, AABB *bb, vector<shared_ptr<Entity> > &es);
- virtual void getEntitiesOfClass(const type_info& ec, AABB *bb, vector<shared_ptr<Entity> > &es);
- virtual int countEntities();
- virtual bool shouldSave(bool force);
- virtual int getBlocksAndData(byteArray *data, int x0, int y0, int z0, int x1, int y1, int z1, int p, bool includeLighting = true); // 4J - added includeLighting parameter
+ virtual void markUnsaved();
+ virtual void getEntities(shared_ptr<Entity> except, AABB *bb, vector<shared_ptr<Entity> > &es, const EntitySelector *selector);
+ virtual void getEntitiesOfClass(const type_info& ec, AABB *bb, vector<shared_ptr<Entity> > &es, const EntitySelector *selector);
+ virtual int countEntities();
+ virtual bool shouldSave(bool force);
+ virtual int getBlocksAndData(byteArray *data, int x0, int y0, int z0, int x1, int y1, int z1, int p, bool includeLighting = true); // 4J - added includeLighting parameter
static void tileUpdatedCallback(int x, int y, int z, void *param, int yparam); // 4J added
- virtual int setBlocksAndData(byteArray data, int x0, int y0, int z0, int x1, int y1, int z1, int p, bool includeLighting = true); // 4J - added includeLighting parameter
+ virtual int setBlocksAndData(byteArray data, int x0, int y0, int z0, int x1, int y1, int z1, int p, bool includeLighting = true); // 4J - added includeLighting parameter
virtual bool testSetBlocksAndData(byteArray data, int x0, int y0, int z0, int x1, int y1, int z1, int p); // 4J added
virtual void setCheckAllLight();
- virtual Random *getRandom(__int64 l);
- virtual bool isEmpty();
- virtual void attemptCompression();
+ virtual Random *getRandom(__int64 l);
+ virtual bool isEmpty();
+ virtual void attemptCompression();
#ifdef SHARING_ENABLED
static CRITICAL_SECTION m_csSharing; // 4J added
@@ -234,6 +239,7 @@ public:
void tick(); // 4J - lighting change brought forward from 1.8.2
ChunkPos *getPos();
bool isYSpaceEmpty(int y1, int y2);
+ void reloadBiomes(); // 4J added
virtual Biome *getBiome(int x, int z, BiomeSource *biomeSource);
byteArray getBiomes();
void setBiomes(byteArray biomes);