Adding basic Banner functionality (#4806)
+ Added item and block for banners Co-authored-by: 12xx12 <12xx12100@gmail.com> Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user