summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2016-11-07 21:16:55 +0100
committerGitHub <noreply@github.com>2016-11-07 21:16:55 +0100
commit087064999473e83389fb28d74ebcaaf5d119320a (patch)
tree8170f00d76228b97627a193c103482e69d649f51
parentAnticheat fastbreak (#3411) (diff)
downloadcuberite-087064999473e83389fb28d74ebcaaf5d119320a.tar
cuberite-087064999473e83389fb28d74ebcaaf5d119320a.tar.gz
cuberite-087064999473e83389fb28d74ebcaaf5d119320a.tar.bz2
cuberite-087064999473e83389fb28d74ebcaaf5d119320a.tar.lz
cuberite-087064999473e83389fb28d74ebcaaf5d119320a.tar.xz
cuberite-087064999473e83389fb28d74ebcaaf5d119320a.tar.zst
cuberite-087064999473e83389fb28d74ebcaaf5d119320a.zip
-rw-r--r--src/WorldStorage/NBTChunkSerializer.cpp2
-rwxr-xr-xsrc/WorldStorage/WSSAnvil.cpp19
2 files changed, 16 insertions, 5 deletions
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index a825e4785..6797d196a 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -215,7 +215,7 @@ void cNBTChunkSerializer::AddBrewingstandEntity(cBrewingstandEntity * a_Brewings
void cNBTChunkSerializer::AddChestEntity(cChestEntity * a_Entity, BLOCKTYPE a_ChestType)
{
m_Writer.BeginCompound("");
- AddBasicTileEntity(a_Entity, (a_ChestType == E_BLOCK_CHEST) ? "Chest" : "TrappedChest");
+ AddBasicTileEntity(a_Entity, "Chest");
m_Writer.BeginList("Items", TAG_Compound);
AddItemGrid(a_Entity->GetContents());
m_Writer.EndList();
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 3fd104004..2bf11d3f4 100755
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -980,13 +980,24 @@ cBlockEntity * cWSSAnvil::LoadBrewingstandFromNBT(const cParsedNBT & a_NBT, int
cBlockEntity * cWSSAnvil::LoadChestFromNBT(const cParsedNBT & a_NBT, int a_TagIdx, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_ChestBlockType)
{
// Check if the data has a proper type:
- // TODO: Does vanilla use "TrappedChest" or not? MCWiki says no, but previous code says yes
- // Ref.: http://minecraft.gamepedia.com/Trapped_Chest
- // https://github.com/cuberite/cuberite/blob/d0551e2e0a98a28f31a88d489d17b408e4a7d38d/src/WorldStorage/WSSAnvil.cpp#L637
- if (!CheckBlockEntityType(a_NBT, a_TagIdx, "Chest") && !CheckBlockEntityType(a_NBT, a_TagIdx, "TrappedChest"))
+ // Note that older Cuberite code used "TrappedChest" for trapped chests; new code mimics vanilla and uses "Chest" throughout, but we allow migration here:
+ if (a_NBT.GetType(a_TagIdx) != TAG_Compound)
+ {
+ return nullptr;
+ }
+ int TagID = a_NBT.FindChildByName(a_TagIdx, "id");
+ if ((TagID < 0) || (a_NBT.GetType(TagID) != TAG_String))
{
return nullptr;
}
+ auto BlockEntityType = a_NBT.GetString(TagID);
+ if ((BlockEntityType != "Chest") && (BlockEntityType != "TrappedChest"))
+ {
+ LOGWARNING("Block entity type mismatch at {%d, %d, %d}: got \"%s\", expected \"Chest\". Chest contents will be lost.",
+ a_BlockX, a_BlockY, a_BlockZ, BlockEntityType.c_str()
+ );
+ return nullptr;
+ }
int Items = a_NBT.FindChildByName(a_TagIdx, "Items");
if ((Items < 0) || (a_NBT.GetType(Items) != TAG_List))