summaryrefslogtreecommitdiffstats
path: root/src/NetherPortalScanner.h
diff options
context:
space:
mode:
authorLane Kolbly <lane@rscheme.org>2015-05-27 03:35:28 +0200
committerLane Kolbly <lane@rscheme.org>2015-06-10 01:23:57 +0200
commit73b6a44d5f9e35f7471b7e86e4fd5ee463b2ea44 (patch)
treeb4871bdf502c91912f99bb9ab00788e17bccd7ef /src/NetherPortalScanner.h
parentMerge pull request #2221 from mc-server/AreaCountBlocks (diff)
downloadcuberite-73b6a44d5f9e35f7471b7e86e4fd5ee463b2ea44.tar
cuberite-73b6a44d5f9e35f7471b7e86e4fd5ee463b2ea44.tar.gz
cuberite-73b6a44d5f9e35f7471b7e86e4fd5ee463b2ea44.tar.bz2
cuberite-73b6a44d5f9e35f7471b7e86e4fd5ee463b2ea44.tar.lz
cuberite-73b6a44d5f9e35f7471b7e86e4fd5ee463b2ea44.tar.xz
cuberite-73b6a44d5f9e35f7471b7e86e4fd5ee463b2ea44.tar.zst
cuberite-73b6a44d5f9e35f7471b7e86e4fd5ee463b2ea44.zip
Diffstat (limited to '')
-rw-r--r--src/NetherPortalScanner.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/NetherPortalScanner.h b/src/NetherPortalScanner.h
new file mode 100644
index 000000000..89ffd7d0e
--- /dev/null
+++ b/src/NetherPortalScanner.h
@@ -0,0 +1,75 @@
+
+#pragma once
+
+#include "Vector3.h"
+#include "ChunkStay.h"
+
+
+class cEntity;
+class cWorld;
+
+
+
+
+
+// This is the chunk stay which finds nearby nether portals
+class cNetherPortalScanner : public cChunkStay
+{
+public:
+ cNetherPortalScanner(cEntity * a_MovingEntity, cWorld * a_DestinationWorld, Vector3d a_DestPosition, int a_MaxY);
+ virtual void OnChunkAvailable(int a_ChunkX, int a_ChunkY) override;
+ virtual bool OnAllChunksAvailable(void) override;
+ virtual void OnDisabled(void) override;
+
+ enum class Direction
+ {
+ X,
+ Y
+ };
+
+private:
+
+ /** Length and height, including the obsidian. */
+ static const int PortalLength = 4;
+ static const int PortalHeight = 5;
+
+ static const int SearchRadius = 128;
+ static const int BuildSearchRadius = 16;
+
+ /** The width of a solid base to search for when building. */
+ static const int SearchSolidBaseWidth = 3;
+
+ /** Where to place the player out from the face and across the face */
+ const double OutOffset = 1.5;
+ const double AcrossOffset = 0.5;
+
+ /** Builds a portal. */
+ void BuildNetherPortal(Vector3i a_Location, Direction a_Direction, bool a_IncludePlatform);
+
+ /** Whether the given location is a valid location to build a portal. */
+ bool IsValidBuildLocation(Vector3i a_BlockPosition);
+
+ /** The entity that's being moved. */
+ cEntity * m_Entity;
+
+ /** The world we're moving the entity to. */
+ cWorld * m_World;
+
+ /** Whether we found a portal during the loading of the chunks. */
+ bool m_FoundPortal;
+
+ /** Whether to build a platform. True if we couldn't build the portal on solid ground */
+ bool m_BuildPlatform;
+
+ /** The direction of the portal. */
+ Direction m_Dir;
+
+ /** The position of the pre-existing portal. */
+ Vector3i m_PortalLoc;
+
+ /** The center of the search area */
+ Vector3d m_Position;
+
+ /** The maximum Y to scan to */
+ int m_MaxY;
+};