Added end portal and enchanting table block entities
This commit is contained in:
@@ -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)",
|
||||
|
||||
@@ -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
|
||||
|
||||
47
src/BlockEntities/EnchantingTableEntity.cpp
Normal file
47
src/BlockEntities/EnchantingTableEntity.cpp
Normal file
@@ -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);
|
||||
}
|
||||
32
src/BlockEntities/EnchantingTableEntity.h
Normal file
32
src/BlockEntities/EnchantingTableEntity.h
Normal file
@@ -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;
|
||||
};
|
||||
43
src/BlockEntities/EndPortalEntity.cpp
Normal file
43
src/BlockEntities/EndPortalEntity.cpp
Normal file
@@ -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);
|
||||
}
|
||||
27
src/BlockEntities/EndPortalEntity.h
Normal file
27
src/BlockEntities/EndPortalEntity.h
Normal file
@@ -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;
|
||||
};
|
||||
Reference in New Issue
Block a user