Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. #include <string>
  2.  
  3. struct CompoundTag {
  4. };
  5.  
  6. struct Block {
  7.     char filler[24];
  8.     CompoundTag tag;
  9. };
  10.  
  11. struct BlockLegacy {
  12.     Block *getStateFromLegacyData(unsigned short) const;
  13. };
  14.  
  15. struct BlockPalette {
  16.     BlockLegacy *getBlockLegacy(std::string const &) const;
  17. };
  18.  
  19. struct Level {
  20.     BlockPalette *getBlockPalette() const;
  21. };
  22.  
  23. struct Minecraft {
  24.     Level *getLevel() const;
  25. };
  26.  
  27. struct ServerInstance {
  28.     Minecraft *getMinecraft();
  29. };
  30.  
  31. struct ReadOnlyBinaryStream {
  32.     void *vt;
  33.     unsigned long offset;
  34.     std::string unk2;
  35.     std::string *buffer;
  36. };
  37.  
  38. struct BinaryStream : ReadOnlyBinaryStream {
  39.     char filler[8];
  40.     std::string unk11;
  41.  
  42.     template<typename T>
  43.     void writeType(T const &);
  44. };
  45.  
  46. void hexdump(void *ptr, int len, int offset) {
  47.     auto *buf = (unsigned char *) ptr + offset;
  48.     int i, j;
  49.     for (i = 0; i < len; i += 16) {
  50.         printf("%06x: ", i);
  51.         for (j = 0; j < 16; j++)
  52.             if (i + j < len)
  53.                 printf("%02x ", buf[i + j]);
  54.             else
  55.                 printf("   ");
  56.         printf(" ");
  57.         for (j = 0; j < 16; j++)
  58.             if (i + j < len)
  59.                 printf("%c", isprint(buf[i + j]) ? buf[i + j] : '.');
  60.         printf("\n");
  61.     }
  62.     printf("\n");
  63. }
  64.  
  65. extern "C" void *_ZN12BinaryStreamC2Ev(BinaryStream *);
  66.  
  67. extern "C" void modloader_on_server_start(ServerInstance *serverInstance) {
  68.     auto palette = serverInstance->getMinecraft()->getLevel()->getBlockPalette();
  69.     auto blockLegacy = palette->getBlockLegacy("minecraft:stone");
  70.     auto block = blockLegacy->getStateFromLegacyData(1);
  71.  
  72.     auto stream = (BinaryStream *) malloc(sizeof(void *));
  73.     _ZN12BinaryStreamC2Ev(stream);
  74.  
  75.     printf("%ld\n", sizeof(BinaryStream));
  76.  
  77.     stream->writeType(block->tag);
  78.     auto buffer = *stream->buffer;
  79.     hexdump((void *) buffer.c_str(), buffer.length(), 0);
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement