diff --git a/LiteLoader/Header/MC/AABB.hpp b/LiteLoader/Header/MC/AABB.hpp index df5f283..3aba9b4 100644 --- a/LiteLoader/Header/MC/AABB.hpp +++ b/LiteLoader/Header/MC/AABB.hpp @@ -9,18 +9,26 @@ class AABB { +public: + Vec3 min; + Vec3 max; + #define AFTER_EXTRA #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_AABB public: - class AABB& operator=(class AABB const &) = delete; - AABB(class AABB const &) = delete; + // class AABB& operator=(class AABB const &) = delete; + // AABB(class AABB const &) = delete; #endif public: #ifdef ENABLE_VIRTUAL_FAKESYMBOL_AABB #endif + + inline AABB(class AABB const& k) : min(k.min), max(k.max){}; +// inline AABB() : min(Vec3::MIN), max(Vec3::MIN){}; + MCAPI AABB(); MCAPI AABB(float, float, float, float, float, float); MCAPI AABB(class Vec3 const &, class Vec3 const &); @@ -41,4 +49,59 @@ public: MCAPI class AABB shrink(class Vec3 const &) const; MCAPI static class AABB const EMPTY; + inline Vec3& operator[](int index) { + if (index < 0 || index > 1) { + return (&min)[0]; + } + return (&min)[index]; + } + + constexpr AABB& operator+=(float& b) { + min += b; + max += b; + return *this; + } + + constexpr AABB& operator-=(float& b) { + min -= b; + max -= b; + return *this; + } + + constexpr AABB& operator+=(Vec3 const& b) { + min += b; + max += b; + return *this; + } + + constexpr AABB& operator-=(Vec3 const& b) { + min -= b; + max -= b; + return *this; + } + + inline AABB operator+(Vec3 const& b) const { + return AABB(min + b, max + b); + } + + inline AABB operator+(float& b) const { + return AABB(min + b, max + b); + } + + inline AABB operator-(Vec3 const& b) const { + return AABB(min - b, max - b); + } + + inline AABB operator-(float& b) const { + return AABB(min - b, max - b); + } + + inline AABB merge(AABB const& a) { + return AABB(Vec3::min(a.min, min), Vec3::max(a.max, max)); + } + + inline AABB merge(Vec3 const& a) { + return AABB(Vec3::min(a, min), Vec3::max(a, max)); + } + }; \ No newline at end of file diff --git a/LiteLoader/Header/MC/Actor.hpp b/LiteLoader/Header/MC/Actor.hpp index 940a9f1..1549eb3 100644 --- a/LiteLoader/Header/MC/Actor.hpp +++ b/LiteLoader/Header/MC/Actor.hpp @@ -8,6 +8,7 @@ #include "MobEffectInstance.hpp" #include "Tick.hpp" #include "ActorDamageSource.hpp" +#include "SimpleContainer.hpp" class Actor; class Player; class NetworkIdentifier; @@ -17,6 +18,9 @@ class BlockInstance; class ItemStack; class BlockSource; enum class FaceID : char; +enum ActorFlags : int{ + MOVING=0x22 +}; #undef BEFORE_EXTRA @@ -61,7 +65,7 @@ public: LIAPI SimpleContainer & getHandContainer(); LIAPI SimpleContainer & getArmorContainer(); - inline Vec3 getPosition() + inline const Vec3 &getPosition()const { return getPos(); } @@ -69,6 +73,12 @@ public: { return getPosOld(); } + inline BlockSource const & getRegionConst() const{ + return dAccess(this,100); + }; + inline bool isMoving() const{ + return getStatusFlag(ActorFlags::MOVING); + }; #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTOR diff --git a/LiteLoader/Header/MC/ActorDefinitionIdentifier.hpp b/LiteLoader/Header/MC/ActorDefinitionIdentifier.hpp index 8ecf174..2dd9a5c 100644 --- a/LiteLoader/Header/MC/ActorDefinitionIdentifier.hpp +++ b/LiteLoader/Header/MC/ActorDefinitionIdentifier.hpp @@ -10,7 +10,12 @@ struct ActorDefinitionIdentifier { #define AFTER_EXTRA - +// Add Member There +std::string ns; // 0 +std::string identifier; // 32 +std::string event; // 64 +std::string fullname; // 96 +HashedString canonicalHash; // 128 #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORDEFINITIONIDENTIFIER public: diff --git a/LiteLoader/Header/MC/BinaryStream.hpp b/LiteLoader/Header/MC/BinaryStream.hpp index 603f86f..898d4d4 100644 --- a/LiteLoader/Header/MC/BinaryStream.hpp +++ b/LiteLoader/Header/MC/BinaryStream.hpp @@ -12,6 +12,8 @@ class BinaryStream : public ReadOnlyBinaryStream { #define AFTER_EXTRA public: + std::string writeBuf, *pwBuf; + LIAPI void write(const void* origin, size_t num); LIAPI void writeByte(uint8_t origin); LIAPI void writeBool(bool origin); @@ -39,6 +41,16 @@ public: LIAPI std::string& getRaw(); LIAPI void writeCompoundTag(class CompoundTag const& tag); + inline void reset(){ + this->pwBuf->clear(); + ReadOnlyBinaryStream::setReadPointer(0); + } + + inline std::string getAndReleaseData(){ + std::string *str = std::move(this->pwBuf); + return *str; + } + #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_BINARYSTREAM diff --git a/LiteLoader/Header/MC/BlockActor.hpp b/LiteLoader/Header/MC/BlockActor.hpp index 8b1bf2e..4e24fd5 100644 --- a/LiteLoader/Header/MC/BlockActor.hpp +++ b/LiteLoader/Header/MC/BlockActor.hpp @@ -17,13 +17,22 @@ class BlockActor { #define AFTER_EXTRA // Add new members to class public: - //LIAPI bool refreshData(); - //LIAPI bool refreshData(BlockSource* bs); + LIAPI bool refreshData(); + // LIAPI bool refreshData(BlockSource* bs); LIAPI std::unique_ptr getNbt(); LIAPI bool setNbt(CompoundTag* nbt); LIAPI bool setNbt(CompoundTag* nbt, BlockSource* bs); //static unsigned int getBlockEntityType(Block* block); + inline void setChanged(){ + //EndGatewayBlockActor::teleportEntity Line115 + dAccess(this) = 1; + } + inline BlockPos const & getPosition() const{ + //EndGatewayBlockActor::teleportEntity Line114 + return dAccess(this,44); + }; + #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_BLOCKACTOR public: diff --git a/LiteLoader/Header/MC/BlockPos.hpp b/LiteLoader/Header/MC/BlockPos.hpp index cc885ac..8e52ae3 100644 --- a/LiteLoader/Header/MC/BlockPos.hpp +++ b/LiteLoader/Header/MC/BlockPos.hpp @@ -35,9 +35,9 @@ public: return res; } - inline std::string toString() const { - return std::to_string(x) + "," + std::to_string(y) + "," + std::to_string(z); - } +// inline std::string toString() const { +// return std::to_string(x) + "," + std::to_string(y) + "," + std::to_string(z); +// } inline BlockPos add(int dx) const { return {x + dx, y, z}; diff --git a/LiteLoader/Header/MC/BlockSerializationUtils.hpp b/LiteLoader/Header/MC/BlockSerializationUtils.hpp index bffcb17..54fc9c8 100644 --- a/LiteLoader/Header/MC/BlockSerializationUtils.hpp +++ b/LiteLoader/Header/MC/BlockSerializationUtils.hpp @@ -11,12 +11,12 @@ namespace BlockSerializationUtils { #define AFTER_EXTRA // Add Member There -// struct NbtToBlockCache { -// NbtToBlockCache() = delete; -// NbtToBlockCache(NbtToBlockCache const&) = delete; -// NbtToBlockCache(NbtToBlockCache const&&) = delete; -// }; -// enum NBTState; + struct NbtToBlockCache { + NbtToBlockCache() = delete; + NbtToBlockCache(NbtToBlockCache const&) = delete; + NbtToBlockCache(NbtToBlockCache const&&) = delete; + }; + enum NBTState; #undef AFTER_EXTRA MCAPI extern class std::unordered_map, struct std::hash, struct std::equal_to, class std::allocator>>> BLOCK_REPLACE_DATA_MAP; diff --git a/LiteLoader/Header/MC/BlockSource.hpp b/LiteLoader/Header/MC/BlockSource.hpp index e5761c3..72f9473 100644 --- a/LiteLoader/Header/MC/BlockSource.hpp +++ b/LiteLoader/Header/MC/BlockSource.hpp @@ -5,6 +5,7 @@ #define BEFORE_EXTRA #include "BlockInstance.hpp" +#include "Dimension.hpp" #undef BEFORE_EXTRA @@ -18,7 +19,12 @@ public: // { // MCAPI static const std::function CHECK_ALL_BLOCKS; // }; - //LIAPI BlockInstance getBlockInstance(BlockPos); + LIAPI BlockInstance getBlockInstance(BlockPos); + inline AutomaticID getDimensionId(){ + //Dimension::onBlockEvent Line24 + Dimension* mDimension = dAccess< Dimension*>(this, 4); + return dAccess>(mDimension, 192); + }; #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_BLOCKSOURCE diff --git a/LiteLoader/Header/MC/ByteArrayTag.hpp b/LiteLoader/Header/MC/ByteArrayTag.hpp index 398269c..8db3025 100644 --- a/LiteLoader/Header/MC/ByteArrayTag.hpp +++ b/LiteLoader/Header/MC/ByteArrayTag.hpp @@ -5,13 +5,24 @@ #include "Tag.hpp" #define BEFORE_EXTRA - +// Include Headers or Declare Types Here +#include "TagMemoryChunk.hpp" #undef BEFORE_EXTRA class ByteArrayTag : public Tag { #define AFTER_EXTRA + // Add Member There + TagMemoryChunk val; +public: + LIAPI TagMemoryChunk& value(); + LIAPI ByteArrayTag& operator=(TagMemoryChunk const& val); + LIAPI static std::unique_ptr create(); + LIAPI static std::unique_ptr create(TagMemoryChunk const& val); + LIAPI static std::unique_ptr create(char data[], size_t size); + LIAPI bool set(TagMemoryChunk const& val); + LIAPI TagMemoryChunk get(); #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_BYTEARRAYTAG public: diff --git a/LiteLoader/Header/MC/ByteTag.hpp b/LiteLoader/Header/MC/ByteTag.hpp index 62c90a4..a3d14cd 100644 --- a/LiteLoader/Header/MC/ByteTag.hpp +++ b/LiteLoader/Header/MC/ByteTag.hpp @@ -11,6 +11,16 @@ class ByteTag : public Tag { #define AFTER_EXTRA + // Add Member There + unsigned char val; + +public: + LIAPI unsigned char& value(); + LIAPI ByteTag& operator=(unsigned char val); + LIAPI static std::unique_ptr create(unsigned char val = 0); + LIAPI bool set(unsigned char val); + LIAPI unsigned char get(); + LIAPI operator unsigned char() const; #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_BYTETAG diff --git a/LiteLoader/Header/MC/ComplexInventoryTransaction.hpp b/LiteLoader/Header/MC/ComplexInventoryTransaction.hpp index db7af03..6f98d82 100644 --- a/LiteLoader/Header/MC/ComplexInventoryTransaction.hpp +++ b/LiteLoader/Header/MC/ComplexInventoryTransaction.hpp @@ -4,12 +4,24 @@ #include "../Global.h" #define BEFORE_EXTRA - +// Include Headers or Declare Types Here +#include "InventoryTransaction.hpp" #undef BEFORE_EXTRA class ComplexInventoryTransaction { #define AFTER_EXTRA +// Add Member There +public: +enum class Type : unsigned +{ + NORMAL = 0, + MISMATCH = 1, + ITEM_USE = 2, + ITEM_USE_ON_ACTOR = 3, + RELEASE_ITEM = 4, +} type; +InventoryTransaction data; #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_COMPLEXINVENTORYTRANSACTION diff --git a/LiteLoader/Header/MC/CompoundTag.hpp b/LiteLoader/Header/MC/CompoundTag.hpp index f76cf6f..f0c6960 100644 --- a/LiteLoader/Header/MC/CompoundTag.hpp +++ b/LiteLoader/Header/MC/CompoundTag.hpp @@ -91,6 +91,24 @@ public: // Deprecated? LIAPI std::string toSNBT(); + inline Tag const * get(class gsl::basic_string_span key) const{ + auto iter = val.find(key.data()); + if(iter != val.end()) + return iter->second.get(); + }; + + inline bool isEmpty(){ + return this->val.empty(); + } + + inline map::const_iterator begin(){ + return this->val.begin(); + } + inline map::const_iterator end(){ + return this->val.end(); + } + + #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_COMPOUNDTAG public: diff --git a/LiteLoader/Header/MC/Container.hpp b/LiteLoader/Header/MC/Container.hpp index ebf2b32..1233b16 100644 --- a/LiteLoader/Header/MC/Container.hpp +++ b/LiteLoader/Header/MC/Container.hpp @@ -4,7 +4,8 @@ #include "../Global.h" #define BEFORE_EXTRA - +// Add include headers & pre-declares +class ItemStack; #undef BEFORE_EXTRA class Container { diff --git a/LiteLoader/Header/MC/DoubleTag.hpp b/LiteLoader/Header/MC/DoubleTag.hpp index 74b6934..9596fe9 100644 --- a/LiteLoader/Header/MC/DoubleTag.hpp +++ b/LiteLoader/Header/MC/DoubleTag.hpp @@ -11,6 +11,16 @@ class DoubleTag : public Tag { #define AFTER_EXTRA + // Add Member There + double val; + +public: + LIAPI double& value(); + LIAPI DoubleTag& operator=(double val); + LIAPI static std::unique_ptr create(double val = 0.0); + LIAPI bool set(double val); + LIAPI double get(); + LIAPI operator double() const; #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_DOUBLETAG diff --git a/LiteLoader/Header/MC/EndTag.hpp b/LiteLoader/Header/MC/EndTag.hpp index abe0708..75fd252 100644 --- a/LiteLoader/Header/MC/EndTag.hpp +++ b/LiteLoader/Header/MC/EndTag.hpp @@ -11,6 +11,12 @@ class EndTag : public Tag { #define AFTER_EXTRA + // Add Member There +public: + LIAPI nullptr_t value(); + LIAPI static std::unique_ptr create(); + LIAPI bool set(); + LIAPI nullptr_t get(); #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_ENDTAG diff --git a/LiteLoader/Header/MC/FloatTag.hpp b/LiteLoader/Header/MC/FloatTag.hpp index a55c237..632f5cc 100644 --- a/LiteLoader/Header/MC/FloatTag.hpp +++ b/LiteLoader/Header/MC/FloatTag.hpp @@ -11,6 +11,16 @@ class FloatTag : public Tag { #define AFTER_EXTRA + // Add Member There + float val; + +public: + LIAPI float& value(); + LIAPI FloatTag& operator=(float val); + LIAPI static std::unique_ptr create(float val = 0.0f); + LIAPI bool set(float val); + LIAPI float get(); + LIAPI operator float() const; #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_FLOATTAG diff --git a/LiteLoader/Header/MC/IMinecraftEventing.hpp b/LiteLoader/Header/MC/IMinecraftEventing.hpp index dad2add..3359e72 100644 --- a/LiteLoader/Header/MC/IMinecraftEventing.hpp +++ b/LiteLoader/Header/MC/IMinecraftEventing.hpp @@ -10,7 +10,8 @@ class IMinecraftEventing { #define AFTER_EXTRA - +public: + enum StructureBlockActionType; #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_IMINECRAFTEVENTING public: diff --git a/LiteLoader/Header/MC/Int64Tag.hpp b/LiteLoader/Header/MC/Int64Tag.hpp index f502a65..5bd9448 100644 --- a/LiteLoader/Header/MC/Int64Tag.hpp +++ b/LiteLoader/Header/MC/Int64Tag.hpp @@ -11,6 +11,16 @@ class Int64Tag : public Tag { #define AFTER_EXTRA + // Add Member There + int64_t val; + +public: + LIAPI int64_t& value(); + LIAPI Int64Tag& operator=(int64_t val); + LIAPI static std::unique_ptr create(int64_t val = 0); + LIAPI bool set(int64_t val); + LIAPI int64_t get(); + LIAPI operator int64_t() const; #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_INT64TAG diff --git a/LiteLoader/Header/MC/IntArrayTag.hpp b/LiteLoader/Header/MC/IntArrayTag.hpp index 4c4c39a..5edc38e 100644 --- a/LiteLoader/Header/MC/IntArrayTag.hpp +++ b/LiteLoader/Header/MC/IntArrayTag.hpp @@ -5,12 +5,24 @@ #include "Tag.hpp" #define BEFORE_EXTRA - +// Include Headers or Declare Types Here +#include "TagMemoryChunk.hpp" #undef BEFORE_EXTRA class IntArrayTag : public Tag { #define AFTER_EXTRA + // Add Member There + TagMemoryChunk val; + +public: + LIAPI TagMemoryChunk& value(); + LIAPI IntArrayTag& operator=(TagMemoryChunk const& val); + LIAPI static std::unique_ptr create(); + LIAPI static std::unique_ptr create(TagMemoryChunk const& val); + LIAPI static std::unique_ptr create(int data[], size_t size); + LIAPI bool set(TagMemoryChunk const& val); + LIAPI TagMemoryChunk get(); #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_INTARRAYTAG diff --git a/LiteLoader/Header/MC/IntTag.hpp b/LiteLoader/Header/MC/IntTag.hpp index 599e291..8563ddf 100644 --- a/LiteLoader/Header/MC/IntTag.hpp +++ b/LiteLoader/Header/MC/IntTag.hpp @@ -11,6 +11,16 @@ class IntTag : public Tag { #define AFTER_EXTRA + // Add Member There + int val; + +public: + LIAPI int& value(); + LIAPI IntTag& operator=(int val); + LIAPI static std::unique_ptr create(int val = 0); + LIAPI bool set(int val); + LIAPI int get(); + LIAPI operator int() const; #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_INTTAG diff --git a/LiteLoader/Header/MC/InventoryAction.hpp b/LiteLoader/Header/MC/InventoryAction.hpp index 36f5fba..4eb0552 100644 --- a/LiteLoader/Header/MC/InventoryAction.hpp +++ b/LiteLoader/Header/MC/InventoryAction.hpp @@ -6,7 +6,6 @@ #define BEFORE_EXTRA // Include Headers or Declare Types Here #include "InventorySource.hpp" -#include "NetworkItemStackDescriptor.hpp" #include "ItemStack.hpp" #undef BEFORE_EXTRA @@ -17,20 +16,16 @@ class InventoryAction { public: InventorySource source; // 0 uint32_t slot; // 12 - NetworkItemStackDescriptor fromDescriptor; // 16 - NetworkItemStackDescriptor toDescriptor; // 104 - ItemStack fromItem; // 192 - ItemStack toItem; // 352 + ItemStack fromItem; // 16 + ItemStack toItem; // 264 private: - inline void test() - { - static_assert(offsetof(InventoryAction, slot) == 12); - static_assert(offsetof(InventoryAction, fromDescriptor) == 16); - static_assert(offsetof(InventoryAction, toDescriptor) == 104); - static_assert(offsetof(InventoryAction, fromItem) == 192); - static_assert(offsetof(InventoryAction, toItem) == 352); - } +// inline void test() +// { +// static_assert(offsetof(InventoryAction, slot) == 12); +// static_assert(offsetof(InventoryAction, fromItem) == 16); +// static_assert(offsetof(InventoryAction, toItem) == 162); +// } #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_INVENTORYACTION public: diff --git a/LiteLoader/Header/MC/InventorySource.hpp b/LiteLoader/Header/MC/InventorySource.hpp new file mode 100644 index 0000000..11d820a --- /dev/null +++ b/LiteLoader/Header/MC/InventorySource.hpp @@ -0,0 +1,73 @@ +/** + * @file InventorySource.hpp + * @note This Header is auto generated by LiteLoaderBDS Toolchain. + * + */ +#pragma once +#define AUTO_GENERATED +#include "../Global.h" + +#define BEFORE_EXTRA +// Include Headers or Declare Types Here + +#undef BEFORE_EXTRA + +/** + * @brief MC class InventorySource. + * + */ +class InventorySource { + +#define AFTER_EXTRA +// Add Member There +public: + enum class InventorySourceFlags + { + NoFlag = 0, + WorldInteraction_Random = 1 + }; + + InventorySourceType type = InventorySourceType::Invalid; + ContainerID container = ContainerID::Invalid; + InventorySourceFlags flags; + inline InventorySource(ContainerID id) + : container(id) + { + } + inline InventorySource(InventorySourceType type) + : type(type) + { + } + inline InventorySource(InventorySourceType type, InventorySourceFlags flags) + : type(type) + , flags(flags) + { + } + inline InventorySource(InventorySourceType type, ContainerID id) + : type(type) + , container(id) + { + } + + +#undef AFTER_EXTRA +#ifndef DISABLE_CONSTRUCTOR_PREVENTION_INVENTORYSOURCE +public: + class InventorySource& operator=(class InventorySource const &) = delete; + InventorySource(class InventorySource const &) = delete; + InventorySource() = delete; +#endif + +public: + // /** + // * @symbol ??8InventorySource@@QEBA_NAEBV0@@Z + // * @hash -974320336 + // */ + // MCAPI bool operator==(class InventorySource const &) const; + // /** + // * @symbol ?toString@InventorySource@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ + // * @hash -923513648 + // */ + // MCAPI std::string toString() const; + +}; \ No newline at end of file diff --git a/LiteLoader/Header/MC/InventoryTransaction.hpp b/LiteLoader/Header/MC/InventoryTransaction.hpp index 1673357..45bd0ae 100644 --- a/LiteLoader/Header/MC/InventoryTransaction.hpp +++ b/LiteLoader/Header/MC/InventoryTransaction.hpp @@ -10,6 +10,10 @@ class InventoryTransaction { #define AFTER_EXTRA +// Add Member There +public: + std::unordered_map> actions; // 0x0 + std::vector items; // 0x40 #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_INVENTORYTRANSACTION diff --git a/LiteLoader/Header/MC/Item.hpp b/LiteLoader/Header/MC/Item.hpp index 57f8a2f..1e68bcd 100644 --- a/LiteLoader/Header/MC/Item.hpp +++ b/LiteLoader/Header/MC/Item.hpp @@ -5,7 +5,13 @@ #include "Json.hpp" #define BEFORE_EXTRA - +template +class SimpleServerNetId { +public: + SimpleServerNetId() = delete; + SimpleServerNetId(SimpleServerNetId const&) = delete; + SimpleServerNetId(SimpleServerNetId const&&) = delete; +}; #undef BEFORE_EXTRA class Item { diff --git a/LiteLoader/Header/MC/ItemInstance.hpp b/LiteLoader/Header/MC/ItemInstance.hpp index f12d652..3cd17de 100644 --- a/LiteLoader/Header/MC/ItemInstance.hpp +++ b/LiteLoader/Header/MC/ItemInstance.hpp @@ -3,12 +3,13 @@ #define AUTO_GENERATED #include "../Global.h" #include "ItemStackBase.hpp" +#include "Item.hpp" #define BEFORE_EXTRA #undef BEFORE_EXTRA -class ItemInstance : public ItemStackBase { +class ItemInstance : public ItemStackBase, public Item { #define AFTER_EXTRA diff --git a/LiteLoader/Header/MC/ItemStack.hpp b/LiteLoader/Header/MC/ItemStack.hpp index de57fac..6bbf3eb 100644 --- a/LiteLoader/Header/MC/ItemStack.hpp +++ b/LiteLoader/Header/MC/ItemStack.hpp @@ -23,6 +23,7 @@ class ItemStack : public ItemStackBase { ItemStackNetIdVariant mNetId; public: + ItemStack clone() const; // The return value should be freed by the developer if it is no longer used LIAPI static ItemStack* create(); // The return value should be freed by the developer if it is no longer used @@ -31,8 +32,8 @@ public: LIAPI static ItemStack* create(std::unique_ptr tag); // The return value should be freed by the developer if it is no longer used LIAPI static ItemStack* create(short itemId, int aux,int count = 1); - //LIAPI ItemStack* clone_s() const; - //LIAPI static ItemStack fromItemInstance(ItemInstance const& ins); + LIAPI ItemStack* clone_s() const; + LIAPI static ItemStack fromItemInstance(ItemInstance const& ins); LIAPI std::string getTypeName() const; LIAPI int getAux() const; diff --git a/LiteLoader/Header/MC/Json.hpp b/LiteLoader/Header/MC/Json.hpp index 7cf8538..cad50f3 100644 --- a/LiteLoader/Header/MC/Json.hpp +++ b/LiteLoader/Header/MC/Json.hpp @@ -239,7 +239,7 @@ public: //MCAPI iterator begin(); //MCAPI iterator end(); - //MCAPI std::string toStyledString() const; + MCAPI std::string toStyledString() const; union ValueHolder { LargestInt int_; diff --git a/LiteLoader/Header/MC/Level.hpp b/LiteLoader/Header/MC/Level.hpp index 216ac77..f60f964 100644 --- a/LiteLoader/Header/MC/Level.hpp +++ b/LiteLoader/Header/MC/Level.hpp @@ -56,9 +56,9 @@ public: LIAPI static Block* getBlock(const BlockPos& pos, BlockSource *blockSource); //LIAPI static Block* getBlockEx(const BlockPos& pos, int dimId); LIAPI static BlockInstance getBlockInstance(BlockPos* pos, int dimId); - //LIAPI static BlockInstance getBlockInstance(BlockPos* pos, BlockSource* blockSource); + LIAPI static BlockInstance getBlockInstance(BlockPos* pos, BlockSource* blockSource); LIAPI static BlockInstance getBlockInstance(const BlockPos& pos, int dimId); - //LIAPI static BlockInstance getBlockInstance(const BlockPos& pos, BlockSource* blockSource); + LIAPI static BlockInstance getBlockInstance(const BlockPos& pos, BlockSource* blockSource); LIAPI static BlockActor* getBlockEntity(BlockPos* pos, int dimId); LIAPI static BlockActor* getBlockEntity(BlockPos* pos, BlockSource* blockSource); LIAPI static BlockActor* getBlockEntity(const BlockPos& pos, int dimId); @@ -80,7 +80,7 @@ public: //Helper LIAPI static BlockSource* getBlockSource(int dimid); - //LIAPI static BlockSource* getBlockSource(Actor* actor); + LIAPI static BlockSource* getBlockSource(Actor* actor); //LIAPI static BlockPalette* getBlockPalette(); //LIAPI static Dimension* getDimension(class AutomaticID a0); LIAPI static Actor* getDamageSourceEntity(ActorDamageSource* ads); diff --git a/LiteLoader/Header/MC/ListTag.hpp b/LiteLoader/Header/MC/ListTag.hpp index 01f690c..8c1d82c 100644 --- a/LiteLoader/Header/MC/ListTag.hpp +++ b/LiteLoader/Header/MC/ListTag.hpp @@ -49,6 +49,17 @@ public: LIAPI std::vector::const_iterator begin() const; LIAPI std::vector::const_iterator end() const; + inline int size() const{ + return this->val.size(); + }; + + inline Tag * get(int num) const{ + if(num < size() || num >0) + return this->val[num]; + else + return nullptr; + }; + #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_LISTTAG public: diff --git a/LiteLoader/Header/MC/MinecraftEventing.hpp b/LiteLoader/Header/MC/MinecraftEventing.hpp index 9e26317..b2439af 100644 --- a/LiteLoader/Header/MC/MinecraftEventing.hpp +++ b/LiteLoader/Header/MC/MinecraftEventing.hpp @@ -12,6 +12,16 @@ class MinecraftEventing { #define AFTER_EXTRA + // Add Member There +public: + enum InteractionType; + enum ChangeType; + enum TeleportationCause; + enum BlockPlacementMethod; + enum AchievementIds; + enum POIBlockInteractionType; + enum AcquisitionMethod; + enum UseMethod; #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_MINECRAFTEVENTING diff --git a/LiteLoader/Header/MC/Packet.hpp b/LiteLoader/Header/MC/Packet.hpp index 4088761..87dbb8d 100644 --- a/LiteLoader/Header/MC/Packet.hpp +++ b/LiteLoader/Header/MC/Packet.hpp @@ -4,13 +4,51 @@ #include "../Global.h" #define BEFORE_EXTRA - +// Include Headers or Declare Types Here +#include "ServerNetworkHandler.hpp" +class ReadOnlyBinaryStream; +class BinaryStream; +class ServerPlayer; +class NetworkIdentifier; +enum StreamReadResult; +enum class PacketReliability { + Relible, + RelibleOrdered +}; #undef BEFORE_EXTRA class Packet { #define AFTER_EXTRA + // Add Member There +public: + unsigned unk2 = 2; // 8 + PacketReliability reliableOrdered = PacketReliability::RelibleOrdered; // 12 + unsigned char clientSubId = 0; // 16 + uint64_t unk24 = 0; // 24 + uint64_t unk40 = 0; // 32 + uint32_t incompressible = 0; // 40 + inline Packet(unsigned compress) + : incompressible(!compress) + { } +#define DISABLE_CONSTRUCTOR_PREVENTION_PACKET + inline Packet() {} + class Packet& operator=(class Packet const&) = delete; + Packet(class Packet const&) = delete; + + inline ServerPlayer* getPlayerFromPacket(ServerNetworkHandler* handler, NetworkIdentifier* netId) + { + return handler->getServerPlayer(*netId, dAccess(this, 16)); + } + inline enum StreamReadResult _read(class ReadOnlyBinaryStream& binaryStream) + { + return read(binaryStream); + } +protected: + std::string toDebugString() { + return fmt::format("{}({})->{}", getName(), getId(), clientSubId); + } #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_PACKET public: diff --git a/LiteLoader/Header/MC/Player.hpp b/LiteLoader/Header/MC/Player.hpp index 5789e2a..89c9af9 100644 --- a/LiteLoader/Header/MC/Player.hpp +++ b/LiteLoader/Header/MC/Player.hpp @@ -34,7 +34,7 @@ public: LIAPI std::string getName(); LIAPI std::string getRealName(); LIAPI std::string getUuid(); - LIAPI std::string getXuid(); + LIAPI std::string getXuid()const; LIAPI unsigned char getClientSubId(); LIAPI string getDeviceTypeName(); LIAPI int getAvgPing(); @@ -43,7 +43,7 @@ public: LIAPI string getLanguageCode(); LIAPI string getServerAddress(); LIAPI NetworkIdentifier* getNetworkIdentifier(); - LIAPI Certificate* getCertificate(); + LIAPI Certificate* getCertificate()const; LIAPI std::pair getRespawnPosition(); LIAPI float getAvgPacketLoss(); LIAPI float getLastPacketLoss(); diff --git a/LiteLoader/Header/MC/PlayerActionPacket.hpp b/LiteLoader/Header/MC/PlayerActionPacket.hpp index 8880703..ce44194 100644 --- a/LiteLoader/Header/MC/PlayerActionPacket.hpp +++ b/LiteLoader/Header/MC/PlayerActionPacket.hpp @@ -5,12 +5,56 @@ #include "Packet.hpp" #define BEFORE_EXTRA +// Include Headers or Declare Types Here +// Refer to https://github.com/LiteLDev/BEProtocolGolang/blob/master/minecraft/protocol/player.go +enum PlayerActionType { + StartBreak, + AbortBreak, + StopBreak, + GetUpdatedBlock, + DropItem, + StartSleeping, + StopSleeping, + Respawn, + Jump, + StartSprint, + StopSprint, + StartSneak, + StopSneak, + CreativePlayerDestroyBlock, + DimensionChangeDone, + StartGlide, + StopGlide, + BuildDenied, + CrackBreak, + ChangeSkin, + SetEnchantmentSeed, + StartSwimming, + StopSwimming, + StartSpinAttack, + StopSpinAttack, + StartBuildingBlock, + PredictDestroyBlock, + ContinueDestroyBlock, +}; #undef BEFORE_EXTRA class PlayerActionPacket : public Packet { #define AFTER_EXTRA +// Add Member There +public: + BlockPos position; // 48 + FaceID blockFace; // 72 + PlayerActionType actionType; // 76 + ActorRuntimeID runtimeID; // 80 + + inline std::string toDebugString() { + return fmt::format("{}: position: ({}), blockFace: {}, actionType: {}, runtimeID: {}", + __super::toDebugString(), + position.toString(), (int)blockFace, (int)actionType, runtimeID.id); + } #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_PLAYERACTIONPACKET diff --git a/LiteLoader/Header/MC/PrettySnbtFormat.hpp b/LiteLoader/Header/MC/PrettySnbtFormat.hpp new file mode 100644 index 0000000..51c3f1f --- /dev/null +++ b/LiteLoader/Header/MC/PrettySnbtFormat.hpp @@ -0,0 +1,58 @@ +#pragma once +#include "../Global.h" +#include + +struct PrettySnbtFormat +{ +protected: + struct ValueFormat + { + std::string mPrefix; + std::string mSuffix; + LIAPI void toPlayerFormat(); + LIAPI void toConsoleFormat(); + }; + + bool mForPlayer = false; + unsigned int mMaxLevel = (unsigned int)-1; + std::array mExpandInList; + bool mExpandCompound = true; + std::array mValueFormats; + ValueFormat mKeyFormat = {"\"", "\""}; + std::string mIndent = " "; + std::string mSeparator = ","; + std::string mColon = ":"; + LIAPI bool setStringColor(std::string& in, mce::Color const& color); + LIAPI void setDefaultColor(); + + template + friend void __appendPrettySNBT(std::ostringstream& oss, T&, unsigned int level, PrettySnbtFormat const& format); + friend void __appendPrettySpace(std::ostringstream& oss, unsigned int level, PrettySnbtFormat const& format); + friend void __appendPrettyReturnSpace(std::ostringstream& oss, unsigned int level, PrettySnbtFormat const& format); + template + friend void __appendPrettyList(std::ostringstream& oss, ListTag& tag, unsigned int level, PrettySnbtFormat const& format, Tag::Type childrenType); + +public: + LIAPI PrettySnbtFormat(); + LIAPI std::string getColorCode(mce::Color const& color) const; + LIAPI std::string getResetColorCode() const; + LIAPI std::string getItalicCode() const; + + template + LIAPI bool setValueColor(mce::Color const& color); + template + LIAPI bool setValueFormat(std::string const& prefix, std::string const& suffix); + template + LIAPI bool setExpand(bool expand); + + LIAPI bool setKeyColor(mce::Color const& color); + LIAPI bool isPlayerFormat() const; + LIAPI bool setColonColor(mce::Color const& color); + LIAPI bool setSeparatorColor(mce::Color const& color); + LIAPI bool setIndent(int indent); + + LIAPI void switchToPlayerFormat(); + LIAPI void switchToConsoleFormat(); + + LIAPI static PrettySnbtFormat const& getDefaultFormat(bool forPlayer); +}; \ No newline at end of file diff --git a/LiteLoader/Header/MC/ReadOnlyBinaryStream.hpp b/LiteLoader/Header/MC/ReadOnlyBinaryStream.hpp index 5704de9..b4a7afe 100644 --- a/LiteLoader/Header/MC/ReadOnlyBinaryStream.hpp +++ b/LiteLoader/Header/MC/ReadOnlyBinaryStream.hpp @@ -13,7 +13,6 @@ class ReadOnlyBinaryStream { // Add Member There public: size_t readPointer{}; - bool unk; std::string ownBuf, *pBuf; public: diff --git a/LiteLoader/Header/MC/ShortTag.hpp b/LiteLoader/Header/MC/ShortTag.hpp index 1c83207..8f46f23 100644 --- a/LiteLoader/Header/MC/ShortTag.hpp +++ b/LiteLoader/Header/MC/ShortTag.hpp @@ -11,6 +11,16 @@ class ShortTag : public Tag { #define AFTER_EXTRA + // Add Member There + short val; + +public: + LIAPI short& value(); + LIAPI ShortTag& operator=(short val); + LIAPI static std::unique_ptr create(short val = 0); + LIAPI bool set(short val); + LIAPI short get(); + LIAPI operator short() const; #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_SHORTTAG diff --git a/LiteLoader/Header/MC/Social.hpp b/LiteLoader/Header/MC/Social.hpp index cc44866..d8e8270 100644 --- a/LiteLoader/Header/MC/Social.hpp +++ b/LiteLoader/Header/MC/Social.hpp @@ -10,7 +10,61 @@ namespace Social { #define AFTER_EXTRA +// Add Member There +namespace Events { +class AchievementEventing { +public: + AchievementEventing() = delete; + AchievementEventing(AchievementEventing const&) = delete; + AchievementEventing(AchievementEventing const&&) = delete; +}; +class Event { +public: + Event() = delete; + Event(Event const&) = delete; + Event(Event const&&) = delete; +}; +class EventManager { +public: + EventManager() = delete; + EventManager(EventManager const&) = delete; + EventManager(EventManager const&&) = delete; +}; +class IEventListener { +public: + IEventListener() = delete; + IEventListener(IEventListener const&) = delete; + IEventListener(IEventListener const&&) = delete; +}; +class Property { +public: + Property() = delete; + Property(Property const&) = delete; + Property(Property const&&) = delete; +}; +} +class MultiplayerService { +public: + MultiplayerService() = delete; + MultiplayerService(MultiplayerService const&) = delete; + MultiplayerService(MultiplayerService const&&) = delete; +}; +enum SignInResult; +enum MultiplayerServiceIdentifier; +class GameConnectionInfo { +public: + GameConnectionInfo() = delete; + GameConnectionInfo(GameConnectionInfo const&) = delete; + GameConnectionInfo(GameConnectionInfo const&&) = delete; +}; +enum GamePublishSetting; +class IUserManager { +public: + IUserManager() = delete; + IUserManager(IUserManager const&) = delete; + IUserManager(IUserManager const&&) = delete; +}; #undef AFTER_EXTRA MCAPI extern class Social::GameConnectionInfo const INVALID_CONNECTION; diff --git a/LiteLoader/Header/MC/TagMemoryChunk.hpp b/LiteLoader/Header/MC/TagMemoryChunk.hpp index 1120244..fab051e 100644 --- a/LiteLoader/Header/MC/TagMemoryChunk.hpp +++ b/LiteLoader/Header/MC/TagMemoryChunk.hpp @@ -4,12 +4,28 @@ #include "../Global.h" #define BEFORE_EXTRA - +// Include Headers or Declare Types Here +#include #undef BEFORE_EXTRA struct TagMemoryChunk { #define AFTER_EXTRA + // Add Member There +public: + size_t capacity = 0; + size_t size = 0; + std::unique_ptr data; + +#define DISABLE_CONSTRUCTOR_PREVENTION_TAGMEMORYCHUNK + TagMemoryChunk() = delete; + + LIAPI TagMemoryChunk(char data[], size_t size); + LIAPI TagMemoryChunk(const TagMemoryChunk& a1); + LIAPI TagMemoryChunk(TagMemoryChunk&& a1); + + LIAPI void operator=(const TagMemoryChunk& a1); + LIAPI void operator=(TagMemoryChunk&& a1); #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_TAGMEMORYCHUNK diff --git a/LiteLoader/Header/MC/TransferPacket.hpp b/LiteLoader/Header/MC/TransferPacket.hpp index 5228a8b..092f420 100644 --- a/LiteLoader/Header/MC/TransferPacket.hpp +++ b/LiteLoader/Header/MC/TransferPacket.hpp @@ -11,7 +11,8 @@ class TransferPacket : public Packet { #define AFTER_EXTRA - + // Add Member There + char filler[40]; #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_TRANSFERPACKET public: diff --git a/LiteLoader/Header/MC/persona.hpp b/LiteLoader/Header/MC/persona.hpp index 4fadfd8..6598908 100644 --- a/LiteLoader/Header/MC/persona.hpp +++ b/LiteLoader/Header/MC/persona.hpp @@ -10,6 +10,9 @@ namespace persona { #define AFTER_EXTRA +// Add Member There +enum AnimatedTextureType; +enum PieceType; #undef AFTER_EXTRA MCAPI extern std::string const ANIMATED_128X128_NAME; diff --git a/LiteLoader/Kernel/EventAPI.cpp b/LiteLoader/Kernel/EventAPI.cpp index af88276..ec20d44 100644 --- a/LiteLoader/Kernel/EventAPI.cpp +++ b/LiteLoader/Kernel/EventAPI.cpp @@ -909,7 +909,7 @@ TClasslessInstanceHook(__int64, "?onEvent@VanillaServerGameplayEventListener@@UE TInstanceHook(bool, "?stopOpen@ChestBlockActor@@UEAAXAEAVPlayer@@@Z", ChestBlockActor, Player* pl) { IF_LISTENED(PlayerCloseContainerEvent) { - BlockActor* ba = (BlockActor*)((char*)this - 240); // IDA ChestBlockActor::stopOpen + BlockActor* ba = (BlockActor*)((char*)this - 248); // IDA ChestBlockActor::stopOpen BlockPos bp = ba->getPosition(); PlayerCloseContainerEvent ev{}; @@ -990,31 +990,31 @@ TInstanceHook(void, "?setSprinting@Mob@@UEAAX_N@Z", #include #include /////////////////// PlayerSetArmor /////////////////// -TInstanceHook(void, "?setArmor@Player@@UEAAXW4ArmorSlot@@AEBVItemStack@@@Z", - Player, unsigned slot, ItemStack* it) { - original(this, slot, it); - IF_LISTENED(PlayerSetArmorEvent) { - if (this->isPlayer()) { - PlayerSetArmorEvent ev{}; - ev.mPlayer = this; - ev.mSlot = slot; - ev.mArmorItem = it; - if (!ev.call()) { - auto& uid = getUniqueID(); - auto& plinv = getSupplies(); - plinv.add(*it, 1); - getArmorContainer().setItem(slot, ItemStack::EMPTY_ITEM); - Schedule::delay([uid] { - auto sp = Global->getPlayer(uid); - if (sp) - sp->refreshInventory(); - }, - 1); - } - } - } - IF_LISTENED_END(PlayerSetArmorEvent) -} +// TInstanceHook(void, "?setArmor@Player@@UEAAXW4ArmorSlot@@AEBVItemStack@@@Z", +// Player, unsigned slot, ItemStack* it) { +// original(this, slot, it); +// IF_LISTENED(PlayerSetArmorEvent) { +// if (this->isPlayer()) { +// PlayerSetArmorEvent ev{}; +// ev.mPlayer = this; +// ev.mSlot = slot; +// ev.mArmorItem = it; +// if (!ev.call()) { +// auto& uid = getUniqueID(); +// auto& plinv = getSupplies(); +// plinv.add(*it, 1); +// getArmorContainer().setItem(slot, ItemStack::EMPTY_ITEM); +// Schedule::delay([uid] { +// auto sp = Global->getPlayer(uid); +// if (sp) +// sp->refreshInventory(); +// }, +// 1); +// } +// } +// } +// IF_LISTENED_END(PlayerSetArmorEvent) +// } /////////////////// PlayerUseRespawnAnchor /////////////////// TInstanceHook(bool, "?trySetSpawn@RespawnAnchorBlock@@CA_NAEAVPlayer@@AEBVBlockPos@@AEAVBlockSource@@AEAVLevel@@@Z", @@ -1043,64 +1043,64 @@ TInstanceHook(bool, "?canOpenContainerScreen@Player@@UEAA_NXZ", Player) { } /////////////////// PlayerCmdEvent & ConsoleCmd /////////////////// -TClasslessInstanceHook(MCRESULT*, "?executeCommand@MinecraftCommands@@QEBA?AUMCRESULT@@V?$shared_ptr@VCommandContext@@@std@@_N@Z", - MCRESULT* rtn, std::shared_ptr context, bool print) { - Player* sp; - string cmd; +// TClasslessInstanceHook(MCRESULT*, "?executeCommand@MinecraftCommands@@QEBA?AUMCRESULT@@V?$shared_ptr@VCommandContext@@@std@@_N@Z", +// MCRESULT* rtn, std::shared_ptr context, bool print) { +// Player* sp; +// string cmd; - try { - sp = context->getOrigin().getPlayer(); - cmd = context->getCmd(); - if (!cmd.empty() && cmd.at(0) == '/') { - cmd = cmd.substr(1, cmd.size() - 1); - } +// try { +// sp = context->getOrigin().getPlayer(); +// cmd = context->getCmd(); +// if (!cmd.empty() && cmd.at(0) == '/') { +// cmd = cmd.substr(1, cmd.size() - 1); +// } - if (!Util::isValidUTF8(cmd)) { - logger.error("Detected invalid utf-8 character, command will not be executed"); - return rtn; - } - } catch (...) { - return rtn; - } +// if (!Util::isValidUTF8(cmd)) { +// logger.error("Detected invalid utf-8 character, command will not be executed"); +// return rtn; +// } +// } catch (...) { +// return rtn; +// } - if (LL::isDebugMode() && LL::globalConfig.tickThreadId != std::this_thread::get_id()) { - logger.warn("The thread executing the command \"{}\" is not the \"MC_SERVER\" thread", cmd); - } - if (sp) { - // PlayerCmd - IF_LISTENED(PlayerCmdEvent) { - PlayerCmdEvent ev{}; - ev.mCommand = cmd; - ev.mPlayer = sp; - ev.mResult = rtn; +// if (LL::isDebugMode() && LL::globalConfig.tickThreadId != std::this_thread::get_id()) { +// logger.warn("The thread executing the command \"{}\" is not the \"MC_SERVER\" thread", cmd); +// } +// if (sp) { +// // PlayerCmd +// IF_LISTENED(PlayerCmdEvent) { +// PlayerCmdEvent ev{}; +// ev.mCommand = cmd; +// ev.mPlayer = sp; +// ev.mResult = rtn; - if (!ev.call()) - return rtn; +// if (!ev.call()) +// return rtn; - if (ev.mCommand.empty() || ev.mCommand.at(0) != '/') - context->getCmd() = "/" + ev.mCommand; - else - context->getCmd() = ev.mCommand; - } - IF_LISTENED_END(PlayerCmdEvent) - } else { - // ConsoleCmd - IF_LISTENED(ConsoleCmdEvent) { - ConsoleCmdEvent ev{}; - ev.mCommand = cmd; +// if (ev.mCommand.empty() || ev.mCommand.at(0) != '/') +// context->getCmd() = "/" + ev.mCommand; +// else +// context->getCmd() = ev.mCommand; +// } +// IF_LISTENED_END(PlayerCmdEvent) +// } else { +// // ConsoleCmd +// IF_LISTENED(ConsoleCmdEvent) { +// ConsoleCmdEvent ev{}; +// ev.mCommand = cmd; - if (!ev.call()) - return rtn; +// if (!ev.call()) +// return rtn; - if (ev.mCommand.empty() || ev.mCommand.at(0) != '/') - context->getCmd() = "/" + ev.mCommand; - else - context->getCmd() = ev.mCommand; - } - IF_LISTENED_END(ConsoleCmdEvent) - } - return original(this, rtn, context, print); -} +// if (ev.mCommand.empty() || ev.mCommand.at(0) != '/') +// context->getCmd() = "/" + ev.mCommand; +// else +// context->getCmd() = ev.mCommand; +// } +// IF_LISTENED_END(ConsoleCmdEvent) +// } +// return original(this, rtn, context, print); +// } /////////////////// PlayerExperienceAddEvent /////////////////// TInstanceHook(void, "?addExperience@Player@@UEAAXH@Z", Player, int exp) { @@ -1132,25 +1132,25 @@ TInstanceHook(void, "?handle@ItemUseOnActorInventoryTransaction@@UEBA?AW4Invento } /////////////////// CmdBlockExecute /////////////////// -TInstanceHook(bool, "?_performCommand@BaseCommandBlock@@AEAA_NAEAVBlockSource@@AEBVCommandOrigin@@AEA_N@Z", - BaseCommandBlock, BlockSource* a2, CommandOrigin* a3, bool* a4) { - IF_LISTENED(CmdBlockExecuteEvent) { - CmdBlockExecuteEvent ev{}; - ev.mCommand = this->getCommand(); - if ((OriginType)a3->getOriginType() == OriginType::MinecartBlock) { - ev.mIsMinecart = true; - ev.mMinecart = a3->getEntity(); - } else { - ev.mIsMinecart = false; - ev.mBlockInstance = Level::getBlockInstance(a3->getBlockPosition(), a2); - } +// TInstanceHook(bool, "?_performCommand@BaseCommandBlock@@AEAA_NAEAVBlockSource@@AEBVCommandOrigin@@AEA_N@Z", +// BaseCommandBlock, BlockSource* a2, CommandOrigin* a3, bool* a4) { +// IF_LISTENED(CmdBlockExecuteEvent) { +// CmdBlockExecuteEvent ev{}; +// ev.mCommand = this->getCommand(); +// if ((OriginType)a3->getOriginType() == OriginType::MinecartBlock) { +// ev.mIsMinecart = true; +// ev.mMinecart = a3->getEntity(); +// } else { +// ev.mIsMinecart = false; +// ev.mBlockInstance = Level::getBlockInstance(a3->getBlockPosition(), a2); +// } - if (!ev.call()) - return false; - } - IF_LISTENED_END(CmdBlockExecuteEvent) - return original(this, a2, a3, a4); -} +// if (!ev.call()) +// return false; +// } +// IF_LISTENED_END(CmdBlockExecuteEvent) +// return original(this, a2, a3, a4); +// } /////////////////// BlockInteracted /////////////////// TClasslessInstanceHook(unsigned short, @@ -1227,30 +1227,30 @@ TClasslessInstanceHook(bool, "?mayPlace@FireBlock@@UEBA_NAEAVBlockSource@@AEBVBl /////////////////// ContainerChange /////////////////// -#include +// #include -TInstanceHook(void, "?_onItemChanged@LevelContainerModel@@MEAAXHAEBVItemStack@@0@Z", - LevelContainerModel, int slotNumber, ItemStack* oldItem, ItemStack* newItem) { - IF_LISTENED(ContainerChangeEvent) { - Player* pl = (Player*)dAccess(this, 208); // IDA LevelContainerModel::LevelContainerModel +// TInstanceHook(void, "?_onItemChanged@LevelContainerModel@@MEAAXHAEBVItemStack@@0@Z", +// LevelContainerModel, int slotNumber, ItemStack* oldItem, ItemStack* newItem) { +// IF_LISTENED(ContainerChangeEvent) { +// Player* pl = (Player*)dAccess(this, 208); // IDA LevelContainerModel::LevelContainerModel - if (pl->hasOpenContainer()) { - BlockPos* bp = (BlockPos*)((char*)this + 216); +// if (pl->hasOpenContainer()) { +// BlockPos* bp = (BlockPos*)((char*)this + 216); - ContainerChangeEvent ev{}; - ev.mBlockInstance = Level::getBlockInstance(bp, pl->getDimensionId()); - ev.mContainer = ev.mBlockInstance.getContainer(); - ev.mPlayer = pl; - ev.mSlot = slotNumber + this->_getContainerOffset(); - ev.mPreviousItemStack = oldItem; - ev.mNewItemStack = newItem; - ev.mActor = this->getEntity(); - ev.call(); - } - } - IF_LISTENED_END(ContainerChangeEvent) - return original(this, slotNumber, oldItem, newItem); -} +// ContainerChangeEvent ev{}; +// ev.mBlockInstance = Level::getBlockInstance(bp, pl->getDimensionId()); +// ev.mContainer = ev.mBlockInstance.getContainer(); +// ev.mPlayer = pl; +// ev.mSlot = slotNumber + this->_getContainerOffset(); +// ev.mPreviousItemStack = oldItem; +// ev.mNewItemStack = newItem; +// ev.mActor = this->getEntity(); +// ev.call(); +// } +// } +// IF_LISTENED_END(ContainerChangeEvent) +// return original(this, slotNumber, oldItem, newItem); +// } /////////////////// ProjectileHitBlock /////////////////// @@ -1273,7 +1273,7 @@ TInstanceHook(void, "?onProjectileHit@Block@@QEBAXAEAVBlockSource@@AEBVBlockPos@ /////////////////// RedStoneUpdate /////////////////// -// 红石ç²? +// 红石�? TClasslessInstanceHook(void, "?onRedstoneUpdate@RedStoneWireBlock@@UEBAXAEAVBlockSource@@AEBVBlockPos@@H_N@Z", BlockSource* bs, BlockPos* bp, int level, bool isActive) { IF_LISTENED(RedStoneUpdateEvent) { @@ -1305,7 +1305,7 @@ TClasslessInstanceHook(void, "?onRedstoneUpdate@RedstoneTorchBlock@@UEBAXAEAVBlo IF_LISTENED_END(RedStoneUpdateEvent) return original(this, bs, bp, level, isActive); } -// 红石中继å™? +// 红石中继�? TClasslessInstanceHook(void, "?onRedstoneUpdate@DiodeBlock@@UEBAXAEAVBlockSource@@AEBVBlockPos@@H_N@Z", BlockSource* bs, BlockPos* bp, int level, bool isActive) { IF_LISTENED(RedStoneUpdateEvent) { @@ -1321,7 +1321,7 @@ TClasslessInstanceHook(void, "?onRedstoneUpdate@DiodeBlock@@UEBAXAEAVBlockSource IF_LISTENED_END(RedStoneUpdateEvent) return original(this, bs, bp, level, isActive); } -// 红石比较å™? +// 红石比较�? TClasslessInstanceHook(void, "?onRedstoneUpdate@ComparatorBlock@@UEBAXAEAVBlockSource@@AEBVBlockPos@@H_N@Z", BlockSource* bs, BlockPos* bp, int level, bool isActive) { IF_LISTENED(RedStoneUpdateEvent) { @@ -1574,97 +1574,97 @@ TInstanceHook(bool, "?useItemOn@GameMode@@UEAA_NAEAVItemStack@@AEBVBlockPos@@EAE /////////////////// MobHurt /////////////////// -TInstanceHook(bool, "?_hurt@Mob@@MEAA_NAEBVActorDamageSource@@M_N1@Z", - Mob, ActorDamageSource& src, float damage, bool unk1_1, bool unk2_0) { - IF_LISTENED(MobHurtEvent) { - if (this) { - MobHurtEvent ev{}; - ev.mMob = this; - ev.mDamageSource = &src; - ev.mDamage = damage; - if (!ev.call()) - return false; +// TInstanceHook(bool, "?_hurt@Mob@@MEAA_NAEBVActorDamageSource@@M_N1@Z", +// Mob, ActorDamageSource& src, float damage, bool unk1_1, bool unk2_0) { +// IF_LISTENED(MobHurtEvent) { +// if (this) { +// MobHurtEvent ev{}; +// ev.mMob = this; +// ev.mDamageSource = &src; +// ev.mDamage = damage; +// if (!ev.call()) +// return false; - damage = ev.mDamage; - } - } - IF_LISTENED_END(MobHurtEvent) - return original(this, src, damage, unk1_1, unk2_0); -} +// damage = ev.mDamage; +// } +// } +// IF_LISTENED_END(MobHurtEvent) +// return original(this, src, damage, unk1_1, unk2_0); +// } -TInstanceHook(float, "?getDamageAfterResistanceEffect@Mob@@UEBAMAEBVActorDamageSource@@M@Z", Mob, ActorDamageSource* src, float damage) { - if (src->getCause() == ActorDamageCause::ActorDamageCause_Magic) { - IF_LISTENED(MobHurtEvent) { - if (this) { - MobHurtEvent ev{}; - ev.mMob = this; - ev.mDamageSource = src; - ev.mDamage = damage; - if (!ev.call()) - return 0; - damage = ev.mDamage; - } - } - IF_LISTENED_END(MobHurtEvent) - } - return original(this, src, damage); -} +// TInstanceHook(float, "?getDamageAfterResistanceEffect@Mob@@UEBAMAEBVActorDamageSource@@M@Z", Mob, ActorDamageSource* src, float damage) { +// if (src->getCause() == ActorDamageCause::ActorDamageCause_Magic) { +// IF_LISTENED(MobHurtEvent) { +// if (this) { +// MobHurtEvent ev{}; +// ev.mMob = this; +// ev.mDamageSource = src; +// ev.mDamage = damage; +// if (!ev.call()) +// return 0; +// damage = ev.mDamage; +// } +// } +// IF_LISTENED_END(MobHurtEvent) +// } +// return original(this, src, damage); +// } //////////////// PlayerUseItem & PlayerEat //////////////// -#include -TInstanceHook(bool, "?baseUseItem@GameMode@@QEAA_NAEAVItemStack@@@Z", GameMode, ItemStack& it) { - auto pl = this->getPlayer(); - IF_LISTENED(PlayerUseItemEvent) { - PlayerUseItemEvent ev{}; - ev.mPlayer = pl; - ev.mItemStack = ⁢ - if (!ev.call()) - return false; - } - IF_LISTENED_END(PlayerUseItemEvent) - IF_LISTENED(PlayerEatEvent) { - if (it.getItem()->isFood() && (pl->isHungry() || pl->forceAllowEating())) { - PlayerEatEvent ev{}; - ev.mPlayer = pl; - ev.mFoodItem = ⁢ - if (!ev.call()) { - pl->refreshAttribute(Player::HUNGER); - return false; - } - } - } - IF_LISTENED_END(PlayerEatEvent) - return original(this, it); -} +// #include +// TInstanceHook(bool, "?baseUseItem@GameMode@@QEAA_NAEAVItemStack@@@Z", GameMode, ItemStack& it) { +// auto pl = this->getPlayer(); +// IF_LISTENED(PlayerUseItemEvent) { +// PlayerUseItemEvent ev{}; +// ev.mPlayer = pl; +// ev.mItemStack = ⁢ +// if (!ev.call()) +// return false; +// } +// IF_LISTENED_END(PlayerUseItemEvent) +// IF_LISTENED(PlayerEatEvent) { +// if (it.getItem()->isFood() && (pl->isHungry() || pl->forceAllowEating())) { +// PlayerEatEvent ev{}; +// ev.mPlayer = pl; +// ev.mFoodItem = ⁢ +// if (!ev.call()) { +// pl->refreshAttribute(Player::HUNGER); +// return false; +// } +// } +// } +// IF_LISTENED_END(PlayerEatEvent) +// return original(this, it); +// } -THook(ItemStack*, "?use@BucketItem@@UEBAAEAVItemStack@@AEAV2@AEAVPlayer@@@Z", Item* _this, ItemStack* a1, Player* a2) { - if (_this->getFullItemName() == "minecraft:milk_bucket") { - IF_LISTENED(PlayerEatEvent) { - PlayerEatEvent ev{}; - ev.mPlayer = a2; - ev.mFoodItem = a1; - if (!ev.call()) { - return a1; - } - } - IF_LISTENED_END(PlayerEatEvent) - } - return original(_this, a1, a2); -} +// THook(ItemStack*, "?use@BucketItem@@UEBAAEAVItemStack@@AEAV2@AEAVPlayer@@@Z", Item* _this, ItemStack* a1, Player* a2) { +// if (_this->getFullItemName() == "minecraft:milk_bucket") { +// IF_LISTENED(PlayerEatEvent) { +// PlayerEatEvent ev{}; +// ev.mPlayer = a2; +// ev.mFoodItem = a1; +// if (!ev.call()) { +// return a1; +// } +// } +// IF_LISTENED_END(PlayerEatEvent) +// } +// return original(_this, a1, a2); +// } -THook(ItemStack*, "?use@PotionItem@@UEBAAEAVItemStack@@AEAV2@AEAVPlayer@@@Z", void* _this, ItemStack* a1, Player* a2) { - IF_LISTENED(PlayerEatEvent) { - PlayerEatEvent ev{}; - ev.mPlayer = a2; - ev.mFoodItem = a1; - if (!ev.call()) { - return a1; - } - } - IF_LISTENED_END(PlayerEatEvent) - return original(_this, a1, a2); -} +// THook(ItemStack*, "?use@PotionItem@@UEBAAEAVItemStack@@AEAV2@AEAVPlayer@@@Z", void* _this, ItemStack* a1, Player* a2) { +// IF_LISTENED(PlayerEatEvent) { +// PlayerEatEvent ev{}; +// ev.mPlayer = a2; +// ev.mFoodItem = a1; +// if (!ev.call()) { +// return a1; +// } +// } +// IF_LISTENED_END(PlayerEatEvent) +// return original(_this, a1, a2); +// } /////////////////// MobDie /////////////////// TInstanceHook(bool, "?die@Mob@@UEAAXAEBVActorDamageSource@@@Z", Mob, ActorDamageSource* ads) { @@ -1743,20 +1743,20 @@ TClasslessInstanceHook(void, "?explode@Explosion@@QEAAXXZ") { ////////////// ProjectileHitEntity ////////////// -TClasslessInstanceHook(void, "?onHit@ProjectileComponent@@QEAAXAEAVActor@@AEBVHitResult@@@Z", - Actor* item, HitResult* res) { - IF_LISTENED(ProjectileHitEntityEvent) { - Actor* to = res->getEntity(); - if (to) { - ProjectileHitEntityEvent ev{}; - ev.mTarget = to; - ev.mSource = item; - ev.call(); - } - } - IF_LISTENED_END(ProjectileHitEntityEvent) - return original(this, item, res); -} +// TClasslessInstanceHook(void, "?onHit@ProjectileComponent@@QEAAXAEAVActor@@AEBVHitResult@@@Z", +// Actor* item, HitResult* res) { +// IF_LISTENED(ProjectileHitEntityEvent) { +// Actor* to = res->getEntity(); +// if (to) { +// ProjectileHitEntityEvent ev{}; +// ev.mTarget = to; +// ev.mSource = item; +// ev.call(); +// } +// } +// IF_LISTENED_END(ProjectileHitEntityEvent) +// return original(this, item, res); +// } ////////////// WitherBossDestroy ////////////// @@ -1809,97 +1809,97 @@ TClasslessInstanceHook(bool, "?shouldTriggerEntityInside@BasePressurePlateBlock@ } ////////////// ProjectileSpawn ////////////// -TClasslessInstanceHook(Actor*, - "?spawnProjectile@Spawner@@QEAAPEAVActor@@AEAVBlockSource@@AEBUActorDefinitionIdentifier@@PEAV2@AEBVVec3@@3@Z", - BlockSource* a2, ActorDefinitionIdentifier* a3, Actor* a4, Vec3* a5, Vec3* a6) { - string name = a3->getCanonicalName(); - if (name != "minecraft:thrown_trident") { - IF_LISTENED(ProjectileSpawnEvent) { - ProjectileSpawnEvent ev{}; - ev.mShooter = a4; - ev.mIdentifier = a3; - ev.mType = name; +// TClasslessInstanceHook(Actor*, +// "?spawnProjectile@Spawner@@QEAAPEAVActor@@AEAVBlockSource@@AEBUActorDefinitionIdentifier@@PEAV2@AEBVVec3@@3@Z", +// BlockSource* a2, ActorDefinitionIdentifier* a3, Actor* a4, Vec3* a5, Vec3* a6) { +// string name = a3->getCanonicalName(); +// if (name != "minecraft:thrown_trident") { +// IF_LISTENED(ProjectileSpawnEvent) { +// ProjectileSpawnEvent ev{}; +// ev.mShooter = a4; +// ev.mIdentifier = a3; +// ev.mType = name; - if (!ev.call()) - return nullptr; - } - IF_LISTENED_END(ProjectileSpawnEvent) - } - auto projectile = original(this, a2, a3, a4, a5, a6); - IF_LISTENED(ProjectileCreatedEvent) { - ProjectileCreatedEvent ev{}; - ev.mShooter = a4; - ev.mProjectile = projectile; - ev.call(); - } - IF_LISTENED_END(ProjectileCreatedEvent) - return projectile; -} +// if (!ev.call()) +// return nullptr; +// } +// IF_LISTENED_END(ProjectileSpawnEvent) +// } +// auto projectile = original(this, a2, a3, a4, a5, a6); +// IF_LISTENED(ProjectileCreatedEvent) { +// ProjectileCreatedEvent ev{}; +// ev.mShooter = a4; +// ev.mProjectile = projectile; +// ev.call(); +// } +// IF_LISTENED_END(ProjectileCreatedEvent) +// return projectile; +// } -#include +// #include #include -static_assert(sizeof(ActorDefinitionIdentifier) == 176); -TInstanceHook(void, "?_shootFirework@CrossbowItem@@AEBAXAEBVItemInstance@@AEAVPlayer@@@Z", - CrossbowItem, void* a1, Player* a2) { - IF_LISTENED(ProjectileSpawnEvent) { - ActorDefinitionIdentifier identifier("minecraft:fireworks_rocket"); - ProjectileSpawnEvent ev{}; - ev.mShooter = a2; - ev.mIdentifier = &identifier; - ev.mType = this->getFullItemName(); +// static_assert(sizeof(ActorDefinitionIdentifier) == 176); +// TInstanceHook(void, "?_shootFirework@CrossbowItem@@AEBAXAEBVItemInstance@@AEAVPlayer@@@Z", +// CrossbowItem, void* a1, Player* a2) { +// IF_LISTENED(ProjectileSpawnEvent) { +// ActorDefinitionIdentifier identifier("minecraft:fireworks_rocket"); +// ProjectileSpawnEvent ev{}; +// ev.mShooter = a2; +// ev.mIdentifier = &identifier; +// ev.mType = this->getFullItemName(); - if (!ev.call()) - return; - } - IF_LISTENED_END(ProjectileSpawnEvent) - original(this, a1, a2); -} +// if (!ev.call()) +// return; +// } +// IF_LISTENED_END(ProjectileSpawnEvent) +// original(this, a1, a2); +// } -TClasslessInstanceHook(void, "?releaseUsing@TridentItem@@UEBAXAEAVItemStack@@PEAVPlayer@@H@Z", - ItemStack* a2, Player* a3, int a4) { - IF_LISTENED(ProjectileSpawnEvent) { - ActorDefinitionIdentifier identifier("minecraft:thrown_trident"); - ProjectileSpawnEvent ev{}; - ev.mShooter = a3; - ev.mIdentifier = &identifier; - ev.mType = a2->getTypeName(); +// TClasslessInstanceHook(void, "?releaseUsing@TridentItem@@UEBAXAEAVItemStack@@PEAVPlayer@@H@Z", +// ItemStack* a2, Player* a3, int a4) { +// IF_LISTENED(ProjectileSpawnEvent) { +// ActorDefinitionIdentifier identifier("minecraft:thrown_trident"); +// ProjectileSpawnEvent ev{}; +// ev.mShooter = a3; +// ev.mIdentifier = &identifier; +// ev.mType = a2->getTypeName(); - if (!ev.call()) - return; - } - IF_LISTENED_END(ProjectileSpawnEvent) - return original(this, a2, a3, a4); -} +// if (!ev.call()) +// return; +// } +// IF_LISTENED_END(ProjectileSpawnEvent) +// return original(this, a2, a3, a4); +// } -#include -#include +// #include +// #include ////////////// NpcCmd ////////////// -TInstanceHook(void, - "?executeCommandAction@NpcComponent@@QEAAXAEAVActor@@AEAVPlayer@@HAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z", - NpcComponent, Actor* ac, Player* pl, int a4, string& a5) { - IF_LISTENED(NpcCmdEvent) { - // IDA NpcComponent::executeCommandAction - // NpcSceneDialogueData data(*this, *ac, a5); +// TInstanceHook(void, +// "?executeCommandAction@NpcComponent@@QEAAXAEAVActor@@AEAVPlayer@@HAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z", +// NpcComponent, Actor* ac, Player* pl, int a4, string& a5) { +// IF_LISTENED(NpcCmdEvent) { +// // IDA NpcComponent::executeCommandAction +// // NpcSceneDialogueData data(*this, *ac, a5); - auto ec = (EntityContext*)((char*)ac + 8); - NpcSceneDialogueData data(WeakEntityRef(ec->getWeakRef()), a5); +// auto ec = (EntityContext*)((char*)ac + 8); +// NpcSceneDialogueData data(WeakEntityRef(ec->getWeakRef()), a5); - auto container = data.getActionsContainer(); - auto actionAt = container->getActionAt(a4); - if (actionAt && dAccess(actionAt, 8) == (char)1) { +// auto container = data.getActionsContainer(); +// auto actionAt = container->getActionAt(a4); +// if (actionAt && dAccess(actionAt, 8) == (char)1) { - NpcCmdEvent ev{}; - ev.mPlayer = pl; - ev.mNpc = ac; - ev.mCommand = actionAt->getText(); - if (!ev.call()) - return; - } - } - IF_LISTENED_END(NpcCmdEvent) - return original(this, ac, pl, a4, a5); -} +// NpcCmdEvent ev{}; +// ev.mPlayer = pl; +// ev.mNpc = ac; +// ev.mCommand = actionAt->getText(); +// if (!ev.call()) +// return; +// } +// } +// IF_LISTENED_END(NpcCmdEvent) +// return original(this, ac, pl, a4, a5); +// } ////////////// ArmorStandChange ////////////// TInstanceHook(bool, "?_trySwapItem@ArmorStand@@AEAA_NAEAVPlayer@@W4EquipmentSlot@@@Z", @@ -2001,19 +2001,19 @@ TClasslessInstanceHook(void, "?execute@StopCommand@@UEBAXAEBVCommandOrigin@@AEAV ////////////// RegCmd ////////////// -TInstanceHook(void, "?setup@ChangeSettingCommand@@SAXAEAVCommandRegistry@@@Z", - CommandRegistry, void* a1) { - Global = this; - original(this, a1); - IF_LISTENED(RegCmdEvent) { - RegCmdEvent ev{}; - ev.mCommandRegistry = this; - ev.call(); - // setup dynamic command - DynamicCommand::onServerCommandsRegister(*this); - } - IF_LISTENED_END(RegCmdEvent) -} +// TInstanceHook(void, "?setup@ChangeSettingCommand@@SAXAEAVCommandRegistry@@@Z", +// CommandRegistry, void* a1) { +// Global = this; +// original(this, a1); +// IF_LISTENED(RegCmdEvent) { +// RegCmdEvent ev{}; +// ev.mCommandRegistry = this; +// ev.call(); +// // setup dynamic command +// DynamicCommand::onServerCommandsRegister(*this); +// } +// IF_LISTENED_END(RegCmdEvent) +// } ////////////// ConsoleOutput ////////////// THook(std::ostream&, @@ -2098,19 +2098,19 @@ TInstanceHook(int, "?startSleepInBed@Player@@UEAA?AW4BedSleepingResult@@AEBVBloc #include ////////////// MobSpawn ////////////// -TInstanceHook(Mob*, "?spawnMob@Spawner@@QEAAPEAVMob@@AEAVBlockSource@@AEBUActorDefinitionIdentifier@@PEAVActor@@AEBVVec3@@_N44@Z", - Spawner, BlockSource* a2, ActorDefinitionIdentifier* a3, Actor* a4, Vec3& a5, bool a6, bool a7, bool a8) { - IF_LISTENED(MobSpawnEvent) { - MobSpawnEvent ev{}; - ev.mTypeName = a3->getCanonicalName(); - ev.mPos = a5; - ev.mDimensionId = a2->getDimensionId(); - if (!ev.call()) - return nullptr; - } - IF_LISTENED_END(MobSpawnEvent) - return original(this, a2, a3, a4, a5, a6, a7, a8); -} +// TInstanceHook(Mob*, "?spawnMob@Spawner@@QEAAPEAVMob@@AEAVBlockSource@@AEBUActorDefinitionIdentifier@@PEAVActor@@AEBVVec3@@_N44@Z", +// Spawner, BlockSource* a2, ActorDefinitionIdentifier* a3, Actor* a4, Vec3& a5, bool a6, bool a7, bool a8) { +// IF_LISTENED(MobSpawnEvent) { +// MobSpawnEvent ev{}; +// ev.mTypeName = a3->getCanonicalName(); +// ev.mPos = a5; +// ev.mDimensionId = a2->getDimensionId(); +// if (!ev.call()) +// return nullptr; +// } +// IF_LISTENED_END(MobSpawnEvent) +// return original(this, a2, a3, a4, a5, a6, a7, a8); +// } #include "Impl/FormPacketHelper.h" #include diff --git a/LiteLoader/Kernel/MC/ActorAPI.cpp b/LiteLoader/Kernel/MC/ActorAPI.cpp index 4e2b4f2..8d54178 100644 --- a/LiteLoader/Kernel/MC/ActorAPI.cpp +++ b/LiteLoader/Kernel/MC/ActorAPI.cpp @@ -113,7 +113,7 @@ ActorUniqueID Actor::getActorUniqueId() const { SimpleContainer & Actor::getHandContainer(){ //ScriptHandContainerComponent::hasComponent actor - return dAccess(this, 176); + return dAccess(this, 176); } ItemStack* Actor::getHandSlot() { @@ -124,7 +124,7 @@ ItemStack* Actor::getHandSlot() { SimpleContainer & Actor::getArmorContainer(){ // ItemStackNetManagerServer::_handleLegacyTransactionRequest Line46 - return dAccess(this, 1400); + return dAccess(this, 1400); } bool Actor::rename(const string& name) { diff --git a/LiteLoader/Kernel/MC/BlockActorAPI.cpp b/LiteLoader/Kernel/MC/BlockActorAPI.cpp index b96dbca..e76383e 100644 --- a/LiteLoader/Kernel/MC/BlockActorAPI.cpp +++ b/LiteLoader/Kernel/MC/BlockActorAPI.cpp @@ -11,10 +11,10 @@ // return block->getBlockEntityType(); // IDA Block::getBlockEntityType // } -// bool BlockActor::refreshData() { -// setChanged(); -// return true; -// } +bool BlockActor::refreshData() { + setChanged(); + return true; +} // bool BlockActor::refreshData(BlockSource* bs) { // refreshData(); diff --git a/LiteLoader/Kernel/MC/BlockSourceAPI.cpp b/LiteLoader/Kernel/MC/BlockSourceAPI.cpp index 3cf3557..8165a03 100644 --- a/LiteLoader/Kernel/MC/BlockSourceAPI.cpp +++ b/LiteLoader/Kernel/MC/BlockSourceAPI.cpp @@ -2,6 +2,6 @@ #include #include -// BlockInstance BlockSource::getBlockInstance(BlockPos a1) { -// return BlockInstance{const_cast(&getBlock(a1)), a1, this->getDimensionId()}; -// } +BlockInstance BlockSource::getBlockInstance(BlockPos a1) { + return BlockInstance{const_cast(&getBlock(a1)), a1, this->getDimensionId()}; +} diff --git a/LiteLoader/Kernel/MC/ItemStackAPI.cpp b/LiteLoader/Kernel/MC/ItemStackAPI.cpp index 4883093..32eadbe 100644 --- a/LiteLoader/Kernel/MC/ItemStackAPI.cpp +++ b/LiteLoader/Kernel/MC/ItemStackAPI.cpp @@ -14,7 +14,7 @@ using namespace std; static_assert(sizeof(ItemStack) == 160); -static_assert(sizeof(ItemInstance) == 136); +static_assert(sizeof(ItemInstance) == 144); ItemStack* ItemStack::create() { try { @@ -49,19 +49,24 @@ ItemStack* ItemStack::create(std::string type, int count) { return create(std::move(nbt)); } -// ItemStack ItemStack::fromItemInstance(ItemInstance const& ins) { -// try { -// return {ins}; -// } catch (...) { -// return ItemStack::EMPTY_ITEM; -// } -// } + ItemStack ItemStack::fromItemInstance(ItemInstance const& ins) { + try { + return {ins}; + } catch (...) { + return ItemStack::EMPTY_ITEM; + } + } -// ItemStack* ItemStack::clone_s() const { -// ItemStack* a = ItemStack::create(); -// *a = clone(); -// return a; -// } + ItemStack ItemStack::clone() const { + ItemStack a = ItemStack(*this); + return a; + } + + ItemStack* ItemStack::clone_s() const { + ItemStack* a = ItemStack::create(); + *a = clone(); + return a; + } std::string ItemStack::getTypeName() const { if (isNull()) diff --git a/LiteLoader/Kernel/MC/LevelAPI.cpp b/LiteLoader/Kernel/MC/LevelAPI.cpp index a69368a..8f2a974 100644 --- a/LiteLoader/Kernel/MC/LevelAPI.cpp +++ b/LiteLoader/Kernel/MC/LevelAPI.cpp @@ -42,9 +42,9 @@ BlockSource* Level::getBlockSource(int dimID) { //return dAccess(dim, 96); } -//BlockSource* Level::getBlockSource(Actor* ac) { -// return const_cast(&ac->getRegionConst()); -//} +BlockSource* Level::getBlockSource(Actor* ac) { + return const_cast(&ac->getRegionConst()); +} Block* Level::getBlock(BlockPos* pos, int dimId) { return getBlock(*pos, Level::getBlockSource(dimId)); @@ -86,17 +86,17 @@ BlockInstance Level::getBlockInstance(BlockPos* pos, int dimId) { return {*pos, dimId}; } -//BlockInstance Level::getBlockInstance(BlockPos* pos, BlockSource* blockSource) { -// return {*pos, blockSource->getDimensionId()}; -//} +BlockInstance Level::getBlockInstance(BlockPos* pos, BlockSource* blockSource) { + return {*pos, blockSource->getDimensionId()}; +} BlockInstance Level::getBlockInstance(const BlockPos& pos, int dim) { return {pos, dim}; } -//BlockInstance Level::getBlockInstance(const BlockPos& pos, BlockSource* blockSource) { -// return {pos, blockSource->getDimensionId()}; -//} +BlockInstance Level::getBlockInstance(const BlockPos& pos, BlockSource* blockSource) { + return {pos, blockSource->getDimensionId()}; +} BlockActor* Level::getBlockEntity(BlockPos* pos, int dimId) { return getBlockEntity(pos, Level::getBlockSource(dimId)); diff --git a/LiteLoader/Kernel/MC/PlayerAPI.cpp b/LiteLoader/Kernel/MC/PlayerAPI.cpp index ef7c216..93ca585 100644 --- a/LiteLoader/Kernel/MC/PlayerAPI.cpp +++ b/LiteLoader/Kernel/MC/PlayerAPI.cpp @@ -50,7 +50,7 @@ NetworkIdentifier* Player::getNetworkIdentifier() { } -Certificate* Player::getCertificate() { +Certificate* Player::getCertificate() const{ //ServerNetworkHandler::_onPlayerLeft Line145 return dAccess(this, 342); } @@ -103,7 +103,7 @@ int Player::getPlatform(){ Container & Player::getInventory(){ //InventoryContainerModel::_getContainer 2928 + 176 - return dAccess(this, 3104); + return dAccess(this, 3104); } enum CommandPermissionLevel Player::getPlayerPermissionLevel(){ @@ -299,7 +299,7 @@ string Player::getUuid() { return result.asString(); } -string Player::getXuid() { +string Player::getXuid() const{ return ExtendedCertificate::getXuid(*getCertificate()); } diff --git a/LiteLoader/Kernel/NBT/CompoundTagAPI.cpp b/LiteLoader/Kernel/NBT/CompoundTagAPI.cpp index 9e435b6..6f7cb7f 100644 --- a/LiteLoader/Kernel/NBT/CompoundTagAPI.cpp +++ b/LiteLoader/Kernel/NBT/CompoundTagAPI.cpp @@ -116,7 +116,7 @@ class CompoundTag const* CompoundTag::getCompoundTag(class gsl::basic_string_spa }; Tag* CompoundTag::operator[](class gsl::basic_string_span key) { - return get(key); + return const_cast(get(key)); } #pragma endregion diff --git a/LiteLoader/Kernel/Network/BinaryStreamAPI.cpp b/LiteLoader/Kernel/Network/BinaryStreamAPI.cpp index 26794ef..aaa0811 100644 --- a/LiteLoader/Kernel/Network/BinaryStreamAPI.cpp +++ b/LiteLoader/Kernel/Network/BinaryStreamAPI.cpp @@ -4,9 +4,10 @@ #include void BinaryStream::write(const void* origin, size_t num){ - //BinaryStream::writeSignedBigEndianInt - std::string* mBuffer = dAccess(this, 12); - mBuffer->append((const char*)origin,num); + //BatchedNetworkPeer::flush Line24 + // std::string* mBuffer = dAccess(this, 15); + // mBuffer->append((const char*)origin,num); + this->pwBuf->append((const char*)origin,num); } void BinaryStream::writeByte(uint8_t origin){ write(&origin,1ull); @@ -62,8 +63,9 @@ void BinaryStream::writeVarInt64(__int64 value){ } void BinaryStream::reserve(size_t size) { - std::string* mBuffer = dAccess(this, 12); - mBuffer->reserve(size); + // std::string* mBuffer = dAccess(this, 15); + // mBuffer->reserve(size); + this->pwBuf->reserve(size); } std::string& BinaryStream::getRaw() { return *dAccess(this); // BinaryStream::getAndReleaseData