适配部分LLAPI,以上适配未测试

This commit is contained in:
Qiuzhizhe 2022-09-28 22:48:19 +08:00
parent 7fbdcc94ef
commit c498483ec7
No known key found for this signature in database
GPG Key ID: 4EF4BF5521540263
49 changed files with 957 additions and 410 deletions

View File

@ -9,18 +9,26 @@
class AABB { class AABB {
public:
Vec3 min;
Vec3 max;
#define AFTER_EXTRA #define AFTER_EXTRA
#undef AFTER_EXTRA #undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_AABB #ifndef DISABLE_CONSTRUCTOR_PREVENTION_AABB
public: public:
class AABB& operator=(class AABB const &) = delete; // class AABB& operator=(class AABB const &) = delete;
AABB(class AABB const &) = delete; // AABB(class AABB const &) = delete;
#endif #endif
public: public:
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_AABB #ifdef ENABLE_VIRTUAL_FAKESYMBOL_AABB
#endif #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();
MCAPI AABB(float, float, float, float, float, float); MCAPI AABB(float, float, float, float, float, float);
MCAPI AABB(class Vec3 const &, class Vec3 const &); MCAPI AABB(class Vec3 const &, class Vec3 const &);
@ -41,4 +49,59 @@ public:
MCAPI class AABB shrink(class Vec3 const &) const; MCAPI class AABB shrink(class Vec3 const &) const;
MCAPI static class AABB const EMPTY; 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));
}
}; };

View File

@ -8,6 +8,7 @@
#include "MobEffectInstance.hpp" #include "MobEffectInstance.hpp"
#include "Tick.hpp" #include "Tick.hpp"
#include "ActorDamageSource.hpp" #include "ActorDamageSource.hpp"
#include "SimpleContainer.hpp"
class Actor; class Actor;
class Player; class Player;
class NetworkIdentifier; class NetworkIdentifier;
@ -17,6 +18,9 @@ class BlockInstance;
class ItemStack; class ItemStack;
class BlockSource; class BlockSource;
enum class FaceID : char; enum class FaceID : char;
enum ActorFlags : int{
MOVING=0x22
};
#undef BEFORE_EXTRA #undef BEFORE_EXTRA
@ -61,7 +65,7 @@ public:
LIAPI SimpleContainer & getHandContainer(); LIAPI SimpleContainer & getHandContainer();
LIAPI SimpleContainer & getArmorContainer(); LIAPI SimpleContainer & getArmorContainer();
inline Vec3 getPosition() inline const Vec3 &getPosition()const
{ {
return getPos(); return getPos();
} }
@ -69,6 +73,12 @@ public:
{ {
return getPosOld(); return getPosOld();
} }
inline BlockSource const & getRegionConst() const{
return dAccess<BlockSource>(this,100);
};
inline bool isMoving() const{
return getStatusFlag(ActorFlags::MOVING);
};
#undef AFTER_EXTRA #undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTOR #ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTOR

View File

@ -10,7 +10,12 @@
struct ActorDefinitionIdentifier { struct ActorDefinitionIdentifier {
#define AFTER_EXTRA #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 #undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORDEFINITIONIDENTIFIER #ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORDEFINITIONIDENTIFIER
public: public:

View File

@ -12,6 +12,8 @@ class BinaryStream : public ReadOnlyBinaryStream {
#define AFTER_EXTRA #define AFTER_EXTRA
public: public:
std::string writeBuf, *pwBuf;
LIAPI void write(const void* origin, size_t num); LIAPI void write(const void* origin, size_t num);
LIAPI void writeByte(uint8_t origin); LIAPI void writeByte(uint8_t origin);
LIAPI void writeBool(bool origin); LIAPI void writeBool(bool origin);
@ -39,6 +41,16 @@ public:
LIAPI std::string& getRaw(); LIAPI std::string& getRaw();
LIAPI void writeCompoundTag(class CompoundTag const& tag); 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 #undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_BINARYSTREAM #ifndef DISABLE_CONSTRUCTOR_PREVENTION_BINARYSTREAM

View File

@ -17,13 +17,22 @@ class BlockActor {
#define AFTER_EXTRA #define AFTER_EXTRA
// Add new members to class // Add new members to class
public: public:
//LIAPI bool refreshData(); LIAPI bool refreshData();
//LIAPI bool refreshData(BlockSource* bs); // LIAPI bool refreshData(BlockSource* bs);
LIAPI std::unique_ptr<CompoundTag> getNbt(); LIAPI std::unique_ptr<CompoundTag> getNbt();
LIAPI bool setNbt(CompoundTag* nbt); LIAPI bool setNbt(CompoundTag* nbt);
LIAPI bool setNbt(CompoundTag* nbt, BlockSource* bs); LIAPI bool setNbt(CompoundTag* nbt, BlockSource* bs);
//static unsigned int getBlockEntityType(Block* block); //static unsigned int getBlockEntityType(Block* block);
inline void setChanged(){
//EndGatewayBlockActor::teleportEntity Line115
dAccess<bool, 200>(this) = 1;
}
inline BlockPos const & getPosition() const{
//EndGatewayBlockActor::teleportEntity Line114
return dAccess<BlockPos>(this,44);
};
#undef AFTER_EXTRA #undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_BLOCKACTOR #ifndef DISABLE_CONSTRUCTOR_PREVENTION_BLOCKACTOR
public: public:

View File

@ -35,9 +35,9 @@ public:
return res; return res;
} }
inline std::string toString() const { // inline std::string toString() const {
return std::to_string(x) + "," + std::to_string(y) + "," + std::to_string(z); // return std::to_string(x) + "," + std::to_string(y) + "," + std::to_string(z);
} // }
inline BlockPos add(int dx) const { inline BlockPos add(int dx) const {
return {x + dx, y, z}; return {x + dx, y, z};

View File

@ -11,12 +11,12 @@ namespace BlockSerializationUtils {
#define AFTER_EXTRA #define AFTER_EXTRA
// Add Member There // Add Member There
// struct NbtToBlockCache { struct NbtToBlockCache {
// NbtToBlockCache() = delete; NbtToBlockCache() = delete;
// NbtToBlockCache(NbtToBlockCache const&) = delete; NbtToBlockCache(NbtToBlockCache const&) = delete;
// NbtToBlockCache(NbtToBlockCache const&&) = delete; NbtToBlockCache(NbtToBlockCache const&&) = delete;
// }; };
// enum NBTState; enum NBTState;
#undef AFTER_EXTRA #undef AFTER_EXTRA
MCAPI extern class std::unordered_map<std::string, class std::function<void (int, class CompoundTag &)>, struct std::hash<std::string>, struct std::equal_to<std::string>, class std::allocator<struct std::pair<std::string const, class std::function<void (int, class CompoundTag &)>>>> BLOCK_REPLACE_DATA_MAP; MCAPI extern class std::unordered_map<std::string, class std::function<void (int, class CompoundTag &)>, struct std::hash<std::string>, struct std::equal_to<std::string>, class std::allocator<struct std::pair<std::string const, class std::function<void (int, class CompoundTag &)>>>> BLOCK_REPLACE_DATA_MAP;

View File

@ -5,6 +5,7 @@
#define BEFORE_EXTRA #define BEFORE_EXTRA
#include "BlockInstance.hpp" #include "BlockInstance.hpp"
#include "Dimension.hpp"
#undef BEFORE_EXTRA #undef BEFORE_EXTRA
@ -18,7 +19,12 @@ public:
// { // {
// MCAPI static const std::function<bool(class Block const&)> CHECK_ALL_BLOCKS; // MCAPI static const std::function<bool(class Block const&)> CHECK_ALL_BLOCKS;
// }; // };
//LIAPI BlockInstance getBlockInstance(BlockPos); LIAPI BlockInstance getBlockInstance(BlockPos);
inline AutomaticID<Dimension, int> getDimensionId(){
//Dimension::onBlockEvent Line24
Dimension* mDimension = dAccess< Dimension*>(this, 4);
return dAccess<AutomaticID<Dimension, int>>(mDimension, 192);
};
#undef AFTER_EXTRA #undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_BLOCKSOURCE #ifndef DISABLE_CONSTRUCTOR_PREVENTION_BLOCKSOURCE

View File

@ -5,13 +5,24 @@
#include "Tag.hpp" #include "Tag.hpp"
#define BEFORE_EXTRA #define BEFORE_EXTRA
// Include Headers or Declare Types Here
#include "TagMemoryChunk.hpp"
#undef BEFORE_EXTRA #undef BEFORE_EXTRA
class ByteArrayTag : public Tag { class ByteArrayTag : public Tag {
#define AFTER_EXTRA #define AFTER_EXTRA
// Add Member There
TagMemoryChunk val;
public:
LIAPI TagMemoryChunk& value();
LIAPI ByteArrayTag& operator=(TagMemoryChunk const& val);
LIAPI static std::unique_ptr<ByteArrayTag> create();
LIAPI static std::unique_ptr<ByteArrayTag> create(TagMemoryChunk const& val);
LIAPI static std::unique_ptr<ByteArrayTag> create(char data[], size_t size);
LIAPI bool set(TagMemoryChunk const& val);
LIAPI TagMemoryChunk get();
#undef AFTER_EXTRA #undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_BYTEARRAYTAG #ifndef DISABLE_CONSTRUCTOR_PREVENTION_BYTEARRAYTAG
public: public:

View File

@ -11,6 +11,16 @@
class ByteTag : public Tag { class ByteTag : public Tag {
#define AFTER_EXTRA #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<ByteTag> create(unsigned char val = 0);
LIAPI bool set(unsigned char val);
LIAPI unsigned char get();
LIAPI operator unsigned char() const;
#undef AFTER_EXTRA #undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_BYTETAG #ifndef DISABLE_CONSTRUCTOR_PREVENTION_BYTETAG

View File

@ -4,12 +4,24 @@
#include "../Global.h" #include "../Global.h"
#define BEFORE_EXTRA #define BEFORE_EXTRA
// Include Headers or Declare Types Here
#include "InventoryTransaction.hpp"
#undef BEFORE_EXTRA #undef BEFORE_EXTRA
class ComplexInventoryTransaction { class ComplexInventoryTransaction {
#define AFTER_EXTRA #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 #undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_COMPLEXINVENTORYTRANSACTION #ifndef DISABLE_CONSTRUCTOR_PREVENTION_COMPLEXINVENTORYTRANSACTION

View File

@ -91,6 +91,24 @@ public:
// Deprecated? // Deprecated?
LIAPI std::string toSNBT(); LIAPI std::string toSNBT();
inline Tag const * get(class gsl::basic_string_span<char const, -1> 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<std::string, CompoundTagVariant>::const_iterator begin(){
return this->val.begin();
}
inline map<std::string, CompoundTagVariant>::const_iterator end(){
return this->val.end();
}
#undef AFTER_EXTRA #undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_COMPOUNDTAG #ifndef DISABLE_CONSTRUCTOR_PREVENTION_COMPOUNDTAG
public: public:

View File

@ -4,7 +4,8 @@
#include "../Global.h" #include "../Global.h"
#define BEFORE_EXTRA #define BEFORE_EXTRA
// Add include headers & pre-declares
class ItemStack;
#undef BEFORE_EXTRA #undef BEFORE_EXTRA
class Container { class Container {

View File

@ -11,6 +11,16 @@
class DoubleTag : public Tag { class DoubleTag : public Tag {
#define AFTER_EXTRA #define AFTER_EXTRA
// Add Member There
double val;
public:
LIAPI double& value();
LIAPI DoubleTag& operator=(double val);
LIAPI static std::unique_ptr<DoubleTag> create(double val = 0.0);
LIAPI bool set(double val);
LIAPI double get();
LIAPI operator double() const;
#undef AFTER_EXTRA #undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_DOUBLETAG #ifndef DISABLE_CONSTRUCTOR_PREVENTION_DOUBLETAG

View File

@ -11,6 +11,12 @@
class EndTag : public Tag { class EndTag : public Tag {
#define AFTER_EXTRA #define AFTER_EXTRA
// Add Member There
public:
LIAPI nullptr_t value();
LIAPI static std::unique_ptr<EndTag> create();
LIAPI bool set();
LIAPI nullptr_t get();
#undef AFTER_EXTRA #undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ENDTAG #ifndef DISABLE_CONSTRUCTOR_PREVENTION_ENDTAG

View File

@ -11,6 +11,16 @@
class FloatTag : public Tag { class FloatTag : public Tag {
#define AFTER_EXTRA #define AFTER_EXTRA
// Add Member There
float val;
public:
LIAPI float& value();
LIAPI FloatTag& operator=(float val);
LIAPI static std::unique_ptr<FloatTag> create(float val = 0.0f);
LIAPI bool set(float val);
LIAPI float get();
LIAPI operator float() const;
#undef AFTER_EXTRA #undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_FLOATTAG #ifndef DISABLE_CONSTRUCTOR_PREVENTION_FLOATTAG

View File

@ -10,7 +10,8 @@
class IMinecraftEventing { class IMinecraftEventing {
#define AFTER_EXTRA #define AFTER_EXTRA
public:
enum StructureBlockActionType;
#undef AFTER_EXTRA #undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_IMINECRAFTEVENTING #ifndef DISABLE_CONSTRUCTOR_PREVENTION_IMINECRAFTEVENTING
public: public:

View File

@ -11,6 +11,16 @@
class Int64Tag : public Tag { class Int64Tag : public Tag {
#define AFTER_EXTRA #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<Int64Tag> create(int64_t val = 0);
LIAPI bool set(int64_t val);
LIAPI int64_t get();
LIAPI operator int64_t() const;
#undef AFTER_EXTRA #undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_INT64TAG #ifndef DISABLE_CONSTRUCTOR_PREVENTION_INT64TAG

View File

@ -5,12 +5,24 @@
#include "Tag.hpp" #include "Tag.hpp"
#define BEFORE_EXTRA #define BEFORE_EXTRA
// Include Headers or Declare Types Here
#include "TagMemoryChunk.hpp"
#undef BEFORE_EXTRA #undef BEFORE_EXTRA
class IntArrayTag : public Tag { class IntArrayTag : public Tag {
#define AFTER_EXTRA #define AFTER_EXTRA
// Add Member There
TagMemoryChunk val;
public:
LIAPI TagMemoryChunk& value();
LIAPI IntArrayTag& operator=(TagMemoryChunk const& val);
LIAPI static std::unique_ptr<IntArrayTag> create();
LIAPI static std::unique_ptr<IntArrayTag> create(TagMemoryChunk const& val);
LIAPI static std::unique_ptr<IntArrayTag> create(int data[], size_t size);
LIAPI bool set(TagMemoryChunk const& val);
LIAPI TagMemoryChunk get();
#undef AFTER_EXTRA #undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_INTARRAYTAG #ifndef DISABLE_CONSTRUCTOR_PREVENTION_INTARRAYTAG

View File

@ -11,6 +11,16 @@
class IntTag : public Tag { class IntTag : public Tag {
#define AFTER_EXTRA #define AFTER_EXTRA
// Add Member There
int val;
public:
LIAPI int& value();
LIAPI IntTag& operator=(int val);
LIAPI static std::unique_ptr<IntTag> create(int val = 0);
LIAPI bool set(int val);
LIAPI int get();
LIAPI operator int() const;
#undef AFTER_EXTRA #undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_INTTAG #ifndef DISABLE_CONSTRUCTOR_PREVENTION_INTTAG

View File

@ -6,7 +6,6 @@
#define BEFORE_EXTRA #define BEFORE_EXTRA
// Include Headers or Declare Types Here // Include Headers or Declare Types Here
#include "InventorySource.hpp" #include "InventorySource.hpp"
#include "NetworkItemStackDescriptor.hpp"
#include "ItemStack.hpp" #include "ItemStack.hpp"
#undef BEFORE_EXTRA #undef BEFORE_EXTRA
@ -17,20 +16,16 @@ class InventoryAction {
public: public:
InventorySource source; // 0 InventorySource source; // 0
uint32_t slot; // 12 uint32_t slot; // 12
NetworkItemStackDescriptor fromDescriptor; // 16 ItemStack fromItem; // 16
NetworkItemStackDescriptor toDescriptor; // 104 ItemStack toItem; // 264
ItemStack fromItem; // 192
ItemStack toItem; // 352
private: private:
inline void test() // inline void test()
{ // {
static_assert(offsetof(InventoryAction, slot) == 12); // static_assert(offsetof(InventoryAction, slot) == 12);
static_assert(offsetof(InventoryAction, fromDescriptor) == 16); // static_assert(offsetof(InventoryAction, fromItem) == 16);
static_assert(offsetof(InventoryAction, toDescriptor) == 104); // static_assert(offsetof(InventoryAction, toItem) == 162);
static_assert(offsetof(InventoryAction, fromItem) == 192); // }
static_assert(offsetof(InventoryAction, toItem) == 352);
}
#undef AFTER_EXTRA #undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_INVENTORYACTION #ifndef DISABLE_CONSTRUCTOR_PREVENTION_INVENTORYACTION
public: public:

View File

@ -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;
};

View File

@ -10,6 +10,10 @@
class InventoryTransaction { class InventoryTransaction {
#define AFTER_EXTRA #define AFTER_EXTRA
// Add Member There
public:
std::unordered_map<class InventorySource, std::vector<class InventoryAction>> actions; // 0x0
std::vector<class InventoryTransactionItemGroup> items; // 0x40
#undef AFTER_EXTRA #undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_INVENTORYTRANSACTION #ifndef DISABLE_CONSTRUCTOR_PREVENTION_INVENTORYTRANSACTION

View File

@ -5,7 +5,13 @@
#include "Json.hpp" #include "Json.hpp"
#define BEFORE_EXTRA #define BEFORE_EXTRA
template<class T, class T1, int T2>
class SimpleServerNetId {
public:
SimpleServerNetId() = delete;
SimpleServerNetId(SimpleServerNetId const&) = delete;
SimpleServerNetId(SimpleServerNetId const&&) = delete;
};
#undef BEFORE_EXTRA #undef BEFORE_EXTRA
class Item { class Item {

View File

@ -3,12 +3,13 @@
#define AUTO_GENERATED #define AUTO_GENERATED
#include "../Global.h" #include "../Global.h"
#include "ItemStackBase.hpp" #include "ItemStackBase.hpp"
#include "Item.hpp"
#define BEFORE_EXTRA #define BEFORE_EXTRA
#undef BEFORE_EXTRA #undef BEFORE_EXTRA
class ItemInstance : public ItemStackBase { class ItemInstance : public ItemStackBase, public Item {
#define AFTER_EXTRA #define AFTER_EXTRA

View File

@ -23,6 +23,7 @@ class ItemStack : public ItemStackBase {
ItemStackNetIdVariant mNetId; ItemStackNetIdVariant mNetId;
public: public:
ItemStack clone() const;
// The return value should be freed by the developer if it is no longer used // The return value should be freed by the developer if it is no longer used
LIAPI static ItemStack* create(); LIAPI static ItemStack* create();
// The return value should be freed by the developer if it is no longer used // 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<CompoundTag> tag); LIAPI static ItemStack* create(std::unique_ptr<CompoundTag> tag);
// The return value should be freed by the developer if it is no longer used // 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 static ItemStack* create(short itemId, int aux,int count = 1);
//LIAPI ItemStack* clone_s() const; LIAPI ItemStack* clone_s() const;
//LIAPI static ItemStack fromItemInstance(ItemInstance const& ins); LIAPI static ItemStack fromItemInstance(ItemInstance const& ins);
LIAPI std::string getTypeName() const; LIAPI std::string getTypeName() const;
LIAPI int getAux() const; LIAPI int getAux() const;

View File

@ -239,7 +239,7 @@ public:
//MCAPI iterator begin(); //MCAPI iterator begin();
//MCAPI iterator end(); //MCAPI iterator end();
//MCAPI std::string toStyledString() const; MCAPI std::string toStyledString() const;
union ValueHolder { union ValueHolder {
LargestInt int_; LargestInt int_;

View File

@ -56,9 +56,9 @@ public:
LIAPI static Block* getBlock(const BlockPos& pos, BlockSource *blockSource); LIAPI static Block* getBlock(const BlockPos& pos, BlockSource *blockSource);
//LIAPI static Block* getBlockEx(const BlockPos& pos, int dimId); //LIAPI static Block* getBlockEx(const BlockPos& pos, int dimId);
LIAPI static BlockInstance getBlockInstance(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, 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, int dimId);
LIAPI static BlockActor* getBlockEntity(BlockPos* pos, BlockSource* blockSource); LIAPI static BlockActor* getBlockEntity(BlockPos* pos, BlockSource* blockSource);
LIAPI static BlockActor* getBlockEntity(const BlockPos& pos, int dimId); LIAPI static BlockActor* getBlockEntity(const BlockPos& pos, int dimId);
@ -80,7 +80,7 @@ public:
//Helper //Helper
LIAPI static BlockSource* getBlockSource(int dimid); LIAPI static BlockSource* getBlockSource(int dimid);
//LIAPI static BlockSource* getBlockSource(Actor* actor); LIAPI static BlockSource* getBlockSource(Actor* actor);
//LIAPI static BlockPalette* getBlockPalette(); //LIAPI static BlockPalette* getBlockPalette();
//LIAPI static Dimension* getDimension(class AutomaticID<class Dimension, int> a0); //LIAPI static Dimension* getDimension(class AutomaticID<class Dimension, int> a0);
LIAPI static Actor* getDamageSourceEntity(ActorDamageSource* ads); LIAPI static Actor* getDamageSourceEntity(ActorDamageSource* ads);

View File

@ -49,6 +49,17 @@ public:
LIAPI std::vector<Tag*>::const_iterator begin() const; LIAPI std::vector<Tag*>::const_iterator begin() const;
LIAPI std::vector<Tag*>::const_iterator end() const; LIAPI std::vector<Tag*>::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 #undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_LISTTAG #ifndef DISABLE_CONSTRUCTOR_PREVENTION_LISTTAG
public: public:

View File

@ -12,6 +12,16 @@
class MinecraftEventing { class MinecraftEventing {
#define AFTER_EXTRA #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 #undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_MINECRAFTEVENTING #ifndef DISABLE_CONSTRUCTOR_PREVENTION_MINECRAFTEVENTING

View File

@ -4,13 +4,51 @@
#include "../Global.h" #include "../Global.h"
#define BEFORE_EXTRA #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 #undef BEFORE_EXTRA
class Packet { class Packet {
#define AFTER_EXTRA #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<char>(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 #undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_PACKET #ifndef DISABLE_CONSTRUCTOR_PREVENTION_PACKET
public: public:

View File

@ -34,7 +34,7 @@ public:
LIAPI std::string getName(); LIAPI std::string getName();
LIAPI std::string getRealName(); LIAPI std::string getRealName();
LIAPI std::string getUuid(); LIAPI std::string getUuid();
LIAPI std::string getXuid(); LIAPI std::string getXuid()const;
LIAPI unsigned char getClientSubId(); LIAPI unsigned char getClientSubId();
LIAPI string getDeviceTypeName(); LIAPI string getDeviceTypeName();
LIAPI int getAvgPing(); LIAPI int getAvgPing();
@ -43,7 +43,7 @@ public:
LIAPI string getLanguageCode(); LIAPI string getLanguageCode();
LIAPI string getServerAddress(); LIAPI string getServerAddress();
LIAPI NetworkIdentifier* getNetworkIdentifier(); LIAPI NetworkIdentifier* getNetworkIdentifier();
LIAPI Certificate* getCertificate(); LIAPI Certificate* getCertificate()const;
LIAPI std::pair<BlockPos, int> getRespawnPosition(); LIAPI std::pair<BlockPos, int> getRespawnPosition();
LIAPI float getAvgPacketLoss(); LIAPI float getAvgPacketLoss();
LIAPI float getLastPacketLoss(); LIAPI float getLastPacketLoss();

View File

@ -5,12 +5,56 @@
#include "Packet.hpp" #include "Packet.hpp"
#define BEFORE_EXTRA #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 #undef BEFORE_EXTRA
class PlayerActionPacket : public Packet { class PlayerActionPacket : public Packet {
#define AFTER_EXTRA #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 #undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_PLAYERACTIONPACKET #ifndef DISABLE_CONSTRUCTOR_PREVENTION_PLAYERACTIONPACKET

View File

@ -0,0 +1,58 @@
#pragma once
#include "../Global.h"
#include <MC/Tag.hpp>
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<bool, 12> mExpandInList;
bool mExpandCompound = true;
std::array<ValueFormat, 12> 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 <typename T>
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 <typename type>
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 <Tag::Type type>
LIAPI bool setValueColor(mce::Color const& color);
template <Tag::Type type>
LIAPI bool setValueFormat(std::string const& prefix, std::string const& suffix);
template <Tag::Type type>
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);
};

View File

@ -13,7 +13,6 @@ class ReadOnlyBinaryStream {
// Add Member There // Add Member There
public: public:
size_t readPointer{}; size_t readPointer{};
bool unk;
std::string ownBuf, *pBuf; std::string ownBuf, *pBuf;
public: public:

View File

@ -11,6 +11,16 @@
class ShortTag : public Tag { class ShortTag : public Tag {
#define AFTER_EXTRA #define AFTER_EXTRA
// Add Member There
short val;
public:
LIAPI short& value();
LIAPI ShortTag& operator=(short val);
LIAPI static std::unique_ptr<ShortTag> create(short val = 0);
LIAPI bool set(short val);
LIAPI short get();
LIAPI operator short() const;
#undef AFTER_EXTRA #undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_SHORTTAG #ifndef DISABLE_CONSTRUCTOR_PREVENTION_SHORTTAG

View File

@ -10,7 +10,61 @@
namespace Social { namespace Social {
#define AFTER_EXTRA #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 #undef AFTER_EXTRA
MCAPI extern class Social::GameConnectionInfo const INVALID_CONNECTION; MCAPI extern class Social::GameConnectionInfo const INVALID_CONNECTION;

View File

@ -4,12 +4,28 @@
#include "../Global.h" #include "../Global.h"
#define BEFORE_EXTRA #define BEFORE_EXTRA
// Include Headers or Declare Types Here
#include <memory>
#undef BEFORE_EXTRA #undef BEFORE_EXTRA
struct TagMemoryChunk { struct TagMemoryChunk {
#define AFTER_EXTRA #define AFTER_EXTRA
// Add Member There
public:
size_t capacity = 0;
size_t size = 0;
std::unique_ptr<char[]> 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 #undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_TAGMEMORYCHUNK #ifndef DISABLE_CONSTRUCTOR_PREVENTION_TAGMEMORYCHUNK

View File

@ -11,7 +11,8 @@
class TransferPacket : public Packet { class TransferPacket : public Packet {
#define AFTER_EXTRA #define AFTER_EXTRA
// Add Member There
char filler[40];
#undef AFTER_EXTRA #undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_TRANSFERPACKET #ifndef DISABLE_CONSTRUCTOR_PREVENTION_TRANSFERPACKET
public: public:

View File

@ -10,6 +10,9 @@
namespace persona { namespace persona {
#define AFTER_EXTRA #define AFTER_EXTRA
// Add Member There
enum AnimatedTextureType;
enum PieceType;
#undef AFTER_EXTRA #undef AFTER_EXTRA
MCAPI extern std::string const ANIMATED_128X128_NAME; MCAPI extern std::string const ANIMATED_128X128_NAME;

View File

@ -909,7 +909,7 @@ TClasslessInstanceHook(__int64, "?onEvent@VanillaServerGameplayEventListener@@UE
TInstanceHook(bool, "?stopOpen@ChestBlockActor@@UEAAXAEAVPlayer@@@Z", TInstanceHook(bool, "?stopOpen@ChestBlockActor@@UEAAXAEAVPlayer@@@Z",
ChestBlockActor, Player* pl) { ChestBlockActor, Player* pl) {
IF_LISTENED(PlayerCloseContainerEvent) { 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(); BlockPos bp = ba->getPosition();
PlayerCloseContainerEvent ev{}; PlayerCloseContainerEvent ev{};
@ -990,31 +990,31 @@ TInstanceHook(void, "?setSprinting@Mob@@UEAAX_N@Z",
#include <MC/PlayerInventory.hpp> #include <MC/PlayerInventory.hpp>
#include <MC/SimpleContainer.hpp> #include <MC/SimpleContainer.hpp>
/////////////////// PlayerSetArmor /////////////////// /////////////////// PlayerSetArmor ///////////////////
TInstanceHook(void, "?setArmor@Player@@UEAAXW4ArmorSlot@@AEBVItemStack@@@Z", // TInstanceHook(void, "?setArmor@Player@@UEAAXW4ArmorSlot@@AEBVItemStack@@@Z",
Player, unsigned slot, ItemStack* it) { // Player, unsigned slot, ItemStack* it) {
original(this, slot, it); // original(this, slot, it);
IF_LISTENED(PlayerSetArmorEvent) { // IF_LISTENED(PlayerSetArmorEvent) {
if (this->isPlayer()) { // if (this->isPlayer()) {
PlayerSetArmorEvent ev{}; // PlayerSetArmorEvent ev{};
ev.mPlayer = this; // ev.mPlayer = this;
ev.mSlot = slot; // ev.mSlot = slot;
ev.mArmorItem = it; // ev.mArmorItem = it;
if (!ev.call()) { // if (!ev.call()) {
auto& uid = getUniqueID(); // auto& uid = getUniqueID();
auto& plinv = getSupplies(); // auto& plinv = getSupplies();
plinv.add(*it, 1); // plinv.add(*it, 1);
getArmorContainer().setItem(slot, ItemStack::EMPTY_ITEM); // getArmorContainer().setItem(slot, ItemStack::EMPTY_ITEM);
Schedule::delay([uid] { // Schedule::delay([uid] {
auto sp = Global<Level>->getPlayer(uid); // auto sp = Global<Level>->getPlayer(uid);
if (sp) // if (sp)
sp->refreshInventory(); // sp->refreshInventory();
}, // },
1); // 1);
} // }
} // }
} // }
IF_LISTENED_END(PlayerSetArmorEvent) // IF_LISTENED_END(PlayerSetArmorEvent)
} // }
/////////////////// PlayerUseRespawnAnchor /////////////////// /////////////////// PlayerUseRespawnAnchor ///////////////////
TInstanceHook(bool, "?trySetSpawn@RespawnAnchorBlock@@CA_NAEAVPlayer@@AEBVBlockPos@@AEAVBlockSource@@AEAVLevel@@@Z", TInstanceHook(bool, "?trySetSpawn@RespawnAnchorBlock@@CA_NAEAVPlayer@@AEBVBlockPos@@AEAVBlockSource@@AEAVLevel@@@Z",
@ -1043,64 +1043,64 @@ TInstanceHook(bool, "?canOpenContainerScreen@Player@@UEAA_NXZ", Player) {
} }
/////////////////// PlayerCmdEvent & ConsoleCmd /////////////////// /////////////////// PlayerCmdEvent & ConsoleCmd ///////////////////
TClasslessInstanceHook(MCRESULT*, "?executeCommand@MinecraftCommands@@QEBA?AUMCRESULT@@V?$shared_ptr@VCommandContext@@@std@@_N@Z", // TClasslessInstanceHook(MCRESULT*, "?executeCommand@MinecraftCommands@@QEBA?AUMCRESULT@@V?$shared_ptr@VCommandContext@@@std@@_N@Z",
MCRESULT* rtn, std::shared_ptr<CommandContext> context, bool print) { // MCRESULT* rtn, std::shared_ptr<CommandContext> context, bool print) {
Player* sp; // Player* sp;
string cmd; // string cmd;
try { // try {
sp = context->getOrigin().getPlayer(); // sp = context->getOrigin().getPlayer();
cmd = context->getCmd(); // cmd = context->getCmd();
if (!cmd.empty() && cmd.at(0) == '/') { // if (!cmd.empty() && cmd.at(0) == '/') {
cmd = cmd.substr(1, cmd.size() - 1); // cmd = cmd.substr(1, cmd.size() - 1);
} // }
if (!Util::isValidUTF8(cmd)) { // if (!Util::isValidUTF8(cmd)) {
logger.error("Detected invalid utf-8 character, command will not be executed"); // logger.error("Detected invalid utf-8 character, command will not be executed");
return rtn; // return rtn;
} // }
} catch (...) { // } catch (...) {
return rtn; // return rtn;
} // }
if (LL::isDebugMode() && LL::globalConfig.tickThreadId != std::this_thread::get_id()) { // 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); // logger.warn("The thread executing the command \"{}\" is not the \"MC_SERVER\" thread", cmd);
} // }
if (sp) { // if (sp) {
// PlayerCmd // // PlayerCmd
IF_LISTENED(PlayerCmdEvent) { // IF_LISTENED(PlayerCmdEvent) {
PlayerCmdEvent ev{}; // PlayerCmdEvent ev{};
ev.mCommand = cmd; // ev.mCommand = cmd;
ev.mPlayer = sp; // ev.mPlayer = sp;
ev.mResult = rtn; // ev.mResult = rtn;
if (!ev.call()) // if (!ev.call())
return rtn; // return rtn;
if (ev.mCommand.empty() || ev.mCommand.at(0) != '/') // if (ev.mCommand.empty() || ev.mCommand.at(0) != '/')
context->getCmd() = "/" + ev.mCommand; // context->getCmd() = "/" + ev.mCommand;
else // else
context->getCmd() = ev.mCommand; // context->getCmd() = ev.mCommand;
} // }
IF_LISTENED_END(PlayerCmdEvent) // IF_LISTENED_END(PlayerCmdEvent)
} else { // } else {
// ConsoleCmd // // ConsoleCmd
IF_LISTENED(ConsoleCmdEvent) { // IF_LISTENED(ConsoleCmdEvent) {
ConsoleCmdEvent ev{}; // ConsoleCmdEvent ev{};
ev.mCommand = cmd; // ev.mCommand = cmd;
if (!ev.call()) // if (!ev.call())
return rtn; // return rtn;
if (ev.mCommand.empty() || ev.mCommand.at(0) != '/') // if (ev.mCommand.empty() || ev.mCommand.at(0) != '/')
context->getCmd() = "/" + ev.mCommand; // context->getCmd() = "/" + ev.mCommand;
else // else
context->getCmd() = ev.mCommand; // context->getCmd() = ev.mCommand;
} // }
IF_LISTENED_END(ConsoleCmdEvent) // IF_LISTENED_END(ConsoleCmdEvent)
} // }
return original(this, rtn, context, print); // return original(this, rtn, context, print);
} // }
/////////////////// PlayerExperienceAddEvent /////////////////// /////////////////// PlayerExperienceAddEvent ///////////////////
TInstanceHook(void, "?addExperience@Player@@UEAAXH@Z", Player, int exp) { TInstanceHook(void, "?addExperience@Player@@UEAAXH@Z", Player, int exp) {
@ -1132,25 +1132,25 @@ TInstanceHook(void, "?handle@ItemUseOnActorInventoryTransaction@@UEBA?AW4Invento
} }
/////////////////// CmdBlockExecute /////////////////// /////////////////// CmdBlockExecute ///////////////////
TInstanceHook(bool, "?_performCommand@BaseCommandBlock@@AEAA_NAEAVBlockSource@@AEBVCommandOrigin@@AEA_N@Z", // TInstanceHook(bool, "?_performCommand@BaseCommandBlock@@AEAA_NAEAVBlockSource@@AEBVCommandOrigin@@AEA_N@Z",
BaseCommandBlock, BlockSource* a2, CommandOrigin* a3, bool* a4) { // BaseCommandBlock, BlockSource* a2, CommandOrigin* a3, bool* a4) {
IF_LISTENED(CmdBlockExecuteEvent) { // IF_LISTENED(CmdBlockExecuteEvent) {
CmdBlockExecuteEvent ev{}; // CmdBlockExecuteEvent ev{};
ev.mCommand = this->getCommand(); // ev.mCommand = this->getCommand();
if ((OriginType)a3->getOriginType() == OriginType::MinecartBlock) { // if ((OriginType)a3->getOriginType() == OriginType::MinecartBlock) {
ev.mIsMinecart = true; // ev.mIsMinecart = true;
ev.mMinecart = a3->getEntity(); // ev.mMinecart = a3->getEntity();
} else { // } else {
ev.mIsMinecart = false; // ev.mIsMinecart = false;
ev.mBlockInstance = Level::getBlockInstance(a3->getBlockPosition(), a2); // ev.mBlockInstance = Level::getBlockInstance(a3->getBlockPosition(), a2);
} // }
if (!ev.call()) // if (!ev.call())
return false; // return false;
} // }
IF_LISTENED_END(CmdBlockExecuteEvent) // IF_LISTENED_END(CmdBlockExecuteEvent)
return original(this, a2, a3, a4); // return original(this, a2, a3, a4);
} // }
/////////////////// BlockInteracted /////////////////// /////////////////// BlockInteracted ///////////////////
TClasslessInstanceHook(unsigned short, TClasslessInstanceHook(unsigned short,
@ -1227,30 +1227,30 @@ TClasslessInstanceHook(bool, "?mayPlace@FireBlock@@UEBA_NAEAVBlockSource@@AEBVBl
/////////////////// ContainerChange /////////////////// /////////////////// ContainerChange ///////////////////
#include <MC/LevelContainerModel.hpp> // #include <MC/LevelContainerModel.hpp>
TInstanceHook(void, "?_onItemChanged@LevelContainerModel@@MEAAXHAEBVItemStack@@0@Z", // TInstanceHook(void, "?_onItemChanged@LevelContainerModel@@MEAAXHAEBVItemStack@@0@Z",
LevelContainerModel, int slotNumber, ItemStack* oldItem, ItemStack* newItem) { // LevelContainerModel, int slotNumber, ItemStack* oldItem, ItemStack* newItem) {
IF_LISTENED(ContainerChangeEvent) { // IF_LISTENED(ContainerChangeEvent) {
Player* pl = (Player*)dAccess<Actor*>(this, 208); // IDA LevelContainerModel::LevelContainerModel // Player* pl = (Player*)dAccess<Actor*>(this, 208); // IDA LevelContainerModel::LevelContainerModel
if (pl->hasOpenContainer()) { // if (pl->hasOpenContainer()) {
BlockPos* bp = (BlockPos*)((char*)this + 216); // BlockPos* bp = (BlockPos*)((char*)this + 216);
ContainerChangeEvent ev{}; // ContainerChangeEvent ev{};
ev.mBlockInstance = Level::getBlockInstance(bp, pl->getDimensionId()); // ev.mBlockInstance = Level::getBlockInstance(bp, pl->getDimensionId());
ev.mContainer = ev.mBlockInstance.getContainer(); // ev.mContainer = ev.mBlockInstance.getContainer();
ev.mPlayer = pl; // ev.mPlayer = pl;
ev.mSlot = slotNumber + this->_getContainerOffset(); // ev.mSlot = slotNumber + this->_getContainerOffset();
ev.mPreviousItemStack = oldItem; // ev.mPreviousItemStack = oldItem;
ev.mNewItemStack = newItem; // ev.mNewItemStack = newItem;
ev.mActor = this->getEntity(); // ev.mActor = this->getEntity();
ev.call(); // ev.call();
} // }
} // }
IF_LISTENED_END(ContainerChangeEvent) // IF_LISTENED_END(ContainerChangeEvent)
return original(this, slotNumber, oldItem, newItem); // return original(this, slotNumber, oldItem, newItem);
} // }
/////////////////// ProjectileHitBlock /////////////////// /////////////////// ProjectileHitBlock ///////////////////
@ -1273,7 +1273,7 @@ TInstanceHook(void, "?onProjectileHit@Block@@QEBAXAEAVBlockSource@@AEBVBlockPos@
/////////////////// RedStoneUpdate /////////////////// /////////////////// RedStoneUpdate ///////////////////
// 绾㈢煶绮? // 红石<EFBFBD>?
TClasslessInstanceHook(void, "?onRedstoneUpdate@RedStoneWireBlock@@UEBAXAEAVBlockSource@@AEBVBlockPos@@H_N@Z", TClasslessInstanceHook(void, "?onRedstoneUpdate@RedStoneWireBlock@@UEBAXAEAVBlockSource@@AEBVBlockPos@@H_N@Z",
BlockSource* bs, BlockPos* bp, int level, bool isActive) { BlockSource* bs, BlockPos* bp, int level, bool isActive) {
IF_LISTENED(RedStoneUpdateEvent) { IF_LISTENED(RedStoneUpdateEvent) {
@ -1305,7 +1305,7 @@ TClasslessInstanceHook(void, "?onRedstoneUpdate@RedstoneTorchBlock@@UEBAXAEAVBlo
IF_LISTENED_END(RedStoneUpdateEvent) IF_LISTENED_END(RedStoneUpdateEvent)
return original(this, bs, bp, level, isActive); return original(this, bs, bp, level, isActive);
} }
// 绾㈢煶涓<EFBFBD>户鍣? // 红石中继<EFBFBD>?
TClasslessInstanceHook(void, "?onRedstoneUpdate@DiodeBlock@@UEBAXAEAVBlockSource@@AEBVBlockPos@@H_N@Z", TClasslessInstanceHook(void, "?onRedstoneUpdate@DiodeBlock@@UEBAXAEAVBlockSource@@AEBVBlockPos@@H_N@Z",
BlockSource* bs, BlockPos* bp, int level, bool isActive) { BlockSource* bs, BlockPos* bp, int level, bool isActive) {
IF_LISTENED(RedStoneUpdateEvent) { IF_LISTENED(RedStoneUpdateEvent) {
@ -1321,7 +1321,7 @@ TClasslessInstanceHook(void, "?onRedstoneUpdate@DiodeBlock@@UEBAXAEAVBlockSource
IF_LISTENED_END(RedStoneUpdateEvent) IF_LISTENED_END(RedStoneUpdateEvent)
return original(this, bs, bp, level, isActive); return original(this, bs, bp, level, isActive);
} }
// 绾㈢煶姣旇緝鍣? // 红石比较<EFBFBD>?
TClasslessInstanceHook(void, "?onRedstoneUpdate@ComparatorBlock@@UEBAXAEAVBlockSource@@AEBVBlockPos@@H_N@Z", TClasslessInstanceHook(void, "?onRedstoneUpdate@ComparatorBlock@@UEBAXAEAVBlockSource@@AEBVBlockPos@@H_N@Z",
BlockSource* bs, BlockPos* bp, int level, bool isActive) { BlockSource* bs, BlockPos* bp, int level, bool isActive) {
IF_LISTENED(RedStoneUpdateEvent) { IF_LISTENED(RedStoneUpdateEvent) {
@ -1574,97 +1574,97 @@ TInstanceHook(bool, "?useItemOn@GameMode@@UEAA_NAEAVItemStack@@AEBVBlockPos@@EAE
/////////////////// MobHurt /////////////////// /////////////////// MobHurt ///////////////////
TInstanceHook(bool, "?_hurt@Mob@@MEAA_NAEBVActorDamageSource@@M_N1@Z", // TInstanceHook(bool, "?_hurt@Mob@@MEAA_NAEBVActorDamageSource@@M_N1@Z",
Mob, ActorDamageSource& src, float damage, bool unk1_1, bool unk2_0) { // Mob, ActorDamageSource& src, float damage, bool unk1_1, bool unk2_0) {
IF_LISTENED(MobHurtEvent) { // IF_LISTENED(MobHurtEvent) {
if (this) { // if (this) {
MobHurtEvent ev{}; // MobHurtEvent ev{};
ev.mMob = this; // ev.mMob = this;
ev.mDamageSource = &src; // ev.mDamageSource = &src;
ev.mDamage = damage; // ev.mDamage = damage;
if (!ev.call()) // if (!ev.call())
return false; // return false;
damage = ev.mDamage; // damage = ev.mDamage;
} // }
} // }
IF_LISTENED_END(MobHurtEvent) // IF_LISTENED_END(MobHurtEvent)
return original(this, src, damage, unk1_1, unk2_0); // return original(this, src, damage, unk1_1, unk2_0);
} // }
TInstanceHook(float, "?getDamageAfterResistanceEffect@Mob@@UEBAMAEBVActorDamageSource@@M@Z", Mob, ActorDamageSource* src, float damage) { // TInstanceHook(float, "?getDamageAfterResistanceEffect@Mob@@UEBAMAEBVActorDamageSource@@M@Z", Mob, ActorDamageSource* src, float damage) {
if (src->getCause() == ActorDamageCause::ActorDamageCause_Magic) { // if (src->getCause() == ActorDamageCause::ActorDamageCause_Magic) {
IF_LISTENED(MobHurtEvent) { // IF_LISTENED(MobHurtEvent) {
if (this) { // if (this) {
MobHurtEvent ev{}; // MobHurtEvent ev{};
ev.mMob = this; // ev.mMob = this;
ev.mDamageSource = src; // ev.mDamageSource = src;
ev.mDamage = damage; // ev.mDamage = damage;
if (!ev.call()) // if (!ev.call())
return 0; // return 0;
damage = ev.mDamage; // damage = ev.mDamage;
} // }
} // }
IF_LISTENED_END(MobHurtEvent) // IF_LISTENED_END(MobHurtEvent)
} // }
return original(this, src, damage); // return original(this, src, damage);
} // }
//////////////// PlayerUseItem & PlayerEat //////////////// //////////////// PlayerUseItem & PlayerEat ////////////////
#include <MC/ComponentItem.hpp> // #include <MC/ComponentItem.hpp>
TInstanceHook(bool, "?baseUseItem@GameMode@@QEAA_NAEAVItemStack@@@Z", GameMode, ItemStack& it) { // TInstanceHook(bool, "?baseUseItem@GameMode@@QEAA_NAEAVItemStack@@@Z", GameMode, ItemStack& it) {
auto pl = this->getPlayer(); // auto pl = this->getPlayer();
IF_LISTENED(PlayerUseItemEvent) { // IF_LISTENED(PlayerUseItemEvent) {
PlayerUseItemEvent ev{}; // PlayerUseItemEvent ev{};
ev.mPlayer = pl; // ev.mPlayer = pl;
ev.mItemStack = &it; // ev.mItemStack = &it;
if (!ev.call()) // if (!ev.call())
return false; // return false;
} // }
IF_LISTENED_END(PlayerUseItemEvent) // IF_LISTENED_END(PlayerUseItemEvent)
IF_LISTENED(PlayerEatEvent) { // IF_LISTENED(PlayerEatEvent) {
if (it.getItem()->isFood() && (pl->isHungry() || pl->forceAllowEating())) { // if (it.getItem()->isFood() && (pl->isHungry() || pl->forceAllowEating())) {
PlayerEatEvent ev{}; // PlayerEatEvent ev{};
ev.mPlayer = pl; // ev.mPlayer = pl;
ev.mFoodItem = &it; // ev.mFoodItem = &it;
if (!ev.call()) { // if (!ev.call()) {
pl->refreshAttribute(Player::HUNGER); // pl->refreshAttribute(Player::HUNGER);
return false; // return false;
} // }
} // }
} // }
IF_LISTENED_END(PlayerEatEvent) // IF_LISTENED_END(PlayerEatEvent)
return original(this, it); // return original(this, it);
} // }
THook(ItemStack*, "?use@BucketItem@@UEBAAEAVItemStack@@AEAV2@AEAVPlayer@@@Z", Item* _this, ItemStack* a1, Player* a2) { // THook(ItemStack*, "?use@BucketItem@@UEBAAEAVItemStack@@AEAV2@AEAVPlayer@@@Z", Item* _this, ItemStack* a1, Player* a2) {
if (_this->getFullItemName() == "minecraft:milk_bucket") { // if (_this->getFullItemName() == "minecraft:milk_bucket") {
IF_LISTENED(PlayerEatEvent) { // IF_LISTENED(PlayerEatEvent) {
PlayerEatEvent ev{}; // PlayerEatEvent ev{};
ev.mPlayer = a2; // ev.mPlayer = a2;
ev.mFoodItem = a1; // ev.mFoodItem = a1;
if (!ev.call()) { // if (!ev.call()) {
return a1; // return a1;
} // }
} // }
IF_LISTENED_END(PlayerEatEvent) // IF_LISTENED_END(PlayerEatEvent)
} // }
return original(_this, a1, a2); // return original(_this, a1, a2);
} // }
THook(ItemStack*, "?use@PotionItem@@UEBAAEAVItemStack@@AEAV2@AEAVPlayer@@@Z", void* _this, ItemStack* a1, Player* a2) { // THook(ItemStack*, "?use@PotionItem@@UEBAAEAVItemStack@@AEAV2@AEAVPlayer@@@Z", void* _this, ItemStack* a1, Player* a2) {
IF_LISTENED(PlayerEatEvent) { // IF_LISTENED(PlayerEatEvent) {
PlayerEatEvent ev{}; // PlayerEatEvent ev{};
ev.mPlayer = a2; // ev.mPlayer = a2;
ev.mFoodItem = a1; // ev.mFoodItem = a1;
if (!ev.call()) { // if (!ev.call()) {
return a1; // return a1;
} // }
} // }
IF_LISTENED_END(PlayerEatEvent) // IF_LISTENED_END(PlayerEatEvent)
return original(_this, a1, a2); // return original(_this, a1, a2);
} // }
/////////////////// MobDie /////////////////// /////////////////// MobDie ///////////////////
TInstanceHook(bool, "?die@Mob@@UEAAXAEBVActorDamageSource@@@Z", Mob, ActorDamageSource* ads) { TInstanceHook(bool, "?die@Mob@@UEAAXAEBVActorDamageSource@@@Z", Mob, ActorDamageSource* ads) {
@ -1743,20 +1743,20 @@ TClasslessInstanceHook(void, "?explode@Explosion@@QEAAXXZ") {
////////////// ProjectileHitEntity ////////////// ////////////// ProjectileHitEntity //////////////
TClasslessInstanceHook(void, "?onHit@ProjectileComponent@@QEAAXAEAVActor@@AEBVHitResult@@@Z", // TClasslessInstanceHook(void, "?onHit@ProjectileComponent@@QEAAXAEAVActor@@AEBVHitResult@@@Z",
Actor* item, HitResult* res) { // Actor* item, HitResult* res) {
IF_LISTENED(ProjectileHitEntityEvent) { // IF_LISTENED(ProjectileHitEntityEvent) {
Actor* to = res->getEntity(); // Actor* to = res->getEntity();
if (to) { // if (to) {
ProjectileHitEntityEvent ev{}; // ProjectileHitEntityEvent ev{};
ev.mTarget = to; // ev.mTarget = to;
ev.mSource = item; // ev.mSource = item;
ev.call(); // ev.call();
} // }
} // }
IF_LISTENED_END(ProjectileHitEntityEvent) // IF_LISTENED_END(ProjectileHitEntityEvent)
return original(this, item, res); // return original(this, item, res);
} // }
////////////// WitherBossDestroy ////////////// ////////////// WitherBossDestroy //////////////
@ -1809,97 +1809,97 @@ TClasslessInstanceHook(bool, "?shouldTriggerEntityInside@BasePressurePlateBlock@
} }
////////////// ProjectileSpawn ////////////// ////////////// ProjectileSpawn //////////////
TClasslessInstanceHook(Actor*, // TClasslessInstanceHook(Actor*,
"?spawnProjectile@Spawner@@QEAAPEAVActor@@AEAVBlockSource@@AEBUActorDefinitionIdentifier@@PEAV2@AEBVVec3@@3@Z", // "?spawnProjectile@Spawner@@QEAAPEAVActor@@AEAVBlockSource@@AEBUActorDefinitionIdentifier@@PEAV2@AEBVVec3@@3@Z",
BlockSource* a2, ActorDefinitionIdentifier* a3, Actor* a4, Vec3* a5, Vec3* a6) { // BlockSource* a2, ActorDefinitionIdentifier* a3, Actor* a4, Vec3* a5, Vec3* a6) {
string name = a3->getCanonicalName(); // string name = a3->getCanonicalName();
if (name != "minecraft:thrown_trident") { // if (name != "minecraft:thrown_trident") {
IF_LISTENED(ProjectileSpawnEvent) { // IF_LISTENED(ProjectileSpawnEvent) {
ProjectileSpawnEvent ev{}; // ProjectileSpawnEvent ev{};
ev.mShooter = a4; // ev.mShooter = a4;
ev.mIdentifier = a3; // ev.mIdentifier = a3;
ev.mType = name; // ev.mType = name;
if (!ev.call()) // if (!ev.call())
return nullptr; // return nullptr;
} // }
IF_LISTENED_END(ProjectileSpawnEvent) // IF_LISTENED_END(ProjectileSpawnEvent)
} // }
auto projectile = original(this, a2, a3, a4, a5, a6); // auto projectile = original(this, a2, a3, a4, a5, a6);
IF_LISTENED(ProjectileCreatedEvent) { // IF_LISTENED(ProjectileCreatedEvent) {
ProjectileCreatedEvent ev{}; // ProjectileCreatedEvent ev{};
ev.mShooter = a4; // ev.mShooter = a4;
ev.mProjectile = projectile; // ev.mProjectile = projectile;
ev.call(); // ev.call();
} // }
IF_LISTENED_END(ProjectileCreatedEvent) // IF_LISTENED_END(ProjectileCreatedEvent)
return projectile; // return projectile;
} // }
#include <MC/CrossbowItem.hpp> // #include <MC/CrossbowItem.hpp>
#include <MC/ActorDefinitionIdentifier.hpp> #include <MC/ActorDefinitionIdentifier.hpp>
static_assert(sizeof(ActorDefinitionIdentifier) == 176); // static_assert(sizeof(ActorDefinitionIdentifier) == 176);
TInstanceHook(void, "?_shootFirework@CrossbowItem@@AEBAXAEBVItemInstance@@AEAVPlayer@@@Z", // TInstanceHook(void, "?_shootFirework@CrossbowItem@@AEBAXAEBVItemInstance@@AEAVPlayer@@@Z",
CrossbowItem, void* a1, Player* a2) { // CrossbowItem, void* a1, Player* a2) {
IF_LISTENED(ProjectileSpawnEvent) { // IF_LISTENED(ProjectileSpawnEvent) {
ActorDefinitionIdentifier identifier("minecraft:fireworks_rocket"); // ActorDefinitionIdentifier identifier("minecraft:fireworks_rocket");
ProjectileSpawnEvent ev{}; // ProjectileSpawnEvent ev{};
ev.mShooter = a2; // ev.mShooter = a2;
ev.mIdentifier = &identifier; // ev.mIdentifier = &identifier;
ev.mType = this->getFullItemName(); // ev.mType = this->getFullItemName();
if (!ev.call()) // if (!ev.call())
return; // return;
} // }
IF_LISTENED_END(ProjectileSpawnEvent) // IF_LISTENED_END(ProjectileSpawnEvent)
original(this, a1, a2); // original(this, a1, a2);
} // }
TClasslessInstanceHook(void, "?releaseUsing@TridentItem@@UEBAXAEAVItemStack@@PEAVPlayer@@H@Z", // TClasslessInstanceHook(void, "?releaseUsing@TridentItem@@UEBAXAEAVItemStack@@PEAVPlayer@@H@Z",
ItemStack* a2, Player* a3, int a4) { // ItemStack* a2, Player* a3, int a4) {
IF_LISTENED(ProjectileSpawnEvent) { // IF_LISTENED(ProjectileSpawnEvent) {
ActorDefinitionIdentifier identifier("minecraft:thrown_trident"); // ActorDefinitionIdentifier identifier("minecraft:thrown_trident");
ProjectileSpawnEvent ev{}; // ProjectileSpawnEvent ev{};
ev.mShooter = a3; // ev.mShooter = a3;
ev.mIdentifier = &identifier; // ev.mIdentifier = &identifier;
ev.mType = a2->getTypeName(); // ev.mType = a2->getTypeName();
if (!ev.call()) // if (!ev.call())
return; // return;
} // }
IF_LISTENED_END(ProjectileSpawnEvent) // IF_LISTENED_END(ProjectileSpawnEvent)
return original(this, a2, a3, a4); // return original(this, a2, a3, a4);
} // }
#include <MC/WeakEntityRef.hpp> // #include <MC/WeakEntityRef.hpp>
#include <mc/EntityContext.hpp> // #include <mc/EntityContext.hpp>
////////////// NpcCmd ////////////// ////////////// NpcCmd //////////////
TInstanceHook(void, // TInstanceHook(void,
"?executeCommandAction@NpcComponent@@QEAAXAEAVActor@@AEAVPlayer@@HAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z", // "?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) { // NpcComponent, Actor* ac, Player* pl, int a4, string& a5) {
IF_LISTENED(NpcCmdEvent) { // IF_LISTENED(NpcCmdEvent) {
// IDA NpcComponent::executeCommandAction // // IDA NpcComponent::executeCommandAction
// NpcSceneDialogueData data(*this, *ac, a5); // // NpcSceneDialogueData data(*this, *ac, a5);
auto ec = (EntityContext*)((char*)ac + 8); // auto ec = (EntityContext*)((char*)ac + 8);
NpcSceneDialogueData data(WeakEntityRef(ec->getWeakRef()), a5); // NpcSceneDialogueData data(WeakEntityRef(ec->getWeakRef()), a5);
auto container = data.getActionsContainer(); // auto container = data.getActionsContainer();
auto actionAt = container->getActionAt(a4); // auto actionAt = container->getActionAt(a4);
if (actionAt && dAccess<char>(actionAt, 8) == (char)1) { // if (actionAt && dAccess<char>(actionAt, 8) == (char)1) {
NpcCmdEvent ev{}; // NpcCmdEvent ev{};
ev.mPlayer = pl; // ev.mPlayer = pl;
ev.mNpc = ac; // ev.mNpc = ac;
ev.mCommand = actionAt->getText(); // ev.mCommand = actionAt->getText();
if (!ev.call()) // if (!ev.call())
return; // return;
} // }
} // }
IF_LISTENED_END(NpcCmdEvent) // IF_LISTENED_END(NpcCmdEvent)
return original(this, ac, pl, a4, a5); // return original(this, ac, pl, a4, a5);
} // }
////////////// ArmorStandChange ////////////// ////////////// ArmorStandChange //////////////
TInstanceHook(bool, "?_trySwapItem@ArmorStand@@AEAA_NAEAVPlayer@@W4EquipmentSlot@@@Z", TInstanceHook(bool, "?_trySwapItem@ArmorStand@@AEAA_NAEAVPlayer@@W4EquipmentSlot@@@Z",
@ -2001,19 +2001,19 @@ TClasslessInstanceHook(void, "?execute@StopCommand@@UEBAXAEBVCommandOrigin@@AEAV
////////////// RegCmd ////////////// ////////////// RegCmd //////////////
TInstanceHook(void, "?setup@ChangeSettingCommand@@SAXAEAVCommandRegistry@@@Z", // TInstanceHook(void, "?setup@ChangeSettingCommand@@SAXAEAVCommandRegistry@@@Z",
CommandRegistry, void* a1) { // CommandRegistry, void* a1) {
Global<CommandRegistry> = this; // Global<CommandRegistry> = this;
original(this, a1); // original(this, a1);
IF_LISTENED(RegCmdEvent) { // IF_LISTENED(RegCmdEvent) {
RegCmdEvent ev{}; // RegCmdEvent ev{};
ev.mCommandRegistry = this; // ev.mCommandRegistry = this;
ev.call(); // ev.call();
// setup dynamic command // // setup dynamic command
DynamicCommand::onServerCommandsRegister(*this); // DynamicCommand::onServerCommandsRegister(*this);
} // }
IF_LISTENED_END(RegCmdEvent) // IF_LISTENED_END(RegCmdEvent)
} // }
////////////// ConsoleOutput ////////////// ////////////// ConsoleOutput //////////////
THook(std::ostream&, THook(std::ostream&,
@ -2098,19 +2098,19 @@ TInstanceHook(int, "?startSleepInBed@Player@@UEAA?AW4BedSleepingResult@@AEBVBloc
#include <MC/Spawner.hpp> #include <MC/Spawner.hpp>
////////////// MobSpawn ////////////// ////////////// MobSpawn //////////////
TInstanceHook(Mob*, "?spawnMob@Spawner@@QEAAPEAVMob@@AEAVBlockSource@@AEBUActorDefinitionIdentifier@@PEAVActor@@AEBVVec3@@_N44@Z", // 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) { // Spawner, BlockSource* a2, ActorDefinitionIdentifier* a3, Actor* a4, Vec3& a5, bool a6, bool a7, bool a8) {
IF_LISTENED(MobSpawnEvent) { // IF_LISTENED(MobSpawnEvent) {
MobSpawnEvent ev{}; // MobSpawnEvent ev{};
ev.mTypeName = a3->getCanonicalName(); // ev.mTypeName = a3->getCanonicalName();
ev.mPos = a5; // ev.mPos = a5;
ev.mDimensionId = a2->getDimensionId(); // ev.mDimensionId = a2->getDimensionId();
if (!ev.call()) // if (!ev.call())
return nullptr; // return nullptr;
} // }
IF_LISTENED_END(MobSpawnEvent) // IF_LISTENED_END(MobSpawnEvent)
return original(this, a2, a3, a4, a5, a6, a7, a8); // return original(this, a2, a3, a4, a5, a6, a7, a8);
} // }
#include "Impl/FormPacketHelper.h" #include "Impl/FormPacketHelper.h"
#include <MC/Json.hpp> #include <MC/Json.hpp>

View File

@ -113,7 +113,7 @@ ActorUniqueID Actor::getActorUniqueId() const {
SimpleContainer & Actor::getHandContainer(){ SimpleContainer & Actor::getHandContainer(){
//ScriptHandContainerComponent::hasComponent actor //ScriptHandContainerComponent::hasComponent actor
return dAccess<SimpleContainer&>(this, 176); return dAccess<SimpleContainer>(this, 176);
} }
ItemStack* Actor::getHandSlot() { ItemStack* Actor::getHandSlot() {
@ -124,7 +124,7 @@ ItemStack* Actor::getHandSlot() {
SimpleContainer & Actor::getArmorContainer(){ SimpleContainer & Actor::getArmorContainer(){
// ItemStackNetManagerServer::_handleLegacyTransactionRequest Line46 // ItemStackNetManagerServer::_handleLegacyTransactionRequest Line46
return dAccess<SimpleContainer&>(this, 1400); return dAccess<SimpleContainer>(this, 1400);
} }
bool Actor::rename(const string& name) { bool Actor::rename(const string& name) {

View File

@ -11,10 +11,10 @@
// return block->getBlockEntityType(); // IDA Block::getBlockEntityType // return block->getBlockEntityType(); // IDA Block::getBlockEntityType
// } // }
// bool BlockActor::refreshData() { bool BlockActor::refreshData() {
// setChanged(); setChanged();
// return true; return true;
// } }
// bool BlockActor::refreshData(BlockSource* bs) { // bool BlockActor::refreshData(BlockSource* bs) {
// refreshData(); // refreshData();

View File

@ -2,6 +2,6 @@
#include <MC/BlockInstance.hpp> #include <MC/BlockInstance.hpp>
#include <MC/BlockSource.hpp> #include <MC/BlockSource.hpp>
// BlockInstance BlockSource::getBlockInstance(BlockPos a1) { BlockInstance BlockSource::getBlockInstance(BlockPos a1) {
// return BlockInstance{const_cast<Block*>(&getBlock(a1)), a1, this->getDimensionId()}; return BlockInstance{const_cast<Block*>(&getBlock(a1)), a1, this->getDimensionId()};
// } }

View File

@ -14,7 +14,7 @@
using namespace std; using namespace std;
static_assert(sizeof(ItemStack) == 160); static_assert(sizeof(ItemStack) == 160);
static_assert(sizeof(ItemInstance) == 136); static_assert(sizeof(ItemInstance) == 144);
ItemStack* ItemStack::create() { ItemStack* ItemStack::create() {
try { try {
@ -49,19 +49,24 @@ ItemStack* ItemStack::create(std::string type, int count) {
return create(std::move(nbt)); return create(std::move(nbt));
} }
// ItemStack ItemStack::fromItemInstance(ItemInstance const& ins) { ItemStack ItemStack::fromItemInstance(ItemInstance const& ins) {
// try { try {
// return {ins}; return {ins};
// } catch (...) { } catch (...) {
// return ItemStack::EMPTY_ITEM; return ItemStack::EMPTY_ITEM;
// } }
// } }
// ItemStack* ItemStack::clone_s() const { ItemStack ItemStack::clone() const {
// ItemStack* a = ItemStack::create(); ItemStack a = ItemStack(*this);
// *a = clone(); return a;
// return a; }
// }
ItemStack* ItemStack::clone_s() const {
ItemStack* a = ItemStack::create();
*a = clone();
return a;
}
std::string ItemStack::getTypeName() const { std::string ItemStack::getTypeName() const {
if (isNull()) if (isNull())

View File

@ -42,9 +42,9 @@ BlockSource* Level::getBlockSource(int dimID) {
//return dAccess<BlockSource*>(dim, 96); //return dAccess<BlockSource*>(dim, 96);
} }
//BlockSource* Level::getBlockSource(Actor* ac) { BlockSource* Level::getBlockSource(Actor* ac) {
// return const_cast<BlockSource*>(&ac->getRegionConst()); return const_cast<BlockSource*>(&ac->getRegionConst());
//} }
Block* Level::getBlock(BlockPos* pos, int dimId) { Block* Level::getBlock(BlockPos* pos, int dimId) {
return getBlock(*pos, Level::getBlockSource(dimId)); return getBlock(*pos, Level::getBlockSource(dimId));
@ -86,17 +86,17 @@ BlockInstance Level::getBlockInstance(BlockPos* pos, int dimId) {
return {*pos, dimId}; return {*pos, dimId};
} }
//BlockInstance Level::getBlockInstance(BlockPos* pos, BlockSource* blockSource) { BlockInstance Level::getBlockInstance(BlockPos* pos, BlockSource* blockSource) {
// return {*pos, blockSource->getDimensionId()}; return {*pos, blockSource->getDimensionId()};
//} }
BlockInstance Level::getBlockInstance(const BlockPos& pos, int dim) { BlockInstance Level::getBlockInstance(const BlockPos& pos, int dim) {
return {pos, dim}; return {pos, dim};
} }
//BlockInstance Level::getBlockInstance(const BlockPos& pos, BlockSource* blockSource) { BlockInstance Level::getBlockInstance(const BlockPos& pos, BlockSource* blockSource) {
// return {pos, blockSource->getDimensionId()}; return {pos, blockSource->getDimensionId()};
//} }
BlockActor* Level::getBlockEntity(BlockPos* pos, int dimId) { BlockActor* Level::getBlockEntity(BlockPos* pos, int dimId) {
return getBlockEntity(pos, Level::getBlockSource(dimId)); return getBlockEntity(pos, Level::getBlockSource(dimId));

View File

@ -50,7 +50,7 @@ NetworkIdentifier* Player::getNetworkIdentifier() {
} }
Certificate* Player::getCertificate() { Certificate* Player::getCertificate() const{
//ServerNetworkHandler::_onPlayerLeft Line145 //ServerNetworkHandler::_onPlayerLeft Line145
return dAccess<Certificate*>(this, 342); return dAccess<Certificate*>(this, 342);
} }
@ -103,7 +103,7 @@ int Player::getPlatform(){
Container & Player::getInventory(){ Container & Player::getInventory(){
//InventoryContainerModel::_getContainer 2928 + 176 //InventoryContainerModel::_getContainer 2928 + 176
return dAccess<Container&>(this, 3104); return dAccess<Container>(this, 3104);
} }
enum CommandPermissionLevel Player::getPlayerPermissionLevel(){ enum CommandPermissionLevel Player::getPlayerPermissionLevel(){
@ -299,7 +299,7 @@ string Player::getUuid() {
return result.asString(); return result.asString();
} }
string Player::getXuid() { string Player::getXuid() const{
return ExtendedCertificate::getXuid(*getCertificate()); return ExtendedCertificate::getXuid(*getCertificate());
} }

View File

@ -116,7 +116,7 @@ class CompoundTag const* CompoundTag::getCompoundTag(class gsl::basic_string_spa
}; };
Tag* CompoundTag::operator[](class gsl::basic_string_span<char const, -1> key) { Tag* CompoundTag::operator[](class gsl::basic_string_span<char const, -1> key) {
return get(key); return const_cast<Tag*>(get(key));
} }
#pragma endregion #pragma endregion

View File

@ -4,9 +4,10 @@
#include <MC/IDataOutput.hpp> #include <MC/IDataOutput.hpp>
void BinaryStream::write(const void* origin, size_t num){ void BinaryStream::write(const void* origin, size_t num){
//BinaryStream::writeSignedBigEndianInt //BatchedNetworkPeer::flush Line24
std::string* mBuffer = dAccess<std::string*>(this, 12); // std::string* mBuffer = dAccess<std::string*>(this, 15);
mBuffer->append((const char*)origin,num); // mBuffer->append((const char*)origin,num);
this->pwBuf->append((const char*)origin,num);
} }
void BinaryStream::writeByte(uint8_t origin){ void BinaryStream::writeByte(uint8_t origin){
write(&origin,1ull); write(&origin,1ull);
@ -62,8 +63,9 @@ void BinaryStream::writeVarInt64(__int64 value){
} }
void BinaryStream::reserve(size_t size) { void BinaryStream::reserve(size_t size) {
std::string* mBuffer = dAccess<std::string*>(this, 12); // std::string* mBuffer = dAccess<std::string*>(this, 15);
mBuffer->reserve(size); // mBuffer->reserve(size);
this->pwBuf->reserve(size);
} }
std::string& BinaryStream::getRaw() { std::string& BinaryStream::getRaw() {
return *dAccess<std::string*, 15>(this); // BinaryStream::getAndReleaseData return *dAccess<std::string*, 15>(this); // BinaryStream::getAndReleaseData