Skip to content

Commit

Permalink
Fix Dimension vtable (#1538)
Browse files Browse the repository at this point in the history
  • Loading branch information
quizhizhe authored and ShrBox committed May 31, 2024
1 parent cb1a052 commit d22a43e
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 105 deletions.
235 changes: 132 additions & 103 deletions src/mc/world/level/dimension/Dimension.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,21 +134,22 @@ class Dimension : public IDimension,
std::set<ActorUniqueID> mWitherIDs; // this+0x560
std::unique_ptr<LevelChunkBuilderData> mLevelChunkBuilderData; // this+0x570
std::chrono::steady_clock::time_point mLastPruneTime; // this+0x578
std::unique_ptr<ChunkBuildOrderPolicyBase> mChunkBuildOrderPolicy; // this+0x580
std::unique_ptr<VillageManager> mVillageManager; // this+0x588
std::vector<NetworkIdentifierWithSubId> mTemporaryPlayerIds; // this+0x590
std::unique_ptr<ChunkLoadActionList> mChunkLoadActionList; // this+0x5A8
std::unique_ptr<DelayActionList> mDelayActionList; // this+0x5B0
std::chrono::steady_clock::time_point mNextPruneTime; // this+0x580
std::unique_ptr<ChunkBuildOrderPolicyBase> mChunkBuildOrderPolicy; // this+0x588
std::unique_ptr<VillageManager> mVillageManager; // this+0x590
std::vector<NetworkIdentifierWithSubId> mTemporaryPlayerIds; // this+0x598
std::unique_ptr<ChunkLoadActionList> mChunkLoadActionList; // this+0x5B0
std::unique_ptr<DelayActionList> mDelayActionList; // this+0x5B8

std::unordered_map<SubChunkPos, UpdateSubChunkBlocksPacket::BlocksChangedInfo>
mBlocksChangedBySubChunkMap; // this+0x5B8
mBlocksChangedBySubChunkMap; // this+0x5C8

// Scripting::StrongObjectHandle
uchar mClientScriptDimension[0x48]; // this+0x5F8
uchar mClientScriptDimension[0x48]; // this+0x600

std::unique_ptr<PlayerReplicationStructures> mReplicationStructures; // this+0x640
std::vector<WeakEntityRef> mPlayersToReplicate; // this+0x648
bool mRunChunkGenWatchDog; // this+0x660
std::unique_ptr<PlayerReplicationStructures> mReplicationStructures; // this+0x648
std::vector<WeakEntityRef> mPlayersToReplicate; // this+0x650
bool mRunChunkGenWatchDog; // this+0x668

public:
// prevent constructor by default
Expand All @@ -158,103 +159,146 @@ class Dimension : public IDimension,

public:
// NOLINTBEGIN
// symbol:
// ?_createChunkBuildOrderPolicy@Dimension@@EEAA?AV?$unique_ptr@VChunkBuildOrderPolicyBase@@U?$default_delete@VChunkBuildOrderPolicyBase@@@std@@@std@@XZ
MCVAPI std::unique_ptr<class ChunkBuildOrderPolicyBase> _createChunkBuildOrderPolicy();
// symbol: ??1Dimension@@UEAA@XZ
// symbol: ??1Dimension@@UEAA@XZ
virtual ~Dimension();

// symbol: ?deserialize@Dimension@@UEAAXAEBVCompoundTag@@@Z
MCVAPI void deserialize(class CompoundTag const& tag);
// vIndex: 1, symbol: ?isNaturalDimension@Dimension@@UEBA_NXZ
virtual bool isNaturalDimension() const;

// vIndex: 2, symbol: ?getDimensionId@Dimension@@UEBA?AV?$AutomaticID@VDimension@@H@@XZ
virtual DimensionType getDimensionId() const;

// symbol: ?fetchEntity@Dimension@@UEBAPEAVActor@@UActorUniqueID@@_N@Z
MCVAPI class Actor* fetchEntity(struct ActorUniqueID actorID, bool getRemoved) const;
// vIndex: 3, symbol: ?sendPacketForPosition@Dimension@@UEAAXAEBVBlockPos@@AEBVPacket@@PEBVPlayer@@@Z
virtual void
sendPacketForPosition(class BlockPos const& position, class Packet const& packet, class Player const* except);

// symbol: ?flushLevelChunkGarbageCollector@Dimension@@UEAAXXZ
MCVAPI void flushLevelChunkGarbageCollector();
// vIndex: 4, symbol: ?flushLevelChunkGarbageCollector@Dimension@@UEAAXXZ
virtual void flushLevelChunkGarbageCollector();

// symbol: ?forEachPlayer@Dimension@@UEBAXV?$function@$$A6A_NAEAVPlayer@@@Z@std@@@Z
MCVAPI void forEachPlayer(std::function<bool(class Player&)> callback) const;
// vIndex: 5, symbol: ?initializeWithLevelStorageManager@Dimension@@UEAAXAEAVLevelStorageManager@@@Z
virtual void initializeWithLevelStorageManager(class LevelStorageManager&);

// symbol: ?forceCheckAllNeighChunkSavedStat@Dimension@@UEBA_NXZ
MCVAPI bool forceCheckAllNeighChunkSavedStat() const;
// vIndex: 6, symbol: ?getBiomeRegistry@Dimension@@UEAAAEAVBiomeRegistry@@XZ
virtual class BiomeRegistry& getBiomeRegistry();

// symbol: ?getBiomeRegistry@Dimension@@UEAAAEAVBiomeRegistry@@XZ
MCVAPI class BiomeRegistry& getBiomeRegistry();
// vIndex: 7, symbol: ?getBiomeRegistry@Dimension@@UEBAAEBVBiomeRegistry@@XZ
virtual class BiomeRegistry const& getBiomeRegistry() const;

// symbol: ?getBiomeRegistry@Dimension@@UEBAAEBVBiomeRegistry@@XZ
MCVAPI class BiomeRegistry const& getBiomeRegistry() const;
// vIndex: 9, symbol: ?forEachPlayer@Dimension@@UEBAXV?$function@$$A6A_NAEAVPlayer@@@Z@std@@@Z
virtual void forEachPlayer(std::function<bool(class Player&)> callback) const;

// symbol: ?getBrightnessDependentFogColor@Dimension@@UEBA?AVColor@mce@@AEBV23@M@Z
MCVAPI class mce::Color getBrightnessDependentFogColor(class mce::Color const& baseColor, float brightness) const;
// vIndex: 10, symbol: ?fetchEntity@Dimension@@UEBAPEAVActor@@UActorUniqueID@@_N@Z
virtual class Actor* fetchEntity(struct ActorUniqueID actorID, bool getRemoved) const;

// symbol: ?getBrightnessRamp@Dimension@@UEBAAEBVDimensionBrightnessRamp@@XZ
MCVAPI class DimensionBrightnessRamp const& getBrightnessRamp() const;
// vIndex: 11, symbol: ?init@Dimension@@UEAAXAEBVStructureSetRegistry@worldgen@br@@@Z
virtual void init(class br::worldgen::StructureSetRegistry const&);

// symbol: ?getClearColorScale@Dimension@@UEAAMXZ
MCVAPI float getClearColorScale();
// vIndex: 12, symbol: ?tick@Dimension@@UEAAXXZ
virtual void tick();

// symbol: ?getCloudHeight@Dimension@@UEBAFXZ
MCVAPI short getCloudHeight() const;
// vIndex: 13, symbol: ?tickRedstone@Dimension@@UEAAXXZ
virtual void tickRedstone();

// symbol: ?getDefaultBiome@Dimension@@UEBA?AVHashedString@@XZ
MCVAPI class HashedString getDefaultBiome() const;
// vIndex: 14
virtual std::unique_ptr<class WorldGenerator> createGenerator(class br::worldgen::StructureSetRegistry const&) = 0;

// symbol: ?getDimensionId@Dimension@@UEBA?AV?$AutomaticID@VDimension@@H@@XZ
MCVAPI DimensionType getDimensionId() const;
// vIndex: 15
virtual void
upgradeLevelChunk(class ChunkSource& source, class LevelChunk& lc, class LevelChunk& generatedChunk) = 0;

// symbol: ?getLightTextureImageBuilder@Dimension@@UEBAPEAVBaseLightTextureImageBuilder@@XZ
MCVAPI class BaseLightTextureImageBuilder* getLightTextureImageBuilder() const;
// vIndex: 16
virtual void fixWallChunk(class ChunkSource&, class LevelChunk&) = 0;

// symbol: ?getSpawnPos@Dimension@@UEBA?AVBlockPos@@XZ
MCVAPI class BlockPos getSpawnPos() const;
// vIndex: 17
virtual bool levelChunkNeedsUpgrade(class LevelChunk const&) const = 0;

// symbol: ?getSpawnYPosition@Dimension@@UEBAHXZ
MCVAPI int getSpawnYPosition() const;
// vIndex: 18, symbol: ?isValidSpawn@Dimension@@UEBA_NHH@Z
virtual bool isValidSpawn(int x, int z) const;

// symbol: ?getSunIntensity@Dimension@@UEBAMMAEBVVec3@@M@Z
MCVAPI float getSunIntensity(float a, class Vec3 const& viewVector, float minInfluenceAngle) const;
// vIndex: 19, symbol: ?getBrightnessDependentFogColor@Dimension@@UEBA?AVColor@mce@@AEBV23@M@Z
virtual class mce::Color getBrightnessDependentFogColor(class mce::Color const& baseColor, float brightness) const;

// symbol: ?getTimeOfDay@Dimension@@MEBAMHM@Z
MCVAPI float getTimeOfDay(int time, float a) const;
// vIndex: 20, symbol: ?isFoggyAt@Dimension@@UEBA_NHH@Z
virtual bool isFoggyAt(int x, int z) const;

// symbol: ?hasBedrockFog@Dimension@@UEAA_NXZ
MCVAPI bool hasBedrockFog();
// vIndex: 21, symbol: ?hasPrecipitationFog@Dimension@@UEBA_NXZ
virtual bool hasPrecipitationFog() const;

// symbol: ?hasGround@Dimension@@UEBA_NXZ
MCVAPI bool hasGround() const;
// vIndex: 22, symbol: ?getCloudHeight@Dimension@@UEBAFXZ
virtual short getCloudHeight() const;

// symbol: ?hasPrecipitationFog@Dimension@@UEBA_NXZ
MCVAPI bool hasPrecipitationFog() const;
// vIndex: 23, symbol: ?getDefaultBiome@Dimension@@UEBA?AVHashedString@@XZ
virtual class HashedString getDefaultBiome() const;

// symbol: ?init@Dimension@@UEAAXAEBVStructureSetRegistry@worldgen@br@@@Z
MCVAPI void init(class br::worldgen::StructureSetRegistry const&);
// vIndex: 24, symbol: ?mayRespawnViaBed@Dimension@@UEBA_NXZ
virtual bool mayRespawnViaBed() const;

// symbol: ?initializeWithLevelStorageManager@Dimension@@UEAAXAEAVLevelStorageManager@@@Z
MCVAPI void initializeWithLevelStorageManager(class LevelStorageManager&);
// vIndex: 25, symbol: ?hasGround@Dimension@@UEBA_NXZ
virtual bool hasGround() const;

// symbol: ?is2DPositionRelevantForPlayer@Dimension@@UEBA_NAEBVBlockPos@@AEAVPlayer@@@Z
MCVAPI bool is2DPositionRelevantForPlayer(class BlockPos const& position, class Player& player) const;
// vIndex: 26, symbol: ?getSpawnPos@Dimension@@UEBA?AVBlockPos@@XZ
virtual class BlockPos getSpawnPos() const;

// symbol: ?isActorRelevantForPlayer@Dimension@@UEBA_NAEAVPlayer@@AEBVActor@@@Z
MCVAPI bool isActorRelevantForPlayer(class Player& player, class Actor const& actor) const;
// vIndex: 27, symbol: ?getSpawnYPosition@Dimension@@UEBAHXZ
virtual int getSpawnYPosition() const;

// symbol: ?isDay@Dimension@@UEBA_NXZ
MCVAPI bool isDay() const;
// vIndex: 28, symbol: ?hasBedrockFog@Dimension@@UEAA_NXZ
virtual bool hasBedrockFog();

// symbol: ?isFoggyAt@Dimension@@UEBA_NHH@Z
MCVAPI bool isFoggyAt(int x, int z) const;
// vIndex: 29, symbol: ?getClearColorScale@Dimension@@UEAAMXZ
virtual float getClearColorScale();

// symbol: ?isNaturalDimension@Dimension@@UEBA_NXZ
MCVAPI bool isNaturalDimension() const;
// vIndex: 30, symbol: ?showSky@Dimension@@UEBA_NXZ
virtual bool showSky() const;

// symbol: ?isValidSpawn@Dimension@@UEBA_NHH@Z
MCVAPI bool isValidSpawn(int x, int z) const;
// vIndex: 31, symbol: ?isDay@Dimension@@UEBA_NXZ
virtual bool isDay() const;

// symbol: ?mayRespawnViaBed@Dimension@@UEBA_NXZ
MCVAPI bool mayRespawnViaBed() const;
// vIndex: 32, symbol: ?getTimeOfDay@Dimension@@MEBAMHM@Z
virtual float getTimeOfDay(int time, float a) const;

// symbol:
// vIndex: 33, symbol: ?getSunIntensity@Dimension@@UEBAMMAEBVVec3@@M@Z
virtual float getSunIntensity(float a, class Vec3 const& viewVector, float minInfluenceAngle) const;

// vIndex: 34, symbol: ?forceCheckAllNeighChunkSavedStat@Dimension@@UEBA_NXZ
virtual bool forceCheckAllNeighChunkSavedStat() const;

// vIndex: 35, vIndex: 34, symbol: ?sendBroadcast@Dimension@@UEAAXAEBVPacket@@PEAVPlayer@@@Z
virtual void sendBroadcast(class Packet const& packet, class Player* except);

// vIndex: 36, symbol: ?is2DPositionRelevantForPlayer@Dimension@@UEBA_NAEBVBlockPos@@AEAVPlayer@@@Z
virtual bool is2DPositionRelevantForPlayer(class BlockPos const& position, class Player& player) const;

// vIndex: 37, symbol: ?isActorRelevantForPlayer@Dimension@@UEBA_NAEAVPlayer@@AEBVActor@@@Z
virtual bool isActorRelevantForPlayer(class Player& player, class Actor const& actor) const;

// vIndex: 38, symbol: ?getLightTextureImageBuilder@Dimension@@UEBAPEAVBaseLightTextureImageBuilder@@XZ
virtual class BaseLightTextureImageBuilder* getLightTextureImageBuilder() const;

// vIndex: 39, symbol: ?getBrightnessRamp@Dimension@@UEBAAEBVDimensionBrightnessRamp@@XZ
virtual class DimensionBrightnessRamp const& getBrightnessRamp() const;

// vIndex: 40, symbol: ?startLeaveGame@Dimension@@UEAAXXZ
virtual void startLeaveGame();

// vIndex: 41, symbol:
// ?_createChunkBuildOrderPolicy@Dimension@@EEAA?AV?$unique_ptr@VChunkBuildOrderPolicyBase@@U?$default_delete@VChunkBuildOrderPolicyBase@@@std@@@std@@XZ
virtual std::unique_ptr<class ChunkBuildOrderPolicyBase> _createChunkBuildOrderPolicy();

// vIndex: 42
virtual void _upgradeOldLimboEntity(class CompoundTag& tag, ::LimboEntitiesVersion vers) = 0;

// vIndex: 43
virtual std::unique_ptr<class ChunkSource> _wrapStorageForVersionCompatibility(
std::unique_ptr<class ChunkSource> storageSource,
::StorageVersion levelVersion
) = 0;

// LevelListener vtable overloaded functions
// vIndex: 4, symbol:
// ?onBlockChanged@Dimension@@UEAAXAEAVBlockSource@@AEBVBlockPos@@IAEBVBlock@@2HPEBUActorBlockSyncMessage@@W4BlockChangedEventTarget@@PEAVActor@@@Z
MCVAPI void onBlockChanged(
virtual void onBlockChanged(
class BlockSource& source,
class BlockPos const& pos,
uint layer,
Expand All @@ -266,39 +310,24 @@ class Dimension : public IDimension,
class Actor* blockChangeSource
);

// symbol: ?onBlockEvent@Dimension@@UEAAXAEAVBlockSource@@HHHHH@Z
MCVAPI void onBlockEvent(class BlockSource& source, int x, int y, int z, int b0, int b1);

// symbol: ?onChunkLoaded@Dimension@@UEAAXAEAVChunkSource@@AEAVLevelChunk@@@Z
MCVAPI void onChunkLoaded(class ChunkSource& source, class LevelChunk& lc);
// LevelListener->BlockSourceListener vtable overloaded function
// vIndex: 8, symbol: ?onBlockEvent@Dimension@@UEAAXAEAVBlockSource@@HHHHH@Z
virtual void onBlockEvent(class BlockSource& source, int x, int y, int z, int b0, int b1);

// symbol: ?onLevelDestruction@Dimension@@UEAAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z
MCVAPI void onLevelDestruction(std::string const&);
// LevelListener vtable overloaded functions
// vIndex: 19,symbol: ?onChunkLoaded@Dimension@@UEAAXAEAVChunkSource@@AEAVLevelChunk@@@Z
virtual void onChunkLoaded(class ChunkSource& source, class LevelChunk& lc);

// symbol: ?sendBroadcast@Dimension@@UEAAXAEBVPacket@@PEAVPlayer@@@Z
MCVAPI void sendBroadcast(class Packet const& packet, class Player* except);
// vIndex: 23, symbol:
// ?onLevelDestruction@Dimension@@UEAAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z
virtual void onLevelDestruction(std::string const&);

// symbol: ?sendPacketForPosition@Dimension@@UEAAXAEBVBlockPos@@AEBVPacket@@PEBVPlayer@@@Z
MCVAPI void
sendPacketForPosition(class BlockPos const& position, class Packet const& packet, class Player const* except);
// SavedData vtable overloaded functions
// symbol: ?deserialize@Dimension@@UEAAXAEBVCompoundTag@@@Z
virtual void deserialize(class CompoundTag const& tag);

// symbol: ?serialize@Dimension@@UEBAXAEAVCompoundTag@@@Z
MCVAPI void serialize(class CompoundTag& tag) const;

// symbol: ?showSky@Dimension@@UEBA_NXZ
MCVAPI bool showSky() const;

// symbol: ?startLeaveGame@Dimension@@UEAAXXZ
MCVAPI void startLeaveGame();

// symbol: ?tick@Dimension@@UEAAXXZ
MCVAPI void tick();

// symbol: ?tickRedstone@Dimension@@UEAAXXZ
MCVAPI void tickRedstone();

// symbol: ??1Dimension@@UEAA@XZ
MCVAPI ~Dimension();
virtual void serialize(class CompoundTag& tag) const;

// symbol:
// ??0Dimension@@QEAA@AEAVILevel@@V?$AutomaticID@VDimension@@H@@VDimensionHeightRange@@AEAVScheduler@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z
Expand Down
5 changes: 5 additions & 0 deletions src/mc/world/level/dimension/IDimension.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
namespace mce { class Color; }
// clang-format on

class Actor;

class IDimension {

public:
Expand Down Expand Up @@ -41,5 +43,8 @@ class IDimension {
// vIndex: 9
virtual void forEachPlayer(std::function<bool(class Player&)> callback) const = 0;

// vIndex: 10
virtual Actor* fetchEntity(struct ActorUniqueID actorID, bool getRemoved) const = 0;

// NOLINTEND
};
4 changes: 2 additions & 2 deletions src/mc/world/level/levelgen/WorldGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class WorldGenerator : public ChunkSource, public IPreliminarySurfaceProvider {

// vIndex: 46
virtual void decorateWorldGenLoadChunk(
class Biome& biome,
class Biome const& biome,
class LevelChunk& lc,
class BlockVolumeTarget& target,
class Random& random,
Expand All @@ -107,7 +107,7 @@ class WorldGenerator : public ChunkSource, public IPreliminarySurfaceProvider {

// vIndex: 47
virtual void decorateWorldGenPostProcess(
class Biome& biome,
class Biome const& biome,
class LevelChunk& lc,
class BlockSource& source,
class Random& random
Expand Down

0 comments on commit d22a43e

Please sign in to comment.