Fix BlockSource::getDimensionId

This commit is contained in:
Qiuzhizhe 2023-02-02 14:37:11 +08:00
parent 7332bc36c7
commit 4ee7f71968
No known key found for this signature in database
GPG Key ID: 4EF4BF5521540263
2 changed files with 19 additions and 2 deletions

View File

@ -27,7 +27,7 @@ public:
inline AutomaticID<class Dimension, int> getDimensionId() const{
//Dimension::onBlockEvent Line24
// Dimension* mDimension = dAccess< Dimension*>(this, 4);
return dAccess<AutomaticID<class Dimension, int>>(getDimension(), 192);
return this->getDimension()->getDimensionId();
};
inline LevelChunk * getChunkAt(const BlockPos& pos) const{
ChunkPos chunkPos = ChunkPos(pos.x>>4, pos.z>>4);

View File

@ -4,7 +4,16 @@
#include "../Global.h"
#define BEFORE_EXTRA
#include "MC/BlockSource.hpp"
class BlockSource;
class DimensionHeightRange
{
public:
short min = 0;
short max;
DimensionHeightRange(short a):max(a){};
};
#undef BEFORE_EXTRA
class Dimension {
@ -23,6 +32,14 @@ public:
//Player::checkSpawnBlock Line19
return dAccess<AutomaticID<Dimension,int>>(this,192);
};
inline DimensionHeightRange const & getHeightRange() const{
// 0为主世界1为下界2为末地
if(this->getDimensionId() == 2 || this->getDimensionId() == 0)
return DimensionHeightRange(255);
else if(this->getDimensionId() == 1)
return DimensionHeightRange(127);
return DimensionHeightRange(0);
};
#undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_DIMENSION
public: