|
62 | 62 | #include "mc/world/ActorUniqueID.h" |
63 | 63 | #include "mc/world/Container.h" |
64 | 64 | #include "mc/world/Minecraft.h" |
| 65 | +#include "mc/world/SimpleContainer.h" |
65 | 66 | #include "mc/world/actor/player/EnderChestContainer.h" |
66 | 67 | #include "mc/world/actor/player/PlayerScoreSetFunction.h" |
67 | 68 | #include "mc/world/actor/player/PlayerUISlot.h" |
|
79 | 80 |
|
80 | 81 | #include <algorithm> |
81 | 82 | #include <mc/entity/EntityContext.h> |
| 83 | +#include <mc/entity/utilities/ActorEquipment.h> |
82 | 84 | #include <mc/entity/utilities/ActorMobilityUtils.h> |
83 | 85 | #include <mc/nbt/CompoundTag.h> |
84 | 86 | #include <mc/world/SimpleContainer.h> |
@@ -370,7 +372,8 @@ Local<Value> McClass::setPlayerNbt(const Arguments& args) { |
370 | 372 | auto tag = NbtCompoundClass::extract(args[1]); |
371 | 373 | Player* player = ll::service::getLevel()->getPlayer(uuid); |
372 | 374 | if (player) { |
373 | | - player->load(*tag); |
| 375 | + DefaultDataLoadHelper defaultDataLoadHelper; |
| 376 | + player->load(*tag, defaultDataLoadHelper); |
374 | 377 | return Boolean::newBoolean(true); |
375 | 378 | } else { |
376 | 379 | DBStorage* db = MoreGlobal::db; |
@@ -414,8 +417,8 @@ Local<Value> McClass::setPlayerNbtTags(const Arguments& args) { |
414 | 417 | } |
415 | 418 | } |
416 | 419 | } |
417 | | - |
418 | | - player->load(playerNbt); |
| 420 | + DefaultDataLoadHelper defaultDataLoadHelper; |
| 421 | + player->load(playerNbt, defaultDataLoadHelper); |
419 | 422 | player->refreshInventory(); |
420 | 423 | return Boolean::newBoolean(true); |
421 | 424 | } |
@@ -1626,7 +1629,7 @@ Local<Value> PlayerClass::getArmor(const Arguments& args) { |
1626 | 1629 | Player* player = get(); |
1627 | 1630 | if (!player) return Local<Value>(); |
1628 | 1631 |
|
1629 | | - return ContainerClass::newContainer(&player->getArmorContainer()); |
| 1632 | + return ContainerClass::newContainer(&ActorEquipment::getArmorContainer(player->getEntityContext())); |
1630 | 1633 | } |
1631 | 1634 | CATCH("Fail in getArmor!"); |
1632 | 1635 | } |
@@ -2840,26 +2843,26 @@ Local<Value> PlayerClass::clearItem(const Arguments& args) { |
2840 | 2843 | player->getInventory().removeItem(slot, clearCount); |
2841 | 2844 | } |
2842 | 2845 | } |
2843 | | - auto& handSlots = player->getHandContainer().getSlots(); |
| 2846 | + auto& handSlots = ActorEquipment::getHandContainer(player->getEntityContext()).getSlots(); |
2844 | 2847 | for (unsigned short slot = 0; slot < handSlots.size(); ++slot) { |
2845 | 2848 | if (handSlots[slot]->getTypeName() == args[0].asString().toString()) { |
2846 | 2849 | if (handSlots[slot]->mCount < clearCount) { |
2847 | 2850 | result += handSlots[slot]->mCount; |
2848 | 2851 | } else { |
2849 | 2852 | result += clearCount; |
2850 | 2853 | } |
2851 | | - player->getHandContainer().removeItem(slot, clearCount); |
| 2854 | + ActorEquipment::getHandContainer(player->getEntityContext()).removeItem(slot, clearCount); |
2852 | 2855 | } |
2853 | 2856 | } |
2854 | | - auto& armorSlots = player->getArmorContainer().getSlots(); |
| 2857 | + auto& armorSlots = ActorEquipment::getArmorContainer(player->getEntityContext()).getSlots(); |
2855 | 2858 | for (unsigned short slot = 0; slot < armorSlots.size(); ++slot) { |
2856 | 2859 | if (armorSlots[slot]->getTypeName() == args[0].asString().toString()) { |
2857 | 2860 | if (armorSlots[slot]->mCount < clearCount) { |
2858 | 2861 | result += armorSlots[slot]->mCount; |
2859 | 2862 | } else { |
2860 | 2863 | result += clearCount; |
2861 | 2864 | } |
2862 | | - player->getArmorContainer().removeItem(slot, clearCount); |
| 2865 | + ActorEquipment::getArmorContainer(player->getEntityContext()).removeItem(slot, clearCount); |
2863 | 2866 | } |
2864 | 2867 | } |
2865 | 2868 | player->refreshInventory(); |
@@ -3212,8 +3215,8 @@ Local<Value> PlayerClass::getAllItems(const Arguments& args) { |
3212 | 3215 | const ItemStack& hand = player->getCarriedItem(); |
3213 | 3216 | const ItemStack& offHand = player->getOffhandSlot(); |
3214 | 3217 | std::vector<const ItemStack*> inventory = player->getInventory().getSlots(); |
3215 | | - std::vector<const ItemStack*> armor = player->getArmorContainer().getSlots(); |
3216 | | - std::vector<const ItemStack*> endChest = player->getEnderChestContainer()->getSlots(); |
| 3218 | + std::vector<const ItemStack*> armor = ActorEquipment::getArmorContainer(player->getEntityContext()).getSlots(); |
| 3219 | + std::vector<const ItemStack*> endChest = player->getEnderChestContainer()->getSlots(); |
3217 | 3220 |
|
3218 | 3221 | Local<Object> result = Object::newObject(); |
3219 | 3222 |
|
|
0 commit comments