mirror of
https://github.com/quizhizhe/LiteLoaderBDS-1.16.40.git
synced 2025-06-03 04:23:39 +00:00
改好了LLSE部分,能过编译,但尝试了行为记录JS,不出意外,是一片红
This commit is contained in:
parent
551594cb3e
commit
9ea23ec487
@ -20,7 +20,100 @@ class ItemStack;
|
||||
class BlockSource;
|
||||
enum class FaceID : char;
|
||||
enum ActorFlags : int{
|
||||
MOVING=0x22
|
||||
Unknown_25 = -1,
|
||||
ONFIRE = 0x0,
|
||||
SNEAKING = 0x1,
|
||||
RIDING = 0x2,
|
||||
SPRINTING = 0x3,
|
||||
USINGITEM = 0x4,
|
||||
INVISIBLE = 0x5,
|
||||
TEMPTED = 0x6,
|
||||
INLOVE = 0x7,
|
||||
SADDLED = 0x8,
|
||||
POWERED = 0x9,
|
||||
IGNITED = 0xA,
|
||||
BABY = 0xB,
|
||||
CONVERTING = 0xC,
|
||||
CRITICAL = 0xD,
|
||||
CAN_SHOW_NAME = 0xE,
|
||||
ALWAYS_SHOW_NAME = 0xF,
|
||||
NOAI = 0x10,
|
||||
SILENT = 0x11,
|
||||
WALLCLIMBING = 0x12,
|
||||
CANCLIMB = 0x13,
|
||||
CANSWIM = 0x14,
|
||||
CANFLY = 0x15,
|
||||
CANWALK = 0x16,
|
||||
RESTING = 0x17,
|
||||
SITTING = 0x18,
|
||||
ANGRY = 0x19,
|
||||
INTERESTED = 0x1A,
|
||||
CHARGED = 0x1B,
|
||||
TAMED = 0x1C,
|
||||
ORPHANED = 0x1D,
|
||||
LEASHED = 0x1E,
|
||||
SHEARED = 0x1F,
|
||||
GLIDING = 0x20,
|
||||
ELDER = 0x21,
|
||||
MOVING = 0x22,
|
||||
BREATHING = 0x23,
|
||||
CHESTED = 0x24,
|
||||
STACKABLE = 0x25,
|
||||
SHOW_BOTTOM = 0x26,
|
||||
STANDING = 0x27,
|
||||
SHAKING = 0x28,
|
||||
IDLING = 0x29,
|
||||
CASTING = 0x2A,
|
||||
CHARGING = 0x2B,
|
||||
WASD_CONTROLLED = 0x2C,
|
||||
CAN_POWER_JUMP = 0x2D,
|
||||
LINGERING = 0x2E,
|
||||
HAS_COLLISION = 0x2F,
|
||||
HAS_GRAVITY = 0x30,
|
||||
FIRE_IMMUNE = 0x31,
|
||||
DANCING = 0x32,
|
||||
ENCHANTED = 0x33,
|
||||
RETURNTRIDENT = 0x34,
|
||||
CONTAINER_IS_PRIVATE = 0x35,
|
||||
IS_TRANSFORMING = 0x36,
|
||||
DAMAGENEARBYMOBS = 0x37,
|
||||
SWIMMING = 0x38,
|
||||
BRIBED = 0x39,
|
||||
IS_PREGNANT = 0x3A,
|
||||
LAYING_EGG = 0x3B,
|
||||
RIDER_CAN_PICK = 0x3C,
|
||||
TRANSITION_SITTING = 0x3D,
|
||||
EATING = 0x3E,
|
||||
LAYING_DOWN = 0x3F,
|
||||
SNEEZING = 0x40,
|
||||
TRUSTING = 0x41,
|
||||
ROLLING = 0x42,
|
||||
SCARED = 0x43,
|
||||
IN_SCAFFOLDING = 0x44,
|
||||
OVER_SCAFFOLDING = 0x45,
|
||||
FALL_THROUGH_SCAFFOLDING = 0x46,
|
||||
BLOCKING = 0x47,
|
||||
TRANSITION_BLOCKING = 0x48,
|
||||
BLOCKED_USING_SHIELD = 0x49,
|
||||
BLOCKED_USING_DAMAGED_SHIELD = 0x4A,
|
||||
SLEEPING = 0x4B,
|
||||
WANTS_TO_WAKE = 0x4C,
|
||||
TRADE_INTEREST = 0x4D,
|
||||
DOOR_BREAKER = 0x4E,
|
||||
BREAKING_OBSTRUCTION = 0x4F,
|
||||
DOOR_OPENER = 0x50,
|
||||
IS_ILLAGER_CAPTAIN = 0x51,
|
||||
STUNNED = 0x52,
|
||||
ROARING = 0x53,
|
||||
DELAYED_ATTACK = 0x54,
|
||||
IS_AVOIDING_MOBS = 0x55,
|
||||
FACING_TARGET_TO_RANGE_ATTACK = 0x56,
|
||||
HIDDEN_WHEN_INVISIBLE = 0x57,
|
||||
IS_IN_UI = 0x58,
|
||||
STALKING = 0x59,
|
||||
EMOTING = 0x5A,
|
||||
CELEBRATING = 0x5B,
|
||||
Count_7 = 0x5C,
|
||||
};
|
||||
|
||||
#undef BEFORE_EXTRA
|
||||
@ -42,7 +135,7 @@ public:
|
||||
//LIAPI BlockInstance getBlockFromViewVector(bool includeLiquid = false, bool solidOnly = false, float maxDistance = 5.25f, bool ignoreBorderBlocks = true, bool fullOnly = false) const;
|
||||
//LIAPI BlockInstance getBlockFromViewVector(FaceID& face, bool includeLiquid = false, bool solidOnly = false, float maxDistance = 5.25f, bool ignoreBorderBlocks = true, bool fullOnly = false) const;
|
||||
//LIAPI UserEntityIdentifierComponent* getUserEntityIdentifierComponent() const;
|
||||
//LIAPI Actor* getActorFromViewVector(float maxDistance);
|
||||
LIAPI Actor* getActorFromViewVector(float maxDistance);
|
||||
LIAPI BlockPos getBlockPos();
|
||||
LIAPI BlockInstance getBlockStandingOn() const;
|
||||
|
||||
@ -52,7 +145,7 @@ public:
|
||||
//LIAPI bool setOnFire(int time, bool isEffect);
|
||||
//LIAPI bool stopFire();
|
||||
LIAPI bool hasTag(const string& tag);
|
||||
//LIAPI bool hurtEntity(float damage, ActorDamageCause damageCause = ActorDamageCause::ActorDamageCause_Override);
|
||||
LIAPI bool hurtEntity(float damage, ActorDamageCause damageCause = ActorDamageCause::ActorDamageCause_Override);
|
||||
LIAPI bool teleport(Vec3 to, int dimID, float x, float y);
|
||||
LIAPI bool teleport(Vec3 pos,int dimid);
|
||||
LIAPI ItemStack* getHandSlot();
|
||||
@ -61,7 +154,7 @@ public:
|
||||
LIAPI bool setNbt(CompoundTag* nbt);
|
||||
LIAPI bool refreshActorData();
|
||||
LIAPI bool addEffect(MobEffect::EffectType type, int tick, int level, bool ambient = false, bool showParticles = true, bool showAnimation = false);
|
||||
LIAPI float quickEvalMolangScript(const string& expression);
|
||||
// LIAPI float quickEvalMolangScript(const string& expression);
|
||||
//LIAPI Json::Value quickEvalMolangScriptAsJson(const string& expression);
|
||||
LIAPI SimpleContainer & getHandContainer();
|
||||
LIAPI SimpleContainer & getArmorContainer();
|
||||
@ -84,6 +177,20 @@ public:
|
||||
// IDA Player::take Line123
|
||||
return (dAccess<ActorCategory>(this, 79) & actorCategory) !=0;
|
||||
};
|
||||
inline BlockSource & getRegion() {
|
||||
//VanillaServerGameplayEventListener::onBlockPlacedByPlayer Line35
|
||||
return dAccess<BlockSource>(this,100);
|
||||
};
|
||||
inline AABB const & getAABB() const{
|
||||
//FollowMobGoal::_setWantedMob Line52
|
||||
return dAccess<AABB>(this,1112);
|
||||
};
|
||||
inline bool isDancing(){
|
||||
return getStatusFlag(ActorFlags::DANCING);
|
||||
};
|
||||
inline bool isTrading(){
|
||||
return getTradingPlayer() != nullptr;
|
||||
};
|
||||
|
||||
Vec2 getRotation() const{
|
||||
// Actor::getMapDecorationRotation
|
||||
|
@ -52,6 +52,9 @@ class ActorDamageSource {
|
||||
char filler[4];
|
||||
|
||||
public:
|
||||
ActorDamageSource(ActorDamageCause cause){
|
||||
this->mCause = cause;
|
||||
};
|
||||
LIAPI Actor* getEntity();
|
||||
|
||||
#undef AFTER_EXTRA
|
||||
|
@ -6,7 +6,7 @@
|
||||
#define BEFORE_EXTRA
|
||||
// Add include headers & pre-declares
|
||||
#include "CompoundTag.hpp"
|
||||
|
||||
#include "BlockLegacy.hpp"
|
||||
#undef BEFORE_EXTRA
|
||||
|
||||
class Block {
|
||||
@ -18,12 +18,19 @@ public:
|
||||
LIAPI static Block* create(CompoundTag* nbt);
|
||||
|
||||
LIAPI string getTypeName() const;
|
||||
//LIAPI int getId() const;
|
||||
LIAPI int getId() const;
|
||||
LIAPI unsigned short getTileData();
|
||||
LIAPI std::unique_ptr<CompoundTag> getNbt();
|
||||
LIAPI bool setNbt(CompoundTag* nbt);
|
||||
LIAPI unsigned int const & getRuntimeId() const;
|
||||
|
||||
inline bool hasBlockEntity(){
|
||||
return getLegacyBlock().hasBlockEntity();
|
||||
}
|
||||
inline enum BlockActorType getBlockEntityType() const{
|
||||
return getLegacyBlock().getBlockEntityType();
|
||||
};
|
||||
|
||||
inline bool operator==(class Block const& a2) const {
|
||||
__int64 v2; // r8
|
||||
__int64 v3; // rax
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
#define BEFORE_EXTRA
|
||||
// Add include headers & pre-declares
|
||||
#include "BlockActorDataPacket.hpp"
|
||||
|
||||
class Block;
|
||||
class Container;
|
||||
class CompoundTag;
|
||||
@ -18,11 +20,11 @@ class BlockActor {
|
||||
// Add new members to class
|
||||
public:
|
||||
LIAPI bool refreshData();
|
||||
// LIAPI bool refreshData(BlockSource* bs);
|
||||
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);
|
||||
static unsigned int getBlockEntityType(Block* block);
|
||||
|
||||
inline void setChanged(){
|
||||
//EndGatewayBlockActor::teleportEntity Line115
|
||||
@ -33,6 +35,14 @@ public:
|
||||
return dAccess<BlockPos>(this,44);
|
||||
};
|
||||
|
||||
inline enum BlockActorType getType(){
|
||||
//FlowerPotBlock::playerWillDestroy Line16
|
||||
return dAccess<BlockActorType>(this,21);
|
||||
}
|
||||
|
||||
inline std::unique_ptr<BlockActorDataPacket> getServerUpdatePacket(BlockSource &bs){
|
||||
return _getUpdatePacket(bs);
|
||||
};
|
||||
#undef AFTER_EXTRA
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_BLOCKACTOR
|
||||
public:
|
||||
|
@ -23,6 +23,23 @@ public:
|
||||
LIAPI bool applyBoneMeal(BlockSource*, BlockPos*);
|
||||
LIAPI ItemStack* getBlockDrops();
|
||||
|
||||
inline int getBlockItemId() const{
|
||||
//ItemStackBase::init(ItemStackBase *this, const struct BlockLegacy *a2, int a3) Line14
|
||||
int id = dAccess<int>(this,134);
|
||||
if(id < 0x100u)
|
||||
return id;
|
||||
else
|
||||
return 255-id;
|
||||
};
|
||||
inline bool hasBlockEntity() const{
|
||||
// LevelChunk::_removeCallbacks Line28
|
||||
return getBlockEntityType();
|
||||
}
|
||||
inline enum BlockActorType getBlockEntityType() const{
|
||||
// LevelChunk::_removeCallbacks Line28
|
||||
return dAccess<BlockActorType>(this,168);;
|
||||
};
|
||||
|
||||
#undef AFTER_EXTRA
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_BLOCKLEGACY
|
||||
public:
|
||||
|
@ -21,15 +21,41 @@ public:
|
||||
// MCAPI static const std::function<bool(class Block const&)> CHECK_ALL_BLOCKS;
|
||||
// };
|
||||
LIAPI BlockInstance getBlockInstance(BlockPos);
|
||||
AutomaticID<class Dimension, int> getDimensionId(){
|
||||
inline Dimension* getDimension() const{
|
||||
return dAccess< Dimension*>(this, 4);
|
||||
}
|
||||
inline AutomaticID<class Dimension, int> getDimensionId() const{
|
||||
//Dimension::onBlockEvent Line24
|
||||
Dimension* mDimension = dAccess< Dimension*>(this, 4);
|
||||
return dAccess<AutomaticID<class Dimension, int>>(mDimension, 192);
|
||||
};
|
||||
LevelChunk * getChunkAt(const BlockPos& pos) const{
|
||||
inline LevelChunk * getChunkAt(const BlockPos& pos) const{
|
||||
ChunkPos chunkPos = ChunkPos(pos.x>>4, pos.z>>4);
|
||||
return getChunk(chunkPos);
|
||||
}
|
||||
inline std::shared_ptr<class BlockActor> removeBlockEntity(class BlockPos const &bp){
|
||||
auto levelChunk = getChunkAt(bp);
|
||||
if(levelChunk)
|
||||
return levelChunk->removeBlockEntity(bp);
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
inline Dimension const & getDimensionConst() const{
|
||||
//BegGoal::canUse Line6
|
||||
return dAccess<Dimension>(this,808);
|
||||
};
|
||||
// inline short getHeightmap(class BlockPos const &bs) const{
|
||||
// auto levelchunk = getChunkAt(bs);
|
||||
// if(!levelchunk)
|
||||
// return 0;
|
||||
// ChunkBlockPos cpos = ChunkBlockPos(bs);
|
||||
// return levelchunk->getHeightmap(&cpos);
|
||||
// };
|
||||
inline BlockPos getHeightmapPos(class BlockPos const &a1) const{
|
||||
int heightmap = this->getHeightmap(a1);
|
||||
BlockPos result = BlockPos(a1.x,heightmap,a1.z);
|
||||
return result;
|
||||
};
|
||||
|
||||
#undef AFTER_EXTRA
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_BLOCKSOURCE
|
||||
|
@ -46,6 +46,9 @@ ChunkBlockPos(char x, short y, char z)
|
||||
ChunkBlockPos(class BlockPos const & pos, short a2){
|
||||
ChunkBlockPos(pos.x & 16,pos.y - a2,pos.z & 16);
|
||||
};
|
||||
ChunkBlockPos(class BlockPos const & pos){
|
||||
ChunkBlockPos(pos.x & 16,pos.y,pos.z & 16);
|
||||
}
|
||||
ChunkBlockPos(unsigned char x, class ChunkLocalHeight y, unsigned char z){
|
||||
ChunkBlockPos(x, y, z);
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ class CommandOrigin {
|
||||
mce::UUID mUUID;
|
||||
public:
|
||||
LIAPI ServerPlayer* getPlayer() const;
|
||||
// LIAPI CompoundTag serialize_1() const;
|
||||
|
||||
#undef AFTER_EXTRA
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_COMMANDORIGIN
|
||||
|
@ -21,16 +21,20 @@ class CommandOutput {
|
||||
// Add Member There
|
||||
public:
|
||||
|
||||
int getSuccessCount() const{
|
||||
inline int getSuccessCount() const{
|
||||
//DayLockCommand::execute Line91
|
||||
return dAccess<int>(this,0x28);
|
||||
};
|
||||
|
||||
void success(){
|
||||
inline void success(){
|
||||
int successCount = dAccess<int>(this,0x28);
|
||||
++successCount;
|
||||
dAccess<int>(this,0x28) = successCount;
|
||||
};
|
||||
|
||||
inline bool empty() const{
|
||||
return *(int*)this != 4;
|
||||
};
|
||||
/**
|
||||
* @brief Output a message(without I18nBase).
|
||||
*
|
||||
|
@ -47,14 +47,16 @@ public:
|
||||
// get tag
|
||||
LIAPI class ByteTag const* getByteTag(class gsl::basic_string_span<char const, -1> key) const;
|
||||
//BDS has implemented this interface
|
||||
//LIAPI class ShortTag const* getShortTag(class gsl::basic_string_span<char const, -1> key) const;
|
||||
LIAPI class ShortTag const* getShortTag(class gsl::basic_string_span<char const, -1> key) const;
|
||||
LIAPI class FloatTag const* getFloatTag(class gsl::basic_string_span<char const, -1> key) const;
|
||||
LIAPI class DoubleTag const* getDoubleTag(class gsl::basic_string_span<char const, -1> key) const;
|
||||
LIAPI class ByteArrayTag const* getByteArrayTag(class gsl::basic_string_span<char const, -1> key) const;
|
||||
//LIAPI class StringTag const* getStringTag(class gsl::basic_string_span<char const, -1> key) const;
|
||||
LIAPI class StringTag const* getStringTag(class gsl::basic_string_span<char const, -1> key) const;
|
||||
LIAPI class IntArrayTag const* getIntArrayTag(class gsl::basic_string_span<char const, -1> key) const;
|
||||
LIAPI class ListTag const* getListTag(class gsl::basic_string_span<char const, -1> key) const;
|
||||
LIAPI class CompoundTag const* getCompoundTag(class gsl::basic_string_span<char const, -1> key) const;
|
||||
LIAPI class IntTag const* getIntTag(class gsl::basic_string_span<char const, -1> key) const;
|
||||
LIAPI class Int64Tag const* getInt64Tag(class gsl::basic_string_span<char const, -1> key) const;
|
||||
LIAPI class Tag* operator[](class gsl::basic_string_span<char const, -1> key);
|
||||
|
||||
// IO
|
||||
|
@ -10,7 +10,49 @@
|
||||
class CompoundTagVariant {
|
||||
|
||||
#define AFTER_EXTRA
|
||||
|
||||
public:
|
||||
inline Tag::Type getTagType() {
|
||||
return dAccess<Tag::Type, 40>(this);
|
||||
}
|
||||
inline Tag* asTag() {
|
||||
return (Tag*)this;
|
||||
}
|
||||
inline EndTag* asEndTag() {
|
||||
return (EndTag*)this;
|
||||
}
|
||||
inline ByteTag* asByteTag() {
|
||||
return (ByteTag*)this;
|
||||
}
|
||||
inline ShortTag* asShortTag(){
|
||||
return (ShortTag*)this;
|
||||
}
|
||||
inline IntTag* asIntTag(){
|
||||
return (IntTag*)this;
|
||||
}
|
||||
inline Int64Tag* asInt64Tag(){
|
||||
return (Int64Tag*)this;
|
||||
}
|
||||
inline FloatTag* asFloatTag(){
|
||||
return (FloatTag*)this;
|
||||
}
|
||||
inline DoubleTag* asDoubleTag(){
|
||||
return (DoubleTag*)this;
|
||||
}
|
||||
inline StringTag* asStringTag(){
|
||||
return (StringTag*)this;
|
||||
}
|
||||
inline ListTag* asListTag(){
|
||||
return (ListTag*)this;
|
||||
}
|
||||
inline CompoundTag* asCompoundTag(){
|
||||
return (CompoundTag*)this;
|
||||
}
|
||||
inline ByteArrayTag* asByteArrayTag(){
|
||||
return (ByteArrayTag*)this;
|
||||
}
|
||||
inline IntArrayTag* asIntArrayTag(){
|
||||
return (IntArrayTag*)this;
|
||||
}
|
||||
#undef AFTER_EXTRA
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_COMPOUNDTAGVARIANT
|
||||
public:
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#define BEFORE_EXTRA
|
||||
// Add include headers & pre-declares
|
||||
class ItemStack;
|
||||
#include "ItemStack.hpp"
|
||||
#undef BEFORE_EXTRA
|
||||
|
||||
class Container {
|
||||
@ -13,7 +13,7 @@ class Container {
|
||||
#define AFTER_EXTRA
|
||||
// Add new members to class
|
||||
public:
|
||||
//LIAPI std::string getTypeName();
|
||||
LIAPI std::string getTypeName();
|
||||
|
||||
LIAPI bool addItem_s(ItemStack* item);
|
||||
LIAPI bool addItemToFirstEmptySlot_s(ItemStack* item);
|
||||
@ -27,6 +27,20 @@ public:
|
||||
// static??
|
||||
LIAPI Container* getContainerAt(Vec3& pos, int dim);
|
||||
|
||||
inline bool isEmpty() const{
|
||||
int size = getContainerSize();
|
||||
if( size <= 0)
|
||||
return 1;
|
||||
for(int i = 0; i < size;i++){
|
||||
ItemStack item = getItem(i);
|
||||
if(!item.isNull())
|
||||
break ;
|
||||
if(i+1 >= size)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
#undef AFTER_EXTRA
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_CONTAINER
|
||||
public:
|
||||
|
@ -11,13 +11,18 @@ class Dimension {
|
||||
|
||||
#define AFTER_EXTRA
|
||||
public:
|
||||
BlockSource& getBlockSourceFromMainChunkSource() const{
|
||||
inline BlockSource& getBlockSourceFromMainChunkSource() const{
|
||||
//ExplorationMapFunction::apply Line57
|
||||
return *dAccess<BlockSource*>(this, 72);
|
||||
};
|
||||
int getHeight(){
|
||||
inline int getHeight(){
|
||||
return dAccess<int>(this,202);
|
||||
}
|
||||
};
|
||||
inline AutomaticID<class Dimension, int> getDimensionId() const{
|
||||
//Player::moveSpawnView Line33
|
||||
//Player::checkSpawnBlock Line19
|
||||
return dAccess<AutomaticID<Dimension,int>>(this,192);
|
||||
};
|
||||
#undef AFTER_EXTRA
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_DIMENSION
|
||||
public:
|
||||
|
@ -4,13 +4,31 @@
|
||||
#include "../Global.h"
|
||||
|
||||
#define BEFORE_EXTRA
|
||||
#include "math.h"
|
||||
namespace glm{
|
||||
template <typename t,int>
|
||||
struct tmat3x3{
|
||||
tmat3x3() = delete;
|
||||
tmat3x3(tmat3x3 const&) = delete;
|
||||
tmat3x3(tmat3x3 const&&) = delete;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#undef BEFORE_EXTRA
|
||||
|
||||
class Facing {
|
||||
|
||||
#define AFTER_EXTRA
|
||||
enum Name;
|
||||
enum Rotation;
|
||||
public:
|
||||
|
||||
static int convertYRotationToFacingDirection(float yRotation){
|
||||
int cardinalDirection = (int)floor(((4.0 * yRotation)/360.0)+0.5) & 3;
|
||||
void* Facing_Plane_HORIZONTAL = dlsym("?HORIZONTAL@Plane@Facing@@2V?$vector@EV?$allocator@E@std@@@std@@A");
|
||||
return dAccess<int>(Facing_Plane_HORIZONTAL,cardinalDirection);
|
||||
}
|
||||
#undef AFTER_EXTRA
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_FACING
|
||||
public:
|
||||
|
@ -5,7 +5,9 @@
|
||||
#include "Json.hpp"
|
||||
|
||||
#define BEFORE_EXTRA
|
||||
|
||||
#include "Item.hpp"
|
||||
#include "BlockLegacy.hpp"
|
||||
#include <cstddef>
|
||||
#undef BEFORE_EXTRA
|
||||
|
||||
class ItemStackBase {
|
||||
@ -13,11 +15,28 @@ class ItemStackBase {
|
||||
#define AFTER_EXTRA
|
||||
// Add Member There
|
||||
private:
|
||||
//void* vtbl;
|
||||
char filler[128];
|
||||
WeakPtr<Item> mItem;
|
||||
std::unique_ptr<CompoundTag> mUserData;
|
||||
const Block *mBlock;
|
||||
int mAuxValue;
|
||||
std::byte mCount;
|
||||
bool mValid;
|
||||
std::chrono::steady_clock::time_point mPickupTime;
|
||||
bool mShowPickUp;
|
||||
bool mWasPickedUp;
|
||||
bool mCanUseOn;
|
||||
std::vector<const BlockLegacy*> mCanPlaceOn;
|
||||
size_t mCanPlaceOnHash;
|
||||
std::vector<const BlockLegacy*> mCanDestroy;
|
||||
size_t mCanDestroyHash;
|
||||
int mBlockingTick;
|
||||
std::unique_ptr<ItemInstance> mChargedItem;
|
||||
|
||||
public:
|
||||
LIAPI int getCount() const;
|
||||
inline void setAuxValue(short a1){
|
||||
this->mAuxValue = a1;
|
||||
};
|
||||
|
||||
#undef AFTER_EXTRA
|
||||
public:
|
||||
|
@ -24,6 +24,7 @@ class Container;
|
||||
class Dimension;
|
||||
struct ActorUniqueID;
|
||||
class Packet;
|
||||
class Spawner;
|
||||
|
||||
#undef BEFORE_EXTRA
|
||||
|
||||
@ -43,11 +44,11 @@ public:
|
||||
LIAPI static Actor* getEntity(ActorUniqueID id);
|
||||
LIAPI static std::vector<Actor*> getAllEntities(int dimId);
|
||||
LIAPI static std::vector<Actor*> getAllEntities();
|
||||
//LIAPI static Actor* spawnMob(Vec3 pos, int dimId, std::string typeName);
|
||||
//LIAPI static Actor* spawnItem(Vec3 pos, int dimId, ItemStack *item);
|
||||
LIAPI static Actor* spawnMob(Vec3 pos, int dimId, std::string typeName);
|
||||
LIAPI static Actor* spawnItem(Vec3 pos, int dimId, ItemStack *item);
|
||||
LIAPI static bool createExplosion(Vec3 pos, int dimId, Actor* source, float radius, bool createFire, bool canBreak, float maxResistance = 3.40282347e+38);
|
||||
//LIAPI static class MapItemSavedData* getMapSavedData(struct ActorUniqueID a0);
|
||||
//LIAPI static Actor* cloneMob(Vec3 pos, int dimId, Actor* ac);
|
||||
LIAPI static Actor* cloneMob(Vec3 pos, int dimId, Actor* ac);
|
||||
|
||||
//Block
|
||||
LIAPI static Block* getBlock(BlockPos* pos, int dimId);
|
||||
@ -139,6 +140,10 @@ public:
|
||||
{
|
||||
return executeCommand(cmd);
|
||||
}
|
||||
|
||||
inline Spawner& getSpawner() const{
|
||||
return *dAccess<std::unique_ptr<Spawner>>(this,1968).get();
|
||||
};
|
||||
|
||||
#undef AFTER_EXTRA
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_LEVEL
|
||||
|
@ -44,6 +44,11 @@ public:
|
||||
//CommandAreaFactory::_getArea Line156
|
||||
return *dAccess<Tick*>(this, 144);
|
||||
};
|
||||
inline int getHeightmap(const ChunkBlockPos *pos){
|
||||
//LevelChunk::_lightingCallbacks Line31 应该是这样的
|
||||
auto chunk = pos->x +16 * pos->z;
|
||||
return dAccess<int>(this,chunk+1960);
|
||||
};
|
||||
#undef AFTER_EXTRA
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_LEVELCHUNK
|
||||
public:
|
||||
|
@ -60,16 +60,23 @@ public:
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
inline std::unique_ptr<class ListTag> copyList() const{
|
||||
auto listTag = std::make_unique<ListTag>();
|
||||
listTag->elementType = this->elementType;
|
||||
listTag->val = this->val;
|
||||
return listTag;
|
||||
};
|
||||
~ListTag(){};
|
||||
#undef AFTER_EXTRA
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_LISTTAG
|
||||
public:
|
||||
class ListTag& operator=(class ListTag const &) = delete;
|
||||
ListTag(class ListTag const &) = delete;
|
||||
ListTag() = delete;
|
||||
ListTag(){};
|
||||
#endif
|
||||
|
||||
public:
|
||||
/*0*/ virtual ~ListTag();
|
||||
// /*0*/ virtual ~ListTag();
|
||||
/*1*/ virtual void deleteChildren();
|
||||
/*2*/ virtual void write(class IDataOutput &) const;
|
||||
/*3*/ virtual void load(class IDataInput &);
|
||||
|
@ -23,6 +23,9 @@ enum TravelType;
|
||||
public:
|
||||
|
||||
LIAPI bool refreshInventory();
|
||||
inline bool isGliding(){
|
||||
return getStatusFlag(ActorFlags::GLIDING);
|
||||
}
|
||||
|
||||
#undef AFTER_EXTRA
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_MOB
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "../Global.h"
|
||||
|
||||
#define BEFORE_EXTRA
|
||||
|
||||
#include "HashedString.hpp"
|
||||
#undef BEFORE_EXTRA
|
||||
|
||||
class MobEffect {
|
||||
@ -51,10 +51,14 @@ public:
|
||||
FactorCalculationData(FactorCalculationData const&&) = delete;
|
||||
};
|
||||
|
||||
std::string const & getResourceName() const{
|
||||
inline std::string const & getResourceName() const{
|
||||
//EffectCommand::execute Line247
|
||||
return dAccess<std::string>(this,80);
|
||||
};
|
||||
inline HashedString const & getComponentName() const{
|
||||
//MobEffect::MobEffect Line43;
|
||||
return dAccess<HashedString>(this,152);
|
||||
};
|
||||
|
||||
#undef AFTER_EXTRA
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_MOBEFFECT
|
||||
|
@ -12,7 +12,11 @@
|
||||
class MobEffectInstance {
|
||||
|
||||
#define AFTER_EXTRA
|
||||
|
||||
public:
|
||||
inline HashedString const & getComponentName() const{
|
||||
void* mMobEffects = dlsym("?mMobEffects@MobEffect@@2PAV?$unique_ptr@VMobEffect@@U?$default_delete@VMobEffect@@@std@@@std@@A");
|
||||
return dAccess<MobEffect>(mMobEffects,*(int*)this).getComponentName();
|
||||
};
|
||||
#undef AFTER_EXTRA
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_MOBEFFECTINSTANCE
|
||||
public:
|
||||
|
@ -12,9 +12,17 @@ class Objective {
|
||||
#define AFTER_EXTRA
|
||||
// Add Member There
|
||||
public:
|
||||
std::string getName();
|
||||
inline std::string getName(){
|
||||
//ScoreboardCommand::applyPlayerOperation Line186
|
||||
return dAccess<std::string>(this, 64);
|
||||
};
|
||||
|
||||
LIAPI bool setDisplay(const std::string& slotName, ObjectiveSortOrder sort);
|
||||
|
||||
inline std::string const & getDisplayName() const{
|
||||
//Objective::serialize
|
||||
return dAccess<std::string>(this,96);
|
||||
};
|
||||
|
||||
#undef AFTER_EXTRA
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_OBJECTIVE
|
||||
|
@ -17,6 +17,7 @@ class CompoundTag;
|
||||
#include "ScorePacketInfo.hpp"
|
||||
#include "DataItem.hpp"
|
||||
#include "../I18nAPI.h"
|
||||
#include "AttributeInstance.hpp"
|
||||
#undef BEFORE_EXTRA
|
||||
|
||||
class Player : public Mob {
|
||||
@ -47,7 +48,7 @@ public:
|
||||
LIAPI std::pair<BlockPos, int> getRespawnPosition();
|
||||
LIAPI float getAvgPacketLoss();
|
||||
LIAPI float getLastPacketLoss();
|
||||
//LIAPI string getClientId();
|
||||
LIAPI string getClientId();
|
||||
LIAPI int getDeviceType();
|
||||
LIAPI bool isOperator();
|
||||
LIAPI bool isOP();
|
||||
@ -132,9 +133,9 @@ public:
|
||||
LIAPI bool setNbt(CompoundTag* nbt);
|
||||
LIAPI bool refreshAttribute(class Attribute const& attribute);
|
||||
LIAPI bool refreshAttributes(std::vector<Attribute const*> const& attributes);
|
||||
//LIAPI void addBossEvent(int64_t uid, string name, float percent, BossEventColour colour, int overlay = 0);
|
||||
LIAPI void addBossEvent(int64_t uid, string name, float percent, BossEventColour colour, int overlay = 0);
|
||||
LIAPI void removeBossEvent(int64_t uid);
|
||||
//LIAPI void updateBossEvent(int64_t uid, string name, float percent, BossEventColour colour, int overlay = 0);
|
||||
LIAPI void updateBossEvent(int64_t uid, string name, float percent, BossEventColour colour, int overlay = 0);
|
||||
|
||||
LIAPI int getScore(const string& key);
|
||||
LIAPI bool setScore(const string& key, int value);
|
||||
@ -154,13 +155,13 @@ public:
|
||||
LIAPI bool sendSpawnParticleEffectPacket(Vec3 spawnPos, int dimid, string ParticleName, int64_t EntityUniqueID = -1) const;
|
||||
/*bad*/ LIAPI bool sendPlaySoundPacket(string SoundName, Vec3 Position, float Volume, float Pitch) const;
|
||||
//LIAPI bool sendAddItemEntityPacket(unsigned long long runtimeID, class Item const& item, int stackSize, short aux, Vec3 pos, vector<std::unique_ptr<DataItem>> dataItems = {}) const;
|
||||
//LIAPI bool sendAddEntityPacket(unsigned long long runtimeID, string entityType, Vec3 pos, Vec2 rotation, float headYaw, vector<std::unique_ptr<DataItem>> dataItems = {});
|
||||
LIAPI bool sendAddEntityPacket(unsigned long long runtimeID, string entityType, Vec3 pos, Vec2 rotation, float headYaw, vector<std::unique_ptr<DataItem>> dataItems = {});
|
||||
LIAPI bool sendUpdateBlockPacket(BlockPos const& blockPos, unsigned int runtimeId, UpdateBlockFlags flag = UpdateBlockFlags::BlockUpdateAll, UpdateBlockLayer layer = UpdateBlockLayer::UpdateBlockDefault);
|
||||
LIAPI bool sendUpdateBlockPacket(BlockPos const& blockPos, const Block& block, UpdateBlockFlags flag = UpdateBlockFlags::BlockUpdateAll, UpdateBlockLayer layer = UpdateBlockLayer::UpdateBlockDefault);
|
||||
LIAPI bool sendTransferPacket(const string& address, short port) const;
|
||||
LIAPI bool sendSetDisplayObjectivePacket(const string& title, const string& name, char sortOrder) const;
|
||||
LIAPI bool sendSetScorePacket(char type, const vector<ScorePacketInfo>& data);
|
||||
//LIAPI bool sendBossEventPacket(BossEvent type, string name, float percent, BossEventColour colour, int overlay = 0);
|
||||
LIAPI bool sendBossEventPacket(BossEvent type, string name, float percent, BossEventColour colour, int overlay = 0);
|
||||
LIAPI bool sendCommandRequestPacket(const string& cmd);
|
||||
LIAPI bool sendTextTalkPacket(const string& msg);
|
||||
LIAPI bool sendTextTalkPacket(const string& msg, Player* target /* = nullptr*/);
|
||||
@ -176,6 +177,19 @@ public:
|
||||
inline string getDeviceName() {
|
||||
return getDeviceTypeName();
|
||||
}
|
||||
inline std::string* getDeviceId(){
|
||||
//AddPlayerPacket::AddPlayerPacket Line58
|
||||
return dAccess<std::string*>(this,7872);
|
||||
};
|
||||
inline bool isFlying(){
|
||||
//Actor::onAboveBubbleColumn Line5 照抄的,不知行不行
|
||||
return (dAccess<int>(this,2228) == 1 || !dAccess<bool>(this,2232)) && (dAccess<int>(this, 2324) == 1 || !dAccess<bool>(this, 2328));
|
||||
};
|
||||
inline bool isHungry(){
|
||||
void* Player_HUNGER = dlsym("?HUNGER@Player@@2VAttribute@@B");
|
||||
return getAttribute(*(Attribute*)Player_HUNGER).getMaxValue() > getAttribute(*(Attribute*)Player_HUNGER).getCurrentValue();
|
||||
}
|
||||
|
||||
LIAPI bool sendSimpleFormPacket(const string& title, const string& content, const vector<string>& buttons, const std::vector<std::string>& images, std::function<void(int)> callback) const;
|
||||
LIAPI bool sendModalFormPacket(const string& title, const string& content, const string& button1, const string& button2, std::function<void(bool)> callback);
|
||||
LIAPI bool sendCustomFormPacket(const std::string& data, std::function<void(string)> callback);
|
||||
|
@ -10,7 +10,12 @@
|
||||
class StructureBlockPalette {
|
||||
|
||||
#define AFTER_EXTRA
|
||||
|
||||
public:
|
||||
struct BlockPositionData {
|
||||
BlockPositionData() = delete;
|
||||
BlockPositionData(BlockPositionData const&) = delete;
|
||||
BlockPositionData(BlockPositionData const&&) = delete;
|
||||
};
|
||||
#undef AFTER_EXTRA
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_STRUCTUREBLOCKPALETTE
|
||||
public:
|
||||
|
@ -27,7 +27,17 @@ class StructureSettings {
|
||||
#define AFTER_EXTRA
|
||||
// Add Member There
|
||||
private:
|
||||
char filler[104];
|
||||
std::string mPaletteName;
|
||||
bool mIgnoreEntities;
|
||||
bool mIgnoreBlocks;
|
||||
BlockPos mStructureSize;
|
||||
BlockPos mStructureOffset;
|
||||
Vec3 mPivot;
|
||||
ActorUniqueID mLastTouchedByPlayer;
|
||||
Rotation mRotation;
|
||||
Mirror mMirror;
|
||||
float mIntegrityValue;
|
||||
unsigned int mIntegritySeed;
|
||||
|
||||
// public:
|
||||
// inline StructureSettings(BlockPos const& size, bool ignoreEntities, bool ignoreBlocks)
|
||||
@ -37,6 +47,22 @@ char filler[104];
|
||||
// setIgnoreEntities(ignoreEntities);
|
||||
// setStructureSize(size);
|
||||
// };
|
||||
public:
|
||||
inline void setIgnoreBlocks(bool a0){
|
||||
this->mIgnoreBlocks = a0;
|
||||
};
|
||||
inline void setIgnoreEntities(bool a0){
|
||||
this->mIgnoreEntities = a0;
|
||||
};
|
||||
inline void setStructureSize(class BlockPos const & bp){
|
||||
this->mStructureSize = bp;
|
||||
};
|
||||
inline void setMirror(enum Mirror a0){
|
||||
this->mMirror = a0;
|
||||
};
|
||||
inline void setRotation(enum Rotation a0){
|
||||
this->mRotation = a0;
|
||||
};
|
||||
|
||||
#undef AFTER_EXTRA
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_STRUCTURESETTINGS
|
||||
|
@ -4,28 +4,44 @@
|
||||
#include "../Global.h"
|
||||
|
||||
#define BEFORE_EXTRA
|
||||
|
||||
// Include Headers or Declare Types Here
|
||||
#include "StructureSettings.hpp"
|
||||
#include "StructureTemplateData.hpp"
|
||||
#undef BEFORE_EXTRA
|
||||
|
||||
class StructureTemplate {
|
||||
|
||||
#define AFTER_EXTRA
|
||||
// Add Member There
|
||||
// string mName;
|
||||
// StructureTemplateData mStructureTemplateData;
|
||||
// unsigned __int8 mStructureVersion;
|
||||
//Add Member There
|
||||
string mName;
|
||||
StructureTemplateData mStructureTemplateData;
|
||||
|
||||
// public:
|
||||
// #define DISABLE_CONSTRUCTOR_PREVENTION_STRUCTURETEMPLATE
|
||||
// class StructureTemplate& operator=(class StructureTemplate const&) = delete;
|
||||
// StructureTemplate(class StructureTemplate const&);
|
||||
// StructureTemplate() = delete;
|
||||
// LIAPI static StructureTemplate fromTag(std::string name, CompoundTag const& tag);
|
||||
// LIAPI static StructureTemplate fromWorld(std::string name, int dimid, BlockPos p1, BlockPos p2, bool ignoreEntities = true, bool ignoreBlocks = false);
|
||||
// //LIAPI bool load(CompoundTag const& tag);
|
||||
// LIAPI std::unique_ptr<CompoundTag> toTag();
|
||||
// LIAPI bool toWorld(int dimid, BlockPos const& p1, Mirror mirror = Mirror::None_15, Rotation rotation = Rotation::None_14);
|
||||
// LIAPI StructureTemplateData* getData();
|
||||
public:
|
||||
#define DISABLE_CONSTRUCTOR_PREVENTION_STRUCTURETEMPLATE
|
||||
class StructureTemplate& operator=(class StructureTemplate const&) = delete;
|
||||
StructureTemplate(class StructureTemplate const&);
|
||||
StructureTemplate() = delete;
|
||||
LIAPI static StructureTemplate fromTag(std::string name, CompoundTag const& tag);
|
||||
LIAPI static StructureTemplate fromWorld(std::string name, int dimid, BlockPos p1, BlockPos p2, bool ignoreEntities = true, bool ignoreBlocks = false);
|
||||
//LIAPI bool load(CompoundTag const& tag);
|
||||
LIAPI std::unique_ptr<CompoundTag> toTag();
|
||||
LIAPI bool toWorld(int dimid, BlockPos const& p1, Mirror mirror = Mirror::None_15, Rotation rotation = Rotation::None_14);
|
||||
LIAPI StructureTemplateData* getData();
|
||||
|
||||
inline bool load(class CompoundTag const & a0){
|
||||
return mStructureTemplateData.load(a0);
|
||||
};
|
||||
|
||||
inline std::unique_ptr<class CompoundTag> save() const{
|
||||
return mStructureTemplateData.save();
|
||||
};
|
||||
|
||||
inline std::string const & getName() const{
|
||||
return this->mName;
|
||||
};
|
||||
inline BlockPos const & getSize() const{
|
||||
return mStructureTemplateData.getSize();
|
||||
};
|
||||
|
||||
#undef AFTER_EXTRA
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_STRUCTURETEMPLATE
|
||||
|
@ -4,13 +4,27 @@
|
||||
#include "../Global.h"
|
||||
|
||||
#define BEFORE_EXTRA
|
||||
|
||||
// Include Headers or Declare Types Here
|
||||
#include "StructureBlockPalette.hpp"
|
||||
#undef BEFORE_EXTRA
|
||||
|
||||
class StructureTemplateData {
|
||||
|
||||
#define AFTER_EXTRA
|
||||
|
||||
// Add Member There
|
||||
private:
|
||||
void* __vftable;
|
||||
int mFormatVersion;
|
||||
BlockPos mSize;
|
||||
BlockPos mStructureWorldOrigin;
|
||||
std::vector<int> mBlockIndices;
|
||||
std::vector<int> mExtraBlockIndices;
|
||||
std::unordered_map<std::string, StructureBlockPalette> mPalettes;
|
||||
std::vector<std::unique_ptr<CompoundTag>> mEntityData;
|
||||
public:
|
||||
inline BlockPos const & getSize() const{
|
||||
return mSize;
|
||||
};
|
||||
#undef AFTER_EXTRA
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_STRUCTURETEMPLATEDATA
|
||||
public:
|
||||
|
@ -99,7 +99,7 @@ public:
|
||||
public:
|
||||
class Tag& operator=(class Tag const &) = delete;
|
||||
Tag(class Tag const &) = delete;
|
||||
Tag() = delete;
|
||||
Tag(){};
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
@ -6,13 +6,13 @@ template <int pid, bool batching = true, bool compress = true>
|
||||
class NetworkPacket : public Packet {
|
||||
public:
|
||||
std::string_view view;
|
||||
NetworkPacket() {
|
||||
incompressible = compress;
|
||||
}
|
||||
NetworkPacket(std::string_view sv)
|
||||
: view(sv) {
|
||||
incompressible = compress;
|
||||
}
|
||||
// NetworkPacket() {
|
||||
// incompressible = compress;
|
||||
// }
|
||||
// NetworkPacket(std::string_view sv)
|
||||
// : view(sv) {
|
||||
// incompressible = compress;
|
||||
// }
|
||||
inline virtual ~NetworkPacket() {
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,13 @@
|
||||
#include <MC/CommandOrigin.hpp>
|
||||
#include <MC/Actor.hpp>
|
||||
#include "MC/CompoundTag.hpp"
|
||||
|
||||
ServerPlayer* CommandOrigin::getPlayer() const {
|
||||
Actor* origin = getEntity();
|
||||
return origin->isPlayer() ? (ServerPlayer*)origin : nullptr;
|
||||
}
|
||||
}
|
||||
// CompoundTag CommandOrigin::serialize_1() const {
|
||||
// CompoundTag tag;
|
||||
// tag.putByte("OriginType",getOriginType());
|
||||
// return tag;
|
||||
// };
|
@ -63,13 +63,13 @@ bool Actor::isOnGround() const {
|
||||
return getActorIdentifier().getCanonicalName();
|
||||
}
|
||||
|
||||
// bool Actor::hurtEntity(float damage, ActorDamageCause damageCause) {
|
||||
// auto ads = new ActorDamageSource(damageCause);
|
||||
// auto res = ((Mob*)this)->_hurt(*ads, damage, true, false);
|
||||
// ads->~ActorDamageSource();
|
||||
// delete ads;
|
||||
// return res;
|
||||
// }
|
||||
bool Actor::hurtEntity(float damage,ActorDamageCause damageCause) {
|
||||
auto ads = new ActorDamageSource(damageCause);
|
||||
auto res = ((Mob*)this)->_hurt(*ads, damage, true, false);
|
||||
ads->~ActorDamageSource();
|
||||
delete ads;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
Vec2* Actor::getDirection() const {
|
||||
@ -211,18 +211,18 @@ Vec3 Actor::getCameraPos() const {
|
||||
// return getBlockFromViewVector(face, includeLiquid, solidOnly, maxDistance, ignoreBorderBlocks, fullOnly);
|
||||
// }
|
||||
|
||||
// Actor* Actor::getActorFromViewVector(float maxDistance) {
|
||||
// auto& bs = getRegion();
|
||||
// auto pos = getCameraPos();
|
||||
// auto viewVec = getViewVector(1.0f);
|
||||
// auto aabb = *(AABB*)&getAABB();
|
||||
// auto player = isPlayer() ? (Player*)this : nullptr;
|
||||
// Actor* result = nullptr;
|
||||
// float distance = 0.0f;
|
||||
// Vec3 resultPos{};
|
||||
// // HitDetection::searchActors(viewVec, maxDistance, pos, aabb, this, (Player*)this, distance, result, resultPos, player);
|
||||
// return result;
|
||||
// }
|
||||
Actor* Actor::getActorFromViewVector(float maxDistance) {
|
||||
auto& bs = getRegion();
|
||||
auto pos = getCameraPos();
|
||||
auto viewVec = getViewVector(1.0f);
|
||||
auto aabb = *(AABB*)&getAABB();
|
||||
auto player = isPlayer() ? (Player*)this : nullptr;
|
||||
Actor* result = nullptr;
|
||||
float distance = 0.0f;
|
||||
Vec3 resultPos{};
|
||||
// HitDetection::searchActors(viewVec, maxDistance, pos, aabb, this, (Player*)this, distance, result, resultPos, player);
|
||||
return result;
|
||||
}
|
||||
|
||||
// bool Actor::addEffect(MobEffect::EffectType type, int tick, int level, bool ambient, bool showParticles, bool showAnimation) {
|
||||
// MobEffectInstance ins = MobEffectInstance((unsigned int)type, tick, -1,-1,-1,level, ambient, showParticles, showAnimation);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <MC/ActorDamageSource.hpp>
|
||||
#include <MC/Level.hpp>
|
||||
|
||||
// Actor* ActorDamageSource::getEntity() {
|
||||
// ActorUniqueID v6 = getDamagingEntityUniqueID();
|
||||
// return Global<Level>->getEntity(v6);
|
||||
// }
|
||||
Actor* ActorDamageSource::getEntity() {
|
||||
ActorUniqueID v6 = getDamagingEntityUniqueID();
|
||||
return Global<Level>->getEntity(v6);
|
||||
}
|
@ -27,9 +27,9 @@ string Block::getTypeName() const {
|
||||
}
|
||||
|
||||
|
||||
// int Block::getId() const {
|
||||
// return getLegacyBlock().getBlockItemId();
|
||||
// }
|
||||
int Block::getId() const {
|
||||
return getLegacyBlock().getBlockItemId();
|
||||
}
|
||||
|
||||
unsigned short Block::getTileData() {
|
||||
// 等待大佬改进
|
||||
|
@ -7,28 +7,28 @@
|
||||
#include <MC/StructureBlockPalette.hpp>
|
||||
#include <MC/StructureEditorData.hpp>
|
||||
|
||||
// unsigned int BlockActor::getBlockEntityType(Block* block) {
|
||||
// return block->getBlockEntityType(); // IDA Block::getBlockEntityType
|
||||
// }
|
||||
unsigned int BlockActor::getBlockEntityType(Block* block) {
|
||||
return block->getBlockEntityType(); // IDA Block::getBlockEntityType
|
||||
}
|
||||
|
||||
bool BlockActor::refreshData() {
|
||||
setChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
// bool BlockActor::refreshData(BlockSource* bs) {
|
||||
// refreshData();
|
||||
// if (!bs)
|
||||
// return false;
|
||||
// auto pkt = getServerUpdatePacket(*bs);
|
||||
// if (!pkt)
|
||||
// return false;
|
||||
// auto dimension = const_cast<Dimension*>(&bs->getDimensionConst());
|
||||
// if (!dimension)
|
||||
// return false;
|
||||
// dimension->sendPacketForPosition(getPosition(), *pkt, nullptr);
|
||||
// return true;
|
||||
// }
|
||||
bool BlockActor::refreshData(BlockSource* bs) {
|
||||
refreshData();
|
||||
if (!bs)
|
||||
return false;
|
||||
auto pkt = getServerUpdatePacket(*bs);
|
||||
if (!pkt)
|
||||
return false;
|
||||
auto dimension = const_cast<Dimension*>(&bs->getDimensionConst());
|
||||
if (!dimension)
|
||||
return false;
|
||||
dimension->sendPacketForPosition(getPosition(), *pkt, nullptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::unique_ptr<CompoundTag> BlockActor::getNbt() {
|
||||
return CompoundTag::fromBlockActor(this);
|
||||
@ -38,7 +38,7 @@ bool BlockActor::setNbt(CompoundTag* nbt) {
|
||||
return nbt->setBlockActor(this);
|
||||
}
|
||||
|
||||
// bool BlockActor::setNbt(CompoundTag* nbt, BlockSource* bs) {
|
||||
// auto res = setNbt(nbt);
|
||||
// return res && (!bs || refreshData(bs));
|
||||
// }
|
||||
bool BlockActor::setNbt(CompoundTag* nbt, BlockSource* bs) {
|
||||
auto res = setNbt(nbt);
|
||||
return res && (!bs || refreshData(bs));
|
||||
}
|
@ -2,12 +2,13 @@
|
||||
#include <MC/Container.hpp>
|
||||
#include <MC/ItemStack.hpp>
|
||||
#include <MC/Level.hpp>
|
||||
#include "third-party/magic_enum/magic_enum.hpp"
|
||||
|
||||
// LIAPI std::string Container::getTypeName() {
|
||||
// ContainerType type = dAccess<ContainerType>(this, 8); //IDA Container::Container
|
||||
// // ContainerType type = getContainerType();
|
||||
// return getContainerTypeName(type);
|
||||
// }
|
||||
LIAPI std::string Container::getTypeName() {
|
||||
ContainerType type = dAccess<ContainerType>(this, 8); //IDA Container::Container
|
||||
// ContainerType type = getContainerType();
|
||||
return std::string{magic_enum::enum_name(type)};
|
||||
}
|
||||
|
||||
// Safely add items to the container
|
||||
LIAPI bool Container::addItem_s(ItemStack* item) {
|
||||
|
@ -302,23 +302,23 @@ Player* Level::getPlayer(ActorUniqueID id) {
|
||||
//return SymCall("?getPlayer@Level@@UEBAPEAVPlayer@@UActorUniqueID@@@Z", Player*, Level*, ActorUniqueID)(Global<Level>, id);
|
||||
}
|
||||
|
||||
// Actor* Level::spawnMob(Vec3 pos, int dimId, std::string name) {
|
||||
Actor* Level::spawnMob(Vec3 pos, int dimId, std::string name) {
|
||||
|
||||
// Spawner* sp = &Global<Level>->getSpawner();
|
||||
// return sp->spawnMob(pos, dimId, std::move(name));
|
||||
// }
|
||||
Spawner* sp = &Global<Level>->getSpawner();
|
||||
return sp->spawnMob(pos, dimId, std::move(name));
|
||||
}
|
||||
|
||||
// Actor* Level::cloneMob(Vec3 pos, int dimId, Actor* ac) {
|
||||
// Spawner* sp = &Global<Level>->getSpawner();
|
||||
// Mob* mob = sp->spawnMob(pos, dimId, std::move(ac->getTypeName()));
|
||||
// mob->setNbt(ac->getNbt().get());
|
||||
// return mob;
|
||||
// }
|
||||
Actor* Level::cloneMob(Vec3 pos, int dimId, Actor* ac) {
|
||||
Spawner* sp = &Global<Level>->getSpawner();
|
||||
Mob* mob = sp->spawnMob(pos, dimId, std::move(ac->getTypeName()));
|
||||
mob->setNbt(ac->getNbt().get());
|
||||
return mob;
|
||||
}
|
||||
|
||||
// Actor* Level::spawnItem(Vec3 pos, int dimId, ItemStack* item) {
|
||||
// Spawner* sp = &Global<Level>->getSpawner();
|
||||
// return sp->spawnItem(pos, dimId, item);
|
||||
// }
|
||||
Actor* Level::spawnItem(Vec3 pos, int dimId, ItemStack* item) {
|
||||
Spawner* sp = &Global<Level>->getSpawner();
|
||||
return sp->spawnItem(pos, dimId, item);
|
||||
}
|
||||
|
||||
bool Level::createExplosion(Vec3 pos, int dimId, Actor* source, float radius, bool createFire, bool canBreak, float maxResistance) {
|
||||
Global<Level>->explode(*Level::getBlockSource(dimId), source, pos, radius, createFire, canBreak, maxResistance, false);
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <MC/RakNet.hpp>
|
||||
|
||||
string NetworkIdentifier::getIP() {
|
||||
string rv;
|
||||
Global<RakNet::RakPeer>->getAdr(*this).ToString_New(true, rv.data(), ':');
|
||||
string rv =getAddress();
|
||||
// Global<RakNet::RakPeer>->getAdr(*this).ToString_New(true, rv.data(), ':');
|
||||
return rv.substr(0, rv.find('|'));
|
||||
}
|
@ -333,9 +333,9 @@ float Player::getLastPacketLoss() {
|
||||
return Global<Minecraft>->getNetworkHandler().getPeerForUser(*getNetworkIdentifier())->getNetworkStatus().mCurrentPacketLoss;
|
||||
}
|
||||
|
||||
// string Player::getClientId() {
|
||||
// return Global<ServerNetworkHandler>->fetchConnectionRequest(*getNetworkIdentifier()).getDeviceId();
|
||||
// }
|
||||
string Player::getClientId() {
|
||||
return *getDeviceId();
|
||||
}
|
||||
|
||||
int Player::getDeviceType() {
|
||||
return getPlatform();
|
||||
@ -479,20 +479,20 @@ bool Player::deleteScore(const string& key) {
|
||||
return Scoreboard::deleteScore(this, key);
|
||||
}
|
||||
|
||||
// void Player::addBossEvent(int64_t uid, string name, float percent, BossEventColour colour, int overlay) {
|
||||
// BinaryStream wp;
|
||||
// wp.writeVarInt64(uid);
|
||||
// wp.writeUnsignedVarInt((int)0);
|
||||
// wp.writeString(name);
|
||||
// wp.writeFloat(percent);
|
||||
// wp.writeUnsignedShort(1);
|
||||
// wp.writeUnsignedVarInt((int)colour);
|
||||
// wp.writeUnsignedVarInt(overlay);
|
||||
// auto pkt = MinecraftPackets::createPacket(MinecraftPacketIds::BossEvent);
|
||||
// pkt->read(wp);
|
||||
// sendAddEntityPacket(uid, "player", Vec3(getPos().x, (float)-70, getPos().z), Vec2{0, 0}, 0);
|
||||
// sendNetworkPacket(*pkt);
|
||||
// }
|
||||
void Player::addBossEvent(int64_t uid, string name, float percent, BossEventColour colour, int overlay) {
|
||||
BinaryStream wp;
|
||||
wp.writeVarInt64(uid);
|
||||
wp.writeUnsignedVarInt((int)0);
|
||||
wp.writeString(name);
|
||||
wp.writeFloat(percent);
|
||||
wp.writeUnsignedShort(1);
|
||||
wp.writeUnsignedVarInt((int)colour);
|
||||
wp.writeUnsignedVarInt(overlay);
|
||||
auto pkt = MinecraftPackets::createPacket(MinecraftPacketIds::BossEvent);
|
||||
pkt->read(wp);
|
||||
sendAddEntityPacket(uid, "player", Vec3(getPos().x, (float)-70, getPos().z), Vec2{0, 0}, 0);
|
||||
sendNetworkPacket(*pkt);
|
||||
}
|
||||
|
||||
void Player::removeBossEvent(int64_t uid) {
|
||||
BinaryStream wp;
|
||||
@ -503,10 +503,10 @@ void Player::removeBossEvent(int64_t uid) {
|
||||
sendNetworkPacket(*pkt);
|
||||
}
|
||||
|
||||
// void Player::updateBossEvent(int64_t uid, string name, float percent, BossEventColour colour, int overlay) {
|
||||
// removeBossEvent(uid);
|
||||
// addBossEvent(uid, name, percent, colour, overlay);
|
||||
// }
|
||||
void Player::updateBossEvent(int64_t uid, string name, float percent, BossEventColour colour, int overlay) {
|
||||
removeBossEvent(uid);
|
||||
addBossEvent(uid, name, percent, colour, overlay);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////// Packet //////////////////////////
|
||||
@ -635,28 +635,30 @@ bool Player::sendPlaySoundPacket(string SoundName, Vec3 Position, float Volume,
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// bool Player::sendAddEntityPacket(unsigned long long runtimeID, string entityType, Vec3 pos, Vec2 rotation, float headYaw, vector<std::unique_ptr<DataItem>> dataItems) {
|
||||
// BinaryStream bs;
|
||||
// bs.writeVarInt64(runtimeID);
|
||||
// bs.writeUnsignedVarInt64(runtimeID);
|
||||
// bs.writeString(entityType);
|
||||
// bs.writeType(pos);
|
||||
// bs.writeType(Vec3{0, 0, 0});
|
||||
// bs.writeType(Vec3{0, 0, 0});
|
||||
// bs.writeFloat(0.0);
|
||||
// // Atrribute
|
||||
// bs.writeUnsignedVarInt(0);
|
||||
bool Player::sendAddEntityPacket(unsigned long long runtimeID, string entityType, Vec3 pos, Vec2 rotation, float headYaw, vector<std::unique_ptr<DataItem>> dataItems) {
|
||||
BinaryStream bs;
|
||||
bs.writeVarInt64(runtimeID);
|
||||
bs.writeUnsignedVarInt64(runtimeID);
|
||||
bs.writeString(entityType);
|
||||
bs.writeType(pos);
|
||||
bs.writeType(Vec3{0, 0, 0});
|
||||
bs.writeType(Vec3{0, 0, 0});
|
||||
bs.writeFloat(0.0);
|
||||
// Atrribute
|
||||
bs.writeUnsignedVarInt(0);
|
||||
|
||||
// // DataItem
|
||||
// bs.writeUnsignedVarInt(0);
|
||||
// DataItem
|
||||
bs.writeUnsignedVarInt(0);
|
||||
|
||||
// // Links
|
||||
// bs.writeUnsignedVarInt(0);
|
||||
// Links
|
||||
bs.writeUnsignedVarInt(0);
|
||||
|
||||
// NetworkPacket<13> pkt(bs.getAndReleaseData());
|
||||
// sendNetworkPacket(pkt);
|
||||
// return true;
|
||||
// }
|
||||
//NetworkPacket<13> pkt(bs.getAndReleaseData());
|
||||
auto pkt = MinecraftPackets::createPacket(13);
|
||||
pkt->read(bs);
|
||||
sendNetworkPacket(*pkt);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Player::sendUpdateBlockPacket(BlockPos const& bpos, unsigned int runtimeId, UpdateBlockFlags flag, UpdateBlockLayer layer) {
|
||||
BinaryStream wp;
|
||||
@ -697,49 +699,49 @@ bool Player::sendSetScorePacket(char type, const vector<ScorePacketInfo>& data)
|
||||
return true;
|
||||
}
|
||||
|
||||
// bool Player::sendBossEventPacket(BossEvent type, string name, float percent, BossEventColour colour, int overlay) {
|
||||
// BinaryStream wp;
|
||||
// wp.writeVarInt64(getUniqueID() + 1145141919);
|
||||
// wp.writeUnsignedVarInt((int)type);
|
||||
// switch (type) {
|
||||
// case BossEvent::Show:
|
||||
// wp.writeString(name);
|
||||
// wp.writeFloat(percent);
|
||||
// goto LABEL_3;
|
||||
// case BossEvent::RegisterPlayer:
|
||||
// case BossEvent::UnregisterPlayer:
|
||||
// case BossEvent::ResendRaidBossEventData: {
|
||||
// wp.writeVarInt64(getUniqueID() + 1145141919);
|
||||
// break;
|
||||
// }
|
||||
// case BossEvent::HealthPercentage: {
|
||||
// wp.writeFloat(percent);
|
||||
// break;
|
||||
// }
|
||||
// case BossEvent::Title: {
|
||||
// wp.writeString(name);
|
||||
// break;
|
||||
// }
|
||||
// case BossEvent::AppearanceProperties:
|
||||
// LABEL_3:
|
||||
// wp.writeUnsignedShort(1);
|
||||
// goto LABEL_4;
|
||||
// case BossEvent::Texture:
|
||||
// LABEL_4:
|
||||
// wp.writeUnsignedVarInt((int)colour);
|
||||
// wp.writeUnsignedVarInt(overlay);
|
||||
// break;
|
||||
// }
|
||||
bool Player::sendBossEventPacket(BossEvent type, string name, float percent, BossEventColour colour, int overlay) {
|
||||
BinaryStream wp;
|
||||
wp.writeVarInt64(getUniqueID() + 1145141919);
|
||||
wp.writeUnsignedVarInt((int)type);
|
||||
switch (type) {
|
||||
case BossEvent::Show:
|
||||
wp.writeString(name);
|
||||
wp.writeFloat(percent);
|
||||
goto LABEL_3;
|
||||
case BossEvent::RegisterPlayer:
|
||||
case BossEvent::UnregisterPlayer:
|
||||
case BossEvent::ResendRaidBossEventData: {
|
||||
wp.writeVarInt64(getUniqueID() + 1145141919);
|
||||
break;
|
||||
}
|
||||
case BossEvent::HealthPercentage: {
|
||||
wp.writeFloat(percent);
|
||||
break;
|
||||
}
|
||||
case BossEvent::Title: {
|
||||
wp.writeString(name);
|
||||
break;
|
||||
}
|
||||
case BossEvent::AppearanceProperties:
|
||||
LABEL_3:
|
||||
wp.writeUnsignedShort(1);
|
||||
goto LABEL_4;
|
||||
case BossEvent::Texture:
|
||||
LABEL_4:
|
||||
wp.writeUnsignedVarInt((int)colour);
|
||||
wp.writeUnsignedVarInt(overlay);
|
||||
break;
|
||||
}
|
||||
|
||||
// auto pkt = MinecraftPackets::createPacket(MinecraftPacketIds::BossEvent);
|
||||
// pkt->read(wp);
|
||||
// sendAddEntityPacket(getUniqueID() + 1145141919, "player", Vec3(getPos().x, (float)-70, getPos().z), Vec2{0, 0}, 0);
|
||||
// if (type != BossEvent::Hide) {
|
||||
// sendBossEventPacket(BossEvent::Hide, "", 0, BossEventColour::White);
|
||||
// }
|
||||
// sendNetworkPacket(*pkt);
|
||||
// return true;
|
||||
// }
|
||||
auto pkt = MinecraftPackets::createPacket(MinecraftPacketIds::BossEvent);
|
||||
pkt->read(wp);
|
||||
sendAddEntityPacket(getUniqueID() + 1145141919, "player", Vec3(getPos().x, (float)-70, getPos().z), Vec2{0, 0}, 0);
|
||||
if (type != BossEvent::Hide) {
|
||||
sendBossEventPacket(BossEvent::Hide, "", 0, BossEventColour::White);
|
||||
}
|
||||
sendNetworkPacket(*pkt);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Player::sendCommandRequestPacket(const string& cmd) {
|
||||
auto packet = MinecraftPackets::createPacket(0x4d);
|
||||
|
@ -5,52 +5,52 @@
|
||||
#include <MC/StructureTemplate.hpp>
|
||||
#include <MC/StructureTemplateData.hpp>
|
||||
|
||||
// StructureTemplate StructureTemplate::fromTag(std::string name, CompoundTag const& tag) {
|
||||
// StructureTemplate st(name);
|
||||
// // st.getName(name_span)
|
||||
// st.getData()->load(tag);
|
||||
// return st;
|
||||
// }
|
||||
StructureTemplate StructureTemplate::fromTag(std::string name, CompoundTag const& tag) {
|
||||
StructureTemplate st(name);
|
||||
// st.getName(name_span)
|
||||
st.getData()->load(tag);
|
||||
return st;
|
||||
}
|
||||
|
||||
// StructureTemplate::StructureTemplate(class StructureTemplate const& copy)
|
||||
// : StructureTemplate(copy.getName()) {
|
||||
// load(*copy.save());
|
||||
// }
|
||||
StructureTemplate::StructureTemplate(class StructureTemplate const& copy)
|
||||
: StructureTemplate(copy.getName()) {
|
||||
load(*copy.save());
|
||||
}
|
||||
|
||||
// // bool StructureTemplate::load(CompoundTag const& tag)
|
||||
// //{
|
||||
// // return getData()->load(tag);
|
||||
// // }
|
||||
// bool StructureTemplate::load(CompoundTag const& tag)
|
||||
//{
|
||||
// return getData()->load(tag);
|
||||
// }
|
||||
|
||||
// std::unique_ptr<CompoundTag> StructureTemplate::toTag() {
|
||||
// return save();
|
||||
// }
|
||||
std::unique_ptr<CompoundTag> StructureTemplate::toTag() {
|
||||
return save();
|
||||
}
|
||||
|
||||
// StructureTemplate StructureTemplate::fromWorld(std::string name, int dimID, BlockPos p1, BlockPos p2, bool ignoreBlocks, bool ignoreEntities) {
|
||||
// auto st = StructureTemplate(name);
|
||||
// // st.getName();
|
||||
// BlockPos start = {std::min(p1.x, p2.x), std::min(p1.y, p2.y), std::min(p1.z, p2.z)};
|
||||
// BlockPos size = {std::abs(p1.x - p2.x) + 1, std::abs(p1.y - p2.y) + 1, std::abs(p1.z - p2.z) + 1};
|
||||
// auto setting = StructureSettings();
|
||||
// setting.setIgnoreBlocks(ignoreBlocks);
|
||||
// setting.setIgnoreEntities(ignoreEntities);
|
||||
// setting.setStructureSize(size);
|
||||
// st.fillFromWorld(*Level::getBlockSource(dimID), start, setting);
|
||||
// return st;
|
||||
// }
|
||||
StructureTemplate StructureTemplate::fromWorld(std::string name, int dimID, BlockPos p1, BlockPos p2, bool ignoreBlocks, bool ignoreEntities) {
|
||||
auto st = StructureTemplate(name);
|
||||
// st.getName();
|
||||
BlockPos start = {std::min(p1.x, p2.x), std::min(p1.y, p2.y), std::min(p1.z, p2.z)};
|
||||
BlockPos size = {std::abs(p1.x - p2.x) + 1, std::abs(p1.y - p2.y) + 1, std::abs(p1.z - p2.z) + 1};
|
||||
auto setting = StructureSettings();
|
||||
setting.setIgnoreBlocks(ignoreBlocks);
|
||||
setting.setIgnoreEntities(ignoreEntities);
|
||||
setting.setStructureSize(size);
|
||||
st.fillFromWorld(*Level::getBlockSource(dimID), start, setting);
|
||||
return st;
|
||||
}
|
||||
|
||||
// #include <MC/BlockPalette.hpp>
|
||||
// bool StructureTemplate::toWorld(int dimID, BlockPos const& p1, Mirror mirror, Rotation rotation) {
|
||||
// auto& palette = Global<Level>->getBlockPalette();
|
||||
// auto bs = Level::getBlockSource(dimID);
|
||||
// auto setting = StructureSettings();
|
||||
// setting.setMirror(mirror);
|
||||
// setting.setStructureSize(getSize());
|
||||
// setting.setRotation(rotation);
|
||||
// placeInWorld(*bs, palette, p1, setting, nullptr, false);
|
||||
// return true;
|
||||
// };
|
||||
#include <MC/BlockPalette.hpp>
|
||||
bool StructureTemplate::toWorld(int dimID, BlockPos const& p1, Mirror mirror, Rotation rotation) {
|
||||
auto& palette = Global<Level>->getBlockPalette();
|
||||
auto bs = Level::getBlockSource(dimID);
|
||||
auto setting = StructureSettings();
|
||||
setting.setMirror(mirror);
|
||||
setting.setStructureSize(getSize());
|
||||
setting.setRotation(rotation);
|
||||
placeInWorld(*bs, palette, p1, setting, nullptr, false);
|
||||
return true;
|
||||
};
|
||||
|
||||
// StructureTemplateData* StructureTemplate::getData() {
|
||||
// return (StructureTemplateData*)((uintptr_t)this + 32);
|
||||
// };
|
||||
StructureTemplateData* StructureTemplate::getData() {
|
||||
return (StructureTemplateData*)((uintptr_t)this + 32);
|
||||
};
|
||||
|
@ -82,10 +82,10 @@ class ByteTag const* CompoundTag::getByteTag(class gsl::basic_string_span<char c
|
||||
};
|
||||
|
||||
// BDS has implemented this interface
|
||||
// class ShortTag const* CompoundTag::getShortTag(class gsl::basic_string_span<char const, -1> key) const
|
||||
//{
|
||||
// return const_cast<Tag*>(get(key))->asShortTag();
|
||||
//};
|
||||
class ShortTag const* CompoundTag::getShortTag(class gsl::basic_string_span<char const, -1> key) const
|
||||
{
|
||||
return const_cast<Tag*>(get(key))->asShortTag();
|
||||
};
|
||||
|
||||
class FloatTag const* CompoundTag::getFloatTag(class gsl::basic_string_span<char const, -1> key) const {
|
||||
return const_cast<Tag*>(get(key))->asFloatTag();
|
||||
@ -103,9 +103,9 @@ class IntArrayTag const* CompoundTag::getIntArrayTag(class gsl::basic_string_spa
|
||||
return const_cast<Tag*>(get(key))->asIntArrayTag();
|
||||
};
|
||||
|
||||
// class StringTag const* CompoundTag::getStringTag(class gsl::basic_string_span<char const, -1> key) const {
|
||||
// return const_cast<Tag*>(get(key))->asStringTag();
|
||||
// };
|
||||
class StringTag const* CompoundTag::getStringTag(class gsl::basic_string_span<char const, -1> key) const {
|
||||
return const_cast<Tag*>(get(key))->asStringTag();
|
||||
};
|
||||
|
||||
class ListTag const* CompoundTag::getListTag(class gsl::basic_string_span<char const, -1> key) const {
|
||||
return getList(key);
|
||||
@ -115,6 +115,14 @@ class CompoundTag const* CompoundTag::getCompoundTag(class gsl::basic_string_spa
|
||||
return getCompound(key);
|
||||
};
|
||||
|
||||
class IntTag const* CompoundTag::getIntTag(class gsl::basic_string_span<char const, -1> key) const {
|
||||
return const_cast<Tag*>(get(key))->asIntTag();;
|
||||
};
|
||||
|
||||
class Int64Tag const* CompoundTag::getInt64Tag(class gsl::basic_string_span<char const, -1> key) const {
|
||||
return const_cast<Tag*>(get(key))->asInt64Tag();;
|
||||
};
|
||||
|
||||
Tag* CompoundTag::operator[](class gsl::basic_string_span<char const, -1> key) {
|
||||
return const_cast<Tag*>(get(key));
|
||||
}
|
||||
|
@ -15,5 +15,5 @@
|
||||
// return true;
|
||||
// });
|
||||
//}
|
||||
//
|
||||
//ParticleAPI ParticleCUI::api{};
|
||||
|
||||
ParticleAPI ParticleCUI::api{};
|
@ -25,8 +25,3 @@ bool Objective::setDisplay(const std::string& slotName, ObjectiveSortOrder sort)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string Objective::getName(){
|
||||
//ScoreboardCommand::applyPlayerOperation Line186
|
||||
return dAccess<std::string>(this, 64);
|
||||
};
|
@ -253,7 +253,7 @@ void LLMain() {
|
||||
LL::LoadLLConfig();
|
||||
|
||||
//Unzip packed Node Modules
|
||||
//UnzipNodeModules();
|
||||
UnzipNodeModules();
|
||||
|
||||
//Decompress resource packs
|
||||
DecompressResourcePacks();
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <ScriptEngine/API/BaseAPI.h>
|
||||
#include <ScriptEngine/API/EntityAPI.h>
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
#include <MC/JsonHelpers.hpp>
|
||||
#include <third-party/Nlohmann/json.hpp>
|
||||
|
||||
|
||||
//////////////////// Class Definition ////////////////////
|
||||
@ -101,7 +101,7 @@ Local<Value> convertResult(DynamicCommand::Result const& result) {
|
||||
case DynamicCommand::ParameterType::RawText:
|
||||
return String::newString(result.getRaw<std::string>());
|
||||
case DynamicCommand::ParameterType::JsonValue:
|
||||
return String::newString(JsonHelpers::serialize(result.getRaw<Json::Value>()));
|
||||
return String::newString(result.getRaw<Json::Value>().toStyledString());//这里可能会有问题原本使用JsonHelpers::serialize
|
||||
case DynamicCommand::ParameterType::Item:
|
||||
return ItemClass::newItem(new ItemStack(result.getRaw<CommandItem>().createInstance(1, 1, nullptr, true).value_or(ItemInstance::EMPTY_ITEM)));
|
||||
case DynamicCommand::ParameterType::Block:
|
||||
|
@ -34,7 +34,7 @@ ClassDefine<CommandOriginClass> CommandOriginClassBuilder =
|
||||
.instanceProperty("entity", &CommandOriginClass::getEntity)
|
||||
.instanceProperty("player", &CommandOriginClass::getPlayer)
|
||||
|
||||
.instanceFunction("getNbt", &CommandOriginClass::getNbt)
|
||||
// .instanceFunction("getNbt", &CommandOriginClass::getNbt)
|
||||
.instanceFunction("toString", &CommandOriginClass::toString)
|
||||
|
||||
.build();
|
||||
@ -107,12 +107,12 @@ Local<Value> CommandOriginClass::getPlayer() {
|
||||
CATCH("Fail in getPlayer!");
|
||||
}
|
||||
|
||||
Local<Value> CommandOriginClass::getNbt(const Arguments& args) {
|
||||
try {
|
||||
return NbtCompoundClass::pack(std::make_unique<CompoundTag>(get()->serialize()));
|
||||
}
|
||||
CATCH("Fail in getNbt!");
|
||||
}
|
||||
//Local<Value> CommandOriginClass::getNbt(const Arguments& args) {
|
||||
// try {
|
||||
// return NbtCompoundClass::pack(std::make_unique<CompoundTag>(get()->serialize_1()));
|
||||
// }
|
||||
// CATCH("Fail in getNbt!");
|
||||
//}
|
||||
|
||||
Local<Value> CommandOriginClass::toString() {
|
||||
try {
|
||||
|
@ -23,6 +23,6 @@ public:
|
||||
Local<Value> getPosition();
|
||||
Local<Value> getEntity();
|
||||
Local<Value> getPlayer();
|
||||
Local<Value> getNbt(const Arguments& args);
|
||||
// Local<Value> getNbt(const Arguments& args);
|
||||
Local<Value> toString();
|
||||
};
|
||||
|
@ -75,12 +75,12 @@ ClassDefine<EntityClass> EntityClassBuilder =
|
||||
.instanceFunction("setNbt", &EntityClass::setNbt)
|
||||
.instanceFunction("getNbt", &EntityClass::getNbt)
|
||||
.instanceFunction("addTag", &EntityClass::addTag)
|
||||
.instanceFunction("removeTag", &EntityClass::removeTag)
|
||||
// .instanceFunction("removeTag", &EntityClass::removeTag)
|
||||
.instanceFunction("hasTag", &EntityClass::hasTag)
|
||||
.instanceFunction("getAllTags", &EntityClass::getAllTags)
|
||||
.instanceFunction("getEntityFromViewVector", &EntityClass::getEntityFromViewVector)
|
||||
.instanceFunction("getBlockFromViewVector", &EntityClass::getBlockFromViewVector)
|
||||
.instanceFunction("quickEvalMolangScript", &EntityClass::quickEvalMolangScript)
|
||||
// .instanceFunction("getBlockFromViewVector", &EntityClass::getBlockFromViewVector)
|
||||
// .instanceFunction("quickEvalMolangScript", &EntityClass::quickEvalMolangScript)
|
||||
|
||||
// For Compatibility
|
||||
.instanceFunction("setTag", &EntityClass::setNbt)
|
||||
@ -202,7 +202,8 @@ Local<Value> EntityClass::isInsidePortal() {
|
||||
if (!entity)
|
||||
return Local<Value>();
|
||||
|
||||
return Boolean::newBoolean(entity->isInsidePortal());
|
||||
// return Boolean::newBoolean(entity->isInsidePortal());
|
||||
Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in isInsidePortal!")
|
||||
}
|
||||
@ -213,7 +214,8 @@ Local<Value> EntityClass::isTrusting() {
|
||||
if (!entity)
|
||||
return Local<Value>();
|
||||
|
||||
return Boolean::newBoolean(entity->isTrusting());
|
||||
// return Boolean::newBoolean(entity->isTrusting());
|
||||
Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in isTrusting!")
|
||||
}
|
||||
@ -224,7 +226,8 @@ Local<Value> EntityClass::isTouchingDamageBlock() {
|
||||
if (!entity)
|
||||
return Local<Value>();
|
||||
|
||||
return Boolean::newBoolean(entity->isTouchingDamageBlock());
|
||||
// return Boolean::newBoolean(entity->isTouchingDamageBlock());
|
||||
Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in isTouchingDamageBlock!")
|
||||
}
|
||||
@ -312,7 +315,8 @@ Local<Value> EntityClass::isAngry() {
|
||||
if (!entity)
|
||||
return Local<Value>();
|
||||
|
||||
return Boolean::newBoolean(entity->isAngry());
|
||||
// return Boolean::newBoolean(entity->isAngry());
|
||||
Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in isAngry!")
|
||||
}
|
||||
@ -379,7 +383,8 @@ Local<Value> EntityClass::getMaxHealth() {
|
||||
if (!entity)
|
||||
return Local<Value>();
|
||||
|
||||
return Number::newNumber(entity->getMaxHealth());
|
||||
// return Number::newNumber(entity->getMaxHealth());
|
||||
return Number::newNumber(-1);
|
||||
}
|
||||
CATCH("Fail in GetMaxHealth!")
|
||||
}
|
||||
@ -390,7 +395,8 @@ Local<Value> EntityClass::getHealth() {
|
||||
if (!entity)
|
||||
return Local<Value>();
|
||||
|
||||
return Number::newNumber(entity->getHealth());
|
||||
// return Number::newNumber(entity->getHealth());
|
||||
return Number::newNumber(-1);
|
||||
}
|
||||
CATCH("Fail in GetHealth!")
|
||||
}
|
||||
@ -401,7 +407,8 @@ Local<Value> EntityClass::getCanFly() {
|
||||
if (!entity)
|
||||
return Local<Value>();
|
||||
|
||||
return Boolean::newBoolean(entity->canFly());
|
||||
// return Boolean::newBoolean(entity->canFly());
|
||||
return Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in getCanFly!")
|
||||
}
|
||||
@ -412,7 +419,8 @@ Local<Value> EntityClass::getCanFreeze() {
|
||||
if (!entity)
|
||||
return Local<Value>();
|
||||
|
||||
return Boolean::newBoolean(entity->canFreeze());
|
||||
// return Boolean::newBoolean(entity->canFreeze());
|
||||
return Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in getCanFreeze!")
|
||||
}
|
||||
@ -423,7 +431,8 @@ Local<Value> EntityClass::getCanSeeDaylight() {
|
||||
if (!entity)
|
||||
return Local<Value>();
|
||||
|
||||
return Boolean::newBoolean(entity->canSeeDaylight());
|
||||
// return Boolean::newBoolean(entity->canSeeDaylight());
|
||||
return Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in getCanSeeDaylight!")
|
||||
}
|
||||
@ -434,7 +443,8 @@ Local<Value> EntityClass::getCanPickupItems() {
|
||||
if (!entity)
|
||||
return Local<Value>();
|
||||
|
||||
return Boolean::newBoolean(entity->getCanPickupItems());
|
||||
// return Boolean::newBoolean(entity->getCanPickupItems());
|
||||
return Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in getCanPickupItems!")
|
||||
}
|
||||
@ -467,7 +477,8 @@ Local<Value> EntityClass::getInClouds() {
|
||||
if (!entity)
|
||||
return Local<Value>();
|
||||
|
||||
return Boolean::newBoolean(entity->isInClouds());
|
||||
// return Boolean::newBoolean(entity->isInClouds());
|
||||
return Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in getInClouds!")
|
||||
}
|
||||
@ -500,7 +511,8 @@ Local<Value> EntityClass::getInSnow() {
|
||||
if (!entity)
|
||||
return Local<Value>();
|
||||
|
||||
return Boolean::newBoolean(entity->isInSnow());
|
||||
// return Boolean::newBoolean(entity->isInSnow());
|
||||
return Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in getInSnow!")
|
||||
}
|
||||
@ -533,7 +545,8 @@ Local<Value> EntityClass::getInWorld() {
|
||||
if (!entity)
|
||||
return Local<Value>();
|
||||
|
||||
return Boolean::newBoolean(entity->isInWorld());
|
||||
// return Boolean::newBoolean(entity->isInWorld());
|
||||
return Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in getInWorld!")
|
||||
}
|
||||
@ -544,7 +557,8 @@ Local<Value> EntityClass::getSpeed() {
|
||||
if (!entity)
|
||||
return Local<Value>();
|
||||
|
||||
return Number::newNumber(entity->getSpeedInMetersPerSecond());
|
||||
// return Number::newNumber(entity->getSpeedInMetersPerSecond());
|
||||
return Number::newNumber(-1);
|
||||
}
|
||||
CATCH("Fail in getSpeed!")
|
||||
}
|
||||
@ -773,8 +787,8 @@ Local<Value> EntityClass::setOnFire(const Arguments& args) {
|
||||
return Local<Value>();
|
||||
|
||||
int time = args[0].toInt();
|
||||
bool result = entity->setOnFire(time, true);
|
||||
return Boolean::newBoolean(result);
|
||||
entity->setOnFire(time);
|
||||
return Boolean::newBoolean(1);
|
||||
}
|
||||
CATCH("Fail in setOnFire!")
|
||||
}
|
||||
@ -821,19 +835,19 @@ Local<Value> EntityClass::addTag(const Arguments& args) {
|
||||
CATCH("Fail in addTag!");
|
||||
}
|
||||
|
||||
Local<Value> EntityClass::removeTag(const Arguments& args) {
|
||||
CHECK_ARGS_COUNT(args, 1);
|
||||
CHECK_ARG_TYPE(args[0], ValueKind::kString);
|
||||
|
||||
try {
|
||||
Actor* entity = get();
|
||||
if (!entity)
|
||||
return Local<Value>();
|
||||
|
||||
return Boolean::newBoolean(entity->removeTag(args[0].toStr()));
|
||||
}
|
||||
CATCH("Fail in removeTag!");
|
||||
}
|
||||
//Local<Value> EntityClass::removeTag(const Arguments& args) {
|
||||
// CHECK_ARGS_COUNT(args, 1);
|
||||
// CHECK_ARG_TYPE(args[0], ValueKind::kString);
|
||||
//
|
||||
// try {
|
||||
// Actor* entity = get();
|
||||
// if (!entity)
|
||||
// return Local<Value>();
|
||||
//
|
||||
// return Boolean::newBoolean(entity->removeTag(args[0].toStr()));
|
||||
// }
|
||||
// CATCH("Fail in removeTag!");
|
||||
//}
|
||||
|
||||
Local<Value> EntityClass::hasTag(const Arguments& args) {
|
||||
CHECK_ARGS_COUNT(args, 1);
|
||||
@ -883,51 +897,51 @@ Local<Value> EntityClass::getEntityFromViewVector(const Arguments& args) {
|
||||
CATCH("Fail in getEntityFromViewVector!");
|
||||
}
|
||||
|
||||
Local<Value> EntityClass::getBlockFromViewVector(const Arguments& args) {
|
||||
try {
|
||||
Actor* actor = get();
|
||||
if (!actor)
|
||||
return Local<Value>();
|
||||
bool includeLiquid = false;
|
||||
bool solidOnly = false;
|
||||
float maxDistance = 5.25f;
|
||||
bool ignoreBorderBlocks = true;
|
||||
bool fullOnly = false;
|
||||
if (args.size() > 0) {
|
||||
CHECK_ARG_TYPE(args[0], ValueKind::kBoolean);
|
||||
includeLiquid = args[0].asBoolean().value();
|
||||
}
|
||||
if (args.size() > 1) {
|
||||
CHECK_ARG_TYPE(args[1], ValueKind::kBoolean);
|
||||
solidOnly = args[1].asBoolean().value();
|
||||
}
|
||||
if (args.size() > 2) {
|
||||
CHECK_ARG_TYPE(args[2], ValueKind::kNumber);
|
||||
maxDistance = args[2].asNumber().toFloat();
|
||||
}
|
||||
if (args.size() > 3) {
|
||||
CHECK_ARG_TYPE(args[3], ValueKind::kBoolean);
|
||||
fullOnly = args[3].asBoolean().value();
|
||||
}
|
||||
auto blockInstance = actor->getBlockFromViewVector(includeLiquid, solidOnly, maxDistance, ignoreBorderBlocks, fullOnly);
|
||||
if (blockInstance.isNull())
|
||||
return Local<Value>();
|
||||
return BlockClass::newBlock(std::move(blockInstance));
|
||||
}
|
||||
CATCH("Fail in getBlockFromViewVector!");
|
||||
}
|
||||
//Local<Value> EntityClass::getBlockFromViewVector(const Arguments& args) {
|
||||
// try {
|
||||
// Actor* actor = get();
|
||||
// if (!actor)
|
||||
// return Local<Value>();
|
||||
// bool includeLiquid = false;
|
||||
// bool solidOnly = false;
|
||||
// float maxDistance = 5.25f;
|
||||
// bool ignoreBorderBlocks = true;
|
||||
// bool fullOnly = false;
|
||||
// if (args.size() > 0) {
|
||||
// CHECK_ARG_TYPE(args[0], ValueKind::kBoolean);
|
||||
// includeLiquid = args[0].asBoolean().value();
|
||||
// }
|
||||
// if (args.size() > 1) {
|
||||
// CHECK_ARG_TYPE(args[1], ValueKind::kBoolean);
|
||||
// solidOnly = args[1].asBoolean().value();
|
||||
// }
|
||||
// if (args.size() > 2) {
|
||||
// CHECK_ARG_TYPE(args[2], ValueKind::kNumber);
|
||||
// maxDistance = args[2].asNumber().toFloat();
|
||||
// }
|
||||
// if (args.size() > 3) {
|
||||
// CHECK_ARG_TYPE(args[3], ValueKind::kBoolean);
|
||||
// fullOnly = args[3].asBoolean().value();
|
||||
// }
|
||||
// auto blockInstance = actor->getBlockFromViewVector(includeLiquid, solidOnly, maxDistance, ignoreBorderBlocks, fullOnly);
|
||||
// if (blockInstance.isNull())
|
||||
// return Local<Value>();
|
||||
// return BlockClass::newBlock(std::move(blockInstance));
|
||||
// }
|
||||
// CATCH("Fail in getBlockFromViewVector!");
|
||||
//}
|
||||
|
||||
Local<Value> EntityClass::quickEvalMolangScript(const Arguments& args) {
|
||||
CHECK_ARGS_COUNT(args, 1);
|
||||
CHECK_ARG_TYPE(args[0], ValueKind::kString);
|
||||
try {
|
||||
Actor* actor = get();
|
||||
if (!actor)
|
||||
return Local<Value>();
|
||||
return Number::newNumber(actor->quickEvalMolangScript(args[0].toStr()));
|
||||
}
|
||||
CATCH("Fail in quickEvalMolangScript!");
|
||||
}
|
||||
//Local<Value> EntityClass::quickEvalMolangScript(const Arguments& args) {
|
||||
// CHECK_ARGS_COUNT(args, 1);
|
||||
// CHECK_ARG_TYPE(args[0], ValueKind::kString);
|
||||
// try {
|
||||
// Actor* actor = get();
|
||||
// if (!actor)
|
||||
// return Local<Value>();
|
||||
// return Number::newNumber(actor->quickEvalMolangScript(args[0].toStr()));
|
||||
// }
|
||||
// CATCH("Fail in quickEvalMolangScript!");
|
||||
//}
|
||||
|
||||
Local<Value> McClass::getAllEntities(const Arguments& args) {
|
||||
try {
|
||||
|
@ -77,13 +77,13 @@ public:
|
||||
Local<Value> getNbt(const Arguments& args);
|
||||
Local<Value> setNbt(const Arguments& args);
|
||||
Local<Value> addTag(const Arguments& args);
|
||||
Local<Value> removeTag(const Arguments& args);
|
||||
// Local<Value> removeTag(const Arguments& args);
|
||||
Local<Value> hasTag(const Arguments& args);
|
||||
Local<Value> getAllTags(const Arguments& args);
|
||||
Local<Value> getEntityFromViewVector(const Arguments& args);
|
||||
Local<Value> getBlockFromViewVector(const Arguments& args);
|
||||
// Local<Value> getBlockFromViewVector(const Arguments& args);
|
||||
|
||||
Local<Value> quickEvalMolangScript(const Arguments& args);
|
||||
// Local<Value> quickEvalMolangScript(const Arguments& args);
|
||||
};
|
||||
extern ClassDefine<EntityClass> EntityClassBuilder;
|
||||
extern ClassDefine<void> ActorDamageCauseBuilder;
|
@ -765,10 +765,10 @@ void EnableEventListener(int eventId) {
|
||||
else
|
||||
source = Level::getEntity(ev.mDamageSource->getDamagingEntityUniqueID());
|
||||
}
|
||||
|
||||
//TODO 此处的伤害无法获取
|
||||
CallEvent(EVENT_TYPES::onMobHurt, EntityClass::newEntity(ev.mMob),
|
||||
source ? EntityClass::newEntity(source) : Local<Value>(),
|
||||
float(ev.mDamage), Number::newNumber((int)ev.mDamageSource->getCause()));
|
||||
float(ev.mDamage), Number::newNumber(0));
|
||||
}
|
||||
IF_LISTENED_END(EVENT_TYPES::onMobHurt)
|
||||
});
|
||||
@ -792,9 +792,9 @@ void EnableEventListener(int eventId) {
|
||||
if (ev.mDamageSource->isChildEntitySource())
|
||||
source = source->getOwner();
|
||||
}
|
||||
|
||||
//TODO 此处的伤害无法获取
|
||||
CallEvent(EVENT_TYPES::onMobDie, EntityClass::newEntity((Actor*)ev.mMob),
|
||||
(source ? EntityClass::newEntity(source) : Local<Value>()), Number::newNumber((int)ev.mDamageSource->getCause()));
|
||||
(source ? EntityClass::newEntity(source) : Local<Value>()), Number::newNumber(0));
|
||||
}
|
||||
IF_LISTENED_END(EVENT_TYPES::onMobDie);
|
||||
});
|
||||
|
@ -37,9 +37,9 @@ Local<Value> GlobalNativePointer::getScoreboardPtr(const Arguments& args) {
|
||||
return NativePointer::newNativePointer(Global<Scoreboard>);
|
||||
}
|
||||
|
||||
Local<Value> GlobalNativePointer::getAllowListFilePtr(const Arguments& args) {
|
||||
return NativePointer::newNativePointer(Global<AllowListFile>);
|
||||
}
|
||||
//Local<Value> GlobalNativePointer::getAllowListFilePtr(const Arguments& args) {
|
||||
// return NativePointer::newNativePointer(Global<AllowListFile>);
|
||||
//}
|
||||
|
||||
Local<Value> GlobalNativePointer::getPropertiesSettingsPtr(const Arguments& args) {
|
||||
return NativePointer::newNativePointer(Global<PropertiesSettings>);
|
||||
@ -57,6 +57,6 @@ ClassDefine<GlobalNativePointer> GlobalNativePointerBuilder =
|
||||
.function("RakNetServerLocator", &GlobalNativePointer::getRakNetServerLocatorPtr)
|
||||
.function("RakNetRakPeer", &GlobalNativePointer::getRakNetRakPeerPtr)
|
||||
.function("Scoreboard", &GlobalNativePointer::getScoreboardPtr)
|
||||
.function("AllowListFile", &GlobalNativePointer::getAllowListFilePtr)
|
||||
// .function("AllowListFile", &GlobalNativePointer::getAllowListFilePtr)
|
||||
.function("PropertiesSettings", &GlobalNativePointer::getPropertiesSettingsPtr)
|
||||
.build();
|
||||
|
@ -17,7 +17,7 @@ ClassDefine<void> McClassBuilder =
|
||||
.function("spawnMob", &McClass::spawnMob)
|
||||
.function("cloneMob", &McClass::cloneMob)
|
||||
.function("spawnItem", &McClass::spawnItem)
|
||||
.function("spawnSimulatedPlayer", &McClass::spawnSimulatedPlayer)
|
||||
// .function("spawnSimulatedPlayer", &McClass::spawnSimulatedPlayer)
|
||||
.function("explode", &McClass::explode)
|
||||
.function("getBlock", &McClass::getBlock)
|
||||
.function("setBlock", &McClass::setBlock)
|
||||
@ -43,5 +43,5 @@ ClassDefine<void> McClassBuilder =
|
||||
.function("getAllScoreObjective", &McClass::getAllScoreObjectives)
|
||||
.function("getDisplayObjectives", &McClass::getDisplayObjective)
|
||||
.function("crash", &McClass::crashBDS)
|
||||
.function("setMaxPlayers", &McClass::setMaxNumPlayers)
|
||||
// .function("setMaxPlayers", &McClass::setMaxNumPlayers)
|
||||
.build();
|
||||
|
@ -23,7 +23,7 @@ public:
|
||||
static Local<Value> newItem(const Arguments& args);
|
||||
static Local<Value> spawnMob(const Arguments& args);
|
||||
static Local<Value> spawnItem(const Arguments& args);
|
||||
static Local<Value> spawnSimulatedPlayer(const Arguments& args);
|
||||
// static Local<Value> spawnSimulatedPlayer(const Arguments& args);
|
||||
static Local<Value> explode(const Arguments& args);
|
||||
static Local<Value> cloneMob(const Arguments& args);
|
||||
|
||||
@ -39,7 +39,7 @@ public:
|
||||
static Local<Value> sendCmdOutput(const Arguments& args);
|
||||
static Local<Value> crashBDS(const Arguments& args);
|
||||
|
||||
static Local<Value> setMaxNumPlayers(const Arguments& args);
|
||||
// static Local<Value> setMaxNumPlayers(const Arguments& args);
|
||||
|
||||
static Local<Value> newIntPos(const Arguments& args);
|
||||
static Local<Value> newFloatPos(const Arguments& args);
|
||||
|
@ -418,7 +418,7 @@ Local<Value> BinaryStreamClass::writeVec3(const Arguments& args) {
|
||||
return Local<Value>();
|
||||
}
|
||||
FloatPos* posObj = FloatPos::extractPos(args[0]);
|
||||
pkt->writeType<Vec3>(posObj->getVec3());
|
||||
pkt->writeType(posObj->getVec3());
|
||||
return Boolean::newBoolean(true);
|
||||
}
|
||||
CATCH("Fail in BinaryStream writeVec3!");
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include <MC/ScoreboardId.hpp>
|
||||
#include <MC/ListTag.hpp>
|
||||
#include <MC/CompoundTag.hpp>
|
||||
#include <MC/SimulatedPlayer.hpp>
|
||||
#include <MC/BlockSource.hpp>
|
||||
#include <PlayerInfoAPI.h>
|
||||
#include <SafeGuardRecord.h>
|
||||
@ -88,7 +87,7 @@ ClassDefine<PlayerClass> PlayerClassBuilder =
|
||||
.instanceProperty("isAdventure", &PlayerClass::isAdventure)
|
||||
.instanceProperty("isGliding", &PlayerClass::isGliding)
|
||||
.instanceProperty("isSurvival", &PlayerClass::isSurvival)
|
||||
.instanceProperty("isSpectator", &PlayerClass::isSpectator)
|
||||
// .instanceProperty("isSpectator", &PlayerClass::isSpectator)
|
||||
.instanceProperty("isRiding", &PlayerClass::isRiding)
|
||||
.instanceProperty("isDancing", &PlayerClass::isDancing)
|
||||
.instanceProperty("isCreative", &PlayerClass::isCreative)
|
||||
@ -112,12 +111,12 @@ ClassDefine<PlayerClass> PlayerClassBuilder =
|
||||
.instanceFunction("transServer", &PlayerClass::transServer)
|
||||
.instanceFunction("crash", &PlayerClass::crash)
|
||||
.instanceFunction("hurt", &PlayerClass::hurt)
|
||||
.instanceFunction("refreshChunks", &PlayerClass::refreshChunks)
|
||||
// .instanceFunction("refreshChunks", &PlayerClass::refreshChunks)
|
||||
.instanceFunction("giveItem", &PlayerClass::giveItem)
|
||||
.instanceFunction("clearItem", &PlayerClass::clearItem)
|
||||
.instanceFunction("isSprinting", &PlayerClass::isSprinting)
|
||||
.instanceFunction("setSprinting", &PlayerClass::setSprinting)
|
||||
.instanceFunction("sendToast", &PlayerClass::sendToast)
|
||||
// .instanceFunction("sendToast", &PlayerClass::sendToast)
|
||||
|
||||
.instanceFunction("getBlockStandingOn", &PlayerClass::getBlockStandingOn)
|
||||
.instanceFunction("getDevice", &PlayerClass::getDevice)
|
||||
@ -165,35 +164,35 @@ ClassDefine<PlayerClass> PlayerClassBuilder =
|
||||
.instanceFunction("setNbt", &PlayerClass::setNbt)
|
||||
.instanceFunction("getNbt", &PlayerClass::getNbt)
|
||||
.instanceFunction("addTag", &PlayerClass::addTag)
|
||||
.instanceFunction("removeTag", &PlayerClass::removeTag)
|
||||
// .instanceFunction("removeTag", &PlayerClass::removeTag)
|
||||
.instanceFunction("hasTag", &PlayerClass::hasTag)
|
||||
.instanceFunction("getAllTags", &PlayerClass::getAllTags)
|
||||
.instanceFunction("getAbilities", &PlayerClass::getAbilities)
|
||||
.instanceFunction("getAttributes", &PlayerClass::getAttributes)
|
||||
.instanceFunction("getEntityFromViewVector", &PlayerClass::getEntityFromViewVector)
|
||||
.instanceFunction("getBlockFromViewVector", &PlayerClass::getBlockFromViewVector)
|
||||
.instanceFunction("quickEvalMolangScript", &PlayerClass::quickEvalMolangScript)
|
||||
// .instanceFunction("getBlockFromViewVector", &PlayerClass::getBlockFromViewVector)
|
||||
// .instanceFunction("quickEvalMolangScript", &PlayerClass::quickEvalMolangScript)
|
||||
|
||||
// SimulatedPlayer API
|
||||
.instanceFunction("isSimulatedPlayer", &PlayerClass::isSimulatedPlayer)
|
||||
.instanceFunction("simulateSneak", &PlayerClass::simulateSneak)
|
||||
.instanceFunction("simulateAttack", &PlayerClass::simulateAttack)
|
||||
.instanceFunction("simulateDestroy", &PlayerClass::simulateDestroy)
|
||||
.instanceFunction("simulateDisconnect", &PlayerClass::simulateDisconnect)
|
||||
.instanceFunction("simulateInteract", &PlayerClass::simulateInteract)
|
||||
.instanceFunction("simulateJump", &PlayerClass::simulateJump)
|
||||
.instanceFunction("simulateLocalMove", &PlayerClass::simulateLocalMove)
|
||||
.instanceFunction("simulateWorldMove", &PlayerClass::simulateWorldMove)
|
||||
.instanceFunction("simulateMoveTo", &PlayerClass::simulateMoveTo)
|
||||
.instanceFunction("simulateLookAt", &PlayerClass::simulateLookAt)
|
||||
.instanceFunction("simulateSetBodyRotation", &PlayerClass::simulateSetBodyRotation)
|
||||
.instanceFunction("simulateNavigateTo", &PlayerClass::simulateNavigateTo)
|
||||
.instanceFunction("simulateUseItem", &PlayerClass::simulateUseItem)
|
||||
.instanceFunction("simulateStopDestroyingBlock", &PlayerClass::simulateStopDestroyingBlock)
|
||||
.instanceFunction("simulateStopInteracting", &PlayerClass::simulateStopInteracting)
|
||||
.instanceFunction("simulateStopMoving", &PlayerClass::simulateStopMoving)
|
||||
.instanceFunction("simulateStopUsingItem", &PlayerClass::simulateStopUsingItem)
|
||||
.instanceFunction("simulateStopSneaking", &PlayerClass::simulateStopSneaking)
|
||||
// .instanceFunction("isSimulatedPlayer", &PlayerClass::isSimulatedPlayer)
|
||||
// .instanceFunction("simulateSneak", &PlayerClass::simulateSneak)
|
||||
// .instanceFunction("simulateAttack", &PlayerClass::simulateAttack)
|
||||
// .instanceFunction("simulateDestroy", &PlayerClass::simulateDestroy)
|
||||
// .instanceFunction("simulateDisconnect", &PlayerClass::simulateDisconnect)
|
||||
// .instanceFunction("simulateInteract", &PlayerClass::simulateInteract)
|
||||
// .instanceFunction("simulateJump", &PlayerClass::simulateJump)
|
||||
// .instanceFunction("simulateLocalMove", &PlayerClass::simulateLocalMove)
|
||||
// .instanceFunction("simulateWorldMove", &PlayerClass::simulateWorldMove)
|
||||
// .instanceFunction("simulateMoveTo", &PlayerClass::simulateMoveTo)
|
||||
// .instanceFunction("simulateLookAt", &PlayerClass::simulateLookAt)
|
||||
// .instanceFunction("simulateSetBodyRotation", &PlayerClass::simulateSetBodyRotation)
|
||||
// .instanceFunction("simulateNavigateTo", &PlayerClass::simulateNavigateTo)
|
||||
// .instanceFunction("simulateUseItem", &PlayerClass::simulateUseItem)
|
||||
// .instanceFunction("simulateStopDestroyingBlock", &PlayerClass::simulateStopDestroyingBlock)
|
||||
// .instanceFunction("simulateStopInteracting", &PlayerClass::simulateStopInteracting)
|
||||
// .instanceFunction("simulateStopMoving", &PlayerClass::simulateStopMoving)
|
||||
// .instanceFunction("simulateStopUsingItem", &PlayerClass::simulateStopUsingItem)
|
||||
// .instanceFunction("simulateStopSneaking", &PlayerClass::simulateStopSneaking)
|
||||
|
||||
// For Compatibility
|
||||
.instanceProperty("ip", &PlayerClass::getIP)
|
||||
@ -339,15 +338,16 @@ Local<Value> PlayerClass::getBlockPos() {
|
||||
}
|
||||
CATCH("Fail in getPlayerBlockPos!")
|
||||
}
|
||||
|
||||
//TODO 有函数没有
|
||||
Local<Value> PlayerClass::getLastDeathPos() {
|
||||
try {
|
||||
Player* player = get();
|
||||
if (!player || player->hasDiedBefore()) {
|
||||
return Local<Value>();
|
||||
}
|
||||
|
||||
return IntPos::newPos(player->getLastDeathPos().value(), player->getLastDeathDimension().value());
|
||||
// Player* player = get();
|
||||
// if (!player || player->hasDiedBefore()) {
|
||||
// return Local<Value>();
|
||||
// }
|
||||
//
|
||||
// return IntPos::newPos(player->getLastDeathPos().value(), player->getLastDeathDimension().value());
|
||||
return Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in getLastDeathPos!")
|
||||
}
|
||||
@ -420,36 +420,39 @@ Local<Value> PlayerClass::getPermLevel() {
|
||||
}
|
||||
CATCH("Fail in getPlayerPermLevel!")
|
||||
}
|
||||
|
||||
//TODO 有函数没有
|
||||
Local<Value> PlayerClass::getGameMode() {
|
||||
try {
|
||||
Player* player = get();
|
||||
if (!player)
|
||||
return Local<Value>();
|
||||
|
||||
return Number::newNumber((int)player->getPlayerGameType()); //==========???
|
||||
// return Number::newNumber((int)player->getPlayerGameType()); //==========???
|
||||
return Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in getGameMode!")
|
||||
}
|
||||
|
||||
//TODO 有函数没有
|
||||
Local<Value> PlayerClass::getCanSleep() {
|
||||
try {
|
||||
Player* player = get();
|
||||
if (!player)
|
||||
return Local<Value>();
|
||||
|
||||
return Boolean::newBoolean(player->canSleep());
|
||||
// return Boolean::newBoolean(player->canSleep());
|
||||
return Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in getCanSleep!")
|
||||
}
|
||||
|
||||
//TODO 有函数没有
|
||||
Local<Value> PlayerClass::getCanFly() {
|
||||
try {
|
||||
Player* player = get();
|
||||
if (!player)
|
||||
return Local<Value>();
|
||||
|
||||
return Boolean::newBoolean(player->canFly());
|
||||
// return Boolean::newBoolean(player->canFly());
|
||||
return Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in getCanFly!")
|
||||
}
|
||||
@ -465,7 +468,7 @@ Local<Value> PlayerClass::getCanBeSeenOnMap() {
|
||||
}
|
||||
CATCH("Fail in getCanBeSeenOnMap!")
|
||||
}
|
||||
|
||||
//TODO 有函数没有
|
||||
Local<Value> PlayerClass::getCanFreeze() {
|
||||
try {
|
||||
Player* player = get();
|
||||
@ -473,11 +476,12 @@ Local<Value> PlayerClass::getCanFreeze() {
|
||||
return Local<Value>();
|
||||
}
|
||||
|
||||
return Boolean::newBoolean(player->canFreeze());
|
||||
// return Boolean::newBoolean(player->canFreeze());
|
||||
return Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in getCanFreeze!")
|
||||
}
|
||||
|
||||
//TODO 有函数没有
|
||||
Local<Value> PlayerClass::getCanSeeDaylight() {
|
||||
try {
|
||||
Player* player = get();
|
||||
@ -485,7 +489,8 @@ Local<Value> PlayerClass::getCanSeeDaylight() {
|
||||
return Local<Value>();
|
||||
}
|
||||
|
||||
return Boolean::newBoolean(player->canSeeDaylight());
|
||||
// return Boolean::newBoolean(player->canSeeDaylight());
|
||||
return Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in getCanSeeDaylight!")
|
||||
}
|
||||
@ -513,7 +518,7 @@ Local<Value> PlayerClass::getCanStartSleepInBed() {
|
||||
}
|
||||
CATCH("Fail in getCanStartSleepInBed!")
|
||||
}
|
||||
|
||||
//TODO 有函数没有
|
||||
Local<Value> PlayerClass::getCanPickupItems() {
|
||||
try {
|
||||
Player* player = get();
|
||||
@ -521,7 +526,8 @@ Local<Value> PlayerClass::getCanPickupItems() {
|
||||
return Local<Value>();
|
||||
}
|
||||
|
||||
return Boolean::newBoolean(player->getCanPickupItems());
|
||||
// return Boolean::newBoolean(player->getCanPickupItems());
|
||||
return Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in getCanPickupItems!")
|
||||
}
|
||||
@ -559,25 +565,27 @@ Local<Value> PlayerClass::getDirection() {
|
||||
}
|
||||
CATCH("Fail in getDirection!")
|
||||
}
|
||||
|
||||
//TODO 有函数没有
|
||||
Local<Value> PlayerClass::getMaxHealth() {
|
||||
try {
|
||||
Player* player = get();
|
||||
if (!player)
|
||||
return Local<Value>();
|
||||
|
||||
return Number::newNumber(player->getMaxHealth());
|
||||
// return Number::newNumber(player->getMaxHealth());
|
||||
return Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in GetMaxHealth!")
|
||||
}
|
||||
|
||||
//TODO 有函数没有
|
||||
Local<Value> PlayerClass::getHealth() {
|
||||
try {
|
||||
Player* player = get();
|
||||
if (!player)
|
||||
return Local<Value>();
|
||||
|
||||
return Number::newNumber(player->getHealth());
|
||||
// return Number::newNumber(player->getHealth());
|
||||
return Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in GetHealth!")
|
||||
}
|
||||
@ -625,14 +633,15 @@ Local<Value> PlayerClass::getInRain() {
|
||||
}
|
||||
CATCH("Fail in getInRain!")
|
||||
}
|
||||
|
||||
//TODO 有函数没有
|
||||
Local<Value> PlayerClass::getInSnow() {
|
||||
try {
|
||||
Player* player = get();
|
||||
if (!player)
|
||||
return Local<Value>();
|
||||
|
||||
return Boolean::newBoolean(player->isInSnow());
|
||||
// return Boolean::newBoolean(player->isInSnow());
|
||||
return Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in getInSnow!")
|
||||
}
|
||||
@ -658,18 +667,19 @@ Local<Value> PlayerClass::getInWaterOrRain() {
|
||||
}
|
||||
CATCH("Fail in getInWaterOrRain!")
|
||||
}
|
||||
|
||||
//TODO 有函数没有
|
||||
Local<Value> PlayerClass::getInWorld() {
|
||||
try {
|
||||
Player* player = get();
|
||||
if (!player)
|
||||
return Local<Value>();
|
||||
|
||||
return Boolean::newBoolean(player->isInWorld());
|
||||
// return Boolean::newBoolean(player->isInWorld());
|
||||
return Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in getInWorld!")
|
||||
}
|
||||
|
||||
//TODO 有函数没有
|
||||
Local<Value> PlayerClass::getInClouds() {
|
||||
try {
|
||||
Player* player = get();
|
||||
@ -677,7 +687,8 @@ Local<Value> PlayerClass::getInClouds() {
|
||||
return Local<Value>();
|
||||
}
|
||||
|
||||
return Boolean::newBoolean(player->isInClouds());
|
||||
// return Boolean::newBoolean(player->isInClouds());
|
||||
return Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in getInClouds!")
|
||||
}
|
||||
@ -735,7 +746,7 @@ Local<Value> PlayerClass::isInvisible() {
|
||||
}
|
||||
CATCH("Fail in isInvisible!")
|
||||
}
|
||||
|
||||
//TODO 有函数没有
|
||||
Local<Value> PlayerClass::isInsidePortal() {
|
||||
try {
|
||||
Player* player = get();
|
||||
@ -743,11 +754,12 @@ Local<Value> PlayerClass::isInsidePortal() {
|
||||
return Local<Value>();
|
||||
}
|
||||
|
||||
return Boolean::newBoolean(player->isInsidePortal());
|
||||
// return Boolean::newBoolean(player->isInsidePortal());
|
||||
return Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in isInsidePortal!")
|
||||
}
|
||||
|
||||
//TODO 有函数没有
|
||||
Local<Value> PlayerClass::isHurt() {
|
||||
try {
|
||||
Player* player = get();
|
||||
@ -755,11 +767,12 @@ Local<Value> PlayerClass::isHurt() {
|
||||
return Local<Value>();
|
||||
}
|
||||
|
||||
return Boolean::newBoolean(player->isHurt());
|
||||
// return Boolean::newBoolean(player->isHurt());
|
||||
return Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in isHurt!")
|
||||
}
|
||||
|
||||
//TODO 有函数没有
|
||||
Local<Value> PlayerClass::isTrusting() {
|
||||
try {
|
||||
Player* player = get();
|
||||
@ -767,11 +780,12 @@ Local<Value> PlayerClass::isTrusting() {
|
||||
return Local<Value>();
|
||||
}
|
||||
|
||||
return Boolean::newBoolean(player->isTrusting());
|
||||
// return Boolean::newBoolean(player->isTrusting());
|
||||
return Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in isTrusting!")
|
||||
}
|
||||
|
||||
//TODO 有函数没有
|
||||
Local<Value> PlayerClass::isTouchingDamageBlock() {
|
||||
try {
|
||||
Player* player = get();
|
||||
@ -779,7 +793,8 @@ Local<Value> PlayerClass::isTouchingDamageBlock() {
|
||||
return Local<Value>();
|
||||
}
|
||||
|
||||
return Boolean::newBoolean(player->isTouchingDamageBlock());
|
||||
// return Boolean::newBoolean(player->isTouchingDamageBlock());
|
||||
return Boolean::newBoolean(-1);
|
||||
}
|
||||
CATCH("Fail in isTouchingDamageBlock!")
|
||||
}
|
||||
@ -879,18 +894,18 @@ Local<Value> PlayerClass::isSurvival() {
|
||||
}
|
||||
CATCH("Fail in isSurvival!")
|
||||
}
|
||||
|
||||
Local<Value> PlayerClass::isSpectator() {
|
||||
try {
|
||||
Player* player = get();
|
||||
if (!player) {
|
||||
return Local<Value>();
|
||||
}
|
||||
|
||||
return Boolean::newBoolean(player->isSpectator());
|
||||
}
|
||||
CATCH("Fail in isSpectator!")
|
||||
}
|
||||
//1.16.40还没有完整的旁观模式
|
||||
//Local<Value> PlayerClass::isSpectator() {
|
||||
// try {
|
||||
// Player* player = get();
|
||||
// if (!player) {
|
||||
// return Local<Value>();
|
||||
// }
|
||||
//
|
||||
// return Boolean::newBoolean(player->isSpectator());
|
||||
// }
|
||||
// CATCH("Fail in isSpectator!")
|
||||
//}
|
||||
|
||||
Local<Value> PlayerClass::isRiding() {
|
||||
try {
|
||||
@ -1210,7 +1225,7 @@ Local<Value> PlayerClass::getEnderChest(const Arguments& args) {
|
||||
if (!player)
|
||||
return Local<Value>();
|
||||
|
||||
return ContainerClass::newContainer(player->getEnderChestContainer());
|
||||
return ContainerClass::newContainer((Container*)player->getEnderChestContainer());
|
||||
}
|
||||
CATCH("Fail in getEnderChest!");
|
||||
}
|
||||
@ -1974,8 +1989,8 @@ Local<Value> PlayerClass::setFire(const Arguments& args) {
|
||||
int time = args[0].toInt();
|
||||
bool isEffectValue = args[1].asBoolean().value();
|
||||
|
||||
bool result = player->setOnFire(time, isEffectValue);
|
||||
return Boolean::newBoolean(result);
|
||||
player->setOnFire(time);
|
||||
return Boolean::newBoolean(1);
|
||||
}
|
||||
CATCH("Fail in setOnFire!");
|
||||
}
|
||||
@ -1992,23 +2007,23 @@ Local<Value> PlayerClass::setOnFire(const Arguments& args) {
|
||||
|
||||
int time = args[0].toInt();
|
||||
|
||||
bool result = player->setOnFire(time, true);
|
||||
return Boolean::newBoolean(result);
|
||||
player->setOnFire(time);
|
||||
return Boolean::newBoolean(1);
|
||||
}
|
||||
CATCH("Fail in setOnFire!");
|
||||
}
|
||||
|
||||
Local<Value> PlayerClass::refreshChunks(const Arguments& args) {
|
||||
try {
|
||||
Player* player = get();
|
||||
if (!player)
|
||||
return Local<Value>();
|
||||
|
||||
player->resendAllChunks();
|
||||
return Boolean::newBoolean(true);
|
||||
}
|
||||
CATCH("Fail in refreshChunks!");
|
||||
}
|
||||
//Local<Value> PlayerClass::refreshChunks(const Arguments& args) {
|
||||
// try {
|
||||
// Player* player = get();
|
||||
// if (!player)
|
||||
// return Local<Value>();
|
||||
//
|
||||
// player->resendAllChunks();
|
||||
// return Boolean::newBoolean(true);
|
||||
// }
|
||||
// CATCH("Fail in refreshChunks!");
|
||||
//}
|
||||
|
||||
Local<Value> PlayerClass::giveItem(const Arguments& args) {
|
||||
CHECK_ARGS_COUNT(args, 1);
|
||||
@ -2111,19 +2126,19 @@ Local<Value> PlayerClass::addTag(const Arguments& args) {
|
||||
CATCH("Fail in addTag!");
|
||||
}
|
||||
|
||||
Local<Value> PlayerClass::removeTag(const Arguments& args) {
|
||||
CHECK_ARGS_COUNT(args, 1);
|
||||
CHECK_ARG_TYPE(args[0], ValueKind::kString);
|
||||
|
||||
try {
|
||||
Player* player = get();
|
||||
if (!player)
|
||||
return Local<Value>();
|
||||
|
||||
return Boolean::newBoolean(player->removeTag(args[0].toStr()));
|
||||
}
|
||||
CATCH("Fail in removeTag!");
|
||||
}
|
||||
//Local<Value> PlayerClass::removeTag(const Arguments& args) {
|
||||
// CHECK_ARGS_COUNT(args, 1);
|
||||
// CHECK_ARG_TYPE(args[0], ValueKind::kString);
|
||||
//
|
||||
// try {
|
||||
// Player* player = get();
|
||||
// if (!player)
|
||||
// return Local<Value>();
|
||||
//
|
||||
// return Boolean::newBoolean(player->removeTag(args[0].toStr()));
|
||||
// }
|
||||
// CATCH("Fail in removeTag!");
|
||||
//}
|
||||
|
||||
Local<Value> PlayerClass::hasTag(const Arguments& args) {
|
||||
CHECK_ARGS_COUNT(args, 1);
|
||||
@ -2213,58 +2228,58 @@ Local<Value> PlayerClass::getEntityFromViewVector(const Arguments& args) {
|
||||
CATCH("Fail in getEntityFromViewVector!");
|
||||
}
|
||||
|
||||
Local<Value> PlayerClass::getBlockFromViewVector(const Arguments& args) {
|
||||
try {
|
||||
Player* player = get();
|
||||
if (!player)
|
||||
return Local<Value>();
|
||||
bool includeLiquid = false;
|
||||
bool solidOnly = false;
|
||||
float maxDistance = 5.25f;
|
||||
bool ignoreBorderBlocks = true;
|
||||
bool fullOnly = false;
|
||||
if (args.size() > 0) {
|
||||
CHECK_ARG_TYPE(args[0], ValueKind::kBoolean);
|
||||
includeLiquid = args[0].asBoolean().value();
|
||||
}
|
||||
if (args.size() > 1) {
|
||||
CHECK_ARG_TYPE(args[1], ValueKind::kBoolean);
|
||||
solidOnly = args[1].asBoolean().value();
|
||||
}
|
||||
if (args.size() > 2) {
|
||||
CHECK_ARG_TYPE(args[2], ValueKind::kNumber);
|
||||
maxDistance = args[2].asNumber().toFloat();
|
||||
}
|
||||
if (args.size() > 3) {
|
||||
CHECK_ARG_TYPE(args[3], ValueKind::kBoolean);
|
||||
fullOnly = args[3].asBoolean().value();
|
||||
}
|
||||
auto blockInstance = player->getBlockFromViewVector(includeLiquid, solidOnly, maxDistance, ignoreBorderBlocks, fullOnly);
|
||||
if (blockInstance.isNull())
|
||||
return Local<Value>();
|
||||
return BlockClass::newBlock(std::move(blockInstance));
|
||||
}
|
||||
CATCH("Fail in getBlockFromViewVector!");
|
||||
}
|
||||
//Local<Value> PlayerClass::getBlockFromViewVector(const Arguments& args) {
|
||||
// try {
|
||||
// Player* player = get();
|
||||
// if (!player)
|
||||
// return Local<Value>();
|
||||
// bool includeLiquid = false;
|
||||
// bool solidOnly = false;
|
||||
// float maxDistance = 5.25f;
|
||||
// bool ignoreBorderBlocks = true;
|
||||
// bool fullOnly = false;
|
||||
// if (args.size() > 0) {
|
||||
// CHECK_ARG_TYPE(args[0], ValueKind::kBoolean);
|
||||
// includeLiquid = args[0].asBoolean().value();
|
||||
// }
|
||||
// if (args.size() > 1) {
|
||||
// CHECK_ARG_TYPE(args[1], ValueKind::kBoolean);
|
||||
// solidOnly = args[1].asBoolean().value();
|
||||
// }
|
||||
// if (args.size() > 2) {
|
||||
// CHECK_ARG_TYPE(args[2], ValueKind::kNumber);
|
||||
// maxDistance = args[2].asNumber().toFloat();
|
||||
// }
|
||||
// if (args.size() > 3) {
|
||||
// CHECK_ARG_TYPE(args[3], ValueKind::kBoolean);
|
||||
// fullOnly = args[3].asBoolean().value();
|
||||
// }
|
||||
// auto blockInstance = player->getBlockFromViewVector(includeLiquid, solidOnly, maxDistance, ignoreBorderBlocks, fullOnly);
|
||||
// if (blockInstance.isNull())
|
||||
// return Local<Value>();
|
||||
// return BlockClass::newBlock(std::move(blockInstance));
|
||||
// }
|
||||
// CATCH("Fail in getBlockFromViewVector!");
|
||||
//}
|
||||
|
||||
Local<Value> PlayerClass::isSimulatedPlayer(const Arguments& args) {
|
||||
try {
|
||||
return Boolean::newBoolean(get()->isSimulatedPlayer());
|
||||
}
|
||||
CATCH("Fail in isSimulatedPlayer!");
|
||||
}
|
||||
//Local<Value> PlayerClass::isSimulatedPlayer(const Arguments& args) {
|
||||
// try {
|
||||
// return Boolean::newBoolean(get()->isSimulatedPlayer());
|
||||
// }
|
||||
// CATCH("Fail in isSimulatedPlayer!");
|
||||
//}
|
||||
|
||||
Local<Value> PlayerClass::quickEvalMolangScript(const Arguments& args) {
|
||||
CHECK_ARGS_COUNT(args, 1);
|
||||
CHECK_ARG_TYPE(args[0], ValueKind::kString);
|
||||
try {
|
||||
Player* actor = get();
|
||||
if (!actor)
|
||||
return Local<Value>();
|
||||
return Number::newNumber(actor->quickEvalMolangScript(args[0].toStr()));
|
||||
}
|
||||
CATCH("Fail in quickEvalMolangScript!");
|
||||
}
|
||||
//Local<Value> PlayerClass::quickEvalMolangScript(const Arguments& args) {
|
||||
// CHECK_ARGS_COUNT(args, 1);
|
||||
// CHECK_ARG_TYPE(args[0], ValueKind::kString);
|
||||
// try {
|
||||
// Player* actor = get();
|
||||
// if (!actor)
|
||||
// return Local<Value>();
|
||||
// return Number::newNumber(actor->quickEvalMolangScript(args[0].toStr()));
|
||||
// }
|
||||
// CATCH("Fail in quickEvalMolangScript!");
|
||||
//}
|
||||
|
||||
|
||||
//////////////////// For Compatibility ////////////////////
|
||||
@ -2279,7 +2294,8 @@ Local<Value> PlayerClass::getAllItems(const Arguments& args) {
|
||||
ItemStack* offHand = (ItemStack*)&player->getOffhandSlot();
|
||||
vector<const ItemStack*> inventory = player->getInventory().getAllSlots();
|
||||
vector<const ItemStack*> armor = player->getArmorContainer().getAllSlots();
|
||||
vector<const ItemStack*> endChest = player->getEnderChestContainer()->getAllSlots();
|
||||
auto temp = (Container*)player->getEnderChestContainer();
|
||||
vector<const ItemStack*> endChest = temp->getAllSlots();
|
||||
|
||||
Local<Object> result = Object::newObject();
|
||||
|
||||
@ -2335,18 +2351,18 @@ Local<Value> PlayerClass::removeItem(const Arguments& args) {
|
||||
}
|
||||
|
||||
|
||||
Local<Value> PlayerClass::sendToast(const Arguments& args) {
|
||||
CHECK_ARGS_COUNT(args, 2);
|
||||
CHECK_ARG_TYPE(args[0], ValueKind::kString);
|
||||
CHECK_ARG_TYPE(args[1], ValueKind::kString);
|
||||
try {
|
||||
Player* player = get();
|
||||
|
||||
if (!player)
|
||||
return Local<Value>();
|
||||
|
||||
player->sendToastPacket(args[0].toStr(), args[1].toStr());
|
||||
return Boolean::newBoolean(true);
|
||||
}
|
||||
CATCH("Fail in sendToast!");
|
||||
}
|
||||
//Local<Value> PlayerClass::sendToast(const Arguments& args) {
|
||||
// CHECK_ARGS_COUNT(args, 2);
|
||||
// CHECK_ARG_TYPE(args[0], ValueKind::kString);
|
||||
// CHECK_ARG_TYPE(args[1], ValueKind::kString);
|
||||
// try {
|
||||
// Player* player = get();
|
||||
//
|
||||
// if (!player)
|
||||
// return Local<Value>();
|
||||
//
|
||||
// player->sendToastPacket(args[0].toStr(), args[1].toStr());
|
||||
// return Boolean::newBoolean(true);
|
||||
// }
|
||||
// CATCH("Fail in sendToast!");
|
||||
//}
|
@ -16,7 +16,7 @@ public:
|
||||
|
||||
void set(Player* player);
|
||||
Player* get();
|
||||
SimulatedPlayer* asSimulatedPlayer();
|
||||
//SimulatedPlayer* asSimulatedPlayer();
|
||||
|
||||
static Local<Object> newPlayer(Player* p);
|
||||
static Player* extract(Local<Value> v);
|
||||
@ -69,7 +69,8 @@ public:
|
||||
Local<Value> isAdventure();
|
||||
Local<Value> isGliding();
|
||||
Local<Value> isSurvival();
|
||||
Local<Value> isSpectator();
|
||||
// 1.16.40还没有完整的旁观模式
|
||||
// Local<Value> isSpectator();
|
||||
Local<Value> isRiding();
|
||||
Local<Value> isDancing();
|
||||
Local<Value> isCreative();
|
||||
@ -93,12 +94,12 @@ public:
|
||||
Local<Value> hurt(const Arguments& args);
|
||||
Local<Value> setOnFire(const Arguments& args);
|
||||
Local<Value> setFire(const Arguments& args);
|
||||
Local<Value> refreshChunks(const Arguments& args);
|
||||
// Local<Value> refreshChunks(const Arguments& args);
|
||||
Local<Value> giveItem(const Arguments& args);
|
||||
Local<Value> clearItem(const Arguments& args);
|
||||
Local<Value> isSprinting(const Arguments& args);
|
||||
Local<Value> setSprinting(const Arguments& args);
|
||||
Local<Value> sendToast(const Arguments& args);
|
||||
// Local<Value> sendToast(const Arguments& args);
|
||||
|
||||
Local<Value> getBlockStandingOn(const Arguments& args);
|
||||
Local<Value> getDevice(const Arguments& args);
|
||||
@ -147,36 +148,36 @@ public:
|
||||
Local<Value> setNbt(const Arguments& args);
|
||||
Local<Value> addTag(const Arguments& args);
|
||||
Local<Value> hasTag(const Arguments& args);
|
||||
Local<Value> removeTag(const Arguments& args);
|
||||
// Local<Value> removeTag(const Arguments& args);
|
||||
Local<Value> getAllTags(const Arguments& args);
|
||||
Local<Value> getAbilities(const Arguments& args);
|
||||
Local<Value> getAttributes(const Arguments& args);
|
||||
Local<Value> getEntityFromViewVector(const Arguments& args);
|
||||
Local<Value> getBlockFromViewVector(const Arguments& args);
|
||||
// Local<Value> getBlockFromViewVector(const Arguments& args);
|
||||
|
||||
Local<Value> isSimulatedPlayer(const Arguments& args);
|
||||
Local<Value> quickEvalMolangScript(const Arguments& args);
|
||||
//Local<Value> isSimulatedPlayer(const Arguments& args);
|
||||
// Local<Value> quickEvalMolangScript(const Arguments& args);
|
||||
|
||||
// SimulatedPlayer API (API/SimulatedPlayerAPI.cpp)
|
||||
|
||||
Local<Value> simulateSneak(const Arguments& args);
|
||||
Local<Value> simulateAttack(const Arguments& args);
|
||||
Local<Value> simulateDestroy(const Arguments& args);
|
||||
Local<Value> simulateDisconnect(const Arguments& args);
|
||||
Local<Value> simulateInteract(const Arguments& args);
|
||||
Local<Value> simulateJump(const Arguments& args);
|
||||
Local<Value> simulateLocalMove(const Arguments& args);
|
||||
Local<Value> simulateWorldMove(const Arguments& args);
|
||||
Local<Value> simulateMoveTo(const Arguments& args);
|
||||
Local<Value> simulateLookAt(const Arguments& args);
|
||||
Local<Value> simulateSetBodyRotation(const Arguments& args);
|
||||
Local<Value> simulateNavigateTo(const Arguments& args);
|
||||
Local<Value> simulateUseItem(const Arguments& args);
|
||||
Local<Value> simulateStopDestroyingBlock(const Arguments& args);
|
||||
Local<Value> simulateStopInteracting(const Arguments& args);
|
||||
Local<Value> simulateStopMoving(const Arguments& args);
|
||||
Local<Value> simulateStopUsingItem(const Arguments& args);
|
||||
Local<Value> simulateStopSneaking(const Arguments& args);
|
||||
// Local<Value> simulateSneak(const Arguments& args);
|
||||
// Local<Value> simulateAttack(const Arguments& args);
|
||||
// Local<Value> simulateDestroy(const Arguments& args);
|
||||
// Local<Value> simulateDisconnect(const Arguments& args);
|
||||
// Local<Value> simulateInteract(const Arguments& args);
|
||||
// Local<Value> simulateJump(const Arguments& args);
|
||||
// Local<Value> simulateLocalMove(const Arguments& args);
|
||||
// Local<Value> simulateWorldMove(const Arguments& args);
|
||||
// Local<Value> simulateMoveTo(const Arguments& args);
|
||||
// Local<Value> simulateLookAt(const Arguments& args);
|
||||
// Local<Value> simulateSetBodyRotation(const Arguments& args);
|
||||
// Local<Value> simulateNavigateTo(const Arguments& args);
|
||||
// Local<Value> simulateUseItem(const Arguments& args);
|
||||
// Local<Value> simulateStopDestroyingBlock(const Arguments& args);
|
||||
// Local<Value> simulateStopInteracting(const Arguments& args);
|
||||
// Local<Value> simulateStopMoving(const Arguments& args);
|
||||
// Local<Value> simulateStopUsingItem(const Arguments& args);
|
||||
// Local<Value> simulateStopSneaking(const Arguments& args);
|
||||
|
||||
// bool simulateSetItem(class ItemStack&, bool, int);
|
||||
// bool simulateGiveItem(class ItemStack&, bool);
|
||||
|
@ -26,14 +26,14 @@ Local<Value> McClass::crashBDS(const Arguments& args) //===========???
|
||||
return Boolean::newBoolean(false);
|
||||
}
|
||||
|
||||
Local<Value> McClass::setMaxNumPlayers(const Arguments& args) {
|
||||
CHECK_ARGS_COUNT(args, 1)
|
||||
CHECK_ARG_TYPE(args[0], ValueKind::kNumber)
|
||||
|
||||
try {
|
||||
int back = Global<ServerNetworkHandler>->setMaxNumPlayers(args[0].asNumber().toInt32());
|
||||
Global<ServerNetworkHandler>->updateServerAnnouncement();
|
||||
return Boolean::newBoolean(back == 0 ? true : false);
|
||||
}
|
||||
CATCH("Fail in setMaxPlayers!")
|
||||
}
|
||||
//Local<Value> McClass::setMaxNumPlayers(const Arguments& args) {
|
||||
// CHECK_ARGS_COUNT(args, 1)
|
||||
// CHECK_ARG_TYPE(args[0], ValueKind::kNumber)
|
||||
//
|
||||
// try {
|
||||
// int back = Global<ServerNetworkHandler>->setMaxNumPlayers(args[0].asNumber().toInt32());
|
||||
// Global<ServerNetworkHandler>->updateServerAnnouncement();
|
||||
// return Boolean::newBoolean(back == 0 ? true : false);
|
||||
// }
|
||||
// CATCH("Fail in setMaxPlayers!")
|
||||
//}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -58,8 +58,8 @@ Local<Value> McClass::setStructure(const Arguments& args) {
|
||||
return Local<Value>();
|
||||
}
|
||||
auto argsSize = args.size();
|
||||
Mirror mirror = None_15;
|
||||
Rotation rotation = None_14;
|
||||
Mirror mirror = Mirror::None_15;
|
||||
Rotation rotation = Rotation::None_14;
|
||||
if (argsSize > 2) {
|
||||
CHECK_ARG_TYPE(args[2], ValueKind::kNumber);
|
||||
auto rawMirror = args[2].asNumber().toInt32();
|
||||
|
Loading…
Reference in New Issue
Block a user