Skip to content

Commit 72651b3

Browse files
committed
chore: clean code
1 parent 9564218 commit 72651b3

File tree

9 files changed

+45
-47
lines changed

9 files changed

+45
-47
lines changed

src/legacy/api/BlockAPI.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ Local<Value> BlockClass::getPos() {
168168

169169
Local<Value> BlockClass::getTileData() {
170170
try {
171-
// preloaded
172171
return Number::newNumber(block->getBlockType().getVariant(*block));
173172
}
174173
CATCH("Fail in getTileData!");
@@ -197,7 +196,7 @@ Local<Value> BlockClass::getThickness() {
197196

198197
Local<Value> BlockClass::isAir() {
199198
try {
200-
return Boolean::newBoolean(get()->isAir());
199+
return Boolean::newBoolean(block->isAir());
201200
}
202201
CATCH("Fail in isAir!");
203202
}

src/legacy/api/EntityAPI.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ Local<Value> EntityClass::getPos() {
401401
Actor* entity = get();
402402
if (!entity) return Local<Value>();
403403

404-
return FloatPos::newPos(entity->getPosition(), entity->getDimension().mId->id);
404+
return FloatPos::newPos(entity->getPosition(), entity->getDimensionId().id);
405405
}
406406
CATCH("Fail in GetEntityPos!")
407407
}
@@ -411,7 +411,7 @@ Local<Value> EntityClass::getPosDelta() {
411411
Actor* entity = get();
412412
if (!entity) return Local<Value>();
413413

414-
return FloatPos::newPos(entity->getPosDelta(), entity->getDimension().mId->id);
414+
return FloatPos::newPos(entity->getPosDelta(), entity->getDimensionId().id);
415415
}
416416
CATCH("Fail in GetEntityPosDelta!")
417417
}
@@ -450,7 +450,7 @@ Local<Value> EntityClass::getFeetPos() {
450450
Actor* entity = get();
451451
if (!entity) return Local<Value>();
452452

453-
return FloatPos::newPos(entity->getFeetPos(), entity->getDimension().mId->id);
453+
return FloatPos::newPos(entity->getFeetPos(), entity->getDimensionId().id);
454454
}
455455
CATCH("Fail in GetEntityFeetPos!")
456456
}
@@ -460,7 +460,7 @@ Local<Value> EntityClass::getBlockPos() {
460460
Actor* entity = get();
461461
if (!entity) return Local<Value>();
462462

463-
return IntPos::newPos(entity->getFeetBlockPos(), entity->getDimension().mId->id);
463+
return IntPos::newPos(entity->getFeetBlockPos(), entity->getDimensionId().id);
464464
}
465465
CATCH("Fail in GetEntityBlockPos!")
466466
}
@@ -746,7 +746,7 @@ Local<Value> EntityClass::distanceTo(const Arguments& args) {
746746
pos.x = targetActorPos.x;
747747
pos.y = targetActorPos.y;
748748
pos.z = targetActorPos.z;
749-
pos.dim = targetActor->getDimension().mId->id;
749+
pos.dim = targetActor->getDimensionId().id;
750750
} else {
751751
LOG_WRONG_ARG_TYPE(__FUNCTION__);
752752
return Local<Value>();
@@ -767,7 +767,7 @@ Local<Value> EntityClass::distanceTo(const Arguments& args) {
767767
return Local<Value>();
768768
}
769769

770-
if (actor->getDimension().mId->id != pos.dim) return Number::newNumber(INT_MAX);
770+
if (actor->getDimensionId().id != pos.dim) return Number::newNumber(INT_MAX);
771771

772772
return Number::newNumber(actor->getPosition().distanceTo(pos.getVec3()));
773773
}
@@ -809,7 +809,7 @@ Local<Value> EntityClass::distanceToSqr(const Arguments& args) {
809809
pos.x = targetActorPos.x;
810810
pos.y = targetActorPos.y;
811811
pos.z = targetActorPos.z;
812-
pos.dim = targetActor->getDimension().mId->id;
812+
pos.dim = targetActor->getDimensionId().id;
813813
} else {
814814
LOG_WRONG_ARG_TYPE(__FUNCTION__);
815815
return Local<Value>();
@@ -830,7 +830,7 @@ Local<Value> EntityClass::distanceToSqr(const Arguments& args) {
830830
return Local<Value>();
831831
}
832832

833-
if (actor->getDimension().mId->id != pos.dim) return Number::newNumber(INT_MAX);
833+
if (actor->getDimensionId().id != pos.dim) return Number::newNumber(INT_MAX);
834834

835835
return Number::newNumber(actor->getPosition().distanceToSqr(pos.getVec3()));
836836
}
@@ -917,7 +917,7 @@ Local<Value> EntityClass::getBlockStandingOn(const Arguments&) {
917917
Actor* entity = get();
918918
if (!entity) return Local<Value>();
919919

920-
return BlockClass::newBlock(entity->getBlockPosCurrentlyStandingOn(nullptr), entity->getDimension().mId->id);
920+
return BlockClass::newBlock(entity->getBlockPosCurrentlyStandingOn(nullptr), entity->getDimensionId().id);
921921
}
922922
CATCH("Fail in getBlockStandingOn!");
923923
}

src/legacy/api/EventAPI.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ void EnableEventListener(int eventId) {
266266
if (!CallEvent(
267267
EVENT_TYPES::onDestroyBlock,
268268
PlayerClass::newPlayer(&ev.self()),
269-
BlockClass::newBlock(ev.pos(), ev.self().getDimension().mId->id)
269+
BlockClass::newBlock(ev.pos(), ev.self().getDimensionId().id)
270270
)) {
271271
ev.cancel();
272272
}
@@ -303,8 +303,8 @@ void EnableEventListener(int eventId) {
303303
if (!CallEvent(
304304
EVENT_TYPES::onPlaceBlock,
305305
PlayerClass::newPlayer(&ev.self()),
306-
block ? BlockClass::newBlock(*block, truePos, ev.self().getDimension().mId->id)
307-
: BlockClass::newBlock(truePos, ev.self().getDimension().mId->id),
306+
block ? BlockClass::newBlock(*block, truePos, ev.self().getDimensionId().id)
307+
: BlockClass::newBlock(truePos, ev.self().getDimensionId().id),
308308
Number::newNumber((schar)ev.face())
309309
)) {
310310
ev.cancel();
@@ -320,7 +320,7 @@ void EnableEventListener(int eventId) {
320320
CallEvent(
321321
EVENT_TYPES::afterPlaceBlock,
322322
PlayerClass::newPlayer(&ev.self()),
323-
BlockClass::newBlock(ev.pos(), ev.self().getDimension().mId->id)
323+
BlockClass::newBlock(ev.pos(), ev.self().getDimensionId().id)
324324
); // Not cancellable
325325
}
326326
IF_LISTENED_END(EVENT_TYPES::afterPlaceBlock);
@@ -389,9 +389,9 @@ void EnableEventListener(int eventId) {
389389
EVENT_TYPES::onUseItemOn,
390390
PlayerClass::newPlayer(&ev.self()),
391391
ItemClass::newItem(&ev.item()),
392-
BlockClass::newBlock(ev.block(), ev.blockPos(), ev.self().getDimension().mId->id),
392+
BlockClass::newBlock(ev.block(), ev.blockPos(), ev.self().getDimensionId().id),
393393
Number::newNumber((schar)ev.face()),
394-
FloatPos::newPos(ev.clickPos(), ev.self().getDimension().mId->id)
394+
FloatPos::newPos(ev.clickPos(), ev.self().getDimensionId().id)
395395
)) {
396396
ev.cancel();
397397
}
@@ -603,7 +603,7 @@ void EnableEventListener(int eventId) {
603603
if (!CallEvent(
604604
EVENT_TYPES::onBlockInteracted,
605605
PlayerClass::newPlayer(&ev.self()),
606-
BlockClass::newBlock(ev.blockPos(), ev.self().getDimension().mId->id)
606+
BlockClass::newBlock(ev.blockPos(), ev.self().getDimensionId().id)
607607
)) {
608608
ev.cancel();
609609
}

src/legacy/api/PlayerAPI.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ Local<Value> PlayerClass::getPos() {
779779
Player* player = get();
780780
if (!player) return Local<Value>();
781781

782-
return FloatPos::newPos(player->getPosition(), player->getDimension().mId->id);
782+
return FloatPos::newPos(player->getPosition(), player->getDimensionId().id);
783783
}
784784
CATCH("Fail in getPlayerPos!")
785785
}
@@ -789,7 +789,7 @@ Local<Value> PlayerClass::getFeetPos() {
789789
Player* player = get();
790790
if (!player) return Local<Value>();
791791

792-
return FloatPos::newPos(player->getFeetPos(), player->getDimension().mId->id);
792+
return FloatPos::newPos(player->getFeetPos(), player->getDimensionId().id);
793793
}
794794
CATCH("Fail in getPlayerFeetPos!")
795795
}
@@ -799,7 +799,7 @@ Local<Value> PlayerClass::getBlockPos() {
799799
Player* player = get();
800800
if (!player) return Local<Value>();
801801

802-
return IntPos::newPos(player->getFeetBlockPos(), player->getDimension().mId->id);
802+
return IntPos::newPos(player->getFeetBlockPos(), player->getDimensionId().id);
803803
}
804804
CATCH("Fail in getPlayerBlockPos!")
805805
}
@@ -2112,7 +2112,7 @@ Local<Value> PlayerClass::getBlockStandingOn(const Arguments&) {
21122112
Player* player = get();
21132113
if (!player) return Local<Value>();
21142114

2115-
return BlockClass::newBlock(player->getBlockPosCurrentlyStandingOn(nullptr), player->getDimension().mId->id);
2115+
return BlockClass::newBlock(player->getBlockPosCurrentlyStandingOn(nullptr), player->getDimensionId().id);
21162116
}
21172117
CATCH("Fail in getBlockStandingOn!");
21182118
}
@@ -3526,7 +3526,7 @@ Local<Value> PlayerClass::distanceTo(const Arguments& args) {
35263526
pos.x = targetActorPos.x;
35273527
pos.y = targetActorPos.y;
35283528
pos.z = targetActorPos.z;
3529-
pos.dim = targetActor->getDimension().mId->id;
3529+
pos.dim = targetActor->getDimensionId().id;
35303530
} else {
35313531
LOG_WRONG_ARG_TYPE(__FUNCTION__);
35323532
return Local<Value>();
@@ -3547,7 +3547,7 @@ Local<Value> PlayerClass::distanceTo(const Arguments& args) {
35473547
return Local<Value>();
35483548
}
35493549

3550-
if (player->getDimension().mId->id != pos.dim) return Number::newNumber(INT_MAX);
3550+
if (player->getDimensionId().id != pos.dim) return Number::newNumber(INT_MAX);
35513551

35523552
return Number::newNumber(player->getPosition().distanceTo(pos.getVec3()));
35533553
}
@@ -3589,7 +3589,7 @@ Local<Value> PlayerClass::distanceToSqr(const Arguments& args) {
35893589
pos.x = targetActorPos.x;
35903590
pos.y = targetActorPos.y;
35913591
pos.z = targetActorPos.z;
3592-
pos.dim = targetActor->getDimension().mId->id;
3592+
pos.dim = targetActor->getDimensionId().id;
35933593
} else {
35943594
LOG_WRONG_ARG_TYPE(__FUNCTION__);
35953595
return Local<Value>();
@@ -3610,7 +3610,7 @@ Local<Value> PlayerClass::distanceToSqr(const Arguments& args) {
36103610
return Local<Value>();
36113611
}
36123612

3613-
if (player->getDimension().mId->id != pos.dim) return Number::newNumber(INT_MAX);
3613+
if (player->getDimensionId().id != pos.dim) return Number::newNumber(INT_MAX);
36143614

36153615
return Number::newNumber(player->getPosition().distanceToSqr(pos.getVec3()));
36163616
}

src/legacy/api/SimulatedPlayerAPI.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Local<Value> PlayerClass::simulateDestroy(const Arguments& args) {
108108

109109
if (args.size() == 0) return Boolean::newBoolean(sp->simulateDestroyLookAt());
110110

111-
int dimid = sp->getDimension().mId->id;
111+
int dimid = sp->getDimensionId().id;
112112
BlockPos bpos;
113113
size_t index = 0;
114114
ScriptModuleMinecraft::ScriptFacing face = (ScriptModuleMinecraft::ScriptFacing)0;
@@ -175,7 +175,7 @@ Local<Value> PlayerClass::simulateInteract(const Arguments& args) {
175175
return Boolean::newBoolean(sp->isAlive() && sp->interact(*actor, Vec3::ZERO()));
176176
}
177177

178-
int dimid = sp->getDimension().mId->id;
178+
int dimid = sp->getDimensionId().id;
179179
BlockPos bpos;
180180
size_t index = 0;
181181
ScriptModuleMinecraft::ScriptFacing face = (ScriptModuleMinecraft::ScriptFacing)0;
@@ -374,7 +374,7 @@ Local<Value> PlayerClass::simulateLookAt(const Arguments& args) {
374374
try {
375375
auto sp = asSimulatedPlayer();
376376
if (!sp) return Local<Value>();
377-
int dimid = sp->getDimension().mId->id;
377+
int dimid = sp->getDimensionId().id;
378378
auto lookDuration = sim::LookDuration::UntilMove;
379379
if (args.size() > 1) {
380380
if (!args[1].isNumber()) {

src/lse/api/helper/BlockHelper.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "BlockHelper.h"
22

3-
#include "mc/world/level/block/BedrockBlockNames.h"
43
#include "mc/world/level/block/Block.h"
54
#include "mc/world/level/dimension/DimensionHeightRange.h"
65

src/lse/events/BlockEvents.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ LL_TYPE_INSTANCE_HOOK(
7070
if (!CallEvent(
7171
EVENT_TYPES::onContainerChange,
7272
PlayerClass::newPlayer(&mPlayer),
73-
BlockClass::newBlock(mBlockPos, mPlayer.getDimension().mId->id),
73+
BlockClass::newBlock(mBlockPos, mPlayer.getDimensionId().id),
7474
Number::newNumber(slotNumber + this->_getContainerOffset()),
7575
ItemClass::newItem(&const_cast<ItemStack&>(oldItem)),
7676
ItemClass::newItem(&const_cast<ItemStack&>(newItem))

src/lse/events/EntityEvents.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,9 @@ LL_TYPE_INSTANCE_HOOK(
391391
BlockClass::newBlock(
392392
*griefingEvent.mBlock,
393393
BlockPos(griefingEvent.mPos),
394-
entity->getDimension().mId->id
394+
entity->getDimensionId().id
395395
),
396-
IntPos::newPos(BlockPos(griefingEvent.mPos), entity->getDimension().mId->id)
396+
IntPos::newPos(BlockPos(griefingEvent.mPos), entity->getDimensionId().id)
397397
)) {
398398
return true;
399399
}

src/lse/events/PlayerEvents.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ LL_TYPE_INSTANCE_HOOK(
122122
if (!CallEvent(
123123
EVENT_TYPES::onOpenContainer,
124124
PlayerClass::newPlayer(static_cast<Player*>(actor)),
125-
BlockClass::newBlock(playerOpenContainerEvent.mBlockPos, actor->getDimension().mId->id)
125+
BlockClass::newBlock(playerOpenContainerEvent.mBlockPos, actor->getDimensionId().id)
126126
)) {
127127
return EventResult::StopProcessing;
128128
}
@@ -146,7 +146,7 @@ LL_TYPE_INSTANCE_HOOK(
146146
if (!CallEvent(
147147
EVENT_TYPES::onCloseContainer,
148148
PlayerClass::newPlayer(&player),
149-
BlockClass::newBlock(mPosition, player.getDimension().mId->id)
149+
BlockClass::newBlock(mPosition, player.getDimensionId().id)
150150
)) {
151151
return;
152152
}
@@ -170,7 +170,7 @@ LL_TYPE_INSTANCE_HOOK(
170170
if (!CallEvent(
171171
EVENT_TYPES::onCloseContainer,
172172
PlayerClass::newPlayer(&player),
173-
BlockClass::newBlock(mPosition, player.getDimension().mId->id)
173+
BlockClass::newBlock(mPosition, player.getDimensionId().id)
174174
)) {
175175
return;
176176
}
@@ -222,7 +222,7 @@ LL_STATIC_HOOK(
222222
if (!CallEvent(
223223
EVENT_TYPES::onAttackBlock,
224224
PlayerClass::newPlayer(&player),
225-
BlockClass::newBlock(pos, player.getDimension().mId->id),
225+
BlockClass::newBlock(pos, player.getDimensionId().id),
226226
!item.isNull() ? ItemClass::newItem(&const_cast<ItemStack&>(item)) : Local<Value>()
227227
)) {
228228
isCancelled = true;
@@ -233,7 +233,7 @@ LL_STATIC_HOOK(
233233
if (!CallEvent(
234234
EVENT_TYPES::onStartDestroyBlock,
235235
PlayerClass::newPlayer(&player),
236-
BlockClass::newBlock(pos, player.getDimension().mId->id)
236+
BlockClass::newBlock(pos, player.getDimensionId().id)
237237
)) {
238238
isCancelled = true;
239239
}
@@ -258,7 +258,7 @@ LL_TYPE_INSTANCE_HOOK(
258258
if (!CallEvent(
259259
EVENT_TYPES::onUseFrameBlock,
260260
PlayerClass::newPlayer(&player),
261-
BlockClass::newBlock(eventData.mPos, player.getDimension().mId->id)
261+
BlockClass::newBlock(eventData.mPos, player.getDimensionId().id)
262262
)) {
263263
return;
264264
}
@@ -280,7 +280,7 @@ LL_TYPE_INSTANCE_HOOK(
280280
if (!CallEvent(
281281
EVENT_TYPES::onUseFrameBlock,
282282
PlayerClass::newPlayer(player),
283-
BlockClass::newBlock(pos, player->getDimension().mId->id)
283+
BlockClass::newBlock(pos, player->getDimensionId().id)
284284
)) {
285285
return false;
286286
}
@@ -378,7 +378,7 @@ LL_TYPE_INSTANCE_HOOK(
378378
if (!CallEvent(
379379
EVENT_TYPES::onBedEnter,
380380
PlayerClass::newPlayer(this),
381-
IntPos::newPos(pos, this->getDimension().mId->id)
381+
IntPos::newPos(pos, this->getDimensionId().id)
382382
)) {
383383
return BedSleepingResult::Ok;
384384
}
@@ -464,9 +464,9 @@ LL_TYPE_INSTANCE_HOOK(
464464
EVENT_TYPES::onUseBucketTake,
465465
PlayerClass::newPlayer(&static_cast<Player&>(entity)),
466466
ItemClass::newItem(&item),
467-
BlockClass::newBlock(pos, entity.getDimension().mId->id),
467+
BlockClass::newBlock(pos, entity.getDimensionId().id),
468468
Number::newNumber(-1),
469-
FloatPos::newPos(pos, entity.getDimension().mId->id)
469+
FloatPos::newPos(pos, entity.getDimensionId().id)
470470
)) {
471471
return false;
472472
}
@@ -490,9 +490,9 @@ LL_TYPE_INSTANCE_HOOK(
490490
EVENT_TYPES::onUseBucketTake,
491491
PlayerClass::newPlayer(&static_cast<Player&>(entity)),
492492
ItemClass::newItem(&item),
493-
BlockClass::newBlock(pos, entity.getDimension().mId->id),
493+
BlockClass::newBlock(pos, entity.getDimensionId().id),
494494
Number::newNumber(-1),
495-
FloatPos::newPos(pos, entity.getDimension().mId->id)
495+
FloatPos::newPos(pos, entity.getDimensionId().id)
496496
)) {
497497
return false;
498498
}
@@ -521,7 +521,7 @@ LL_TYPE_INSTANCE_HOOK(
521521
// ItemClass::newItem(&instance, false),
522522
// EntityClass::newEntity(&entity),
523523
// Number::newNumber(face),
524-
// FloatPos::newPos(pos, entity.getDimension().mId->id)
524+
// FloatPos::newPos(pos, entity.getDimensionId().id)
525525
// );
526526
// }
527527
// IF_LISTENED_END(EVENT_TYPES::onUseBucketTake);
@@ -577,7 +577,7 @@ LL_TYPE_INSTANCE_HOOK(
577577
EVENT_TYPES::onPlayerInteractEntity,
578578
PlayerClass::newPlayer(this),
579579
EntityClass::newEntity(&actor),
580-
FloatPos::newPos(location, getDimension().mId->id)
580+
FloatPos::newPos(location, getDimensionId().id)
581581
)) {
582582
return false;
583583
}

0 commit comments

Comments
 (0)