Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
1.7.4b更新,暑假最终版本,修复命令行输入字符数目不对的问题,强制将控制台编码设置为UTF-8
Browse files Browse the repository at this point in the history
  • Loading branch information
twoone3l committed Aug 23, 2021
1 parent 8e84c39 commit 7cbc5cd
Show file tree
Hide file tree
Showing 4 changed files with 214 additions and 218 deletions.
16 changes: 3 additions & 13 deletions BDSpyrunner/Header File/PyEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,22 @@
#include "include/Python.h"

#define Py_RETURN_ERROR(str) return PyErr_SetString(PyExc_Exception, str), nullptr
#define Py_CALL_BEGIN\
#define Py_BEGIN_CALL\
int _has_gil = PyGILState_Check();\
PyGILState_STATE _gil_state = PyGILState_LOCKED;\
if (!_has_gil)_gil_state = PyGILState_Ensure();\
Py_BEGIN_ALLOW_THREADS;\
Py_BLOCK_THREADS
#define Py_CALL_END\
#define Py_END_CALL\
Py_UNBLOCK_THREADS;\
Py_END_ALLOW_THREADS;\
if (!_has_gil)PyGILState_Release(_gil_state)

struct Actor;
struct Player;
// ʵÌåÀàÐÍ
struct PyEntity {
PyObject_HEAD;
Actor* actor;
};
//ת»»std::stringΪPyUnicode
PyObject* ToPyUnicode(const std::string&);

PyObject* PyEntity_FromEntity(Actor* ptr);
PyObject* PyEntity_FromEntity(struct Actor* ptr);

//获取属性方法
extern PyGetSetDef PyEntity_GetSet[];
//Entity方法
extern PyMethodDef PyEntity_Methods[];
//EntityÀàÐÍ
extern PyTypeObject PyEntity_Type;
93 changes: 45 additions & 48 deletions BDSpyrunner/Source File/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@ string Actor::getNameTag() {
return SymCall<string&>("?getNameTag@Actor@@UEBAAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ", this);
}

//设置生物名称信息
//设置生物名称信息

void Actor::setNameTag(const std::string&name) {
VirtualCall(0x1F8, this, &name);
}

//设置生物名称是否可见
//设置生物名称是否可见

void Actor::setNameTagVisible(bool visible) {
SymCall("?setNameTagVisible@Actor@@UEAAX_N@Z", this, visible);
}

//获取生物当前所处维度ID

int Actor::getDimensionId() {
int did;
SymCall("?getDimensionId@Actor@@UEBA?AV?$AutomaticID@VDimension@@H@@XZ",
Expand All @@ -31,34 +29,33 @@ int Actor::getDimensionId() {
//return FETCH(int, this + 236);//IDA Actor::getDimensionId
}

//获取生物当前所在坐标

//获取生物当前所在坐标
Vec3* Actor::getPos() {
return SymCall<Vec3*>("?getPos@Actor@@UEBAAEBVVec3@@XZ", this);
//return (Vec3*)(this + 1268);//IDA Actor::getPos
}

//获取生物之前所在坐标
//获取生物之前所在坐标

Vec3* Actor::getPosOld() {
return SymCall<Vec3*>("?getPosOld@Actor@@UEBAAEBVVec3@@XZ", this);
//return (Vec3*)(this + 1280);//IDA Actor::getPosOld
}

//是否已移除
//是否已移除

bool Actor::isRemoved() {
return FETCH(bool, this + 7688);
}

//是否悬空
//是否悬空

bool Actor::isStand() {//IDA MovePlayerPacket::MovePlayerPacket 30
return FETCH(bool, this + 480);
}


//取方块源
//取方块源

BlockSource* Actor::getRegion() {
return SymCall<BlockSource*>("?getRegion@Actor@@QEBAAEAVBlockSource@@XZ", this);
Expand All @@ -70,20 +67,20 @@ ItemStack* Actor::getArmor(int slot) {
this, slot);
}

//获取实体类型
//获取实体类型

unsigned Actor::getEntityTypeId() {
return VirtualCall<unsigned>(0x520, this);
//return SymCall<unsigned>("?getEntityTypeId@Actor@@UEBA?AW4ActorType@@XZ", this);
}

//获取查询用ID
//获取查询用ID

uintptr_t Actor::getUniqueID() {
return SymCall<uintptr_t>("?getUniqueID@Actor@@QEBAAEBUActorUniqueID@@XZ", this);
}

//获取实体类型
//获取实体类型

string Actor::getEntityTypeName() {
string type;
Expand All @@ -92,25 +89,25 @@ string Actor::getEntityTypeName() {
return type;
}

//更新属性
//更新属性

uintptr_t Actor::updateAttrs() {
return SymCall<uintptr_t>("?_sendDirtyActorData@Actor@@QEAAXXZ", this);
}

//获取地图信息
//获取地图信息

Level* Actor::getLevel() {
return SymCall<Level*>("?getLevel@Actor@@QEBAAEBVLevel@@XZ", this);
}

//添加一个状态
//添加一个状态

uintptr_t Actor::addEffect(uintptr_t ef) {
return SymCall<uintptr_t>("?addEffect@Actor@@QEAAXAEBVMobEffectInstance@@@Z", this, ef);
}

//获取生命值
//获取生命值

int Actor::getHealth() {
return SymCall<int>("?getHealth@Actor@@QEBAHXZ", this);
Expand All @@ -134,7 +131,7 @@ void Actor::setMaxHealth(int value) {
//SymCall("?_setDirty@AttributeInstance@@AEAAXXZ", hattr);
}

//获取副手
//获取副手

ItemStack* Actor::getOffHand() {
return SymCall<ItemStack*>("?getOffhandSlot@Actor@@QEBAAEBVItemStack@@XZ", this);
Expand All @@ -146,25 +143,25 @@ Tag* Actor::save() {
return t;
}

//设置大小
//设置大小

void Actor::setSize(float f1, float f2) {
SymCall("?setSize@Actor@@UEAAXMM@Z", this, f1, f2);
}

//是否潜行
//是否潜行

bool Actor::isSneaking() {
return SymCall<bool>("?isSneaking@Actor@@QEBA_NXZ", this);
}

//获取状态列表
//获取状态列表

auto Actor::getAllEffects() {
//return SymCall<vector<MobEffectInstance>*>("?getAllEffects@Actor@@QEBAAEBV?$vector@VMobEffectInstance@@V?$allocator@VMobEffectInstance@@@std@@@std@@XZ", this);
}

//传送
//传送

void Actor::teleport(Vec3* target, int did) {
char mem[128];
Expand All @@ -174,21 +171,21 @@ void Actor::teleport(Vec3* target, int did) {
this, &mem);
}

//新增标签
//新增标签

bool Actor::addTag(const string& str) {
return SymCall<bool>("?addTag@Actor@@QEAA_NAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z",
this, &str);
}

//移除标签
//移除标签

bool Actor::removeTag(const string& str) {
return SymCall<bool>("?removeTag@Actor@@QEAA_NAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z",
this, &str);
}

//获取标签
//获取标签

span<string> Actor::getTags() {
span<string> tags;
Expand All @@ -208,142 +205,142 @@ string Player::getUuid() {//IDA ServerNetworkHandler::_createNewPlayer 222
return p;
}

//根据地图信息获取玩家xuid
//根据地图信息获取玩家xuid

string& Player::getXuid() {
return SymCall<string&>("?getPlayerXUID@Level@@UEBAAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBVUUID@mce@@@Z",
getLevel(), this + 3000);
}

//获取网络标识符
//获取网络标识符

NetworkIdentifier* Player::getClientId() {
return SymCall<NetworkIdentifier*>("?getClientId@Player@@QEBAAEBVNetworkIdentifier@@XZ",
this);
//IDA ServerPlayer::setPermissions 34
}

//获取背包
//获取背包

Container* Player::getInventory() {
return SymCall<Container*>("?getInventory@Player@@QEAAAEAVContainer@@XZ", this);
//return FETCH(Container*, FETCH(uintptr_t, this + 3208) + 176);//IDA Player::getInventory
}

//获取装备容器
//获取装备容器

Container* Player::getArmorContainer() {
return FETCH(Container*, this + 1648);//IDA Actor::_setArmorContainer 11
}

//获取末影箱
//获取末影箱

Container* Player::getEnderChestContainer() {
return FETCH(Container*, this + 4360);//IDA ReplaceItemCommand::execute 1086
}

//设置一个装备
//设置一个装备

uintptr_t Player::setArmor(int i, ItemStack* item) {
return SymCall<uintptr_t>("?setArmor@ServerPlayer@@UEAAXW4ArmorSlot@@AEBVItemStack@@@Z", this, i, item);
}

//设置副手
//设置副手

uintptr_t Player::setOffhandSlot(ItemStack* item) {
return SymCall<uintptr_t>("?setOffhandSlot@Player@@UEAAXAEBVItemStack@@@Z", this, item);
}

//添加一个物品
//添加一个物品

void Player::addItem(ItemStack* item) {
SymCall<uintptr_t>("?addItem@@YAXAEAVPlayer@@AEAVItemStack@@@Z", this, item);
}

//增加等级
//增加等级

void Player::addLevel(int level) {
SymCall("?addLevels@Player@@UEAAXH@Z", this, level);
}

//获取当前选中的框位置
//获取当前选中的框位置

int Player::getSelectedItemSlot() {
return SymCall<int>("?getSelectedItemSlot@Player@@QEBAHXZ", this);
//return FETCH(unsigned, FETCH(uintptr_t, this + 3208) + 16);//IDA Player::getSelectedItemSlot
}

//获取当前物品
//获取当前物品

ItemStack* Player::getSelectedItem() {
return SymCall<ItemStack*>("?getSelectedItem@Player@@QEBAAEBVItemStack@@XZ", this);
}

//获取背包物品
//获取背包物品

ItemStack* Player::getInventoryItem(int slot) {
return getInventory()->getSlots()[slot];
}

//获取游戏时命令权限
//获取游戏时命令权限

char Player::getPermissions() {
return *FETCH(char*, this + 2376);//IDA ServerPlayer::setPermissions 22
}

//设置游戏时命令权限
//设置游戏时命令权限

void Player::setPermissions(char m) {
SymCall("?setPermissions@ServerPlayer@@UEAAXW4CommandPermissionLevel@@@Z",
this, m);
}

//获取游戏时游玩权限
//获取游戏时游玩权限

char Player::getPermissionLevel() {//IDA Abilities::setPlayerPermissions ?
return FETCH(char, FETCH(char*, this + 2376) + 1);
}

//设置游戏时游玩权限
//设置游戏时游玩权限

void Player::setPermissionLevel(char m) {
SymCall("?setPlayerPermissions@Abilities@@QEAAXW4PlayerPermissionLevel@@@Z",
this + 2376, m);
}

//获取设备id
//获取设备id

string Player::getDeviceId() {
return FETCH(string, this + 8352); //IDA Player::Player v13 + 8352
}

//获取设备系统类型
//获取设备系统类型

int Player::getDeviceOS() {
return FETCH(int, this + 2368); //IDA ServerNetworkHandler::createNewPlayer ConnectionRequest::getDeviceOS
}

//发送背包
//发送背包

void Player::sendInventroy() {
SymCall("?sendInventory@ServerPlayer@@UEAAX_N@Z",
this, true);
}

//刷新区块
//刷新区块

void Player::resendAllChunks() {
SymCall("?resendAllChunks@ServerPlayer@@UEAAXXZ", this);
}

//发送数据包
//发送数据包

void Player::sendPacket(uintptr_t pkt) {
SymCall("?sendNetworkPacket@ServerPlayer@@UEBAXAEAVPacket@@@Z",
this, pkt);
}

//使玩家客户端崩溃
//使玩家客户端崩溃
void Player::crash() {
uintptr_t pkt = createPacket(58);
FETCH(int, pkt + 14) = 0;
Expand Down Expand Up @@ -394,7 +391,7 @@ void Player::sendBossEventCodePacket(string name, float per, int eventtype) {
uintptr_t pkt = createPacket(74);
FETCH(uintptr_t, pkt + 56) = FETCH(uintptr_t, getUniqueID());
//FETCH(uintptr_t, pkt + 64) = FETCH(uintptr_t, getUniqueID());
FETCH(int, pkt + 72) = eventtype;//0显示,1更新,2隐藏,
FETCH(int, pkt + 72) = eventtype;//0显示,1更新,2隐藏,
FETCH(string, pkt + 80) = name;
FETCH(float, pkt + 112) = per;
sendPacket(pkt);
Expand Down
Loading

0 comments on commit 7cbc5cd

Please sign in to comment.