2026-03-01 12:16:08 +08:00
# include "stdafx.h"
# include "System.h"
# include "net.minecraft.world.entity.player.h"
# include "com.mojang.nbt.h"
# include "LevelData.h"
# include "LevelType.h"
# include "LevelSettings.h"
LevelData : : LevelData ( )
{
}
LevelData : : LevelData ( CompoundTag * tag )
{
2026-03-03 03:04:10 +08:00
seed = tag - > getLong ( L " RandomSeed " ) ;
2026-03-01 12:16:08 +08:00
m_pGenerator = LevelType : : lvl_normal ;
2026-03-02 17:39:35 +07:00
if ( tag - > contains ( L " generatorName " ) )
2026-03-01 12:16:08 +08:00
{
wstring generatorName = tag - > getString ( L " generatorName " ) ;
m_pGenerator = LevelType : : getLevelType ( generatorName ) ;
2026-03-02 17:39:35 +07:00
if ( m_pGenerator = = NULL )
2026-03-01 12:16:08 +08:00
{
m_pGenerator = LevelType : : lvl_normal ;
2026-03-02 17:39:35 +07:00
}
else if ( m_pGenerator - > hasReplacement ( ) )
2026-03-01 12:16:08 +08:00
{
int generatorVersion = 0 ;
2026-03-02 17:39:35 +07:00
if ( tag - > contains ( L " generatorVersion " ) )
2026-03-01 12:16:08 +08:00
{
generatorVersion = tag - > getInt ( L " generatorVersion " ) ;
}
m_pGenerator = m_pGenerator - > getReplacementForVersion ( generatorVersion ) ;
}
2026-03-03 03:04:10 +08:00
if ( tag - > contains ( L " generatorOptions " ) ) generatorOptions = tag - > getString ( L " generatorOptions " ) ;
2026-03-01 12:16:08 +08:00
}
gameType = GameType : : byId ( tag - > getInt ( L " GameType " ) ) ;
2026-03-03 03:04:10 +08:00
if ( tag - > contains ( L " MapFeatures " ) )
2026-03-01 12:16:08 +08:00
{
2026-03-03 03:04:10 +08:00
generateMapFeatures = tag - > getBoolean ( L " MapFeatures " ) ;
}
2026-03-01 12:16:08 +08:00
else
{
generateMapFeatures = true ;
2026-03-03 03:04:10 +08:00
}
2026-03-01 12:16:08 +08:00
spawnBonusChest = tag - > getBoolean ( L " spawnBonusChest " ) ;
2026-03-03 03:04:10 +08:00
xSpawn = tag - > getInt ( L " SpawnX " ) ;
ySpawn = tag - > getInt ( L " SpawnY " ) ;
zSpawn = tag - > getInt ( L " SpawnZ " ) ;
gameTime = tag - > getLong ( L " Time " ) ;
if ( tag - > contains ( L " DayTime " ) )
{
dayTime = tag - > getLong ( L " DayTime " ) ;
}
else
{
dayTime = gameTime ;
}
lastPlayed = tag - > getLong ( L " LastPlayed " ) ;
sizeOnDisk = tag - > getLong ( L " SizeOnDisk " ) ;
levelName = tag - > getString ( L " LevelName " ) ;
version = tag - > getInt ( L " version " ) ;
rainTime = tag - > getInt ( L " rainTime " ) ;
raining = tag - > getBoolean ( L " raining " ) ;
thunderTime = tag - > getInt ( L " thunderTime " ) ;
thundering = tag - > getBoolean ( L " thundering " ) ;
2026-03-01 12:16:08 +08:00
hardcore = tag - > getBoolean ( L " hardcore " ) ;
if ( tag - > contains ( L " initialized " ) )
{
initialized = tag - > getBoolean ( L " initialized " ) ;
}
else
{
initialized = true ;
}
if ( tag - > contains ( L " allowCommands " ) )
{
allowCommands = tag - > getBoolean ( L " allowCommands " ) ;
}
else
{
allowCommands = gameType = = GameType : : CREATIVE ;
}
2026-03-03 03:04:10 +08:00
// 4J: Game rules are now stored with app game host options
/*if (tag->contains(L"GameRules"))
{
gameRules . loadFromTag ( tag - > getCompound ( L " GameRules " ) ) ;
} */
2026-03-01 12:16:08 +08:00
newSeaLevel = tag - > getBoolean ( L " newSeaLevel " ) ; // 4J added - only use new sea level for newly created maps. This read defaults to false. (sea level changes in 1.8.2)
hasBeenInCreative = tag - > getBoolean ( L " hasBeenInCreative " ) ; // 4J added so we can not award achievements to levels modified in creative
// 4J added - for stronghold position
2026-03-02 17:39:35 +07:00
bStronghold = tag - > getBoolean ( L " hasStronghold " ) ;
2026-03-01 12:16:08 +08:00
if ( bStronghold = = false )
{
// we need to generate the position
xStronghold = yStronghold = zStronghold = 0 ;
}
else
{
xStronghold = tag - > getInt ( L " StrongholdX " ) ;
yStronghold = tag - > getInt ( L " StrongholdY " ) ;
zStronghold = tag - > getInt ( L " StrongholdZ " ) ;
}
// 4J added - for stronghold end portal position
2026-03-02 17:39:35 +07:00
bStrongholdEndPortal = tag - > getBoolean ( L " hasStrongholdEndPortal " ) ;
2026-03-01 12:16:08 +08:00
if ( bStrongholdEndPortal = = false )
{
// we need to generate the position
xStrongholdEndPortal = zStrongholdEndPortal = 0 ;
}
else
{
xStrongholdEndPortal = tag - > getInt ( L " StrongholdEndPortalX " ) ;
zStrongholdEndPortal = tag - > getInt ( L " StrongholdEndPortalZ " ) ;
}
// 4J Added
m_xzSize = tag - > getInt ( L " XZSize " ) ;
m_hellScale = tag - > getInt ( L " HellScale " ) ;
2026-03-03 03:04:10 +08:00
# ifdef _LARGE_WORLDS
m_classicEdgeMoat = tag - > getInt ( L " ClassicMoat " ) ;
m_smallEdgeMoat = tag - > getInt ( L " SmallMoat " ) ;
m_mediumEdgeMoat = tag - > getInt ( L " MediumMoat " ) ;
int newWorldSize = app . GetGameNewWorldSize ( ) ;
int newHellScale = app . GetGameNewHellScale ( ) ;
m_hellScaleOld = m_hellScale ;
m_xzSizeOld = m_xzSize ;
if ( newWorldSize > m_xzSize )
{
bool bUseMoat = app . GetGameNewWorldSizeUseMoat ( ) ;
switch ( m_xzSize )
{
case LEVEL_WIDTH_CLASSIC : m_classicEdgeMoat = bUseMoat ; break ;
case LEVEL_WIDTH_SMALL : m_smallEdgeMoat = bUseMoat ; break ;
case LEVEL_WIDTH_MEDIUM : m_mediumEdgeMoat = bUseMoat ; break ;
default : assert ( 0 ) ; break ;
}
assert ( newWorldSize > m_xzSize ) ;
m_xzSize = newWorldSize ;
m_hellScale = newHellScale ;
}
# endif
2026-03-01 12:16:08 +08:00
m_xzSize = min ( m_xzSize , LEVEL_MAX_WIDTH ) ;
m_xzSize = max ( m_xzSize , LEVEL_MIN_WIDTH ) ;
m_hellScale = min ( m_hellScale , HELL_LEVEL_MAX_SCALE ) ;
m_hellScale = max ( m_hellScale , HELL_LEVEL_MIN_SCALE ) ;
int hellXZSize = m_xzSize / m_hellScale ;
while ( hellXZSize > HELL_LEVEL_MAX_WIDTH & & m_hellScale < HELL_LEVEL_MAX_SCALE )
{
+ + m_hellScale ;
hellXZSize = m_xzSize / m_hellScale ;
}
2026-03-03 03:04:10 +08:00
# ifdef _LARGE_WORLDS
// set the host option, in case it wasn't setup already
EGameHostOptionWorldSize hostOptionworldSize = e_worldSize_Unknown ;
switch ( m_xzSize )
{
case LEVEL_WIDTH_CLASSIC : hostOptionworldSize = e_worldSize_Classic ; break ;
case LEVEL_WIDTH_SMALL : hostOptionworldSize = e_worldSize_Small ; break ;
case LEVEL_WIDTH_MEDIUM : hostOptionworldSize = e_worldSize_Medium ; break ;
case LEVEL_WIDTH_LARGE : hostOptionworldSize = e_worldSize_Large ; break ;
default : assert ( 0 ) ; break ;
}
app . SetGameHostOption ( eGameHostOption_WorldSize , hostOptionworldSize ) ;
# endif
2026-03-01 12:16:08 +08:00
/* 4J - we don't store this anymore
2026-03-03 03:04:10 +08:00
if ( tag - > contains ( L " Player " ) )
2026-03-01 12:16:08 +08:00
{
2026-03-03 03:04:10 +08:00
loadedPlayerTag = tag - > getCompound ( L " Player " ) ;
dimension = loadedPlayerTag - > getInt ( L " Dimension " ) ;
}
2026-03-01 12:16:08 +08:00
else
2026-03-02 17:39:35 +07:00
{
2026-03-03 03:04:10 +08:00
this - > loadedPlayerTag = NULL ;
2026-03-01 12:16:08 +08:00
}
*/
dimension = 0 ;
}
2026-03-02 17:39:35 +07:00
LevelData : : LevelData ( LevelSettings * levelSettings , const wstring & levelName )
2026-03-01 12:16:08 +08:00
{
2026-03-03 03:04:10 +08:00
seed = levelSettings - > getSeed ( ) ;
gameType = levelSettings - > getGameType ( ) ;
generateMapFeatures = levelSettings - > isGenerateMapFeatures ( ) ;
spawnBonusChest = levelSettings - > hasStartingBonusItems ( ) ;
this - > levelName = levelName ;
m_pGenerator = levelSettings - > getLevelType ( ) ;
hardcore = levelSettings - > isHardcore ( ) ;
generatorOptions = levelSettings - > getLevelTypeOptions ( ) ;
allowCommands = levelSettings - > getAllowCommands ( ) ;
2026-03-01 12:16:08 +08:00
2026-03-02 17:39:35 +07:00
// 4J Stu - Default initers
2026-03-03 03:04:10 +08:00
xSpawn = 0 ;
ySpawn = 0 ;
zSpawn = 0 ;
dayTime = - 1 ; // 4J-JEV: Edited: To know when this is uninitialized.
gameTime = - 1 ;
lastPlayed = 0 ;
sizeOnDisk = 0 ;
// this->loadedPlayerTag = NULL; // 4J - we don't store this anymore
dimension = 0 ;
version = 0 ;
rainTime = 0 ;
raining = false ;
thunderTime = 0 ;
thundering = false ;
initialized = false ;
newSeaLevel = levelSettings - > useNewSeaLevel ( ) ; // 4J added - only use new sea level for newly created maps (sea level changes in 1.8.2)
hasBeenInCreative = levelSettings - > getGameType ( ) = = GameType : : CREATIVE ; // 4J added
2026-03-01 12:16:08 +08:00
// 4J-PB for the stronghold position
2026-03-03 03:04:10 +08:00
bStronghold = false ;
xStronghold = 0 ;
yStronghold = 0 ;
zStronghold = 0 ;
xStrongholdEndPortal = 0 ;
zStrongholdEndPortal = 0 ;
bStrongholdEndPortal = false ;
2026-03-01 12:16:08 +08:00
m_xzSize = levelSettings - > getXZSize ( ) ;
m_hellScale = levelSettings - > getHellScale ( ) ;
2026-03-03 03:04:10 +08:00
2026-03-01 12:16:08 +08:00
m_xzSize = min ( m_xzSize , LEVEL_MAX_WIDTH ) ;
m_xzSize = max ( m_xzSize , LEVEL_MIN_WIDTH ) ;
m_hellScale = min ( m_hellScale , HELL_LEVEL_MAX_SCALE ) ;
m_hellScale = max ( m_hellScale , HELL_LEVEL_MIN_SCALE ) ;
int hellXZSize = m_xzSize / m_hellScale ;
while ( hellXZSize > HELL_LEVEL_MAX_WIDTH & & m_hellScale < HELL_LEVEL_MAX_SCALE )
{
+ + m_hellScale ;
hellXZSize = m_xzSize / m_hellScale ;
2026-03-03 03:04:10 +08:00
}
# ifdef _LARGE_WORLDS
m_hellScaleOld = m_hellScale ;
m_xzSizeOld = m_xzSize ;
m_classicEdgeMoat = false ;
m_smallEdgeMoat = false ;
m_mediumEdgeMoat = false ;
# endif
2026-03-01 12:16:08 +08:00
}
LevelData : : LevelData ( LevelData * copy )
{
2026-03-03 03:04:10 +08:00
seed = copy - > seed ;
m_pGenerator = copy - > m_pGenerator ;
generatorOptions = copy - > generatorOptions ;
gameType = copy - > gameType ;
generateMapFeatures = copy - > generateMapFeatures ;
spawnBonusChest = copy - > spawnBonusChest ;
xSpawn = copy - > xSpawn ;
ySpawn = copy - > ySpawn ;
zSpawn = copy - > zSpawn ;
gameTime = copy - > gameTime ;
dayTime = copy - > dayTime ;
lastPlayed = copy - > lastPlayed ;
sizeOnDisk = copy - > sizeOnDisk ;
// this->loadedPlayerTag = copy->loadedPlayerTag; // 4J - we don't store this anymore
dimension = copy - > dimension ;
levelName = copy - > levelName ;
version = copy - > version ;
rainTime = copy - > rainTime ;
raining = copy - > raining ;
thunderTime = copy - > thunderTime ;
thundering = copy - > thundering ;
hardcore = copy - > hardcore ;
allowCommands = copy - > allowCommands ;
initialized = copy - > initialized ;
newSeaLevel = copy - > newSeaLevel ;
hasBeenInCreative = copy - > hasBeenInCreative ;
gameRules = copy - > gameRules ;
2026-03-01 12:16:08 +08:00
// 4J-PB for the stronghold position
2026-03-03 03:04:10 +08:00
bStronghold = copy - > bStronghold ;
xStronghold = copy - > xStronghold ;
yStronghold = copy - > yStronghold ;
zStronghold = copy - > zStronghold ;
xStrongholdEndPortal = copy - > xStrongholdEndPortal ;
zStrongholdEndPortal = copy - > zStrongholdEndPortal ;
bStrongholdEndPortal = copy - > bStrongholdEndPortal ;
2026-03-01 12:16:08 +08:00
m_xzSize = copy - > m_xzSize ;
m_hellScale = copy - > m_hellScale ;
2026-03-03 03:04:10 +08:00
# ifdef _LARGE_WORLDS
m_classicEdgeMoat = copy - > m_classicEdgeMoat ;
m_smallEdgeMoat = copy - > m_smallEdgeMoat ;
m_mediumEdgeMoat = copy - > m_mediumEdgeMoat ;
m_xzSizeOld = copy - > m_xzSizeOld ;
m_hellScaleOld = copy - > m_hellScaleOld ;
# endif
2026-03-01 12:16:08 +08:00
}
CompoundTag * LevelData : : createTag ( )
{
2026-03-03 03:04:10 +08:00
CompoundTag * tag = new CompoundTag ( ) ;
2026-03-01 12:16:08 +08:00
2026-03-03 03:04:10 +08:00
setTagData ( tag ) ;
2026-03-01 12:16:08 +08:00
2026-03-03 03:04:10 +08:00
return tag ;
2026-03-01 12:16:08 +08:00
}
2026-03-02 17:39:35 +07:00
CompoundTag * LevelData : : createTag ( vector < shared_ptr < Player > > * players )
2026-03-01 12:16:08 +08:00
{
// 4J - removed all code for storing tags for players
return createTag ( ) ;
}
2026-03-02 17:39:35 +07:00
void LevelData : : setTagData ( CompoundTag * tag )
2026-03-01 12:16:08 +08:00
{
2026-03-03 03:04:10 +08:00
tag - > putLong ( L " RandomSeed " , seed ) ;
2026-03-01 12:16:08 +08:00
tag - > putString ( L " generatorName " , m_pGenerator - > getGeneratorName ( ) ) ;
tag - > putInt ( L " generatorVersion " , m_pGenerator - > getVersion ( ) ) ;
2026-03-03 03:04:10 +08:00
tag - > putString ( L " generatorOptions " , generatorOptions ) ;
tag - > putInt ( L " GameType " , gameType - > getId ( ) ) ;
tag - > putBoolean ( L " MapFeatures " , generateMapFeatures ) ;
2026-03-01 12:16:08 +08:00
tag - > putBoolean ( L " spawnBonusChest " , spawnBonusChest ) ;
2026-03-03 03:04:10 +08:00
tag - > putInt ( L " SpawnX " , xSpawn ) ;
tag - > putInt ( L " SpawnY " , ySpawn ) ;
tag - > putInt ( L " SpawnZ " , zSpawn ) ;
tag - > putLong ( L " Time " , gameTime ) ;
tag - > putLong ( L " DayTime " , dayTime ) ;
tag - > putLong ( L " SizeOnDisk " , sizeOnDisk ) ;
tag - > putLong ( L " LastPlayed " , System : : currentTimeMillis ( ) ) ;
tag - > putString ( L " LevelName " , levelName ) ;
tag - > putInt ( L " version " , version ) ;
tag - > putInt ( L " rainTime " , rainTime ) ;
tag - > putBoolean ( L " raining " , raining ) ;
tag - > putInt ( L " thunderTime " , thunderTime ) ;
tag - > putBoolean ( L " thundering " , thundering ) ;
2026-03-01 12:16:08 +08:00
tag - > putBoolean ( L " hardcore " , hardcore ) ;
tag - > putBoolean ( L " allowCommands " , allowCommands ) ;
tag - > putBoolean ( L " initialized " , initialized ) ;
2026-03-03 03:04:10 +08:00
// 4J: Game rules are now stored with app game host options
//tag->putCompound(L"GameRules", gameRules.createTag());
2026-03-01 12:16:08 +08:00
tag - > putBoolean ( L " newSeaLevel " , newSeaLevel ) ;
tag - > putBoolean ( L " hasBeenInCreative " , hasBeenInCreative ) ;
// store the stronghold position
tag - > putBoolean ( L " hasStronghold " , bStronghold ) ;
tag - > putInt ( L " StrongholdX " , xStronghold ) ;
tag - > putInt ( L " StrongholdY " , yStronghold ) ;
tag - > putInt ( L " StrongholdZ " , zStronghold ) ;
// store the stronghold end portal position
tag - > putBoolean ( L " hasStrongholdEndPortal " , bStrongholdEndPortal ) ;
tag - > putInt ( L " StrongholdEndPortalX " , xStrongholdEndPortal ) ;
tag - > putInt ( L " StrongholdEndPortalZ " , zStrongholdEndPortal ) ;
tag - > putInt ( L " XZSize " , m_xzSize ) ;
2026-03-03 03:04:10 +08:00
# ifdef _LARGE_WORLDS
tag - > putInt ( L " ClassicMoat " , m_classicEdgeMoat ) ;
tag - > putInt ( L " SmallMoat " , m_smallEdgeMoat ) ;
tag - > putInt ( L " MediumMoat " , m_mediumEdgeMoat ) ;
# endif
2026-03-01 12:16:08 +08:00
tag - > putInt ( L " HellScale " , m_hellScale ) ;
}
2026-03-02 17:39:35 +07:00
__int64 LevelData : : getSeed ( )
2026-03-01 12:16:08 +08:00
{
2026-03-03 03:04:10 +08:00
return seed ;
2026-03-01 12:16:08 +08:00
}
2026-03-02 17:39:35 +07:00
int LevelData : : getXSpawn ( )
2026-03-01 12:16:08 +08:00
{
2026-03-03 03:04:10 +08:00
return xSpawn ;
2026-03-01 12:16:08 +08:00
}
2026-03-02 17:39:35 +07:00
int LevelData : : getYSpawn ( )
2026-03-01 12:16:08 +08:00
{
2026-03-03 03:04:10 +08:00
return ySpawn ;
2026-03-01 12:16:08 +08:00
}
int LevelData : : getZSpawn ( )
{
2026-03-03 03:04:10 +08:00
return zSpawn ;
2026-03-01 12:16:08 +08:00
}
2026-03-02 17:39:35 +07:00
int LevelData : : getXStronghold ( )
2026-03-01 12:16:08 +08:00
{
return xStronghold ;
}
int LevelData : : getZStronghold ( )
{
return zStronghold ;
}
2026-03-02 17:39:35 +07:00
int LevelData : : getXStrongholdEndPortal ( )
2026-03-01 12:16:08 +08:00
{
return xStrongholdEndPortal ;
}
int LevelData : : getZStrongholdEndPortal ( )
{
return zStrongholdEndPortal ;
}
2026-03-03 03:04:10 +08:00
__int64 LevelData : : getGameTime ( )
2026-03-01 12:16:08 +08:00
{
2026-03-03 03:04:10 +08:00
return gameTime ;
}
__int64 LevelData : : getDayTime ( )
{
return dayTime ;
2026-03-01 12:16:08 +08:00
}
2026-03-02 17:39:35 +07:00
__int64 LevelData : : getSizeOnDisk ( )
2026-03-01 12:16:08 +08:00
{
2026-03-03 03:04:10 +08:00
return sizeOnDisk ;
2026-03-01 12:16:08 +08:00
}
CompoundTag * LevelData : : getLoadedPlayerTag ( )
{
2026-03-03 03:04:10 +08:00
return NULL ; // 4J - we don't store this anymore
2026-03-01 12:16:08 +08:00
}
// 4J Removed TU9 as it's never accurate due to the dimension never being set
//int LevelData::getDimension()
//{
// return dimension;
//}
2026-03-02 17:39:35 +07:00
void LevelData : : setSeed ( __int64 seed )
2026-03-01 12:16:08 +08:00
{
2026-03-03 03:04:10 +08:00
this - > seed = seed ;
2026-03-01 12:16:08 +08:00
}
void LevelData : : setXSpawn ( int xSpawn )
{
2026-03-03 03:04:10 +08:00
this - > xSpawn = xSpawn ;
2026-03-01 12:16:08 +08:00
}
2026-03-02 17:39:35 +07:00
void LevelData : : setYSpawn ( int ySpawn )
2026-03-01 12:16:08 +08:00
{
2026-03-03 03:04:10 +08:00
this - > ySpawn = ySpawn ;
2026-03-01 12:16:08 +08:00
}
void LevelData : : setZSpawn ( int zSpawn )
{
2026-03-03 03:04:10 +08:00
this - > zSpawn = zSpawn ;
2026-03-01 12:16:08 +08:00
}
void LevelData : : setHasStronghold ( )
{
this - > bStronghold = true ;
}
bool LevelData : : getHasStronghold ( )
{
return this - > bStronghold ;
}
void LevelData : : setXStronghold ( int xStronghold )
{
this - > xStronghold = xStronghold ;
}
void LevelData : : setZStronghold ( int zStronghold )
{
this - > zStronghold = zStronghold ;
}
void LevelData : : setHasStrongholdEndPortal ( )
{
this - > bStrongholdEndPortal = true ;
}
bool LevelData : : getHasStrongholdEndPortal ( )
{
return this - > bStrongholdEndPortal ;
}
void LevelData : : setXStrongholdEndPortal ( int xStrongholdEndPortal )
{
this - > xStrongholdEndPortal = xStrongholdEndPortal ;
}
void LevelData : : setZStrongholdEndPortal ( int zStrongholdEndPortal )
{
this - > zStrongholdEndPortal = zStrongholdEndPortal ;
}
2026-03-03 03:04:10 +08:00
void LevelData : : setGameTime ( __int64 time )
{
gameTime = time ;
}
void LevelData : : setDayTime ( __int64 time )
2026-03-01 12:16:08 +08:00
{
2026-03-03 03:04:10 +08:00
dayTime = time ;
2026-03-01 12:16:08 +08:00
}
2026-03-02 17:39:35 +07:00
void LevelData : : setSizeOnDisk ( __int64 sizeOnDisk )
2026-03-01 12:16:08 +08:00
{
2026-03-03 03:04:10 +08:00
this - > sizeOnDisk = sizeOnDisk ;
2026-03-01 12:16:08 +08:00
}
void LevelData : : setLoadedPlayerTag ( CompoundTag * loadedPlayerTag )
{
// 4J - we don't store this anymore
2026-03-03 03:04:10 +08:00
// this->loadedPlayerTag = loadedPlayerTag;
2026-03-01 12:16:08 +08:00
}
// 4J Remove TU9 as it's never used
2026-03-02 17:39:35 +07:00
//void LevelData::setDimension(int dimension)
2026-03-01 12:16:08 +08:00
//{
// this->dimension = dimension;
//}
void LevelData : : setSpawn ( int xSpawn , int ySpawn , int zSpawn )
{
2026-03-03 03:04:10 +08:00
this - > xSpawn = xSpawn ;
this - > ySpawn = ySpawn ;
this - > zSpawn = zSpawn ;
2026-03-01 12:16:08 +08:00
}
2026-03-02 17:39:35 +07:00
wstring LevelData : : getLevelName ( )
2026-03-01 12:16:08 +08:00
{
2026-03-03 03:04:10 +08:00
return levelName ;
2026-03-01 12:16:08 +08:00
}
void LevelData : : setLevelName ( const wstring & levelName )
{
2026-03-03 03:04:10 +08:00
this - > levelName = levelName ;
2026-03-01 12:16:08 +08:00
}
2026-03-02 17:39:35 +07:00
int LevelData : : getVersion ( )
2026-03-01 12:16:08 +08:00
{
2026-03-03 03:04:10 +08:00
return version ;
2026-03-01 12:16:08 +08:00
}
void LevelData : : setVersion ( int version )
{
2026-03-03 03:04:10 +08:00
this - > version = version ;
2026-03-01 12:16:08 +08:00
}
2026-03-02 17:39:35 +07:00
__int64 LevelData : : getLastPlayed ( )
2026-03-01 12:16:08 +08:00
{
2026-03-03 03:04:10 +08:00
return lastPlayed ;
2026-03-01 12:16:08 +08:00
}
bool LevelData : : isThundering ( )
{
2026-03-03 03:04:10 +08:00
return thundering ;
2026-03-01 12:16:08 +08:00
}
void LevelData : : setThundering ( bool thundering )
{
2026-03-03 03:04:10 +08:00
this - > thundering = thundering ;
2026-03-01 12:16:08 +08:00
}
int LevelData : : getThunderTime ( )
{
2026-03-03 03:04:10 +08:00
return thunderTime ;
2026-03-01 12:16:08 +08:00
}
void LevelData : : setThunderTime ( int thunderTime )
{
2026-03-03 03:04:10 +08:00
this - > thunderTime = thunderTime ;
2026-03-01 12:16:08 +08:00
}
2026-03-02 17:39:35 +07:00
bool LevelData : : isRaining ( )
2026-03-01 12:16:08 +08:00
{
2026-03-03 03:04:10 +08:00
return raining ;
2026-03-01 12:16:08 +08:00
}
void LevelData : : setRaining ( bool raining )
{
2026-03-03 03:04:10 +08:00
this - > raining = raining ;
2026-03-01 12:16:08 +08:00
}
int LevelData : : getRainTime ( )
{
2026-03-03 03:04:10 +08:00
return rainTime ;
2026-03-01 12:16:08 +08:00
}
void LevelData : : setRainTime ( int rainTime )
{
2026-03-03 03:04:10 +08:00
this - > rainTime = rainTime ;
2026-03-01 12:16:08 +08:00
}
GameType * LevelData : : getGameType ( )
{
return gameType ;
}
bool LevelData : : isGenerateMapFeatures ( )
{
return generateMapFeatures ;
}
bool LevelData : : getSpawnBonusChest ( )
{
return spawnBonusChest ;
}
void LevelData : : setGameType ( GameType * gameType )
{
this - > gameType = gameType ;
// 4J Added
2026-03-03 03:04:10 +08:00
hasBeenInCreative = hasBeenInCreative | |
( gameType = = GameType : : CREATIVE ) | |
( app . GetGameHostOption ( eGameHostOption_CheatsEnabled ) > 0 ) ;
2026-03-01 12:16:08 +08:00
}
bool LevelData : : useNewSeaLevel ( )
{
return newSeaLevel ;
}
bool LevelData : : getHasBeenInCreative ( )
{
return hasBeenInCreative ;
}
void LevelData : : setHasBeenInCreative ( bool value )
{
hasBeenInCreative = value ;
}
2026-03-02 17:39:35 +07:00
LevelType * LevelData : : getGenerator ( )
2026-03-01 12:16:08 +08:00
{
return m_pGenerator ;
}
2026-03-02 17:39:35 +07:00
void LevelData : : setGenerator ( LevelType * generator )
2026-03-01 12:16:08 +08:00
{
m_pGenerator = generator ;
}
2026-03-03 03:04:10 +08:00
wstring LevelData : : getGeneratorOptions ( )
{
return generatorOptions ;
}
void LevelData : : setGeneratorOptions ( const wstring & options )
{
generatorOptions = options ;
}
2026-03-01 12:16:08 +08:00
bool LevelData : : isHardcore ( )
{
return hardcore ;
}
bool LevelData : : getAllowCommands ( )
{
return allowCommands ;
}
void LevelData : : setAllowCommands ( bool allowCommands )
{
this - > allowCommands = allowCommands ;
}
bool LevelData : : isInitialized ( )
{
return initialized ;
}
void LevelData : : setInitialized ( bool initialized )
{
this - > initialized = initialized ;
}
2026-03-03 03:04:10 +08:00
GameRules * LevelData : : getGameRules ( )
{
return & gameRules ;
}
2026-03-01 12:16:08 +08:00
int LevelData : : getXZSize ( )
{
return m_xzSize ;
}
2026-03-03 03:04:10 +08:00
# ifdef _LARGE_WORLDS
int LevelData : : getXZSizeOld ( )
{
return m_xzSizeOld ;
}
void LevelData : : getMoatFlags ( bool * bClassicEdgeMoat , bool * bSmallEdgeMoat , bool * bMediumEdgeMoat )
{
* bClassicEdgeMoat = m_classicEdgeMoat ;
* bSmallEdgeMoat = m_smallEdgeMoat ;
* bMediumEdgeMoat = m_mediumEdgeMoat ;
}
int LevelData : : getXZHellSizeOld ( )
{
int hellXZSizeOld = ceil ( ( float ) m_xzSizeOld / m_hellScaleOld ) ;
while ( hellXZSizeOld > HELL_LEVEL_MAX_WIDTH & & m_hellScaleOld < HELL_LEVEL_MAX_SCALE )
{
assert ( 0 ) ; // should never get in here?
+ + m_hellScaleOld ;
hellXZSizeOld = m_xzSize / m_hellScale ;
}
return hellXZSizeOld ;
}
# endif
2026-03-01 12:16:08 +08:00
int LevelData : : getHellScale ( )
{
return m_hellScale ;
}