summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockPortal.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2020-04-21 22:19:22 +0200
committerGitHub <noreply@github.com>2020-04-21 22:19:22 +0200
commit487f9a2aa9b5497495cef1ac3b9c7a603e69f862 (patch)
tree054a846942f414060e29c72f4a717c8a89e70893 /src/Blocks/BlockPortal.h
parentDelet SpawnObject params (diff)
downloadcuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.tar
cuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.tar.gz
cuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.tar.bz2
cuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.tar.lz
cuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.tar.xz
cuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.tar.zst
cuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.zip
Diffstat (limited to '')
-rw-r--r--src/Blocks/BlockPortal.h40
1 files changed, 25 insertions, 15 deletions
diff --git a/src/Blocks/BlockPortal.h b/src/Blocks/BlockPortal.h
index 3f5d87155..c18da10be 100644
--- a/src/Blocks/BlockPortal.h
+++ b/src/Blocks/BlockPortal.h
@@ -7,25 +7,33 @@
-class cBlockPortalHandler :
+class cBlockPortalHandler:
public cBlockHandler
{
+ using Super = cBlockHandler;
public:
- cBlockPortalHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
+
+ cBlockPortalHandler(BLOCKTYPE a_BlockType):
+ Super(a_BlockType)
{
}
+
+
+
+
virtual bool GetPlacementBlockTypeMeta(
- cChunkInterface & a_ChunkInterface, cPlayer & a_Player,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
- int a_CursorX, int a_CursorY, int a_CursorZ,
+ cChunkInterface & a_ChunkInterface,
+ cPlayer & a_Player,
+ const Vector3i a_PlacedBlockPos,
+ eBlockFace a_ClickedBlockFace,
+ const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
{
- // We set to zero so MCS doesn't stop you from building weird portals like vanilla does
+ // We set meta to zero so Cuberite doesn't stop a Creative-mode player from building custom portal shapes
// CanBeAt doesn't do anything if meta is zero
- // We set to zero because the client sends meta = 2 to the server (it calculates rotation itself)
+ // We set to zero because the client sends meta = 1 or 2 to the server (it calculates rotation itself)
a_BlockType = m_BlockType;
a_BlockMeta = 0;
@@ -67,14 +75,14 @@ public:
- virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
{
- if ((a_RelY <= 0) || (a_RelY >= cChunkDef::Height - 1))
+ if ((a_RelPos.y <= 0) || (a_RelPos.y >= cChunkDef::Height - 1))
{
return false; // In case someone places a portal with meta 1 or 2 at boundaries, and server tries to get invalid coords at Y - 1 or Y + 1
}
- switch (a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ))
+ switch (a_Chunk.GetMeta(a_RelPos))
{
case 0x1:
{
@@ -91,8 +99,7 @@ public:
for (const auto & Direction : PortalCheck)
{
BLOCKTYPE Block;
- a_Chunk.UnboundedRelGetBlockType(a_RelX + Direction.x, a_RelY + Direction.y, a_RelZ + Direction.z, Block);
-
+ a_Chunk.UnboundedRelGetBlockType(a_RelPos + Direction, Block);
if ((Block != E_BLOCK_NETHER_PORTAL) && (Block != E_BLOCK_OBSIDIAN))
{
return false;
@@ -115,8 +122,7 @@ public:
for (const auto & Direction : PortalCheck)
{
BLOCKTYPE Block;
- a_Chunk.UnboundedRelGetBlockType(a_RelX + Direction.x, a_RelY + Direction.y, a_RelZ + Direction.z, Block);
-
+ a_Chunk.UnboundedRelGetBlockType(a_RelPos + Direction, Block);
if ((Block != E_BLOCK_NETHER_PORTAL) && (Block != E_BLOCK_OBSIDIAN))
{
return false;
@@ -128,6 +134,10 @@ public:
return true;
}
+
+
+
+
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);