Skip to content

Commit

Permalink
Merge branch 'cuberite:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
iamtakingithard committed May 1, 2023
2 parents 71912df + 1551357 commit e3d4d6a
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 17 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Seadragon91 (Lukas Pioch)
Sofapriester
Spekdrum (Pablo Beltran)
SphinxC0re
steve-nzr
structinf (xdot)
sweetgiorni
Sxw1212
Expand Down
3 changes: 3 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
pipeline {
options {
timeout(time: 1, unit: 'HOURS')
}
agent {
docker 'cuberite/docker-ci/minimal:latest'
}
Expand Down
2 changes: 1 addition & 1 deletion Server/Plugins/APIDump/APIDesc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12292,7 +12292,7 @@ end
Type = "cTeam",
},
},
Notes = "Registers a new team. Returns the {{cTeam}} instance, nil on error.",
Notes = "Registers a new team. Returns the {{cTeam}} instance, nil on error. For example if the team already exists.",
},
RemoveObjective =
{
Expand Down
21 changes: 21 additions & 0 deletions Server/Plugins/APIDump/Classes/World.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2315,6 +2315,27 @@ function OnAllChunksAvailable()</pre> All return values from the callbacks are i
},
Notes = "Returns whether or not saving chunk data is enabled. If disabled, the world will keep dirty chunks in memory forever, and will simply regenerate non-dirty chunks that are unloaded.",
},
IsSlimeChunk =
{
Params =
{
{
Name = "ChunkX",
Type = "number",
},
{
Name = "ChunkZ",
Type = "number",
},
},
Returns =
{
{
Type = "boolean",
},
},
Notes = "Returns whether slimes can spawn in the chunk.",
},
IsTrapdoorOpen =
{
Params =
Expand Down
9 changes: 9 additions & 0 deletions src/Chunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1980,3 +1980,12 @@ NIBBLETYPE cChunk::GetTimeAlteredLight(NIBBLETYPE a_Skylight) const
// Because NIBBLETYPE is unsigned, we clamp it to 0 .. 15 by checking for values above 15
return (a_Skylight < 16)? a_Skylight : 0;
}





bool cChunk::IsSlimeChunk() const
{
return m_World->IsSlimeChunk(m_PosX, m_PosZ);
}
2 changes: 2 additions & 0 deletions src/Chunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ class cChunk
return cChunkDef::RelativeToAbsolute(a_RelBlockPosition, {m_PosX, m_PosZ});
}

/** Returns true if slimes should spawn in the chunk. */
bool IsSlimeChunk() const;

private:

Expand Down
5 changes: 4 additions & 1 deletion src/MobSpawner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, Vector3i a_RelPos, eMonsterType
(!cBlockInfo::IsTransparent(BlockBelow)) ||
(a_DisableSolidBelowCheck)) &&
(
(a_RelPos.y <= 40) ||
(
(a_RelPos.y <= 40) &&
a_Chunk->IsSlimeChunk()
) ||
(
(a_Biome == biSwampland) &&
(a_RelPos.y >= 50) &&
Expand Down
7 changes: 1 addition & 6 deletions src/RankManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

cRankManager::cRankManager(void) :
m_DB("Ranks.sqlite", SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE),
m_IsInitialized(false),
m_MojangAPI(nullptr)
m_IsInitialized(false)
{
}

Expand All @@ -28,10 +27,6 @@ cRankManager::cRankManager(void) :

cRankManager::~cRankManager()
{
if (m_MojangAPI != nullptr)
{
m_MojangAPI->SetRankManager(nullptr);
}
}


Expand Down
5 changes: 0 additions & 5 deletions src/RankManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,6 @@ class cRankManager
/** Set to true once the manager is initialized. */
bool m_IsInitialized;

/** The MojangAPI instance that is used for keeping player names and UUIDs in sync.
Set in Initialize(), may be nullptr. */
cMojangAPI * m_MojangAPI;


/** Returns true if all the DB tables are empty, indicating a fresh new install. */
bool AreDBTablesEmpty(void);

Expand Down
10 changes: 7 additions & 3 deletions src/Scoreboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,15 @@ cTeam * cScoreboard::RegisterTeam(
const AString & a_Prefix, const AString & a_Suffix
)
{
cTeam Team(a_Name, a_DisplayName, a_Prefix, a_Suffix);
auto [TeamIterator, TeamExists] = m_Teams.try_emplace(a_Name, a_Name, a_DisplayName, a_Prefix, a_Suffix);

std::pair<cTeamMap::iterator, bool> Status = m_Teams.insert(cNamedTeam(a_Name, Team));
if (!TeamExists && GetTeam(a_Name))
{
LOGWARNING("Tried to register a team that already exists: %s", a_Name.c_str());
return nullptr;
}

return Status.second ? &Status.first->second : nullptr;
return &TeamIterator->second;
}


Expand Down
10 changes: 10 additions & 0 deletions src/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3229,3 +3229,13 @@ void cWorld::cChunkGeneratorCallbacks::CallHookChunkGenerated (cChunkDesc & a_Ch
*m_World, a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ(), &a_ChunkDesc
);
}





bool cWorld::IsSlimeChunk(int a_ChunkX, int a_ChunkZ) const
{
cNoise Noise(GetSeed());
return (Noise.IntNoise2DInt(a_ChunkX, a_ChunkZ) / 8) % 10 == 0; // 10% chance
}
4 changes: 3 additions & 1 deletion src/World.h
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ class cWorld // tolua_export
virtual bool IsWeatherWetAtXYZ(Vector3i a_Position) override;

/** Returns the seed of the world. */
int GetSeed(void) { return m_Generator.GetSeed(); }
int GetSeed(void) const { return m_Generator.GetSeed(); }

// tolua_end

Expand Down Expand Up @@ -892,6 +892,8 @@ class cWorld // tolua_export
as at least one requests is active the chunk will be ticked). */
void SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTicked = true); // tolua_export

/** Returns true if slimes should spawn in the chunk. */
bool IsSlimeChunk(int a_ChunkX, int a_ChunkZ) const; // tolua_export
private:

class cTickThread:
Expand Down

0 comments on commit e3d4d6a

Please sign in to comment.