diff --git a/LiteLoader/include/liteloader/Offset.h b/LiteLoader/include/liteloader/Offset.h new file mode 100644 index 0000000..d34afb9 --- /dev/null +++ b/LiteLoader/include/liteloader/Offset.h @@ -0,0 +1,158 @@ +#pragma once +#include +#include + +/* + * 偏移量命名规则:使用的文件名_函数名_(如有多个)第几个使用或者知道的成员名 + * */ + +namespace ll{ + namespace offset{ + + // ->header/llapi/mc + + // Null + constexpr uint64_t ATTRIBUTE_getName = 0x8; + // BaseCommandBlock::_setCommand a4 is Command + constexpr uint64_t BASECOMMANDBLOCK_getCommand = 0x38; + // ItemStackBase::init(ItemStackBase*, BlockLegacy *, int) Line14 + constexpr uint64_t BLOCKLEGAC_getBlockItemId = 0x10C; + // LevelChunk::_removeCallbacks Line28 + constexpr uint64_t BLOCKLEGAC_getBlockEntityType = 0xA8; + // Null + constexpr uint64_t BLOCKSOURCE_getDimension = 0x20; + // BegGoal::canUse Line6 + constexpr uint64_t BLOCKSOURCE_getDimensionConst = 0x328; + // DayLockCommand::execute Line91 + constexpr uint64_t COMMANDOUTPUT_getSuccessCount = 0x28; + // Null + constexpr uint64_t COMPOUNDTAGVARIANT_getTagType = 0x28; + // ExplorationMapFunction::apply Line57 + constexpr uint64_t DIMENSION_getBlockSourceFromMainChunkSource = 0x48; + // Null + constexpr uint64_t DIMENSION_getHeight = 0xCA; + // Player::checkSpawnBlock Line19 + constexpr uint64_t DIMENSION_getDimensionId = 0xC0; + // ItemRegistry::registerItem Line25 + constexpr uint64_t ITEM_getFullItemName = 0xD8; + // Null + constexpr uint64_t LEVEL_getSpawner = 0x7B0; + // CommandAreaFactory::_getArea Line156 + constexpr uint64_t LEVELCHUNK_getLastTick = 0x90; + // lambda_b490644342a3912d59dc52eb79c3a67f_::operator() Line410 + constexpr uint64_t MINECRAFT_getNetworkHandler = 0x18; + // mob::die Line83 + constexpr uint64_t MOB_getDead = 0x73A; + // EffectCommand::execute Line247 + constexpr uint64_t MOBEFFECT_getResourceName = 0x50; + // MobEffect::MobEffect Line43 + constexpr uint64_t MOBEFFECT_getComponentName = 0x98; + // ScoreboardCommand::applyPlayerOperation Line186 + constexpr uint64_t OBJECTIVE_getName = 0x40; + // Objective::serialize Line55 + constexpr uint64_t OBJECTIVE_getDisplayName = 0x60; + // Null + constexpr uint64_t PACKET_OBJECTIVE_getDisplayName = 0x10; + // AddPlayerPacket::AddPlayerPacket Line58 + constexpr uint64_t PLAYER_getDeviceId = 0x1EC0; + // Actor::onAboveBubbleColumn Line5 照抄的,不知行不行 + constexpr uint64_t PLAYER_isFlying_1 = 0x8B4; + constexpr uint64_t PLAYER_isFlying_2 = 0x8B8; + constexpr uint64_t PLAYER_isFlying_3 = 0x914; + constexpr uint64_t PLAYER_isFlying_4 = 0x918; + // PropertiesSettings::PropertiesSettings Line550 + constexpr uint64_t PROPERTIESSETTINGS_useOnlineAuthentication = 0x1A1; + // PropertiesSettings::PropertiesSettings Line518 + constexpr uint64_t PROPERTIESSETTINGS_getLevelName = 0x20; + // Null + constexpr uint64_t RAKNET_getAdr = 0x8; + // ResourcePackRepository::_initializeWorldPackSource Line62 + constexpr uint64_t RESOURCEPACKREPOSITORY_getPackSourceFactory = 0x170; + // ServerScoreboard::_unpackIdentityDefToScorePacket Line30~31 16+72 + constexpr uint64_t SCOREBOARDIDENTITYREF_getIdentityType = 0x58; + + // ->src/EventAPI + + // Null + constexpr uint64_t EVENTAPI_PlayerInteractEntity_1 = 0x68; + // Null + constexpr uint64_t EVENTAPI_PlayerInteractEntity_2 = 0x70; + // Hopper::Hopper + constexpr uint64_t EVENTAPI_HopperSearchItem = 0x5; + + // ->src/llapi/mc + + // Null + constexpr uint64_t BIOMEAPI_getID = 0x78; + // Null + constexpr uint64_t BIOMEAPI_getName = 0x8; + // Null + constexpr uint64_t BLOCKAPI_getTileData = 0x8; + // Actor::_playFlySound Line7 + constexpr uint64_t BLOCKAPI_getRuntimeId = 0x30; + // Null + constexpr uint64_t BLOCKLEGACYAPI_getRuntimeId = 0x80; + // Container::Container + constexpr uint64_t CONTAINERAPI_getTypeName= 0x8; + // Null + constexpr uint64_t GAMEMODEAPI_getPlayer= 0x8; + // Null + constexpr uint64_t HITRESULTAPI_getFacing= 0x1C; + // Null + constexpr uint64_t HITRESULTAPI_getPos= 0x2C; + // Null + constexpr uint64_t HITRESULTAPI_isHitLiquid= 0x50; + // Null + constexpr uint64_t HITRESULTAPI_getBlockPos= 0x20; + // Null + constexpr uint64_t HITRESULTAPI_getLiquidPos= 0x54; + // Null + constexpr uint64_t HITRESULTAPI_getLiquidFacing= 0x51; + // Player::take Line127 + constexpr uint64_t ITEMACTORAPI_getItemStack= 0x620; + // ItemActor::NormalTick Line258 + constexpr uint64_t ITEMACTORAPI_getDespawnTime = 0x6C4; + // ItemActor::NormalTick Line258 也许是? + constexpr uint64_t ITEMACTORAPI_getLatestSpawnTime = 0x6B0; + // Null + constexpr uint64_t ITEMSTACKAPI_getCount = 0x22; + // MovingBlockActor::load Line69 + constexpr uint64_t LEVELAPI_getBlockPalettePtr = 0x7D0; + // ServerPlayer::isHostingPlayer + constexpr uint64_t PLAYERAPI_getNetworkIdentifier = 0x980; + // KickCommand::_kickPlayer Line116 + constexpr uint64_t PLAYERAPI_getCertificate = 0xAB0; + // AddPlayerPacket::AddPlayerPacket Line59 + constexpr uint64_t PLAYERAPI_getPlatform = 0x838; + // InventoryContainerModel::_getContainer 2928 + 176 + constexpr uint64_t PLAYERAPI_getInventory = 0xC20; + // ServerNetworkHandler::_sendLevelData Line316 + constexpr uint64_t PLAYERAPI_getSpawnPosition = 0x1C14; + // ServerNetworkHandler::_sendLevelData Line310 + constexpr uint64_t PLAYERAPI_getSpawnDimension = 0x1C20; + // Null + constexpr uint64_t PLAYERAPI_getClientUUID = 0xAA0; + // ServerPlayer::sendNetworkPacket 参4 + constexpr uint64_t PLAYERAPI_getClientSubId = 0xDC0; + // Null + constexpr uint64_t PLAYERAPI_crashClient = 0X38; + // Null + constexpr uint64_t PLAYERAPI_sendTransferPacket_port = 0X24; + // Null + constexpr uint64_t PLAYERAPI_sendTransferPacket_address = 0X28; + // Null + constexpr uint64_t PLAYERAPI_sendSetScorePacket_type = 0X30; + // Null + constexpr uint64_t PLAYERAPI_sendSetScorePacket_data = 0X38; + // Null + constexpr uint64_t PLAYERAPI_sendCommandRequestPacket_cmd = 0X30; + // Null + constexpr uint64_t RESOURCEPACKREPOSITORYAPI_setCustomResourcePackPath = 0x30; + + // ->src/llapi/nbt + + // Block::Block? + constexpr uint64_t COMPOUNDTAGAPI_fromBlock = 0x18; + } +} + diff --git a/LiteLoader/include/llapi/HookAPI.h b/LiteLoader/include/llapi/HookAPI.h index 49d05f1..dbdd12b 100644 --- a/LiteLoader/include/llapi/HookAPI.h +++ b/LiteLoader/include/llapi/HookAPI.h @@ -1,11 +1,15 @@ #pragma once -#include "Global.h" -#include "utils/Hash.h" -#include + #include #include #include +#include +#include + +#include "Global.h" +#include "utils/Hash.h" + // The core api of the hook function //__declspec(dllimport) int HookFunction(void* oldfunc, void** poutold, void* newfunc); // Used to get a server-defined specific function by name diff --git a/LiteLoader/include/llapi/mc/Attribute.hpp b/LiteLoader/include/llapi/mc/Attribute.hpp index 8b8526e..834ed47 100644 --- a/LiteLoader/include/llapi/mc/Attribute.hpp +++ b/LiteLoader/include/llapi/mc/Attribute.hpp @@ -12,7 +12,7 @@ class Attribute { #define AFTER_EXTRA public: inline class HashedString const & getName() const{ - return dAccess(this, 8); + return dAccess(this, ll::offset::ATTRIBUTE_getName); } #undef AFTER_EXTRA diff --git a/LiteLoader/include/llapi/mc/BaseCommandBlock.hpp b/LiteLoader/include/llapi/mc/BaseCommandBlock.hpp index 79e0469..8c2cca2 100644 --- a/LiteLoader/include/llapi/mc/BaseCommandBlock.hpp +++ b/LiteLoader/include/llapi/mc/BaseCommandBlock.hpp @@ -13,7 +13,7 @@ class BaseCommandBlock { public: inline std::string const & getCommand() const{ //BaseCommandBlock::_setCommand a4 is Command; - return dAccess(this,56); + return dAccess(this,ll::offset::BASECOMMANDBLOCK_getCommand); }; #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_BASECOMMANDBLOCK diff --git a/LiteLoader/include/llapi/mc/BlockLegacy.hpp b/LiteLoader/include/llapi/mc/BlockLegacy.hpp index 80c7a8a..ef85993 100644 --- a/LiteLoader/include/llapi/mc/BlockLegacy.hpp +++ b/LiteLoader/include/llapi/mc/BlockLegacy.hpp @@ -163,7 +163,7 @@ public: inline int getBlockItemId() const{ //ItemStackBase::init(ItemStackBase *this, const struct BlockLegacy *a2, int a3) Line14 - unsigned int id = dAccess(this,268);//mID + unsigned int id = dAccess(this,ll::offset::BLOCKLEGAC_getBlockItemId);//mID // unsigned int id = this->mID; if(id < 256u) return id; @@ -176,7 +176,7 @@ public: } inline enum BlockActorType getBlockEntityType() const{ // LevelChunk::_removeCallbacks Line28 - return dAccess(this,168); + return dAccess(this,ll::offset::BLOCKLEGAC_getBlockEntityType); //return this->mBlockEntityType; }; diff --git a/LiteLoader/include/llapi/mc/BlockSource.hpp b/LiteLoader/include/llapi/mc/BlockSource.hpp index 9c996a1..bc91453 100644 --- a/LiteLoader/include/llapi/mc/BlockSource.hpp +++ b/LiteLoader/include/llapi/mc/BlockSource.hpp @@ -22,7 +22,7 @@ public: // }; LIAPI BlockInstance getBlockInstance(BlockPos); inline Dimension* getDimension() const{ - return dAccess< Dimension*>(this, 32); + return dAccess< Dimension*>(this, ll::offset::BLOCKSOURCE_getDimension); } inline AutomaticID getDimensionId() const{ //Dimension::onBlockEvent Line24 @@ -42,7 +42,7 @@ public: } inline Dimension const & getDimensionConst() const{ //BegGoal::canUse Line6 - return dAccess(this,808); + return dAccess(this,ll::offset::BLOCKSOURCE_getDimensionConst); }; // inline short getHeightmap(class BlockPos const &bs) const{ // auto levelchunk = getChunkAt(bs); diff --git a/LiteLoader/include/llapi/mc/CommandOutput.hpp b/LiteLoader/include/llapi/mc/CommandOutput.hpp index 87cb5cd..392ac5c 100644 --- a/LiteLoader/include/llapi/mc/CommandOutput.hpp +++ b/LiteLoader/include/llapi/mc/CommandOutput.hpp @@ -23,13 +23,13 @@ public: inline int getSuccessCount() const{ //DayLockCommand::execute Line91 - return dAccess(this,0x28); + return dAccess(this,ll::offset::COMMANDOUTPUT_getSuccessCount); }; inline void success(){ - int successCount = dAccess(this,0x28); + int successCount = dAccess(this,ll::offset::COMMANDOUTPUT_getSuccessCount); ++successCount; - dAccess(this,0x28) = successCount; + dAccess(this,ll::offset::COMMANDOUTPUT_getSuccessCount) = successCount; }; inline bool empty() const{ diff --git a/LiteLoader/include/llapi/mc/CompoundTagVariant.hpp b/LiteLoader/include/llapi/mc/CompoundTagVariant.hpp index f3c6666..494fb86 100644 --- a/LiteLoader/include/llapi/mc/CompoundTagVariant.hpp +++ b/LiteLoader/include/llapi/mc/CompoundTagVariant.hpp @@ -12,7 +12,7 @@ class CompoundTagVariant { #define AFTER_EXTRA public: inline Tag::Type getTagType() { - return dAccess(this); + return dAccess(this); } inline Tag* asTag() { return (Tag*)this; diff --git a/LiteLoader/include/llapi/mc/Dimension.hpp b/LiteLoader/include/llapi/mc/Dimension.hpp index 31fd74e..b2073e0 100644 --- a/LiteLoader/include/llapi/mc/Dimension.hpp +++ b/LiteLoader/include/llapi/mc/Dimension.hpp @@ -22,15 +22,15 @@ class Dimension { public: inline BlockSource& getBlockSourceFromMainChunkSource() const{ //ExplorationMapFunction::apply Line57 - return *dAccess(this, 72); + return *dAccess(this, ll::offset::DIMENSION_getBlockSourceFromMainChunkSource); }; inline int getHeight(){ - return dAccess(this,202); + return dAccess(this,ll::offset::DIMENSION_getHeight); }; inline AutomaticID getDimensionId() const{ //Player::moveSpawnView Line33 //Player::checkSpawnBlock Line19 - return dAccess>(this,192); + return dAccess>(this,ll::offset::DIMENSION_getDimensionId); }; inline DimensionHeightRange const & getHeightRange() const{ // 0为主世界,1为下界,2为末地 diff --git a/LiteLoader/include/llapi/mc/Item.hpp b/LiteLoader/include/llapi/mc/Item.hpp index 1ebefdd..4a916ae 100644 --- a/LiteLoader/include/llapi/mc/Item.hpp +++ b/LiteLoader/include/llapi/mc/Item.hpp @@ -20,7 +20,7 @@ class Item { public: inline std::string const & getFullItemName() const{ //ItemRegistry::registerItem Line25 - return dAccess(this,216); + return dAccess(this,ll::offset::ITEM_getFullItemName); }; #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_ITEM diff --git a/LiteLoader/include/llapi/mc/Level.hpp b/LiteLoader/include/llapi/mc/Level.hpp index 00aad7c..1a83d51 100644 --- a/LiteLoader/include/llapi/mc/Level.hpp +++ b/LiteLoader/include/llapi/mc/Level.hpp @@ -143,7 +143,7 @@ public: } inline Spawner& getSpawner() const{ - return *dAccess>(this,1968).get(); + return *dAccess>(this,ll::offset::LEVEL_getSpawner).get(); }; #undef AFTER_EXTRA diff --git a/LiteLoader/include/llapi/mc/LevelChunk.hpp b/LiteLoader/include/llapi/mc/LevelChunk.hpp index 85f3595..469591f 100644 --- a/LiteLoader/include/llapi/mc/LevelChunk.hpp +++ b/LiteLoader/include/llapi/mc/LevelChunk.hpp @@ -42,7 +42,7 @@ struct HardcodedSpawningArea { public: struct Tick const & getLastTick() const{ //CommandAreaFactory::_getArea Line156 - return *dAccess(this, 144); + return *dAccess(this, ll::offset::LEVELCHUNK_getLastTick); }; inline int getHeightmap(const ChunkBlockPos *pos){ //LevelChunk::_lightingCallbacks Line31 应该是这样的 diff --git a/LiteLoader/include/llapi/mc/Minecraft.hpp b/LiteLoader/include/llapi/mc/Minecraft.hpp index a54b823..5ca2e3a 100644 --- a/LiteLoader/include/llapi/mc/Minecraft.hpp +++ b/LiteLoader/include/llapi/mc/Minecraft.hpp @@ -14,7 +14,7 @@ class Minecraft { public: inline NetworkHandler & getNetworkHandler(){ //lambda_b490644342a3912d59dc52eb79c3a67f_::operator() Line410 - return dAccess(this,24); + return dAccess(this,ll::offset::MINECRAFT_getNetworkHandler); }; #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_MINECRAFT diff --git a/LiteLoader/include/llapi/mc/Mob.hpp b/LiteLoader/include/llapi/mc/Mob.hpp index 631885b..5b2adb5 100644 --- a/LiteLoader/include/llapi/mc/Mob.hpp +++ b/LiteLoader/include/llapi/mc/Mob.hpp @@ -28,7 +28,7 @@ public: } inline bool getDead(){ //mob::die Line83 - return dAccess(this,1850); + return dAccess(this,ll::offset::MOB_getDead); }; #undef AFTER_EXTRA diff --git a/LiteLoader/include/llapi/mc/MobEffect.hpp b/LiteLoader/include/llapi/mc/MobEffect.hpp index f017165..191a834 100644 --- a/LiteLoader/include/llapi/mc/MobEffect.hpp +++ b/LiteLoader/include/llapi/mc/MobEffect.hpp @@ -53,11 +53,11 @@ public: inline std::string const & getResourceName() const{ //EffectCommand::execute Line247 - return dAccess(this,80); + return dAccess(this,ll::offset::MOBEFFECT_getResourceName); }; inline HashedString const & getComponentName() const{ //MobEffect::MobEffect Line43; - return dAccess(this,152); + return dAccess(this,ll::offset::MOBEFFECT_getComponentName); }; #undef AFTER_EXTRA diff --git a/LiteLoader/include/llapi/mc/Objective.hpp b/LiteLoader/include/llapi/mc/Objective.hpp index 45aa346..91965de 100644 --- a/LiteLoader/include/llapi/mc/Objective.hpp +++ b/LiteLoader/include/llapi/mc/Objective.hpp @@ -14,14 +14,14 @@ class Objective { public: inline std::string getName(){ //ScoreboardCommand::applyPlayerOperation Line186 - return dAccess(this, 64); + return dAccess(this, ll::offset::OBJECTIVE_getName); }; LIAPI bool setDisplay(const std::string& slotName, ObjectiveSortOrder sort); inline std::string const & getDisplayName() const{ //Objective::serialize - return dAccess(this,96); + return dAccess(this,ll::offset::OBJECTIVE_getDisplayName); }; #undef AFTER_EXTRA diff --git a/LiteLoader/include/llapi/mc/Packet.hpp b/LiteLoader/include/llapi/mc/Packet.hpp index d8bd2bb..ee06570 100644 --- a/LiteLoader/include/llapi/mc/Packet.hpp +++ b/LiteLoader/include/llapi/mc/Packet.hpp @@ -39,7 +39,7 @@ public: inline ServerPlayer* getPlayerFromPacket(ServerNetworkHandler* handler, NetworkIdentifier* netId) { - return handler->getServerPlayer(*netId, dAccess(this, 16)); + return handler->getServerPlayer(*netId, dAccess(this, ll::offset::PACKET_OBJECTIVE_getDisplayName)); } inline enum StreamReadResult _read(class ReadOnlyBinaryStream& binaryStream) { diff --git a/LiteLoader/include/llapi/mc/Player.hpp b/LiteLoader/include/llapi/mc/Player.hpp index c7f93ae..24f51c9 100644 --- a/LiteLoader/include/llapi/mc/Player.hpp +++ b/LiteLoader/include/llapi/mc/Player.hpp @@ -184,11 +184,13 @@ public: } inline std::string* getDeviceId(){ //AddPlayerPacket::AddPlayerPacket Line58 - return dAccess(this,7872); + return dAccess(this,ll::offset::PLAYER_getDeviceId); }; inline bool isFlying(){ //Actor::onAboveBubbleColumn Line5 照抄的,不知行不行 - return (dAccess(this,2228) == 1 || !dAccess(this,2232)) && (dAccess(this, 2324) == 1 || !dAccess(this, 2328)); + return (dAccess(this,ll::offset::PLAYER_isFlying_1) == 1 + || !dAccess(this,ll::offset::PLAYER_isFlying_2)) + && (dAccess(this, ll::offset::PLAYER_isFlying_3) == 1 || !dAccess(this, ll::offset::PLAYER_isFlying_4)); }; inline bool isHungry(){ void* Player_HUNGER = dlsym("?HUNGER@Player@@2VAttribute@@B"); diff --git a/LiteLoader/include/llapi/mc/PropertiesSettings.hpp b/LiteLoader/include/llapi/mc/PropertiesSettings.hpp index fa9de4e..f2bc672 100644 --- a/LiteLoader/include/llapi/mc/PropertiesSettings.hpp +++ b/LiteLoader/include/llapi/mc/PropertiesSettings.hpp @@ -13,11 +13,11 @@ class PropertiesSettings { public: inline bool useOnlineAuthentication(){ //PropertiesSettings::PropertiesSettings Line550; - return dAccess(this, 417); + return dAccess(this, ll::offset::PROPERTIESSETTINGS_useOnlineAuthentication); } inline std::string getLevelName(){ //PropertiesSettings::PropertiesSettings Line518 - return dAccess(this,32); + return dAccess(this,ll::offset::PROPERTIESSETTINGS_getLevelName); } #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_PROPERTIESSETTINGS diff --git a/LiteLoader/include/llapi/mc/RakNet.hpp b/LiteLoader/include/llapi/mc/RakNet.hpp index d2d03a6..7a5844c 100644 --- a/LiteLoader/include/llapi/mc/RakNet.hpp +++ b/LiteLoader/include/llapi/mc/RakNet.hpp @@ -41,7 +41,7 @@ namespace RakNet { RakPeer(RakPeer const&) = delete; RakPeer(RakPeer&&) = delete; SystemAddress getAdr(NetworkIdentifier const& ni) { - RakNetGUID const& guid = dAccess(&ni, 8); + RakNetGUID const& guid = dAccess(&ni, ll::offset::RAKNET_getAdr); return RakPeer::GetSystemAddressFromGuid(guid); } MCAPI virtual SystemAddress GetSystemAddressFromGuid(struct RakNet::RakNetGUID) const; diff --git a/LiteLoader/include/llapi/mc/ResourcePackRepository.hpp b/LiteLoader/include/llapi/mc/ResourcePackRepository.hpp index 8039412..677b6fc 100644 --- a/LiteLoader/include/llapi/mc/ResourcePackRepository.hpp +++ b/LiteLoader/include/llapi/mc/ResourcePackRepository.hpp @@ -21,7 +21,7 @@ public: inline class PackSourceFactory* getPackSourceFactory(){ //ResourcePackRepository::_initializeWorldPackSource Line62 - return dAccess(this, 46 * 8); + return dAccess(this, ll::offset::RESOURCEPACKREPOSITORY_getPackSourceFactory); }; #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_RESOURCEPACKREPOSITORY diff --git a/LiteLoader/include/llapi/mc/ScoreboardIdentityRef.hpp b/LiteLoader/include/llapi/mc/ScoreboardIdentityRef.hpp index 16155b9..162e836 100644 --- a/LiteLoader/include/llapi/mc/ScoreboardIdentityRef.hpp +++ b/LiteLoader/include/llapi/mc/ScoreboardIdentityRef.hpp @@ -13,7 +13,7 @@ class ScoreboardIdentityRef { public: enum IdentityDefinition::Type getIdentityType(){ //ServerScoreboard::_unpackIdentityDefToScorePacket Line30~31 16+72 - return dAccess(this, 88); + return dAccess(this, ll::offset::SCOREBOARDIDENTITYREF_getIdentityType); }; #undef AFTER_EXTRA diff --git a/LiteLoader/src/llapi/EventAPI.cpp b/LiteLoader/src/llapi/EventAPI.cpp index 97bca2f..68402be 100644 --- a/LiteLoader/src/llapi/EventAPI.cpp +++ b/LiteLoader/src/llapi/EventAPI.cpp @@ -1129,8 +1129,8 @@ TInstanceHook(void, "?handle@ItemUseOnActorInventoryTransaction@@UEBA?AW4Invento IF_LISTENED(PlayerInteractEntityEvent) { PlayerInteractEntityEvent ev{}; ev.mPlayer = sp; - ev.mTargetId = dAccess(this);//正确 - ev.mInteractiveMode = static_cast(dAccess(this));//看起来应该正确 + ev.mTargetId = dAccess(this);//正确 + ev.mInteractiveMode = static_cast(dAccess(this));//看起来应该正确 if (!ev.call()) return; } diff --git a/LiteLoader/src/llapi/mc/BiomeAPI.cpp b/LiteLoader/src/llapi/mc/BiomeAPI.cpp index 33c1cd7..f4f1ef4 100644 --- a/LiteLoader/src/llapi/mc/BiomeAPI.cpp +++ b/LiteLoader/src/llapi/mc/BiomeAPI.cpp @@ -5,11 +5,11 @@ #include int Biome::getId() const { - return dAccess(this); + return dAccess(this); } std::string const& Biome::getName() const { - return dAccess(this); + return dAccess(this); } // Biome* Biome::fromId(int id) { diff --git a/LiteLoader/src/llapi/mc/BlockAPI.cpp b/LiteLoader/src/llapi/mc/BlockAPI.cpp index 955947f..8c62005 100644 --- a/LiteLoader/src/llapi/mc/BlockAPI.cpp +++ b/LiteLoader/src/llapi/mc/BlockAPI.cpp @@ -34,7 +34,7 @@ string Block::getTypeName() const { unsigned short Block::getTileData() { // 等待大佬改进 - auto tileData = dAccess(this); + auto tileData = dAccess(this); auto blk = &getLegacyBlock(); if (((BlockLegacy*)blk)->toBlock(tileData) == (Block*)this) { @@ -64,5 +64,5 @@ bool Block::setNbt(CompoundTag* nbt) { unsigned int const & Block::getRuntimeId() const{ // Actor::_playFlySound Line7 - return dAccess(this, 48); + return dAccess(this, ll::offset::BLOCKAPI_getRuntimeId); } \ No newline at end of file diff --git a/LiteLoader/src/llapi/mc/BlockLegacyAPI.cpp b/LiteLoader/src/llapi/mc/BlockLegacyAPI.cpp index 206f68b..2e79b0c 100644 --- a/LiteLoader/src/llapi/mc/BlockLegacyAPI.cpp +++ b/LiteLoader/src/llapi/mc/BlockLegacyAPI.cpp @@ -13,7 +13,7 @@ Block* BlockLegacy::toBlock(unsigned short tileData) { } string BlockLegacy::getTypeName() { - return dAccess(this); + return dAccess(this); } bool BlockLegacy::applyBoneMeal(BlockSource* a1, BlockPos* a2) { diff --git a/LiteLoader/src/llapi/mc/ContainerAPI.cpp b/LiteLoader/src/llapi/mc/ContainerAPI.cpp index 1ab210b..c3e4fdd 100644 --- a/LiteLoader/src/llapi/mc/ContainerAPI.cpp +++ b/LiteLoader/src/llapi/mc/ContainerAPI.cpp @@ -6,7 +6,7 @@ #include LIAPI std::string Container::getTypeName() { - ContainerType type = dAccess(this, 8); //IDA Container::Container + ContainerType type = dAccess(this, ll::offset::CONTAINERAPI_getTypeName); //IDA Container::Container // ContainerType type = getContainerType(); return std::string{magic_enum::enum_name(type)}; } diff --git a/LiteLoader/src/llapi/mc/GameModeAPI.cpp b/LiteLoader/src/llapi/mc/GameModeAPI.cpp index 3172ffd..c8f31af 100644 --- a/LiteLoader/src/llapi/mc/GameModeAPI.cpp +++ b/LiteLoader/src/llapi/mc/GameModeAPI.cpp @@ -3,5 +3,5 @@ #include ServerPlayer* GameMode::getPlayer() { - return dAccess(this); + return dAccess(this); } \ No newline at end of file diff --git a/LiteLoader/src/llapi/mc/HitResultAPI.cpp b/LiteLoader/src/llapi/mc/HitResultAPI.cpp index de0ffca..622469b 100644 --- a/LiteLoader/src/llapi/mc/HitResultAPI.cpp +++ b/LiteLoader/src/llapi/mc/HitResultAPI.cpp @@ -2,13 +2,13 @@ #include FaceID HitResult::getFacing() { - return dAccess(this, 28); + return dAccess(this, ll::offset::HITRESULTAPI_getFacing); } Vec3 HitResult::getPos() { - return dAccess(this, 44); + return dAccess(this, ll::offset::HITRESULTAPI_getPos); } bool HitResult::isHitLiquid() { - return dAccess(this, 80); + return dAccess(this, ll::offset::HITRESULTAPI_isHitLiquid); } // LIAPI bool HitResult::isEntity() { // return getHitResultType() == HitResultType::ENTITY; @@ -17,13 +17,13 @@ bool HitResult::isHitLiquid() { // return getHitResultType() == HitResultType::TILE; // } BlockPos HitResult::getBlockPos() { - return dAccess(this, 32); + return dAccess(this, ll::offset::HITRESULTAPI_getBlockPos); } BlockPos HitResult::getLiquidPos() { - return dAccess(this, 84); + return dAccess(this, ll::offset::HITRESULTAPI_getLiquidPos); } FaceID HitResult::getLiquidFacing() { - return dAccess(this, 81); + return dAccess(this, ll::offset::HITRESULTAPI_getLiquidFacing); } // LIAPI Vec3 HitResult::getLiquidHitPos(); // LIAPI HitResultType HitResult::getHitResultType() { diff --git a/LiteLoader/src/llapi/mc/ItemActorAPI.cpp b/LiteLoader/src/llapi/mc/ItemActorAPI.cpp index 5b1bc5c..c584a2a 100644 --- a/LiteLoader/src/llapi/mc/ItemActorAPI.cpp +++ b/LiteLoader/src/llapi/mc/ItemActorAPI.cpp @@ -3,18 +3,18 @@ #include ItemStack* ItemActor::getItemStack() { - return (ItemStack*)((uintptr_t)this + 1568); // IDA Player::take Line127 + return dAccess(this, ll::offset::ITEMACTORAPI_getItemStack); // IDA Player::take Line127 } int ItemActor::getDespawnTime() { - return dAccess(this); // ItemActor::NormalTick Line258 + return dAccess(this); // ItemActor::NormalTick Line258 } bool ItemActor::setDespawnTime(int a1) { - dAccess(this) = a1; + dAccess(this) = a1; return true; } int ItemActor::getLatestSpawnTime() { - return dAccess(this); + return dAccess(this); } \ No newline at end of file diff --git a/LiteLoader/src/llapi/mc/ItemStackAPI.cpp b/LiteLoader/src/llapi/mc/ItemStackAPI.cpp index 7d8d437..dcdab50 100644 --- a/LiteLoader/src/llapi/mc/ItemStackAPI.cpp +++ b/LiteLoader/src/llapi/mc/ItemStackAPI.cpp @@ -84,7 +84,7 @@ int ItemStack::getAux() const { int ItemStack::getCount() const { if (this->isNull()) return 0; - return dAccess(this); + return dAccess(this); } bool ItemStack::setItem(ItemStack* newItem) { @@ -112,7 +112,7 @@ bool ItemStack::setNbt(CompoundTag* nbt) { int ItemStackBase::getCount() const { if (this->isNull()) return 0; - return dAccess(this); + return dAccess(this); } // string ItemStack::getStandardName(const Localization& language) { diff --git a/LiteLoader/src/llapi/mc/LevelAPI.cpp b/LiteLoader/src/llapi/mc/LevelAPI.cpp index 94f0b63..6db672f 100644 --- a/LiteLoader/src/llapi/mc/LevelAPI.cpp +++ b/LiteLoader/src/llapi/mc/LevelAPI.cpp @@ -65,7 +65,7 @@ Block* Level::getBlock(const BlockPos& pos, BlockSource* blockSource) { BlockPalette* Level::getBlockPalettePtr(){ // MovingBlockActor::load Line69 - return dAccess(Global,2000); + return dAccess(Global,ll::offset::LEVELAPI_getBlockPalettePtr); }; // Return nullptr when failing to get block diff --git a/LiteLoader/src/llapi/mc/PlayerAPI.cpp b/LiteLoader/src/llapi/mc/PlayerAPI.cpp index 682cdd9..26c0250 100644 --- a/LiteLoader/src/llapi/mc/PlayerAPI.cpp +++ b/LiteLoader/src/llapi/mc/PlayerAPI.cpp @@ -47,13 +47,13 @@ extern Logger logger; NetworkIdentifier* Player::getNetworkIdentifier() const{ //ServerPlayer::isHostingPlayer - return dAccess(this, 2432); + return dAccess(this, ll::offset::PLAYERAPI_getNetworkIdentifier); } Certificate* Player::getCertificate() const{ //KickCommand::_kickPlayer Line116 - return dAccess(this, 2736); + return dAccess(this, ll::offset::PLAYERAPI_getCertificate); } std::string Player::getRealName() { @@ -99,12 +99,12 @@ string Player::getServerAddress() { int Player::getPlatform(){ //AddPlayerPacket::AddPlayerPacket Line59 - return dAccess(this, 2104); + return dAccess(this, ll::offset::PLAYERAPI_getPlatform); } Container & Player::getInventory(){ //InventoryContainerModel::_getContainer 2928 + 176 - return dAccess(this, 3104); + return dAccess(this, ll::offset::PLAYERAPI_getInventory); } enum CommandPermissionLevel Player::getPlayerPermissionLevel(){ @@ -258,12 +258,12 @@ bool Player::transferServer(const string& address, unsigned short port) { BlockPos const & Player::getSpawnPosition(){ //ServerNetworkHandler::_sendLevelData Line316 - return dAccess(this, 1797*4); + return dAccess(this, ll::offset::PLAYERAPI_getSpawnPosition); } AutomaticID Player::getSpawnDimension(){ //ServerNetworkHandler::_sendLevelData Line310 - return dAccess>(this, 1800*4); + return dAccess>(this, ll::offset::PLAYERAPI_getSpawnDimension); } std::pair Player::getRespawnPosition() { @@ -322,12 +322,12 @@ string Player::getXuid() const{ } mce::UUID Player::getClientUUID()const{ - return dAccess(this,2720); + return dAccess(this,ll::offset::PLAYERAPI_getClientUUID); }; unsigned char Player::getClientSubId() { //ServerPlayer::sendNetworkPacket 参4 - return dAccess(this,3520); + return dAccess(this,ll::offset::PLAYERAPI_getClientSubId); } float Player::getAvgPacketLoss() { @@ -442,7 +442,7 @@ size_t Player::getTotalXpNeededForLevel(int level) { bool Player::crashClient() { auto pkt = MinecraftPackets::createPacket(MinecraftPacketIds::LevelChunk); - dAccess(pkt.get()) = 1; + dAccess(pkt.get()) = 1; sendNetworkPacket(*pkt); return true; } @@ -684,8 +684,8 @@ bool Player::sendUpdateBlockPacket(BlockPos const& bpos, const Block& block, Upd bool Player::sendTransferPacket(const string& address, short port) const { auto packet = MinecraftPackets::createPacket(0x55); - dAccess(packet.get(), 36) = port; - dAccess(packet.get(), 40) = address; + dAccess(packet.get(), ll::offset::PLAYERAPI_sendTransferPacket_port) = port; + dAccess(packet.get(), ll::offset::PLAYERAPI_sendTransferPacket_address) = address; sendNetworkPacket(*packet); return true; } @@ -698,8 +698,8 @@ bool Player::sendSetDisplayObjectivePacket(const string& title, const string& na bool Player::sendSetScorePacket(char type, const vector& data) { auto packet = MinecraftPackets::createPacket(0x6c); - dAccess(packet.get(), 48) = type; - dAccess>(packet.get(), 56) = data; + dAccess(packet.get(), ll::offset::PLAYERAPI_sendSetScorePacket_type) = type; + dAccess>(packet.get(), ll::offset::PLAYERAPI_sendSetScorePacket_data) = data; sendNetworkPacket(*packet); return true; } @@ -750,7 +750,7 @@ bool Player::sendSetScorePacket(char type, const vector& data) bool Player::sendCommandRequestPacket(const string& cmd) { auto packet = MinecraftPackets::createPacket(0x4d); - dAccess(packet.get()) = cmd; + dAccess(packet.get()) = cmd; Global->handle(*getNetworkIdentifier(), *((CommandRequestPacket*)packet.get())); return true; } diff --git a/LiteLoader/src/llapi/mc/ResourcePackRepositoryAPI.cpp b/LiteLoader/src/llapi/mc/ResourcePackRepositoryAPI.cpp index aee1a14..5c309e9 100644 --- a/LiteLoader/src/llapi/mc/ResourcePackRepositoryAPI.cpp +++ b/LiteLoader/src/llapi/mc/ResourcePackRepositoryAPI.cpp @@ -6,7 +6,7 @@ #include void ResourcePackRepository::setCustomResourcePackPath(PackType type, const std::string& path) { - auto CompositePack = dAccess(this, 48); + auto CompositePack = dAccess(this, ll::offset::RESOURCEPACKREPOSITORYAPI_setCustomResourcePackPath); auto PackSourceFactory = getPackSourceFactory(); auto& DirectoryPackSource = PackSourceFactory->createDirectoryPackSource(Core::Path(path), type, PackOrigin::PackOrigin_Dev, 0); CompositePack->addPackSource((PackSource*)&DirectoryPackSource); diff --git a/LiteLoader/src/llapi/nbt/CompoundTagAPI.cpp b/LiteLoader/src/llapi/nbt/CompoundTagAPI.cpp index 8192d79..898b966 100644 --- a/LiteLoader/src/llapi/nbt/CompoundTagAPI.cpp +++ b/LiteLoader/src/llapi/nbt/CompoundTagAPI.cpp @@ -142,12 +142,12 @@ void CompoundTag::setItemStack(ItemStack* item) { } std::unique_ptr CompoundTag::fromBlock(Block* block) { - auto tag = (CompoundTag*)((uintptr_t)block + 24); //dAccess Block::Block + auto tag = dAccess(block, ll::offset::COMPOUNDTAGAPI_fromBlock); //dAccess Block::Block return tag->clone(); } void CompoundTag::setBlock(Block* blk) { - auto tag = (CompoundTag*)((uintptr_t)blk + 24);//dAccess Block::Block + auto tag = dAccess(blk, ll::offset::COMPOUNDTAGAPI_fromBlock);//dAccess Block::Block tag->deepCopy(*this); }