summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockBed.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2019-10-16 10:06:34 +0200
committerGitHub <noreply@github.com>2019-10-16 10:06:34 +0200
commit221cc4ec5cb6301743e947eaabed3fecedba796f (patch)
tree4e44c8bb7523e5d1d04468fc906ae24674c10abc /src/Blocks/BlockBed.h
parentFixed crash in hopper while pulling items from blockentity above itself (#4412) (diff)
downloadcuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar
cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar.gz
cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar.bz2
cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar.lz
cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar.xz
cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar.zst
cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.zip
Diffstat (limited to 'src/Blocks/BlockBed.h')
-rw-r--r--src/Blocks/BlockBed.h44
1 files changed, 29 insertions, 15 deletions
diff --git a/src/Blocks/BlockBed.h b/src/Blocks/BlockBed.h
index c66542e7d..585067ce2 100644
--- a/src/Blocks/BlockBed.h
+++ b/src/Blocks/BlockBed.h
@@ -4,7 +4,7 @@
#pragma once
#include "BlockEntity.h"
-#include "MetaRotator.h"
+#include "Mixins.h"
#include "ChunkInterface.h"
@@ -18,24 +18,28 @@ class cWorldInterface;
class cBlockBedHandler :
public cMetaRotator<cBlockEntityHandler, 0x3, 0x02, 0x03, 0x00, 0x01, true>
{
+ using super = cMetaRotator<cBlockEntityHandler, 0x3, 0x02, 0x03, 0x00, 0x01, true>;
+
public:
- cBlockBedHandler(BLOCKTYPE a_BlockType)
- : cMetaRotator<cBlockEntityHandler, 0x3, 0x02, 0x03, 0x00, 0x01, true>(a_BlockType)
+
+ cBlockBedHandler(BLOCKTYPE a_BlockType):
+ super(a_BlockType)
{
}
- virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override;
+
+
+
+ // Overrides:
+ virtual void OnBroken(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta) 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 cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) override;
+ virtual void OnPlacedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, const sSetBlock & a_BlockChange) override;
+
- virtual bool IsUseable(void) override
- {
- return true;
- }
- virtual void ConvertToPickups(cItems & Pickups, NIBBLETYPE Meta) override {}
- virtual void ConvertToPickups(cWorldInterface & a_WorldInterface, 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)
@@ -51,18 +55,26 @@ public:
return (static_cast<NIBBLETYPE>(a_Rotation + 2)) % 4;
}
+
+
+
+
static Vector3i MetaDataToDirection(NIBBLETYPE a_MetaData)
{
switch (a_MetaData)
{
- case 0: return Vector3i(0, 0, 1);
- case 1: return Vector3i(-1, 0, 0);
- case 2: return Vector3i(0, 0, -1);
- case 3: return Vector3i(1, 0, 0);
+ case 0: return Vector3i( 0, 0, 1);
+ case 1: return Vector3i(-1, 0, 0);
+ case 2: return Vector3i( 0, 0, -1);
+ case 3: return Vector3i( 1, 0, 0);
}
return Vector3i();
}
+
+
+
+
static void SetBedOccupationState(cChunkInterface & a_ChunkInterface, const Vector3i & a_BedPosition, bool a_IsOccupied)
{
auto Meta = a_ChunkInterface.GetBlockMeta(a_BedPosition);
@@ -78,7 +90,9 @@ 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
{