summaryrefslogtreecommitdiffstats
path: root/src/WorldStorage/WSSAnvil.cpp
diff options
context:
space:
mode:
authorLukas Pioch <lukas@zgow.de>2017-07-07 09:31:45 +0200
committerGitHub <noreply@github.com>2017-07-07 09:31:45 +0200
commit885d8287125439047ca2318f8e349b8da279e612 (patch)
tree2f54b688dba0f49b64544d3c1220a16a6936cd6f /src/WorldStorage/WSSAnvil.cpp
parentChanged Lua plugins to only execute files ending in .lua (#3831) (diff)
downloadcuberite-885d8287125439047ca2318f8e349b8da279e612.tar
cuberite-885d8287125439047ca2318f8e349b8da279e612.tar.gz
cuberite-885d8287125439047ca2318f8e349b8da279e612.tar.bz2
cuberite-885d8287125439047ca2318f8e349b8da279e612.tar.lz
cuberite-885d8287125439047ca2318f8e349b8da279e612.tar.xz
cuberite-885d8287125439047ca2318f8e349b8da279e612.tar.zst
cuberite-885d8287125439047ca2318f8e349b8da279e612.zip
Diffstat (limited to '')
-rwxr-xr-xsrc/WorldStorage/WSSAnvil.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index d5ae388bb..8b8a0482e 100755
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -19,6 +19,7 @@
#include "../Root.h"
#include "../BlockEntities/BeaconEntity.h"
+#include "../BlockEntities/BedEntity.h"
#include "../BlockEntities/BrewingstandEntity.h"
#include "../BlockEntities/ChestEntity.h"
#include "../BlockEntities/CommandBlockEntity.h"
@@ -694,6 +695,7 @@ cBlockEntity * cWSSAnvil::LoadBlockEntityFromNBT(const cParsedNBT & a_NBT, int a
{
// Specific entity loaders:
case E_BLOCK_BEACON: return LoadBeaconFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ);
+ case E_BLOCK_BED: return LoadBedFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ);
case E_BLOCK_BREWING_STAND: return LoadBrewingstandFromNBT(a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ);
case E_BLOCK_CHEST: return LoadChestFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ);
case E_BLOCK_COMMAND_BLOCK: return LoadCommandBlockFromNBT(a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ);
@@ -976,6 +978,32 @@ cBlockEntity * cWSSAnvil::LoadBeaconFromNBT(const cParsedNBT & a_NBT, int a_TagI
+cBlockEntity * cWSSAnvil::LoadBedFromNBT(const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+ // Check if the data has a proper type:
+ static const AStringVector expectedTypes({ "Bed", "minecraft:bed" });
+ if (!CheckBlockEntityType(a_NBT, a_TagIdx, expectedTypes, a_BlockX, a_BlockY, a_BlockZ))
+ {
+ return nullptr;
+ }
+
+ // Use color red as default
+ short Color = E_META_WOOL_RED;
+
+ int ColorIDx = a_NBT.FindChildByName(a_TagIdx, "color");
+ if (ColorIDx >= 0)
+ {
+ Color = static_cast<short>(a_NBT.GetInt(ColorIDx));
+ }
+
+ auto Bed = cpp14::make_unique<cBedEntity>(a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ, m_World, Color);
+ return Bed.release();
+}
+
+
+
+
+
cBlockEntity * cWSSAnvil::LoadBrewingstandFromNBT(const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ)
{
// Check if the data has a proper type: