From 885d8287125439047ca2318f8e349b8da279e612 Mon Sep 17 00:00:00 2001 From: Lukas Pioch Date: Fri, 7 Jul 2017 09:31:45 +0200 Subject: Added bed entity (#3823) * Added bed entity * Export cBedEntity to lua * Set color of bed through item damage value * Added bed entity to APIDoc * NBT: Added loading and saving * Crafting recipes for the colored beds --- src/Blocks/BlockBed.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/Blocks/BlockBed.h') diff --git a/src/Blocks/BlockBed.h b/src/Blocks/BlockBed.h index cfb02ceeb..a9a3d0e20 100644 --- a/src/Blocks/BlockBed.h +++ b/src/Blocks/BlockBed.h @@ -1,10 +1,14 @@ +// BlockBed.h + #pragma once +#include "BlockEntity.h" #include "BlockHandler.h" #include "MetaRotator.h" -#include "Item.h" #include "ChunkInterface.h" +#include "../World.h" +#include "../Entities/Entity.h" class cPlayer; @@ -14,15 +18,16 @@ class cWorldInterface; class cBlockBedHandler : - public cMetaRotator + public cMetaRotator { public: cBlockBedHandler(BLOCKTYPE a_BlockType) - : cMetaRotator(a_BlockType) + : cMetaRotator(a_BlockType) { } virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override; + virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override; virtual bool IsUseable(void) override @@ -30,11 +35,9 @@ public: return true; } - virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override - { - // Reset meta to zero - a_Pickups.push_back(cItem(E_ITEM_BED, 1, 0)); - } + virtual void ConvertToPickups(cItems & Pickups, NIBBLETYPE Meta) override {} + + virtual void ConvertToPickups(cEntity * a_Digger, cItems & a_Pickups, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ) override; // Bed specific helper functions static NIBBLETYPE RotationToMetaData(double a_Rotation) @@ -77,6 +80,8 @@ public: a_ChunkInterface.SetBlockMeta(a_BedPosition.x, a_BedPosition.y, a_BedPosition.z, Meta); } + virtual void OnPlacedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, const sSetBlock & a_BlockChange) override; + virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override { UNUSED(a_Meta); -- cgit v1.2.3