diff options
author | 12xx12 <44411062+12xx12@users.noreply.github.com> | 2021-03-15 03:47:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-15 03:47:55 +0100 |
commit | 243083e01a4b6b496ca4c0ed0a4a33499cd41936 (patch) | |
tree | 49f7149f1b765cad90cc1192dceca35e30530c8e /src/WorldStorage/WSSAnvil.cpp | |
parent | Derive HugeMushroom from the base handler (diff) | |
download | cuberite-243083e01a4b6b496ca4c0ed0a4a33499cd41936.tar cuberite-243083e01a4b6b496ca4c0ed0a4a33499cd41936.tar.gz cuberite-243083e01a4b6b496ca4c0ed0a4a33499cd41936.tar.bz2 cuberite-243083e01a4b6b496ca4c0ed0a4a33499cd41936.tar.lz cuberite-243083e01a4b6b496ca4c0ed0a4a33499cd41936.tar.xz cuberite-243083e01a4b6b496ca4c0ed0a4a33499cd41936.tar.zst cuberite-243083e01a4b6b496ca4c0ed0a4a33499cd41936.zip |
Diffstat (limited to 'src/WorldStorage/WSSAnvil.cpp')
-rw-r--r-- | src/WorldStorage/WSSAnvil.cpp | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index e2a9b1539..dae1ca825 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -19,6 +19,7 @@ #include "../BlockType.h" #include "../JsonUtils.h" +#include "../BlockEntities/BannerEntity.h" #include "../BlockEntities/BeaconEntity.h" #include "../BlockEntities/BedEntity.h" #include "../BlockEntities/BrewingstandEntity.h" @@ -635,7 +636,11 @@ OwnedBlockEntity cWSSAnvil::LoadBlockEntityFromNBT(const cParsedNBT & a_NBT, int // Load the specific BlockEntity type: switch (a_BlockType) { - // Specific entity loaders: + // Banners: + case E_BLOCK_STANDING_BANNER: + case E_BLOCK_WALL_BANNER: return LoadBannerFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos); + + // Others: case E_BLOCK_BEACON: return LoadBeaconFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos); case E_BLOCK_BED: return LoadBedFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos); case E_BLOCK_BREWING_STAND: return LoadBrewingstandFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos); @@ -657,7 +662,6 @@ OwnedBlockEntity cWSSAnvil::LoadBlockEntityFromNBT(const cParsedNBT & a_NBT, int case E_BLOCK_SIGN_POST: return LoadSignFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos); case E_BLOCK_TRAPPED_CHEST: return LoadChestFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos); case E_BLOCK_WALLSIGN: return LoadSignFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos); - default: { // All the other blocktypes should have no entities assigned to them. Report an error: @@ -889,6 +893,29 @@ bool cWSSAnvil::CheckBlockEntityType(const cParsedNBT & a_NBT, int a_TagIdx, con +OwnedBlockEntity cWSSAnvil::LoadBannerFromNBT(const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos) +{ + static const AStringVector expectedTypes({"Banner", "minecraft:standingbanner","minecraft:wallbanner"}); + if (!CheckBlockEntityType(a_NBT, a_TagIdx, expectedTypes, a_Pos)) + { + return nullptr; + } + + // Reads base color from NBT + int CurrentLine = a_NBT.FindChildByName(a_TagIdx, "Base"); + if (CurrentLine >= 0) + { + const auto Color = static_cast<unsigned char>(a_NBT.GetInt(CurrentLine)); + return std::make_unique<cBannerEntity>(a_BlockType, a_BlockMeta, a_Pos, m_World, Color); + } + + return nullptr; +} + + + + + OwnedBlockEntity cWSSAnvil::LoadBeaconFromNBT(const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos) { // Check if the data has a proper type: |