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

Commit

Permalink
feat: packet hook
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcmd committed Jan 13, 2024
1 parent 009e447 commit 06eaf7a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "DataExtractor-v2",
"entry": "DataExtractor-v2.dll",
"name": "DataExtractor",
"entry": "DataExtractor.dll",
"type": "native"
}
31 changes: 29 additions & 2 deletions src/Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
#include <direct.h>
#include <fstream>
#include <iostream>
#include <memory>
#include <utility>

// Compress
#include "zlib.h"
#include <zlib.h>

// LL
#include "Plugin.h"
#include <Plugin.h>
#include <ll/api/command/DynamicCommand.h>
#include <ll/api/plugin/NativePlugin.h>
#include <ll/api/service/Bedrock.h>
#include <ll/api/memory/Hook.h>

// MC
// Item
Expand Down Expand Up @@ -47,6 +50,9 @@
// NBT
#include <mc/nbt/CompoundTag.h>
#include <mc/nbt/CompoundTagVariant.h>
// Network
#include <mc/network/packet/CraftingDataPacket.h>
#include <mc/deps/core/utility/BinaryStream.h>


static bool folderExists(std::string folderName) {
Expand Down Expand Up @@ -117,6 +123,27 @@ static std::string aabbToStr(const AABB& aabb) {
return aabbStr.str();
}

ll::Logger hookLogger("DataExtractor-Hook");

//Recipe packet
LL_AUTO_TYPE_INSTANCE_HOOK(
CraftingDataPacketHook,
ll::memory::HookPriority::Normal,
CraftingDataPacket,
"?write@CraftingDataPacket@@UEBAXAEAVBinaryStream@@@Z",
void,
BinaryStream& stream
) {
origin(stream);
const std::string& data = stream.getAndReleaseData();
std::string datacopy = data;
stream.writeString(data, nullptr, nullptr);
auto out = std::ofstream("data/crafting_data_packet.bin", std::ofstream::out | std::ofstream::binary | std::ofstream::trunc);
out << datacopy;
out.close();
hookLogger.info("create crafting_data_packet.bin success!");
}

namespace plugin {

void dumpCreativeItemData(ll::Logger& logger) {
Expand Down

0 comments on commit 06eaf7a

Please sign in to comment.