summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockBed.cpp
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2017-11-20 12:13:11 +0100
committerAlexander Harkness <me@bearbin.net>2017-11-20 12:13:11 +0100
commit5badb9bccae803009bde182bf69ee0d02a36b22c (patch)
tree31fabd74fcee1138d4cacd0c437892c68c6defa9 /src/Blocks/BlockBed.cpp
parentcItemHandler: Update max stack size of old doors. (#4072) (diff)
downloadcuberite-5badb9bccae803009bde182bf69ee0d02a36b22c.tar
cuberite-5badb9bccae803009bde182bf69ee0d02a36b22c.tar.gz
cuberite-5badb9bccae803009bde182bf69ee0d02a36b22c.tar.bz2
cuberite-5badb9bccae803009bde182bf69ee0d02a36b22c.tar.lz
cuberite-5badb9bccae803009bde182bf69ee0d02a36b22c.tar.xz
cuberite-5badb9bccae803009bde182bf69ee0d02a36b22c.tar.zst
cuberite-5badb9bccae803009bde182bf69ee0d02a36b22c.zip
Diffstat (limited to '')
-rw-r--r--src/Blocks/BlockBed.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp
index d9199846a..901d7936a 100644
--- a/src/Blocks/BlockBed.cpp
+++ b/src/Blocks/BlockBed.cpp
@@ -17,9 +17,8 @@
void cBlockBedHandler::OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
{
- NIBBLETYPE OldMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
-
Vector3i ThisPos(a_BlockX, a_BlockY, a_BlockZ);
+ NIBBLETYPE OldMeta = a_ChunkInterface.GetBlockMeta(ThisPos);
Vector3i Direction = MetaDataToDirection(OldMeta & 0x3);
if (OldMeta & 0x8)
{
@@ -55,9 +54,9 @@ void cBlockBedHandler::OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInt
bool cBlockBedHandler::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)
{
+ Vector3i Coords(a_BlockX, a_BlockY, a_BlockZ);
if (a_WorldInterface.GetDimension() != dimOverworld)
{
- Vector3i Coords(a_BlockX, a_BlockY, a_BlockZ);
a_WorldInterface.DoExplosionAt(5, a_BlockX, a_BlockY, a_BlockZ, true, esBed, &Coords);
}
else if (!((a_WorldInterface.GetTimeOfDay() > 12541) && (a_WorldInterface.GetTimeOfDay() < 23458))) // Source: https://minecraft.gamepedia.com/Bed#Sleeping
@@ -66,7 +65,7 @@ bool cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface
}
else
{
- NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(Coords);
if ((Meta & 0x4) == 0x4)
{
a_Player.SendMessageFailure("This bed is occupied");
@@ -100,13 +99,13 @@ bool cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface
VERIFY((Meta & 0x4) != 0x4); // Occupied flag should never be set, else our compilator (intended) is broken
PillowDirection = MetaDataToDirection(Meta & 0x3);
- if (a_ChunkInterface.GetBlock(a_BlockX + PillowDirection.x, a_BlockY, a_BlockZ + PillowDirection.z) == E_BLOCK_BED) // Must always use pillow location for sleeping
+ if (a_ChunkInterface.GetBlock(Coords + PillowDirection) == E_BLOCK_BED) // Must always use pillow location for sleeping
{
a_WorldInterface.GetBroadcastManager().BroadcastUseBed(a_Player, a_BlockX + PillowDirection.x, a_BlockY, a_BlockZ + PillowDirection.z);
}
}
- a_Player.SetBedPos(Vector3i(a_BlockX, a_BlockY, a_BlockZ));
+ a_Player.SetBedPos(Coords);
SetBedOccupationState(a_ChunkInterface, a_Player.GetLastBedPos(), true);
a_Player.SetIsInBed(true);
a_Player.SendMessageSuccess("Home position set successfully");