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 
74 
76  int m_MaxY;
77 };
unsigned int UInt32
Definition: Globals.h:157
Makes chunks stay loaded until this object is cleared or destroyed Works by setting internal flags in...
Definition: ChunkStay.h:36
Definition: Entity.h:76
Direction m_Dir
The direction of the portal.
UInt32 m_EntityID
The ID of the entity that's being moved.
int m_MaxY
The maximum Y to scan to.
cWorld & m_SourceWorld
The world we're moving the entity from, used to query the entity ID.
bool IsValidBuildLocation(Vector3i a_BlockPosition)
Whether the given location is a valid location to build a portal.
static const double OutOffset
Where to place the player out from the face and across the face.
static const int SearchSolidBaseWidth
The width of a solid base to search for when building.
virtual void OnChunkAvailable(int a_ChunkX, int a_ChunkY) override
Called when a specific chunk become available.
virtual void OnDisabled(void) override
Called by the ChunkMap when the ChunkStay is disabled.
bool m_BuildPlatform
Whether to build a platform.
Vector3d m_Position
The center of the search area.
static const int PortalHeight
static const int PortalLength
Length and height, including the obsidian.
cWorld & m_World
The world we're moving the entity to.
static const int SearchRadius
static const double AcrossOffset
static const int BuildSearchRadius
void BuildNetherPortal(Vector3i a_Location, Direction a_Direction, bool a_IncludePlatform)
Builds a portal.
cNetherPortalScanner(cEntity &a_MovingEntity, cWorld &a_DestinationWorld, Vector3d a_DestPosition, int a_MaxY)
virtual bool OnAllChunksAvailable(void) override
Called once all of the contained chunks are available.
bool m_FoundPortal
Whether we found a portal during the loading of the chunks.
Vector3i m_PortalLoc
The position of the pre-existing portal.
Definition: World.h:53