summaryrefslogtreecommitdiffstats
path: root/src/BlockEntities/BlockEntity.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2017-06-24 11:58:06 +0200
committerGitHub <noreply@github.com>2017-06-24 11:58:06 +0200
commitfe4253834919d6c742c59c701d3d5ce8285f4504 (patch)
treec201ca7a02344029679d4addffb695a3d20c4bec /src/BlockEntities/BlockEntity.cpp
parentLoad entities from old and new names (diff)
downloadcuberite-fe4253834919d6c742c59c701d3d5ce8285f4504.tar
cuberite-fe4253834919d6c742c59c701d3d5ce8285f4504.tar.gz
cuberite-fe4253834919d6c742c59c701d3d5ce8285f4504.tar.bz2
cuberite-fe4253834919d6c742c59c701d3d5ce8285f4504.tar.lz
cuberite-fe4253834919d6c742c59c701d3d5ce8285f4504.tar.xz
cuberite-fe4253834919d6c742c59c701d3d5ce8285f4504.tar.zst
cuberite-fe4253834919d6c742c59c701d3d5ce8285f4504.zip
Diffstat (limited to 'src/BlockEntities/BlockEntity.cpp')
-rw-r--r--src/BlockEntities/BlockEntity.cpp51
1 files changed, 48 insertions, 3 deletions
diff --git a/src/BlockEntities/BlockEntity.cpp b/src/BlockEntities/BlockEntity.cpp
index f0716dd08..f60eb5622 100644
--- a/src/BlockEntities/BlockEntity.cpp
+++ b/src/BlockEntities/BlockEntity.cpp
@@ -25,11 +25,57 @@
+void cBlockEntity::SetPos(int a_NewBlockX, int a_NewBlockY, int a_NewBlockZ)
+{
+ ASSERT(m_World == nullptr); // Cannot move block entities that represent world blocks (only use this for cBlockArea's BEs)
+ m_PosX = a_NewBlockX;
+ m_PosY = a_NewBlockY;
+ m_PosZ = a_NewBlockZ;
+}
+
+
+
+
+
+bool cBlockEntity::IsBlockEntityBlockType(BLOCKTYPE a_BlockType)
+{
+ switch (a_BlockType)
+ {
+ case E_BLOCK_BEACON:
+ case E_BLOCK_BREWING_STAND:
+ case E_BLOCK_CHEST:
+ case E_BLOCK_COMMAND_BLOCK:
+ case E_BLOCK_DISPENSER:
+ case E_BLOCK_DROPPER:
+ case E_BLOCK_ENDER_CHEST:
+ case E_BLOCK_FLOWER_POT:
+ case E_BLOCK_FURNACE:
+ case E_BLOCK_HEAD:
+ case E_BLOCK_HOPPER:
+ case E_BLOCK_JUKEBOX:
+ case E_BLOCK_LIT_FURNACE:
+ case E_BLOCK_MOB_SPAWNER:
+ case E_BLOCK_NOTE_BLOCK:
+ case E_BLOCK_SIGN_POST:
+ case E_BLOCK_TRAPPED_CHEST:
+ case E_BLOCK_WALLSIGN:
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+
+
cBlockEntity * cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World)
{
switch (a_BlockType)
{
case E_BLOCK_BEACON: return new cBeaconEntity (a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ, a_World);
+ case E_BLOCK_BREWING_STAND: return new cBrewingstandEntity(a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_CHEST: return new cChestEntity (a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_COMMAND_BLOCK: return new cCommandBlockEntity(a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_DISPENSER: return new cDispenserEntity (a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ, a_World);
@@ -37,16 +83,15 @@ cBlockEntity * cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE
case E_BLOCK_ENDER_CHEST: return new cEnderChestEntity (a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_FLOWER_POT: return new cFlowerPotEntity (a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_FURNACE: return new cFurnaceEntity (a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ, a_World);
- case E_BLOCK_BREWING_STAND: return new cBrewingstandEntity(a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_HEAD: return new cMobHeadEntity (a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_HOPPER: return new cHopperEntity (a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ, a_World);
- case E_BLOCK_MOB_SPAWNER: return new cMobSpawnerEntity (a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_JUKEBOX: return new cJukeboxEntity (a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_LIT_FURNACE: return new cFurnaceEntity (a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ, a_World);
+ case E_BLOCK_MOB_SPAWNER: return new cMobSpawnerEntity (a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ, a_World);
+ case E_BLOCK_NOTE_BLOCK: return new cNoteEntity (a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_SIGN_POST: return new cSignEntity (a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_TRAPPED_CHEST: return new cChestEntity (a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_WALLSIGN: return new cSignEntity (a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ, a_World);
- case E_BLOCK_NOTE_BLOCK: return new cNoteEntity (a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ, a_World);
}
LOGD("%s: Requesting creation of an unknown block entity - block type %d (%s)",
__FUNCTION__, a_BlockType, ItemTypeToString(a_BlockType).c_str()