Cuberite
A lightweight, fast and extensible game server for Minecraft
NetherPortalScanner.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "ChunkStay.h"
5 
6 
7 class cEntity;
8 class cWorld;
9 
10 
11 
12 
13 
14 // This is the chunk stay which finds nearby nether portals
16 {
17 public:
18  cNetherPortalScanner(cEntity * a_MovingEntity, cWorld * a_DestinationWorld, Vector3d a_DestPosition, int a_MaxY);
19  virtual void OnChunkAvailable(int a_ChunkX, int a_ChunkY) override;
20  virtual bool OnAllChunksAvailable(void) override;
21  virtual void OnDisabled(void) override;
22 
23  enum class Direction
24  {
25  X,
26  Y
27  };
28 
29 private:
30 
32  static const int PortalLength = 4;
33  static const int PortalHeight = 5;
34 
35  static const int SearchRadius = 128;
36  static const int BuildSearchRadius = 16;
37 
39  static const int SearchSolidBaseWidth = 3;
40 
42  static const double OutOffset;
43  static const double AcrossOffset;
44 
46  void BuildNetherPortal(Vector3i a_Location, Direction a_Direction, bool a_IncludePlatform);
47 
49  bool IsValidBuildLocation(Vector3i a_BlockPosition);
50 
53 
56 
59 
62 
65 
68 
71 
73  int m_MaxY;
74 };
Makes chunks stay loaded until this object is cleared or destroyed Works by setting internal flags in...
Definition: ChunkStay.h:35
static const int SearchSolidBaseWidth
The width of a solid base to search for when building.
cNetherPortalScanner(cEntity *a_MovingEntity, cWorld *a_DestinationWorld, Vector3d a_DestPosition, int a_MaxY)
Vector3i m_PortalLoc
The position of the pre-existing portal.
cWorld * m_World
The world we're moving the entity to.
bool m_BuildPlatform
Whether to build a platform.
cEntity * m_Entity
The entity that's being moved.
static const double OutOffset
Where to place the player out from the face and across the face.
virtual void OnDisabled(void) override
Called by the ChunkMap when the ChunkStay is disabled.
Definition: World.h:65
virtual void OnChunkAvailable(int a_ChunkX, int a_ChunkY) override
Called when a specific chunk become available.
static const double AcrossOffset
int m_MaxY
The maximum Y to scan to.
static const int PortalHeight
static const int BuildSearchRadius
bool m_FoundPortal
Whether we found a portal during the loading of the chunks.
Definition: Entity.h:73
void BuildNetherPortal(Vector3i a_Location, Direction a_Direction, bool a_IncludePlatform)
Builds a portal.
Direction m_Dir
The direction of the portal.
static const int SearchRadius
bool IsValidBuildLocation(Vector3i a_BlockPosition)
Whether the given location is a valid location to build a portal.
Vector3d m_Position
The center of the search area.
static const int PortalLength
Length and height, including the obsidian.
virtual bool OnAllChunksAvailable(void) override
Caled once all of the contained chunks are available.