Skip to content

Commit 7c255b5

Browse files
committed
refactor: adapt to LeviLamina 1.0.0 (WIP)
1 parent 2b8c9d3 commit 7c255b5

File tree

7 files changed

+36
-35
lines changed

7 files changed

+36
-35
lines changed

src/legacy/api/CommandAPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include "mc/server/commands/ServerCommandOrigin.h"
3535
#include "mc/world/Minecraft.h"
3636
#include "mc/world/item/ItemInstance.h"
37-
#include "mc/world/item/registry/ItemStack.h"
37+
#include "mc/world/item/ItemStack.h"
3838
#include "mc/world/level/dimension/Dimension.h"
3939

4040
#include <string>

src/legacy/api/ContainerAPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "api/APIHelp.h"
44
#include "api/ItemAPI.h"
55
#include "ll/api/utils/StringUtils.h"
6-
#include "mc/world/item/registry/ItemStack.h"
6+
#include "mc/world/item/ItemStack.h"
77

88
//////////////////// Class Definition ////////////////////
99

src/legacy/api/EntityAPI.cpp

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@
1111
#include "ll/api/memory/Memory.h"
1212
#include "ll/api/service/Bedrock.h"
1313
#include "lse/api/MoreGlobal.h"
14-
#include "mc/common/HitDetection.h"
14+
#include "mc/world/phys/HitDetection.h"
1515
#include "mc/deps/core/string/HashedString.h"
16-
#include "mc/entity/utilities/ActorDamageCause.h"
17-
#include "mc/entity/utilities/ActorEquipment.h"
16+
#include "mc/world/actor/ActorDamageCause.h"
17+
#include "mc/world/actor/provider/ActorEquipment.h"
1818
#include "mc/entity/utilities/ActorMobilityUtils.h"
19-
#include "mc/entity/utilities/ActorType.h"
20-
#include "mc/math/Vec2.h"
19+
#include "mc/world/actor/ActorType.h"
20+
#include "mc/deps/core/math/Vec2.h"
2121
#include "mc/nbt/CompoundTag.h"
2222
#include "mc/world/SimpleContainer.h"
2323
#include "mc/world/actor/ActorDefinitionIdentifier.h"
2424
#include "mc/world/actor/Mob.h"
25-
#include "mc/world/actor/components/SynchedActorDataAccess.h"
25+
#include "mc/world/actor/provider/SynchedActorDataAccess.h"
2626
#include "mc/world/actor/item/ItemActor.h"
2727
#include "mc/world/actor/player/Player.h"
2828
#include "mc/world/attribute/AttributeInstance.h"
@@ -35,6 +35,9 @@
3535
#include "mc/world/level/block/Block.h"
3636
#include "mc/world/level/material/Material.h"
3737
#include "mc/world/phys/AABB.h"
38+
#include "mc/common/ActorUniqueID.h"
39+
#include "mc/world/phys/HitResult.h"
40+
#include "mc/world/effect/EffectDuration.h"
3841

3942
#include <climits>
4043
#include <entt/entt.hpp>
@@ -211,9 +214,6 @@ void EntityClass::set(Actor* actor) {
211214
}
212215
}
213216

214-
WeakStorageEntity& WeakStorageEntity::operator=(WeakStorageEntity const&) = default;
215-
WeakStorageEntity::WeakStorageEntity(WeakStorageEntity const&) = default;
216-
217217
Actor* EntityClass::get() {
218218
if (mValid) {
219219
return mWeakEntity.tryUnwrap<Actor>().as_ptr();
@@ -226,7 +226,7 @@ Local<Value> EntityClass::getUniqueID() {
226226
try {
227227
Actor* entity = get();
228228
if (!entity) return Local<Value>();
229-
else return String::newString(std::to_string(entity->getOrCreateUniqueID().id));
229+
else return String::newString(std::to_string(entity->getOrCreateUniqueID().rawID));
230230
}
231231
CATCH("Fail in getUniqueID!")
232232
}
@@ -296,7 +296,7 @@ Local<Value> EntityClass::isOnHotBlock() {
296296
Actor* entity = get();
297297
if (!entity) return Local<Value>();
298298

299-
return Boolean::newBoolean(entity->isOnHotBlock());
299+
return Boolean::newBoolean(entity->getDimensionBlockSource().getBlock(entity->getFeetBlockPos()).getMaterial().isSuperHot()); // TODO: Unsure
300300
}
301301
CATCH("Fail in isOnHotBlock!")
302302
}
@@ -1029,7 +1029,7 @@ Local<Value> EntityClass::setHealth(const Arguments& args) {
10291029
Actor* entity = get();
10301030
if (!entity) return Local<Value>();
10311031

1032-
AttributeInstance* healthAttribute = entity->getMutableAttribute(SharedAttributes::HEALTH);
1032+
AttributeInstance* healthAttribute = entity->getMutableAttribute(SharedAttributes::HEALTH());
10331033

10341034
healthAttribute->setCurrentValue(args[0].asNumber().toFloat());
10351035

@@ -1046,7 +1046,7 @@ Local<Value> EntityClass::setAbsorption(const Arguments& args) {
10461046
Actor* entity = get();
10471047
if (!entity) return Local<Value>();
10481048

1049-
AttributeInstance* absorptionAttribute = entity->getMutableAttribute(SharedAttributes::ABSORPTION);
1049+
AttributeInstance* absorptionAttribute = entity->getMutableAttribute(SharedAttributes::ABSORPTION());
10501050

10511051
absorptionAttribute->setCurrentValue(args[0].asNumber().toFloat());
10521052

@@ -1063,7 +1063,7 @@ Local<Value> EntityClass::setAttackDamage(const Arguments& args) {
10631063
Actor* entity = get();
10641064
if (!entity) return Local<Value>();
10651065

1066-
AttributeInstance* attactDamageAttribute = entity->getMutableAttribute(SharedAttributes::ATTACK_DAMAGE);
1066+
AttributeInstance* attactDamageAttribute = entity->getMutableAttribute(SharedAttributes::ATTACK_DAMAGE());
10671067

10681068
attactDamageAttribute->setCurrentValue(args[0].asNumber().toFloat());
10691069

@@ -1080,7 +1080,7 @@ Local<Value> EntityClass::setMaxAttackDamage(const Arguments& args) {
10801080
Actor* entity = get();
10811081
if (!entity) return Local<Value>();
10821082

1083-
AttributeInstance* attactDamageAttribute = entity->getMutableAttribute(SharedAttributes::ATTACK_DAMAGE);
1083+
AttributeInstance* attactDamageAttribute = entity->getMutableAttribute(SharedAttributes::ATTACK_DAMAGE());
10841084

10851085
attactDamageAttribute->setMaxValue(args[0].asNumber().toFloat());
10861086

@@ -1097,7 +1097,7 @@ Local<Value> EntityClass::setFollowRange(const Arguments& args) {
10971097
Actor* entity = get();
10981098
if (!entity) return Local<Value>();
10991099

1100-
AttributeInstance* followRangeAttribute = entity->getMutableAttribute(SharedAttributes::FOLLOW_RANGE);
1100+
AttributeInstance* followRangeAttribute = entity->getMutableAttribute(SharedAttributes::FOLLOW_RANGE());
11011101

11021102
followRangeAttribute->setCurrentValue(args[0].asNumber().toFloat());
11031103

@@ -1115,7 +1115,7 @@ Local<Value> EntityClass::setKnockbackResistance(const Arguments& args) {
11151115
if (!entity) return Local<Value>();
11161116

11171117
AttributeInstance* knockbackResistanceAttribute =
1118-
entity->getMutableAttribute(SharedAttributes::KNOCKBACK_RESISTANCE);
1118+
entity->getMutableAttribute(SharedAttributes::KNOCKBACK_RESISTANCE());
11191119

11201120
knockbackResistanceAttribute->setCurrentValue(args[0].asNumber().toFloat());
11211121

@@ -1132,7 +1132,7 @@ Local<Value> EntityClass::setLuck(const Arguments& args) {
11321132
Actor* entity = get();
11331133
if (!entity) return Local<Value>();
11341134

1135-
AttributeInstance* luckAttribute = entity->getMutableAttribute(SharedAttributes::LUCK);
1135+
AttributeInstance* luckAttribute = entity->getMutableAttribute(SharedAttributes::LUCK());
11361136

11371137
luckAttribute->setCurrentValue(args[0].asNumber().toFloat());
11381138

@@ -1149,7 +1149,7 @@ Local<Value> EntityClass::setMovementSpeed(const Arguments& args) {
11491149
Actor* entity = get();
11501150
if (!entity) return Local<Value>();
11511151

1152-
AttributeInstance* movementSpeedAttribute = entity->getMutableAttribute(SharedAttributes::MOVEMENT_SPEED);
1152+
AttributeInstance* movementSpeedAttribute = entity->getMutableAttribute(SharedAttributes::MOVEMENT_SPEED());
11531153
if (movementSpeedAttribute) {
11541154
movementSpeedAttribute->setCurrentValue(args[0].asNumber().toFloat());
11551155
return Boolean::newBoolean(true);
@@ -1169,7 +1169,7 @@ Local<Value> EntityClass::setUnderwaterMovementSpeed(const Arguments& args) {
11691169
if (!entity) return Local<Value>();
11701170

11711171
AttributeInstance* underwaterMovementSpeedAttribute =
1172-
entity->getMutableAttribute(SharedAttributes::UNDERWATER_MOVEMENT_SPEED);
1172+
entity->getMutableAttribute(SharedAttributes::UNDERWATER_MOVEMENT_SPEED());
11731173

11741174
underwaterMovementSpeedAttribute->setCurrentValue(args[0].asNumber().toFloat());
11751175

@@ -1187,7 +1187,7 @@ Local<Value> EntityClass::setLavaMovementSpeed(const Arguments& args) {
11871187
if (!entity) return Local<Value>();
11881188

11891189
AttributeInstance* lavaMovementSpeedAttribute =
1190-
entity->getMutableAttribute(SharedAttributes::LAVA_MOVEMENT_SPEED);
1190+
entity->getMutableAttribute(SharedAttributes::LAVA_MOVEMENT_SPEED());
11911191

11921192
lavaMovementSpeedAttribute->setCurrentValue(args[0].asNumber().toFloat());
11931193

@@ -1204,7 +1204,7 @@ Local<Value> EntityClass::setMaxHealth(const Arguments& args) {
12041204
Actor* entity = get();
12051205
if (!entity) return Local<Value>();
12061206

1207-
AttributeInstance* healthAttribute = entity->getMutableAttribute(SharedAttributes::HEALTH);
1207+
AttributeInstance* healthAttribute = entity->getMutableAttribute(SharedAttributes::HEALTH());
12081208

12091209
healthAttribute->setMaxValue(args[0].asNumber().toFloat());
12101210

@@ -1420,7 +1420,7 @@ Local<Value> EntityClass::getBlockFromViewVector(const Arguments& args) {
14201420
if (includeLiquid && res.mIsHitLiquid) {
14211421
bp = res.mLiquidPos;
14221422
} else {
1423-
bp = res.mBlockPos;
1423+
bp = res.mBlock;
14241424
}
14251425
Block const& bl = actor->getDimensionBlockSource().getBlock(bp);
14261426
if (bl.isEmpty()) {
@@ -1491,10 +1491,11 @@ Local<Value> EntityClass::addEffect(const Arguments& args) {
14911491
return Boolean::newBoolean(false);
14921492
}
14931493
unsigned int id = args[0].asNumber().toInt32();
1494-
int tick = args[1].asNumber().toInt32();
1494+
EffectDuration duration;
1495+
duration.mUnk178312.as<int>() = args[1].asNumber().toInt32();
14951496
int level = args[2].asNumber().toInt32();
14961497
bool showParticles = args[3].asBoolean().value();
1497-
MobEffectInstance effect = MobEffectInstance(id, tick, level, false, showParticles, false);
1498+
MobEffectInstance effect = MobEffectInstance(id, duration, level, false, showParticles, false);
14981499
actor->addEffect(effect);
14991500
return Boolean::newBoolean(true);
15001501
}

src/legacy/api/EventAPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
#include "lse/Entry.h"
4747
#include "lse/events/EventHooks.h"
4848
#include "main/Global.h"
49-
#include "mc/entity/utilities/ActorType.h"
49+
#include "mc/world/actor/ActorType.h"
5050
#include "mc/server/commands/CommandOriginType.h"
5151
#include "mc/world/actor/player/Player.h"
5252
#include "mc/world/item/Item.h"

src/legacy/api/ItemAPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include <mc/nbt/CompoundTag.h>
1515
#include <mc/world/item/Item.h>
16-
#include <mc/world/item/registry/ItemStack.h>
16+
#include <mc/world/item/ItemStack.h>
1717
#include <string>
1818
#include <variant>
1919
#include <vector>

src/legacy/api/PlayerAPI.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
#include "mc/world/actor/player/PlayerScoreSetFunction.h"
5959
#include "mc/world/effect/MobEffectInstance.h"
6060
#include "mc/world/events/BossEventUpdateType.h"
61-
#include "mc/world/item/registry/ItemStack.h"
61+
#include "mc/world/item/ItemStack.h"
6262
#include "mc/world/level/LayeredAbilities.h"
6363
#include "mc/world/level/block/Block.h"
6464
#include "mc/world/level/storage/DBStorage.h"
@@ -71,13 +71,13 @@
7171
#include <algorithm>
7272
#include <climits>
7373
#include <list>
74-
#include <mc/entity/utilities/ActorEquipment.h>
74+
#include <mc/world/actor/provider/ActorEquipment.h>
7575
#include <mc/entity/utilities/ActorMobilityUtils.h>
7676
#include <mc/nbt/CompoundTag.h>
7777
#include <mc/world/actor/Actor.h>
7878
#include <mc/world/actor/SynchedActorData.h>
7979
#include <mc/world/actor/SynchedActorDataEntityWrapper.h>
80-
#include <mc/world/actor/components/SynchedActorDataAccess.h>
80+
#include <mc/world/actor/provider/SynchedActorDataAccess.h>
8181
#include <mc/world/actor/player/Player.h>
8282
#include <mc/world/attribute/Attribute.h>
8383
#include <mc/world/attribute/AttributeInstance.h>

src/lse/events/EventHooks.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "legacy/api/ItemAPI.h"
88
#include "legacy/api/PlayerAPI.h"
99
#include "ll/api/service/Bedrock.h"
10-
#include "mc/entity/utilities/ActorDamageCause.h"
10+
#include "mc/world/actor/ActorDamageCause.h"
1111
#include "mc/server/ServerPlayer.h"
1212
#include "mc/server/commands/CommandOrigin.h"
1313
#include "mc/server/commands/CommandOriginType.h"
@@ -23,7 +23,7 @@
2323
#include <mc/common/wrapper/InteractionResult.h>
2424
#include <mc/deps/ecs/WeakEntityRef.h>
2525
#include <mc/entity/components/ProjectileComponent.h>
26-
#include <mc/entity/utilities/ActorType.h>
26+
#include <mc/world/actor/ActorType.h>
2727
#include <mc/server/module/VanillaServerGameplayEventListener.h>
2828
#include <mc/world/actor/ActorDefinitionIdentifier.h>
2929
#include <mc/world/actor/ArmorStand.h>
@@ -40,7 +40,7 @@
4040
#include <mc/world/item/CrossbowItem.h>
4141
#include <mc/world/item/ItemInstance.h>
4242
#include <mc/world/item/TridentItem.h>
43-
#include <mc/world/item/registry/ItemStack.h>
43+
#include <mc/world/item/ItemStack.h>
4444
#include <mc/world/level/BlockEventCoordinator.h>
4545
#include <mc/world/level/BlockSource.h>
4646
#include <mc/world/level/ChangeDimensionRequest.h>

0 commit comments

Comments
 (0)