diff options
Diffstat (limited to 'src/BlockEntities')
-rw-r--r-- | src/BlockEntities/BlockEntity.cpp | 44 | ||||
-rw-r--r-- | src/BlockEntities/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/BlockEntities/EnchantingTableEntity.cpp | 47 | ||||
-rw-r--r-- | src/BlockEntities/EnchantingTableEntity.h | 32 | ||||
-rw-r--r-- | src/BlockEntities/EndPortalEntity.cpp | 43 | ||||
-rw-r--r-- | src/BlockEntities/EndPortalEntity.h | 27 |
6 files changed, 178 insertions, 19 deletions
diff --git a/src/BlockEntities/BlockEntity.cpp b/src/BlockEntities/BlockEntity.cpp index b32785e3c..7e7f5eaab 100644 --- a/src/BlockEntities/BlockEntity.cpp +++ b/src/BlockEntities/BlockEntity.cpp @@ -7,12 +7,14 @@ #include "BeaconEntity.h" #include "BedEntity.h" #include "BlockEntity.h" +#include "EnchantingTableEntity.h" #include "BrewingstandEntity.h" #include "ChestEntity.h" #include "CommandBlockEntity.h" #include "DispenserEntity.h" #include "DropperEntity.h" #include "EnderChestEntity.h" +#include "EndPortalEntity.h" #include "FlowerPotEntity.h" #include "FurnaceEntity.h" #include "HopperEntity.h" @@ -47,7 +49,9 @@ bool cBlockEntity::IsBlockEntityBlockType(BLOCKTYPE a_BlockType) case E_BLOCK_COMMAND_BLOCK: case E_BLOCK_DISPENSER: case E_BLOCK_DROPPER: + case E_BLOCK_ENCHANTMENT_TABLE: case E_BLOCK_ENDER_CHEST: + case E_BLOCK_END_PORTAL: case E_BLOCK_FLOWER_POT: case E_BLOCK_FURNACE: case E_BLOCK_HEAD: @@ -77,25 +81,27 @@ OwnedBlockEntity cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETY { switch (a_BlockType) { - case E_BLOCK_BEACON: return std::make_unique<cBeaconEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); - case E_BLOCK_BED: return std::make_unique<cBedEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); - case E_BLOCK_BREWING_STAND: return std::make_unique<cBrewingstandEntity>(a_BlockType, a_BlockMeta, a_Pos, a_World); - case E_BLOCK_CHEST: return std::make_unique<cChestEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); - case E_BLOCK_COMMAND_BLOCK: return std::make_unique<cCommandBlockEntity>(a_BlockType, a_BlockMeta, a_Pos, a_World); - case E_BLOCK_DISPENSER: return std::make_unique<cDispenserEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); - case E_BLOCK_DROPPER: return std::make_unique<cDropperEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); - case E_BLOCK_ENDER_CHEST: return std::make_unique<cEnderChestEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); - case E_BLOCK_FLOWER_POT: return std::make_unique<cFlowerPotEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); - case E_BLOCK_FURNACE: return std::make_unique<cFurnaceEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); - case E_BLOCK_HEAD: return std::make_unique<cMobHeadEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); - case E_BLOCK_HOPPER: return std::make_unique<cHopperEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); - case E_BLOCK_JUKEBOX: return std::make_unique<cJukeboxEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); - case E_BLOCK_LIT_FURNACE: return std::make_unique<cFurnaceEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); - case E_BLOCK_MOB_SPAWNER: return std::make_unique<cMobSpawnerEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); - case E_BLOCK_NOTE_BLOCK: return std::make_unique<cNoteEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); - case E_BLOCK_SIGN_POST: return std::make_unique<cSignEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); - case E_BLOCK_TRAPPED_CHEST: return std::make_unique<cChestEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); - case E_BLOCK_WALLSIGN: return std::make_unique<cSignEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); + case E_BLOCK_BEACON: return std::make_unique<cBeaconEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); + case E_BLOCK_BED: return std::make_unique<cBedEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); + case E_BLOCK_BREWING_STAND: return std::make_unique<cBrewingstandEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); + case E_BLOCK_CHEST: return std::make_unique<cChestEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); + case E_BLOCK_COMMAND_BLOCK: return std::make_unique<cCommandBlockEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); + case E_BLOCK_DISPENSER: return std::make_unique<cDispenserEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); + case E_BLOCK_DROPPER: return std::make_unique<cDropperEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); + case E_BLOCK_ENCHANTMENT_TABLE: return std::make_unique<cEnchantingTableEntity>(a_BlockType, a_BlockMeta, a_Pos, a_World); + case E_BLOCK_ENDER_CHEST: return std::make_unique<cEnderChestEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); + case E_BLOCK_END_PORTAL: return std::make_unique<cEndPortalEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); + case E_BLOCK_FLOWER_POT: return std::make_unique<cFlowerPotEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); + case E_BLOCK_FURNACE: return std::make_unique<cFurnaceEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); + case E_BLOCK_HEAD: return std::make_unique<cMobHeadEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); + case E_BLOCK_HOPPER: return std::make_unique<cHopperEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); + case E_BLOCK_JUKEBOX: return std::make_unique<cJukeboxEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); + case E_BLOCK_LIT_FURNACE: return std::make_unique<cFurnaceEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); + case E_BLOCK_MOB_SPAWNER: return std::make_unique<cMobSpawnerEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); + case E_BLOCK_NOTE_BLOCK: return std::make_unique<cNoteEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); + case E_BLOCK_SIGN_POST: return std::make_unique<cSignEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); + case E_BLOCK_TRAPPED_CHEST: return std::make_unique<cChestEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); + case E_BLOCK_WALLSIGN: return std::make_unique<cSignEntity >(a_BlockType, a_BlockMeta, a_Pos, a_World); default: { LOGD("%s: Requesting creation of an unknown block entity - block type %d (%s)", diff --git a/src/BlockEntities/CMakeLists.txt b/src/BlockEntities/CMakeLists.txt index b0e456da3..d8ec1e005 100644 --- a/src/BlockEntities/CMakeLists.txt +++ b/src/BlockEntities/CMakeLists.txt @@ -11,6 +11,8 @@ target_sources( DispenserEntity.cpp DropSpenserEntity.cpp DropperEntity.cpp + EnchantingTableEntity.cpp + EndPortalEntity.cpp EnderChestEntity.cpp FlowerPotEntity.cpp FurnaceEntity.cpp @@ -31,6 +33,8 @@ target_sources( DispenserEntity.h DropSpenserEntity.h DropperEntity.h + EnchantingTableEntity.h + EndPortalEntity.h EnderChestEntity.h FlowerPotEntity.h FurnaceEntity.h diff --git a/src/BlockEntities/EnchantingTableEntity.cpp b/src/BlockEntities/EnchantingTableEntity.cpp new file mode 100644 index 000000000..55124e7d3 --- /dev/null +++ b/src/BlockEntities/EnchantingTableEntity.cpp @@ -0,0 +1,47 @@ + +#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules + +#include "EnchantingTableEntity.h" +#include "../ClientHandle.h" + + + + + +cEnchantingTableEntity::cEnchantingTableEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World, AString a_CustomName) : + Super(a_BlockType, a_BlockMeta, a_Pos, a_World), + m_CustomName(std::move(a_CustomName)) +{ + ASSERT(a_BlockType == E_BLOCK_ENCHANTMENT_TABLE); +} + + + + + +void cEnchantingTableEntity::CopyFrom(const cBlockEntity & a_Src) +{ + Super::CopyFrom(a_Src); + + auto & Src = static_cast<const cEnchantingTableEntity &>(a_Src); + m_CustomName = Src.m_CustomName; +} + + + + + +bool cEnchantingTableEntity::UsedBy(cPlayer * a_Player) +{ + UNUSED(a_Player); + return true; +} + + + + + +void cEnchantingTableEntity::SendTo(cClientHandle & a_Client) +{ + a_Client.SendUpdateBlockEntity(*this); +} diff --git a/src/BlockEntities/EnchantingTableEntity.h b/src/BlockEntities/EnchantingTableEntity.h new file mode 100644 index 000000000..f10fa3c87 --- /dev/null +++ b/src/BlockEntities/EnchantingTableEntity.h @@ -0,0 +1,32 @@ + +#pragma once + +#include "BlockEntity.h" + + + + + +class cEnchantingTableEntity : + public cBlockEntity +{ + using Super = cBlockEntity; + +public: + + BLOCKENTITY_PROTODEF(cEnchantingTableEntity) + + cEnchantingTableEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World, AString a_CustomName = ""); + + const AString & GetCustomName() const { return m_CustomName; } + void SetCustomName(const AString & a_CustomName) { m_CustomName = a_CustomName; } + +private: + + // cBlockEntity overrides: + virtual void CopyFrom(const cBlockEntity & a_Src) override; + virtual bool UsedBy(cPlayer * a_Player) override; + virtual void SendTo(cClientHandle & a_Client) override; + + AString m_CustomName; +}; diff --git a/src/BlockEntities/EndPortalEntity.cpp b/src/BlockEntities/EndPortalEntity.cpp new file mode 100644 index 000000000..f40e9b20e --- /dev/null +++ b/src/BlockEntities/EndPortalEntity.cpp @@ -0,0 +1,43 @@ + +#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules + +#include "EndPortalEntity.h" +#include "../ClientHandle.h" + + + + + +cEndPortalEntity::cEndPortalEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World) : + Super(a_BlockType, a_BlockMeta, a_Pos, a_World) +{ + ASSERT(a_BlockType == E_BLOCK_END_PORTAL); +} + + + + + +void cEndPortalEntity::CopyFrom(const cBlockEntity & a_Src) +{ + Super::CopyFrom(a_Src); +} + + + + + +bool cEndPortalEntity::UsedBy(cPlayer * a_Player) +{ + UNUSED(a_Player); + return true; +} + + + + + +void cEndPortalEntity::SendTo(cClientHandle & a_Client) +{ + a_Client.SendUpdateBlockEntity(*this); +} diff --git a/src/BlockEntities/EndPortalEntity.h b/src/BlockEntities/EndPortalEntity.h new file mode 100644 index 000000000..fe5ed4322 --- /dev/null +++ b/src/BlockEntities/EndPortalEntity.h @@ -0,0 +1,27 @@ + +#pragma once + +#include "BlockEntity.h" + + + + + +class cEndPortalEntity : + public cBlockEntity +{ + using Super = cBlockEntity; + +public: + + BLOCKENTITY_PROTODEF(cEndPortalEntity) + + cEndPortalEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World); + +private: + + // cBlockEntity overrides: + virtual void CopyFrom(const cBlockEntity & a_Src) override; + virtual bool UsedBy(cPlayer * a_Player) override; + virtual void SendTo(cClientHandle & a_Client) override; +}; |