summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--.gitignore1
-rw-r--r--Server/Plugins/APIDump/APIDesc.lua1
-rw-r--r--Server/Plugins/APIDump/Classes/BlockEntities.lua7
-rw-r--r--src/BlockArea.cpp16
-rw-r--r--src/BlockEntities/MobHeadEntity.cpp43
-rw-r--r--src/BlockEntities/MobHeadEntity.h24
-rw-r--r--src/Protocol/Protocol17x.cpp2
-rw-r--r--src/Protocol/Protocol18x.cpp15
-rw-r--r--src/Root.cpp50
-rw-r--r--src/Root.h2
-rw-r--r--src/World.h3
-rw-r--r--src/WorldStorage/NBTChunkSerializer.cpp15
-rwxr-xr-xsrc/WorldStorage/WSSAnvil.cpp43
13 files changed, 196 insertions, 26 deletions
diff --git a/.gitignore b/.gitignore
index a25819b26..ea4ccdd59 100644
--- a/.gitignore
+++ b/.gitignore
@@ -88,6 +88,7 @@ src/AllFiles.lst
*.opensdf
*.sdf
*.sln
+*.opendb
*.idb
# cmake output folders
diff --git a/Server/Plugins/APIDump/APIDesc.lua b/Server/Plugins/APIDump/APIDesc.lua
index 6f3736bef..b253626cd 100644
--- a/Server/Plugins/APIDump/APIDesc.lua
+++ b/Server/Plugins/APIDump/APIDesc.lua
@@ -2507,6 +2507,7 @@ end
GetName = { Params = "", Return = "string", Notes = "Returns the name of the world, as specified in the settings.ini file." },
GetNumChunks = { Params = "", Return = "number", Notes = "Returns the number of chunks currently loaded." },
GetScoreBoard = { Params = "", Return = "{{cScoreBoard}}", Notes = "Returns the {{cScoreBoard|ScoreBoard}} object used by this world. " },
+ GetSeed = { Params = "", Return = "number", Notes = "Returns the seed of the world." },
GetSignLines = { Params = "BlockX, BlockY, BlockZ", Return = "IsValid, [Line1, Line2, Line3, Line4]", Notes = "Returns true and the lines of a sign at the specified coords, or false if there is no sign at the coords." },
GetSpawnX = { Params = "", Return = "number", Notes = "Returns the X coord of the default spawn" },
GetSpawnY = { Params = "", Return = "number", Notes = "Returns the Y coord of the default spawn" },
diff --git a/Server/Plugins/APIDump/Classes/BlockEntities.lua b/Server/Plugins/APIDump/Classes/BlockEntities.lua
index 019e702eb..f3e53351b 100644
--- a/Server/Plugins/APIDump/Classes/BlockEntities.lua
+++ b/Server/Plugins/APIDump/Classes/BlockEntities.lua
@@ -282,10 +282,13 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(),
{
SetType = { Params = "eMobHeadType", Return = "", Notes = "Set the type of the mob head" },
SetRotation = { Params = "eMobHeadRotation", Return = "", Notes = "Sets the rotation of the mob head" },
- SetOwner = { Params = "string", Return = "", Notes = "Set the player name for mob heads with player type" },
+ SetOwner = { Params = "cPlayer", Return = "", Notes = "Set the {{cPlayer|player}} for mob heads with player type" },
GetType = { Params = "", Return = "eMobHeadType", Notes = "Returns the type of the mob head" },
GetRotation = { Params = "", Return = "eMobHeadRotation", Notes = "Returns the rotation of the mob head" },
- GetOwner = { Params = "", Return = "string", Notes = "Returns the player name of the mob head" },
+ GetOwnerName = { Params = "", Return = "string", Notes = "Returns the player name of the mob head" },
+ GetOwnerUUID = { Params = "", Return = "string", Notes = "Returns the player UUID of the mob head" },
+ GetOwnerTexture = { Params = "", Return = "string", Notes = "Returns the player texture of the mob head" },
+ GetOwnerTextureSignature = { Params = "", Return = "string", Notes = "Returns the signature of the player texture of the mob head" },
},
}, -- cMobHeadEntity
diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp
index 761a7b355..34d3bf54a 100644
--- a/src/BlockArea.cpp
+++ b/src/BlockArea.cpp
@@ -454,22 +454,30 @@ bool cBlockArea::Read(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinB
// Check coords validity:
if (a_MinBlockY < 0)
{
- LOGWARNING("%s: MinBlockY less than zero, adjusting to zero", __FUNCTION__);
+ LOGWARNING("%s: MinBlockY less than zero, adjusting to zero. Coords: {%d, %d, %d} - {%d, %d, %d}",
+ __FUNCTION__, a_MinBlockX, a_MinBlockY, a_MinBlockZ, a_MaxBlockX, a_MaxBlockY, a_MaxBlockZ
+ );
a_MinBlockY = 0;
}
else if (a_MinBlockY >= cChunkDef::Height)
{
- LOGWARNING("%s: MinBlockY more than chunk height, adjusting to chunk height", __FUNCTION__);
+ LOGWARNING("%s: MinBlockY more than chunk height, adjusting to chunk height. Coords: {%d, %d, %d} - {%d, %d, %d}",
+ __FUNCTION__, a_MinBlockX, a_MinBlockY, a_MinBlockZ, a_MaxBlockX, a_MaxBlockY, a_MaxBlockZ
+ );
a_MinBlockY = cChunkDef::Height - 1;
}
if (a_MaxBlockY < 0)
{
- LOGWARNING("%s: MaxBlockY less than zero, adjusting to zero", __FUNCTION__);
+ LOGWARNING("%s: MaxBlockY less than zero, adjusting to zero. Coords: {%d, %d, %d} - {%d, %d, %d}",
+ __FUNCTION__, a_MinBlockX, a_MinBlockY, a_MinBlockZ, a_MaxBlockX, a_MaxBlockY, a_MaxBlockZ
+ );
a_MaxBlockY = 0;
}
else if (a_MaxBlockY > cChunkDef::Height)
{
- LOGWARNING("%s: MaxBlockY more than chunk height, adjusting to chunk height", __FUNCTION__);
+ LOGWARNING("%s: MaxBlockY more than chunk height, adjusting to chunk height. Coords: {%d, %d, %d} - {%d, %d, %d}",
+ __FUNCTION__, a_MinBlockX, a_MinBlockY, a_MinBlockZ, a_MaxBlockX, a_MaxBlockY, a_MaxBlockZ
+ );
a_MaxBlockY = cChunkDef::Height;
}
diff --git a/src/BlockEntities/MobHeadEntity.cpp b/src/BlockEntities/MobHeadEntity.cpp
index 3275bf7f2..542e920ba 100644
--- a/src/BlockEntities/MobHeadEntity.cpp
+++ b/src/BlockEntities/MobHeadEntity.cpp
@@ -14,8 +14,7 @@
cMobHeadEntity::cMobHeadEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
super(E_BLOCK_HEAD, a_BlockX, a_BlockY, a_BlockZ, a_World),
m_Type(SKULL_TYPE_SKELETON),
- m_Rotation(SKULL_ROTATION_NORTH),
- m_Owner("")
+ m_Rotation(SKULL_ROTATION_NORTH)
{
}
@@ -35,9 +34,9 @@ bool cMobHeadEntity::UsedBy(cPlayer * a_Player)
void cMobHeadEntity::SetType(const eMobHeadType & a_Type)
{
- if ((!m_Owner.empty()) && (a_Type != SKULL_TYPE_PLAYER))
+ if ((!m_OwnerName.empty()) && (a_Type != SKULL_TYPE_PLAYER))
{
- m_Owner = "";
+ m_OwnerName = m_OwnerUUID = m_OwnerTexture = m_OwnerTextureSignature = "";
}
m_Type = a_Type;
}
@@ -55,13 +54,43 @@ void cMobHeadEntity::SetRotation(eMobHeadRotation a_Rotation)
-void cMobHeadEntity::SetOwner(const AString & a_Owner)
+void cMobHeadEntity::SetOwner(const cPlayer & a_Owner)
{
- if ((a_Owner.length() > 16) || (m_Type != SKULL_TYPE_PLAYER))
+ if (m_Type != SKULL_TYPE_PLAYER)
{
return;
}
- m_Owner = a_Owner;
+
+ m_OwnerName = a_Owner.GetName();
+ m_OwnerUUID = a_Owner.GetUUID();
+
+ const Json::Value & Properties = a_Owner.GetClientHandle()->GetProperties();
+ for (auto & Node : Properties)
+ {
+ if (Node.get("name", "").asString() == "textures")
+ {
+ m_OwnerTexture = Node.get("value", "").asString();
+ m_OwnerTextureSignature = Node.get("signature", "").asString();
+ break;
+ }
+ }
+}
+
+
+
+
+
+void cMobHeadEntity::SetOwner(const AString & a_OwnerUUID, const AString & a_OwnerName, const AString & a_OwnerTexture, const AString & a_OwnerTextureSignature)
+{
+ if (m_Type != SKULL_TYPE_PLAYER)
+ {
+ return;
+ }
+
+ m_OwnerUUID = a_OwnerUUID;
+ m_OwnerName = a_OwnerName;
+ m_OwnerTexture = a_OwnerTexture;
+ m_OwnerTextureSignature = a_OwnerTextureSignature;
}
diff --git a/src/BlockEntities/MobHeadEntity.h b/src/BlockEntities/MobHeadEntity.h
index f25cb3a16..2eb932068 100644
--- a/src/BlockEntities/MobHeadEntity.h
+++ b/src/BlockEntities/MobHeadEntity.h
@@ -39,8 +39,11 @@ public:
/** Set the rotation of the mob head */
void SetRotation(eMobHeadRotation a_Rotation);
- /** Set the player name for mob heads with player type */
- void SetOwner(const AString & a_Owner);
+ /** Set the player for mob heads with player type */
+ void SetOwner(const cPlayer & a_Owner);
+
+ /** Sets the player components for the mob heads with player type */
+ void SetOwner(const AString & a_OwnerUUID, const AString & a_OwnerName, const AString & a_OwnerTexture, const AString & a_OwnerTextureSignature);
/** Returns the type of the mob head */
eMobHeadType GetType(void) const { return m_Type; }
@@ -49,7 +52,16 @@ public:
eMobHeadRotation GetRotation(void) const { return m_Rotation; }
/** Returns the player name of the mob head */
- AString GetOwner(void) const { return m_Owner; }
+ AString GetOwnerName(void) const { return m_OwnerName; }
+
+ /** Returns the player UUID of the mob head */
+ AString GetOwnerUUID(void) const { return m_OwnerUUID; }
+
+ /** Returns the texture of the mob head */
+ AString GetOwnerTexture(void) const { return m_OwnerTexture; }
+
+ /** Returns the texture signature of the mob head */
+ AString GetOwnerTextureSignature(void) const { return m_OwnerTextureSignature; }
// tolua_end
@@ -60,7 +72,11 @@ private:
eMobHeadType m_Type;
eMobHeadRotation m_Rotation;
- AString m_Owner;
+
+ AString m_OwnerName;
+ AString m_OwnerUUID;
+ AString m_OwnerTexture;
+ AString m_OwnerTextureSignature;
} ; // tolua_export
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 010e1a8ba..1c8c81bbd 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -2784,7 +2784,7 @@ void cProtocol172::WriteBlockEntity(cPacketizer & a_Pkt, const cBlockEntity & a_
Writer.AddInt("z", MobHeadEntity.GetPosZ());
Writer.AddByte("SkullType", MobHeadEntity.GetType() & 0xFF);
Writer.AddByte("Rot", MobHeadEntity.GetRotation() & 0xFF);
- Writer.AddString("ExtraType", MobHeadEntity.GetOwner().c_str());
+ Writer.AddString("ExtraType", MobHeadEntity.GetOwnerName());
Writer.AddString("id", "Skull"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though
break;
}
diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp
index d80e9d034..c80907ed8 100644
--- a/src/Protocol/Protocol18x.cpp
+++ b/src/Protocol/Protocol18x.cpp
@@ -3109,8 +3109,21 @@ void cProtocol180::WriteBlockEntity(cPacketizer & a_Pkt, const cBlockEntity & a_
Writer.AddInt("z", MobHeadEntity.GetPosZ());
Writer.AddByte("SkullType", MobHeadEntity.GetType() & 0xFF);
Writer.AddByte("Rot", MobHeadEntity.GetRotation() & 0xFF);
- Writer.AddString("ExtraType", MobHeadEntity.GetOwner().c_str());
Writer.AddString("id", "Skull"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though
+
+ // The new Block Entity format for a Mob Head. See: http://minecraft.gamepedia.com/Head#Block_entity
+ Writer.BeginCompound("Owner");
+ Writer.AddString("Id", MobHeadEntity.GetOwnerUUID());
+ Writer.AddString("Name", MobHeadEntity.GetOwnerName());
+ Writer.BeginCompound("Properties");
+ Writer.BeginList("textures", TAG_Compound);
+ Writer.BeginCompound("");
+ Writer.AddString("Signature", MobHeadEntity.GetOwnerTextureSignature());
+ Writer.AddString("Value", MobHeadEntity.GetOwnerTexture());
+ Writer.EndCompound();
+ Writer.EndList();
+ Writer.EndCompound();
+ Writer.EndCompound();
break;
}
diff --git a/src/Root.cpp b/src/Root.cpp
index 9226efb27..dc00b5c82 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -347,7 +347,6 @@ void cRoot::LoadGlobalSettings()
void cRoot::LoadWorlds(cSettingsRepositoryInterface & a_Settings, bool a_IsNewIniFile)
{
// First get the default world
- AString DefaultWorldName = a_Settings.GetValueSet("Worlds", "DefaultWorld", "world");
if (a_IsNewIniFile)
{
a_Settings.AddValue("Worlds", "World", "world_nether");
@@ -359,11 +358,58 @@ void cRoot::LoadWorlds(cSettingsRepositoryInterface & a_Settings, bool a_IsNewIn
return;
}
+ AString DefaultWorldName = a_Settings.GetValueSet("Worlds", "DefaultWorld", "world");
m_pDefaultWorld = new cWorld(DefaultWorldName.c_str());
m_WorldsByName[ DefaultWorldName ] = m_pDefaultWorld;
+ auto Worlds = a_Settings.GetValues("Worlds");
+
+ // Fix servers that have default world configs created prior to #2815. See #2810.
+ // This can probably be removed several years after 2016
+ // We start by inspecting the world linkage and determining if it's the default one
+ if (DefaultWorldName == "world")
+ {
+ auto DefaultWorldIniFile= cpp14::make_unique<cIniFile>();
+ assert(DefaultWorldIniFile->ReadFile("world/world.ini"));
+ AString NetherName = DefaultWorldIniFile->GetValue("LinkedWorlds", "NetherWorldName", "");
+ AString EndName = DefaultWorldIniFile->GetValue("LinkedWorlds", "EndWorldName", "");
+ if ((NetherName.compare("world_nether") == 0) && (EndName.compare("world_end") == 0))
+ {
+ // This is a default world linkage config, see if the nether and end are in settings.ini
+ // If both of them are not in settings.ini, then this is a pre-#2815 default config
+ // so we add them to settings.ini
+ // Note that if only one of them is not in settings.ini, it's nondefault and we don't touch it
+
+ bool NetherInSettings = false;
+ bool EndInSettings = false;
+
+ for (auto WorldNameValue : Worlds)
+ {
+ AString ValueName = WorldNameValue.first;
+ if (ValueName.compare("World") != 0)
+ {
+ continue;
+ }
+ AString WorldName = WorldNameValue.second;
+ if (WorldName.compare("world_nether") == 0)
+ {
+ NetherInSettings = true;
+ }
+ else if (WorldName.compare("world_end") == 0)
+ {
+ EndInSettings = true;
+ }
+ }
+
+ if ((!NetherInSettings) && (!EndInSettings))
+ {
+ a_Settings.AddValue("Worlds", "World", "world_nether");
+ a_Settings.AddValue("Worlds", "World", "world_end");
+ Worlds = a_Settings.GetValues("Worlds"); // Refresh the Worlds list so that the rest of the function works as usual
+ }
+ }
+ }
// Then load the other worlds
- auto Worlds = a_Settings.GetValues("Worlds");
if (Worlds.size() <= 0)
{
return;
diff --git a/src/Root.h b/src/Root.h
index 064752ab4..261dac29f 100644
--- a/src/Root.h
+++ b/src/Root.h
@@ -224,7 +224,7 @@ private:
void LoadGlobalSettings();
/** Loads the worlds from settings.ini, creates the worldmap */
- void LoadWorlds(cSettingsRepositoryInterface & a_Settings, bool a_NewIniFile);
+ void LoadWorlds(cSettingsRepositoryInterface & a_Settings, bool a_IsNewIniFile);
/** Starts each world's life */
void StartWorlds(void);
diff --git a/src/World.h b/src/World.h
index e9206e176..95ac6b21b 100644
--- a/src/World.h
+++ b/src/World.h
@@ -757,6 +757,9 @@ public:
return (IsWeatherWet() && !IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ)));
}
+ /** Returns the seed of the world. */
+ int GetSeed(void) { return m_Generator.GetSeed(); }
+
// tolua_end
cChunkGenerator & GetGenerator(void) { return m_Generator; }
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index b0451e427..3a0823491 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -358,7 +358,20 @@ void cNBTChunkSerializer::AddMobHeadEntity(cMobHeadEntity * a_MobHead)
AddBasicTileEntity(a_MobHead, "Skull");
m_Writer.AddByte ("SkullType", a_MobHead->GetType() & 0xFF);
m_Writer.AddByte ("Rot", a_MobHead->GetRotation() & 0xFF);
- m_Writer.AddString("ExtraType", a_MobHead->GetOwner());
+
+ // The new Block Entity format for a Mob Head. See: http://minecraft.gamepedia.com/Head#Block_entity
+ m_Writer.BeginCompound("Owner");
+ m_Writer.AddString("Id", a_MobHead->GetOwnerUUID());
+ m_Writer.AddString("Name", a_MobHead->GetOwnerName());
+ m_Writer.BeginCompound("Properties");
+ m_Writer.BeginList("textures", TAG_Compound);
+ m_Writer.BeginCompound("");
+ m_Writer.AddString("Signature", a_MobHead->GetOwnerTextureSignature());
+ m_Writer.AddString("Value", a_MobHead->GetOwnerTexture());
+ m_Writer.EndCompound();
+ m_Writer.EndList();
+ m_Writer.EndCompound();
+ m_Writer.EndCompound();
m_Writer.EndCompound();
}
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 5138717a7..3d325d354 100755
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -1293,10 +1293,47 @@ cBlockEntity * cWSSAnvil::LoadMobHeadFromNBT(const cParsedNBT & a_NBT, int a_Tag
MobHead->SetRotation(static_cast<eMobHeadRotation>(a_NBT.GetByte(currentLine)));
}
- currentLine = a_NBT.FindChildByName(a_TagIdx, "ExtraType");
- if (currentLine >= 0)
+ int ownerLine = a_NBT.FindChildByName(a_TagIdx, "Owner");
+ if (ownerLine >= 0)
{
- MobHead->SetOwner(a_NBT.GetString(currentLine));
+ AString OwnerName, OwnerUUID, OwnerTexture, OwnerTextureSignature;
+
+ currentLine = a_NBT.FindChildByName(ownerLine, "Id");
+ if (currentLine >= 0)
+ {
+ OwnerUUID = a_NBT.GetString(currentLine);
+ }
+
+ currentLine = a_NBT.FindChildByName(ownerLine, "Name");
+ if (currentLine >= 0)
+ {
+ OwnerName = a_NBT.GetString(currentLine);
+ }
+
+ int textureLine = a_NBT.GetFirstChild( // The first texture of
+ a_NBT.FindChildByName( // The texture list of
+ a_NBT.FindChildByName( // The Properties compound of
+ ownerLine, // The Owner compound
+ "Properties"
+ ),
+ "textures"
+ )
+ );
+ if (textureLine >= 0)
+ {
+ currentLine = a_NBT.FindChildByName(textureLine, "Signature");
+ if (currentLine >= 0)
+ {
+ OwnerTextureSignature = a_NBT.GetString(currentLine);
+ }
+
+ currentLine = a_NBT.FindChildByName(textureLine, "Value");
+ if (currentLine >= 0)
+ {
+ OwnerTexture = a_NBT.GetString(currentLine);
+ }
+ }
+ MobHead->SetOwner(OwnerUUID, OwnerName, OwnerTexture, OwnerTextureSignature);
}
return MobHead.release();