mirror of
https://github.com/quizhizhe/LiteLoaderBDS-1.16.40.git
synced 2025-06-03 04:23:39 +00:00
适配部分LLAPI,以上适配未测试
This commit is contained in:
parent
7fbdcc94ef
commit
c498483ec7
@ -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));
|
||||
}
|
||||
|
||||
};
|
@ -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<BlockSource>(this,100);
|
||||
};
|
||||
inline bool isMoving() const{
|
||||
return getStatusFlag(ActorFlags::MOVING);
|
||||
};
|
||||
|
||||
#undef AFTER_EXTRA
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTOR
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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<CompoundTag> 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<bool, 200>(this) = 1;
|
||||
}
|
||||
inline BlockPos const & getPosition() const{
|
||||
//EndGatewayBlockActor::teleportEntity Line114
|
||||
return dAccess<BlockPos>(this,44);
|
||||
};
|
||||
|
||||
#undef AFTER_EXTRA
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_BLOCKACTOR
|
||||
public:
|
||||
|
@ -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};
|
||||
|
@ -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<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;
|
||||
|
@ -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<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
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_BLOCKSOURCE
|
||||
|
@ -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<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
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_BYTEARRAYTAG
|
||||
public:
|
||||
|
@ -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<ByteTag> 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
|
||||
|
@ -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
|
||||
|
@ -91,6 +91,24 @@ public:
|
||||
// Deprecated?
|
||||
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
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_COMPOUNDTAG
|
||||
public:
|
||||
|
@ -4,7 +4,8 @@
|
||||
#include "../Global.h"
|
||||
|
||||
#define BEFORE_EXTRA
|
||||
|
||||
// Add include headers & pre-declares
|
||||
class ItemStack;
|
||||
#undef BEFORE_EXTRA
|
||||
|
||||
class Container {
|
||||
|
@ -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<DoubleTag> 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
|
||||
|
@ -11,6 +11,12 @@
|
||||
class EndTag : public Tag {
|
||||
|
||||
#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
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ENDTAG
|
||||
|
@ -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<FloatTag> 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
|
||||
|
@ -10,7 +10,8 @@
|
||||
class IMinecraftEventing {
|
||||
|
||||
#define AFTER_EXTRA
|
||||
|
||||
public:
|
||||
enum StructureBlockActionType;
|
||||
#undef AFTER_EXTRA
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_IMINECRAFTEVENTING
|
||||
public:
|
||||
|
@ -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<Int64Tag> 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
|
||||
|
@ -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<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
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_INTARRAYTAG
|
||||
|
@ -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<IntTag> create(int val = 0);
|
||||
LIAPI bool set(int val);
|
||||
LIAPI int get();
|
||||
LIAPI operator int() const;
|
||||
|
||||
#undef AFTER_EXTRA
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_INTTAG
|
||||
|
@ -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:
|
||||
|
73
LiteLoader/Header/MC/InventorySource.hpp
Normal file
73
LiteLoader/Header/MC/InventorySource.hpp
Normal 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;
|
||||
|
||||
};
|
@ -10,6 +10,10 @@
|
||||
class InventoryTransaction {
|
||||
|
||||
#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
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_INVENTORYTRANSACTION
|
||||
|
@ -5,7 +5,13 @@
|
||||
#include "Json.hpp"
|
||||
|
||||
#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
|
||||
|
||||
class Item {
|
||||
|
@ -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
|
||||
|
||||
|
@ -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<CompoundTag> 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;
|
||||
|
@ -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_;
|
||||
|
@ -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<class Dimension, int> a0);
|
||||
LIAPI static Actor* getDamageSourceEntity(ActorDamageSource* ads);
|
||||
|
@ -49,6 +49,17 @@ public:
|
||||
LIAPI std::vector<Tag*>::const_iterator begin() 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
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_LISTTAG
|
||||
public:
|
||||
|
@ -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
|
||||
|
@ -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<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
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_PACKET
|
||||
public:
|
||||
|
@ -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<BlockPos, int> getRespawnPosition();
|
||||
LIAPI float getAvgPacketLoss();
|
||||
LIAPI float getLastPacketLoss();
|
||||
|
@ -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
|
||||
|
58
LiteLoader/Header/MC/PrettySnbtFormat.hpp
Normal file
58
LiteLoader/Header/MC/PrettySnbtFormat.hpp
Normal 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);
|
||||
};
|
@ -13,7 +13,6 @@ class ReadOnlyBinaryStream {
|
||||
// Add Member There
|
||||
public:
|
||||
size_t readPointer{};
|
||||
bool unk;
|
||||
std::string ownBuf, *pBuf;
|
||||
|
||||
public:
|
||||
|
@ -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<ShortTag> create(short val = 0);
|
||||
LIAPI bool set(short val);
|
||||
LIAPI short get();
|
||||
LIAPI operator short() const;
|
||||
|
||||
#undef AFTER_EXTRA
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_SHORTTAG
|
||||
|
@ -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;
|
||||
|
||||
|
@ -4,12 +4,28 @@
|
||||
#include "../Global.h"
|
||||
|
||||
#define BEFORE_EXTRA
|
||||
|
||||
// Include Headers or Declare Types Here
|
||||
#include <memory>
|
||||
#undef BEFORE_EXTRA
|
||||
|
||||
struct TagMemoryChunk {
|
||||
|
||||
#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
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_TAGMEMORYCHUNK
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
|
@ -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 <MC/PlayerInventory.hpp>
|
||||
#include <MC/SimpleContainer.hpp>
|
||||
/////////////////// 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<Level>->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<Level>->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<CommandContext> 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<CommandContext> 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 <MC/LevelContainerModel.hpp>
|
||||
// #include <MC/LevelContainerModel.hpp>
|
||||
|
||||
TInstanceHook(void, "?_onItemChanged@LevelContainerModel@@MEAAXHAEBVItemStack@@0@Z",
|
||||
LevelContainerModel, int slotNumber, ItemStack* oldItem, ItemStack* newItem) {
|
||||
IF_LISTENED(ContainerChangeEvent) {
|
||||
Player* pl = (Player*)dAccess<Actor*>(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<Actor*>(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 ///////////////////
|
||||
// 绾㈢煶绮?
|
||||
// 红石<EFBFBD>?
|
||||
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);
|
||||
}
|
||||
// 绾㈢煶涓<EFBFBD>户鍣?
|
||||
// 红石中继<EFBFBD>?
|
||||
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);
|
||||
}
|
||||
// 绾㈢煶姣旇緝鍣?
|
||||
// 红石比较<EFBFBD>?
|
||||
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 <MC/ComponentItem.hpp>
|
||||
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 <MC/ComponentItem.hpp>
|
||||
// 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 <MC/CrossbowItem.hpp>
|
||||
// #include <MC/CrossbowItem.hpp>
|
||||
#include <MC/ActorDefinitionIdentifier.hpp>
|
||||
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 <MC/WeakEntityRef.hpp>
|
||||
#include <mc/EntityContext.hpp>
|
||||
// #include <MC/WeakEntityRef.hpp>
|
||||
// #include <mc/EntityContext.hpp>
|
||||
|
||||
////////////// 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<char>(actionAt, 8) == (char)1) {
|
||||
// auto container = data.getActionsContainer();
|
||||
// auto actionAt = container->getActionAt(a4);
|
||||
// if (actionAt && dAccess<char>(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<CommandRegistry> = 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<CommandRegistry> = 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 <MC/Spawner.hpp>
|
||||
|
||||
////////////// 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 <MC/Json.hpp>
|
||||
|
@ -113,7 +113,7 @@ ActorUniqueID Actor::getActorUniqueId() const {
|
||||
|
||||
SimpleContainer & Actor::getHandContainer(){
|
||||
//ScriptHandContainerComponent::hasComponent actor
|
||||
return dAccess<SimpleContainer&>(this, 176);
|
||||
return dAccess<SimpleContainer>(this, 176);
|
||||
}
|
||||
|
||||
ItemStack* Actor::getHandSlot() {
|
||||
@ -124,7 +124,7 @@ ItemStack* Actor::getHandSlot() {
|
||||
|
||||
SimpleContainer & Actor::getArmorContainer(){
|
||||
// ItemStackNetManagerServer::_handleLegacyTransactionRequest Line46
|
||||
return dAccess<SimpleContainer&>(this, 1400);
|
||||
return dAccess<SimpleContainer>(this, 1400);
|
||||
}
|
||||
|
||||
bool Actor::rename(const string& name) {
|
||||
|
@ -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();
|
||||
|
@ -2,6 +2,6 @@
|
||||
#include <MC/BlockInstance.hpp>
|
||||
#include <MC/BlockSource.hpp>
|
||||
|
||||
// BlockInstance BlockSource::getBlockInstance(BlockPos a1) {
|
||||
// return BlockInstance{const_cast<Block*>(&getBlock(a1)), a1, this->getDimensionId()};
|
||||
// }
|
||||
BlockInstance BlockSource::getBlockInstance(BlockPos a1) {
|
||||
return BlockInstance{const_cast<Block*>(&getBlock(a1)), a1, this->getDimensionId()};
|
||||
}
|
||||
|
@ -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())
|
||||
|
@ -42,9 +42,9 @@ BlockSource* Level::getBlockSource(int dimID) {
|
||||
//return dAccess<BlockSource*>(dim, 96);
|
||||
}
|
||||
|
||||
//BlockSource* Level::getBlockSource(Actor* ac) {
|
||||
// return const_cast<BlockSource*>(&ac->getRegionConst());
|
||||
//}
|
||||
BlockSource* Level::getBlockSource(Actor* ac) {
|
||||
return const_cast<BlockSource*>(&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));
|
||||
|
@ -50,7 +50,7 @@ NetworkIdentifier* Player::getNetworkIdentifier() {
|
||||
}
|
||||
|
||||
|
||||
Certificate* Player::getCertificate() {
|
||||
Certificate* Player::getCertificate() const{
|
||||
//ServerNetworkHandler::_onPlayerLeft Line145
|
||||
return dAccess<Certificate*>(this, 342);
|
||||
}
|
||||
@ -103,7 +103,7 @@ int Player::getPlatform(){
|
||||
|
||||
Container & Player::getInventory(){
|
||||
//InventoryContainerModel::_getContainer 2928 + 176
|
||||
return dAccess<Container&>(this, 3104);
|
||||
return dAccess<Container>(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());
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
return get(key);
|
||||
return const_cast<Tag*>(get(key));
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
@ -4,9 +4,10 @@
|
||||
#include <MC/IDataOutput.hpp>
|
||||
|
||||
void BinaryStream::write(const void* origin, size_t num){
|
||||
//BinaryStream::writeSignedBigEndianInt
|
||||
std::string* mBuffer = dAccess<std::string*>(this, 12);
|
||||
mBuffer->append((const char*)origin,num);
|
||||
//BatchedNetworkPeer::flush Line24
|
||||
// std::string* mBuffer = dAccess<std::string*>(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<std::string*>(this, 12);
|
||||
mBuffer->reserve(size);
|
||||
// std::string* mBuffer = dAccess<std::string*>(this, 15);
|
||||
// mBuffer->reserve(size);
|
||||
this->pwBuf->reserve(size);
|
||||
}
|
||||
std::string& BinaryStream::getRaw() {
|
||||
return *dAccess<std::string*, 15>(this); // BinaryStream::getAndReleaseData
|
||||
|
Loading…
Reference in New Issue
Block a user