Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
feat: update to 1.20.81.01
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcmd committed May 4, 2024
1 parent 9475cbe commit 824e940
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
38 changes: 35 additions & 3 deletions src/Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
#include <mc/network/packet/CraftingDataPacket.h>
#include <mc/network/packet/AvailableCommandsPacket.h>
#include <mc/deps/core/utility/BinaryStream.h>
#include <mc/network/packet/BiomeDefinitionListPacket.h>

namespace plugin {
bool folderExists(const std::string& folderName) {
Expand Down Expand Up @@ -153,6 +154,21 @@ namespace plugin {
hookLogger.info("Create crafting_data_packet.bin success!");
}

//Biome definition packet
//A way to get biome_definitions from network
//LL_AUTO_TYPE_INSTANCE_HOOK(
// BiomeDefinitionListPacketHook,
// ll::memory::HookPriority::Normal,
// BiomeDefinitionListPacket,
// "?write@BiomeDefinitionListPacket@@UEBAXAEAVBinaryStream@@@Z",
// void,
// BinaryStream& stream
//) {
// origin(stream);
// writeNBT("biome_definitions.nbt", this->mBiomeData);
// hookLogger.info("Create biome_definitions.nbt success!");
//}

//Cmd packet
LL_AUTO_TYPE_INSTANCE_HOOK(
AvailableCommandsPacketHook,
Expand Down Expand Up @@ -532,14 +548,30 @@ namespace plugin {
logger.info("Command constrained values data have been saved to \"data/command_constrained_values.json\"");
}

int getBiomeId(const ll::Logger& logger, const Biome& biome) {
try {
return ll::memory::dAccess<int>(&biome, 0x80);
} catch (...) {
logger.error("Failed in getBiomeId()! Please check if the memory offset is right!");
}
}

std::string getBiomeName(const ll::Logger& logger, const Biome& biome) {
try {
return ll::memory::dAccess<HashedString>(&biome, 0x08).getString();
} catch (...) {
logger.error("Failed in getBiomeName()! Please check if the memory offset is right!");
}
}

void dumpBiomeData(const ll::Logger &logger) {
BiomeRegistry &registry = ll::service::getLevel()->getBiomeRegistry();
auto biomeInfoMap = nlohmann::json::object();
auto biomes = CompoundTag();
TagRegistry<IDType<BiomeTagIDType>, IDType<BiomeTagSetIDType> > &tagReg = registry.getTagRegistry();
registry.forEachBiome([&biomes, &logger, &tagReg, &biomeInfoMap](Biome &biome) {
auto &name = biome.getName().getString();
int id = biome.getId();
auto name = getBiomeName(logger, biome);
int id = getBiomeId(logger, biome);
logger.info("Extracting biome data - " + name);
auto tag = CompoundTag();
biome.writePacketData(tag, tagReg);
Expand Down Expand Up @@ -845,7 +877,7 @@ namespace plugin {
dumpCommonCommandArgData(logger);
dumpFullCommandArgData(logger);
dumpCommandmConstrainedValues(logger);
dumpBiomeData(logger);
// dumpBiomeData(logger);
dumpCreativeItemData(logger);
dumpBlockAttributesData(logger);
dumpPalette(logger);
Expand Down
2 changes: 1 addition & 1 deletion xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ end
add_requires("zlib-ng 2.1.3")

-- Latest release
add_requires("levilamina 0.10.2")
add_requires("levilamina 0.12.3")

-- Latest commit on develop
-- add_requires("levilamina develop")
Expand Down

0 comments on commit 824e940

Please sign in to comment.