-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBDS.hpp
462 lines (458 loc) · 14.4 KB
/
BDS.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
#pragma once
#include "pch.h"
#include "NBT.hpp"
using namespace std;
#pragma region Block
struct BlockLegacy {
string getBlockName() {
return f(string, this + 128);
}
short getBlockItemID() { // IDA Item::beginCreativeGroup(,Block*,) 18~22
short v3 = f(short, this + 328);
if (v3 < 0x100) {
return v3;
}
return (short)(255 - v3);
//return SYMCALL<short>("?getBlockItemId@BlockLegacy@@QEBAFXZ", this);
}
};
struct Block {
BlockLegacy* getBlockLegacy() {
return f(BlockLegacy*,this + 16);
//return SYMCALL<BlockLegacy*>("?getLegacyBlock@Block@@QEBAAEBVBlockLegacy@@XZ", this);
}
};
struct BlockPos { int x = 0, y = 0, z = 0; };
struct BlockActor {
Block* getBlock() {
return f(Block*, this + 16);
}
BlockPos* getPosition() {// IDA BlockActor::BlockActor 18~20
return (BlockPos*)(this + 44);
}
};
struct BlockSource {
Block* getBlock(const BlockPos& bp) {
return SYMCALL<Block*>("?getBlock@BlockSource@@QEBAAEBVBlock@@AEBVBlockPos@@@Z",
this, &bp);
}
bool setBlock(const string& name, const BlockPos& bp) {
return SYMCALL<bool>("?setBlock@BlockSource@@QEAA_NAEBVBlockPos@@AEBVBlock@@HPEBUActorBlockSyncMessage@@@Z",
this, &bp, *(Block**)GetServerSymbol(("?m" + name + "@VanillaBlocks@@3PEBVBlock@@EB").c_str()), 3, nullptr);
}
void updateNeighborsAt(const BlockPos* pos) {
SYMCALL("?updateNeighborsAt@BlockSource@@QEAAXAEBVBlockPos@@@Z",
this, pos);
}
int getDimensionId() { // IDA Dimension::onBlockChanged 42
return f(int, (f(VA, this + 32) + 216));
//return f(int, (f(VA, this + 32) + 208));
}
};
#pragma endregion
#pragma region Math
struct Vec3 {
float x = 0.0f, y = 0.0f, z = 0.0f;
string toString() {
char str[64];
sprintf_s(str, "(%f,%f,%f)", x, y, z);
return str;
}
};
struct Vec2 { float x = 0.0f, y = 0.0f; };
#pragma endregion
#pragma region Item
struct Item;
struct ItemStackBase {
VA vtable;
VA mItem;
VA mUserData;
VA mBlock;
short mAuxValue;
char mCount;
char mValid;
char unk[4];
VA mPickupTime;
char mShowPickUp;
char unk2[7];
vector<VA*> mCanPlaceOn;
VA mCanPlaceOnHash;
vector<VA*> mCanDestroy;
VA mCanDestroyHash;
VA mBlockingTick;
ItemStackBase* mChargedItem;
VA uk;
// 取物品ID,特殊值,损耗
short getId() {
return SYMCALL<short>("?getId@ItemStackBase@@QEBAFXZ", this);
}
short getDamageValue() {
return SYMCALL<short>("?getDamageValue@ItemStackBase@@QEBAFXZ", this);
}
// 取物品名称
string getName() {
string str;
SYMCALL<string*>("?getRawNameId@ItemStackBase@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ",
this, &str);
return str;
}
// 取容器内数量
//int getStackCount() {// IDA ContainerModel::networkUpdateItem
// return f(int, this + 34);
//}
// 判断是否空容器
bool isNull() {
return SYMCALL<bool>("?isNull@ItemStackBase@@QEBA_NXZ", this);
}
//bool isEmptyStack() {
// return f(char, this + 34) == 0;
//}
Tag* getNetworkUserData() {
Tag* ct;
SYMCALL("?getNetworkUserData@ItemStackBase@@QEBA?AV?$unique_ptr@VCompoundTag@@U?$default_delete@VCompoundTag@@@std@@@std@@XZ",
this, &ct);
return ct;
}
Tag* save() {
Tag* t = 0;
SYMCALL("?save@ItemStackBase@@QEBA?AV?$unique_ptr@VCompoundTag@@U?$default_delete@VCompoundTag@@@std@@@std@@XZ",
this, &t);
return t;
}
ItemStackBase* fromTag(Tag* t) {
return SYMCALL<ItemStackBase*>("?fromTag@ItemStack@@SA?AV1@AEBVCompoundTag@@@Z",
this, t);
}
bool getFromId(short id, short aux, char count) {
memcpy(this, SYM("?EMPTY_ITEM@ItemStack@@2V1@B"), 0x90);
bool ret = SYMCALL<bool>("?_setItem@ItemStackBase@@IEAA_NH@Z", this, id);
mCount = count;
mAuxValue = aux;
mValid = true;
return ret;
}
Item* getItem() {
return SYMCALL<Item*>("?getItem@ItemStackBase@@QEBAPEBVItem@@XZ", this);
}
void fromJson(Json::Value j) {
Tag* t = toTag(j);
fromTag(t);
t->deCompound();
delete t;
}
};
struct ItemStack : ItemStackBase {};
struct Container {
// 获取容器内所有物品
vector<ItemStack*> getSlots() {
vector<ItemStack*> s;
SYMCALL<VA>("?getSlots@Container@@UEBA?BV?$vector@PEBVItemStack@@V?$allocator@PEBVItemStack@@@std@@@std@@XZ",
this, &s);
return s;
}
void clearItem(int slot, int num) {
SYMCALL("?removeItem@Container@@UEAAXHH@Z", this, slot, num);
}
};
#pragma endregion
#pragma region Actor
struct Actor {
// 获取生物名称信息
string getNameTag() {
return SYMCALL<string&>("?getNameTag@Actor@@UEBAAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ", this);
}
// 获取生物当前所处维度ID
int getDimensionId() {
int did;
SYMCALL<int&>("?getDimensionId@Actor@@UEBA?AV?$AutomaticID@VDimension@@H@@XZ",
this, &did);
return did;
}
// 获取生物当前所在坐标
Vec3* getPos() {
return SYMCALL<Vec3*>("?getPos@Actor@@UEBAAEBVVec3@@XZ", this);
}
// 是否悬空
bool isStand() {// IDA MovePlayerPacket::MovePlayerPacket 30
return f(bool, this + 448);
}
// 取方块源
BlockSource* getBlockSource() {
return f(BlockSource*, this + 840);//对
}
ItemStack* getArmor(int slot) {
return SYMCALL<ItemStack*>("?getArmor@Actor@@UEBAAEBVItemStack@@W4ArmorSlot@@@Z",
this,slot);
}
// 获取实体类型
unsigned getEntityTypeId() {
return f(unsigned, this + 968);
//return f(unsigned, this + 964);
}
// 获取查询用ID
VA getUniqueID() {
return SYMCALL<VA>("?getUniqueID@Actor@@QEBAAEBUActorUniqueID@@XZ", this);
}
// 获取实体类型
string getEntityTypeName() {
string en_name;
SYMCALL<string&>("?EntityTypeToLocString@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@W4ActorType@@W4ActorTypeNamespaceRules@@@Z",
&en_name, getEntityTypeId());
return en_name;
}
// 更新属性
VA updateAttrs() {
return SYMCALL<VA>("?_sendDirtyActorData@Actor@@QEAAXXZ", this);
}
//VA getAttribute() {
//return f(VA, this + 1144);
//}
// 添加一个状态
VA addEffect(VA ef) {
return SYMCALL<VA>("?addEffect@Actor@@QEAAXAEBVMobEffectInstance@@@Z", this, ef);
}
// 获取生命值
int getHealth() {
return SYMCALL<int>("?getHealth@Actor@@QEBAHXZ", this);
}
int getMaxHealth() {
return SYMCALL<int>("?getMaxHealth@Actor@@QEBAHXZ", this);
}
void setHealth(int value, int max) {
VA hattr = ((*(VA(__fastcall**)(Actor*, void*))(*(VA*)this + 1552))(
this, SYM("?HEALTH@SharedAttributes@@2VAttribute@@B")));
f(int, hattr + 132) = value;
f(int, hattr + 128) = max;
//SYMCALL("?_setDirty@AttributeInstance@@AEAAXXZ", hattr);
}
Tag* save() {
Tag* t = newTag(Compound);
SYMCALL("?save@Actor@@UEAA_NAEAVCompoundTag@@@Z", this, t);
return t;
}
};
struct Mob : Actor {
struct MobEffectInstance { char fill[0x1C]; };
// 获取状态列表
auto getEffects() { // IDA Mob::addAdditionalSaveData 84
return (vector<MobEffectInstance>*)((VA*)this + 190);
}
// 保存当前副手至容器
VA saveOffhand(VA hlist) {
return SYMCALL<VA>("?saveOffhand@Mob@@IEBA?AV?$unique_ptr@VListTag@@U?$default_delete@VListTag@@@std@@@std@@XZ",
this, hlist);
}
/*
// 获取地图信息
VA getLevel() {// IDA Mob::die 143
return f(VA, this + 856);
}*/
};
struct Player : Mob {
string getUuid() {// IDA ServerNetworkHandler::_createNewPlayer 217
string p;
SYMCALL<string&>("?asString@UUID@mce@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ",
this + 2832, &p);
//SYMCALL<string&>("?asString@UUID@mce@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ",
//this + 2824, &p);
return p;
}
// 发送数据包
void sendPacket(VA pkt) {
return SYMCALL<void>("?sendNetworkPacket@ServerPlayer@@UEBAXAEAVPacket@@@Z",
this, pkt);
}
// 根据地图信息获取玩家xuid
string getXuid(struct Level* level) {
return SYMCALL<string&>("?getPlayerXUID@Level@@UEBAAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBVUUID@mce@@@Z",
level, (VA)this + 2832);
}
// 重设服务器玩家名
void setName(string name) {
SYMCALL("?setName@Player@@UEAAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z",
this, name);
}
// 获取网络标识符
VA getNetId() {
return (VA)this + 2544;
//return (VA)this + 2536;// IDA ServerPlayer::setPermissions 34
}
// 获取背包
Container* getContainer() {
return (Container*)f(VA, f(VA, this + 3040) + 176);
//return (Container*)f(VA, f(VA, this + 3048) + 176);
}
VA getContainerManager() {
return (VA)this + 3024;
//return (VA)this + 3040; // IDA Player::setContainerManager 18
}
// 获取末影箱
Container* getEnderChestContainer() {
return SYMCALL<Container*>("?getEnderChestContainer@Player@@QEAAPEAVEnderChestContainer@@XZ", this);
}
// 设置一个装备
VA setArmor(int i, ItemStack* item) {
return SYMCALL<VA>("?setArmor@ServerPlayer@@UEAAXW4ArmorSlot@@AEBVItemStack@@@Z", this, i, item);
}
// 设置副手
VA setOffhandSlot(ItemStack* item) {
return SYMCALL<VA>("?setOffhandSlot@Player@@UEAAXAEBVItemStack@@@Z", this, item);
}
// 添加一个物品
void addItem(ItemStackBase* item) {
SYMCALL<VA>("?addItem@@YAXAEAVPlayer@@AEAVItemStack@@@Z", this, item);
}
// 获取当前选中的框位置
int getSelectdItemSlot() {// IDA Player::getSelectedItem 12
return f(unsigned, f(VA, this + 3040) + 16);
//return f(unsigned, f(VA, this + 3048) + 16);
}
// 获取当前物品
ItemStack* getSelectedItem() {
return SYMCALL<ItemStack*>("?getSelectedItem@Player@@QEBAAEBVItemStack@@XZ", this);
}
// 获取背包物品
ItemStack* getInventoryItem(int slot) {
return SYMCALL<ItemStack*>("?getItem@FillingContainer@@UEBAAEBVItemStack@@H@Z", *(__int64**)(*((__int64*)this + 0x17D) + 0xB0), slot);
}
// 获取游戏时命令权限
char getPermission() {// IDA ServerPlayer::setPermissions 17
return *f(char*, this + 2224);
//return *f(char*, this + 2216);
}
// 设置游戏时命令权限
void setPermission(char m) {
SYMCALL("?setPermissions@ServerPlayer@@UEAAXW4CommandPermissionLevel@@@Z",
this, m);
}
// 获取游戏时游玩权限
//char getPermissionLevel() {// IDA Abilities::setPlayerPermissions ?
// return f(char, f(char*, this + 2192) + 1);
//}
// 设置游戏时游玩权限
void setPermissionLevel(char m) {
SYMCALL("?setPlayerPermissions@Abilities@@QEAAXW4PlayerPermissionLevel@@@Z",
this + 2192, m);
}
void sendInventroy() {
SYMCALL("?sendInventory@ServerPlayer@@UEAAX_N@Z",
this, true);
}
void teleport(Vec3 target, int dim) {
SYMCALL("?teleport@TeleportCommand@@SAXAEAVActor@@VVec3@@PEAV3@V?$AutomaticID@VDimension@@H@@VRelativeFloat@@4H@Z",
this, target, 0, dim, 0, 0, 0);
//SYMCALL("?teleport@TeleportCommand@@SAXAEAVActor@@VVec3@@PEAV3@V?$AutomaticID@VDimension@@H@@VRelativeFloat@@4HAEBUActorUniqueID@@@Z",
// this, target, 0, dim, 0, 0, 0, SYM("?INVALID_ID@ActorUniqueID@@2U1@B"));
}
};
#pragma endregion
#pragma region Scoreboard
struct PlayerScore {
VA getscore() {
return f(VA, this + 4);
}
};
struct ScoreInfo {
//scoreboardcmd list; objective::objective; scoreboard getscores
//int scores +12 this[12]
// string displayname +96
//string name +64
int getCount() {
return f(int, this + 12);
}
};
struct ScoreboardId {
int id;
VA null;
};
struct ScorePacketInfo {
ScoreboardId sid;
string obj_name = "name";
unsigned score;
enum Type : char { Invalid = 0, Player = 1, Actor = 2, Fake = 3 };
Type type = Fake;
VA pid;
VA aid;
string fake_name;
ScorePacketInfo(ScoreboardId* s, unsigned num, const string& fake) :
sid(*s), score(num), fake_name(fake) {}
};
struct Objective {
//获取计分板名称
auto getScoreName() {
return f(string, this + 64);
}
//获取计分板展示名称
auto getScoreDisplayName() {
return f(string, this + 96);
}
auto createScoreboardId(Player* player) {
return SYMCALL<ScoreboardId*>("?createScoreboardId@ServerScoreboard@@UEAAAEBUScoreboardId@@AEBVPlayer@@@Z", this, player);
}
ScoreInfo* getPlayerScore(ScoreboardId* a2) {
char a1[12];
return SYMCALL<ScoreInfo*>("?getPlayerScore@Objective@@QEBA?AUScoreInfo@@AEBUScoreboardId@@@Z",
this, a1, a2);
}
};
struct Scoreboard {
auto getObjective(string str) {
return SYMCALL<Objective*>("?getObjective@Scoreboard@@QEBAPEAVObjective@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z", this, &str);
}
auto getScoreboardId(const string& str) {
return SYMCALL<ScoreboardId*>("?getScoreboardId@Scoreboard@@QEBAAEBUScoreboardId@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z",
this, &str);
}
vector<Objective*> getObjectives() {
vector<Objective*> s;
SYMCALL("?getObjectives@Scoreboard@@QEBA?AV?$vector@PEBVObjective@@V?$allocator@PEBVObjective@@@std@@@std@@XZ",
this, &s);
return s;
}
auto getDisplayInfoFiltered(string* str) {
return SYMCALL<vector<PlayerScore>*>("?getDisplayInfoFiltered@Scoreboard@@QEBA?AV?$vector@UPlayerScore@@V?$allocator@UPlayerScore@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@3@@Z", this, str);
}
auto getTrackedIds() {
return SYMCALL<vector<ScoreboardId>*>("?getTrackedIds@Scoreboard@@QEBA?AV?$vector@UScoreboardId@@V?$allocator@UScoreboardId@@@std@@@std@@XZ", this);
}
auto getScoreboardId(Player* a2) {
return SYMCALL<ScoreboardId*>("?getScoreboardId@Scoreboard@@QEBAAEBUScoreboardId@@AEBVActor@@@Z", this, a2);
}
//更改玩家分数
int modifyPlayerScore(ScoreboardId* a3, Objective* a4, int count, int mode) {
bool a2 = true;
return SYMCALL<int>("?modifyPlayerScore@Scoreboard@@QEAAHAEA_NAEBUScoreboardId@@AEAVObjective@@HW4PlayerScoreSetFunction@@@Z",
this, &a2, a3, a4, count, mode);
}
auto createScoreBoardId(const string& s) {
return SYMCALL<ScoreboardId*>("?createScoreboardId@ServerScoreboard@@UEAAAEBUScoreboardId@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z",
this, &s);
}
auto createScoreBoardId(Player* player) {
return SYMCALL<ScoreboardId*>("?createScoreboardId@ServerScoreboard@@UEAAAEBUScoreboardId@@AEBVPlayer@@@Z", this, player);
}
};
#pragma endregion
struct Level {
// 获取方块源 没这个维度返回空指针
BlockSource* getBlockSource(int did) {
VA d = SYMCALL<VA>("?getDimension@Level@@QEBAPEAVDimension@@V?$AutomaticID@VDimension@@H@@@Z",
this, did);
if (!d)return 0;
return f(BlockSource*, d + 96);
//return f(BlockSource*, d + 88);// IDA Level::tickEntities 120
}
//VA getScoreBoard() {// IDA Level::removeEntityReferences
//return f(VA, this + 8376);
//}
Actor* fetchEntity(VA id) {
return SYMCALL< Actor*>("?fetchEntity@Level@@UEBAPEAVActor@@UActorUniqueID@@_N@Z",
this, id, false);
}
};
struct ServerNetworkHandler {
Player* _getServerPlayer(VA id, VA pkt) {
return SYMCALL<Player*>("?_getServerPlayer@ServerNetworkHandler@@AEAAPEAVServerPlayer@@AEBVNetworkIdentifier@@E@Z",
this, id, f(char, pkt + 16));
}
};