Skip to content

Commit

Permalink
refactor: refactoring test data item
Browse files Browse the repository at this point in the history
  • Loading branch information
OEOTYAN committed Feb 12, 2024
1 parent a89364d commit 1a5a39c
Showing 1 changed file with 8 additions and 38 deletions.
46 changes: 8 additions & 38 deletions src/ll/test/TestDataItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,13 @@
#include <memory>
#include <string>

std::shared_ptr<SetActorDataPacket> buildSetActorDataPacketPacket(ItemActor* iac) {
bool viewable = true;
std::vector<std::unique_ptr<DataItem>> DataItems;
DataItems.emplace_back(DataItem::create<const std::string&>(ActorDataIDs::Name, iac->item().getTypeName()));
DataItems.emplace_back(DataItem::create<signed char>(ActorDataIDs::NametagAlwaysShow, (signed char)viewable));
BinaryStream bs;
bs.writeUnsignedVarInt64(iac->getRuntimeID());
bs.writeType(DataItems);
bs.writeUnsignedVarInt(0);
bs.writeUnsignedVarInt(0);
bs.writeUnsignedVarInt64(0);
auto packet = MinecraftPackets::createPacket(MinecraftPacketIds::SetActorData);
packet->read(bs);
return std::static_pointer_cast<SetActorDataPacket>(packet);
}

// LL_AUTO_TYPE_INSTANCE_HOOK(ACTickHook, HookPriority::Normal, ItemActor, &ItemActor::postNormalTick, void) {
// origin();
// ll::service::getLevel()->forEachPlayer([&](Player& player) {
// player.sendNetworkPacket(*buildSetActorDataPacketPacket(this));
// return true;
// });
// }


// et buildSetActorDataPacketPacket(ItemActor* iac) {
LL_AUTO_TYPE_INSTANCE_HOOK(ACTickHook, HookPriority::Normal, ItemActor, &ItemActor::postNormalTick, void) {
origin();
SetActorDataPacket packet{getRuntimeID(), getEntityData(), nullptr, 0, true};

// SetActorDataPacket packet{iac->getRuntimeID(), iac->getEntityData(), nullptr, 0, true};
packet.mPackedItems.emplace_back(DataItem::create<const std::string&>(ActorDataIDs::Name, item().getTypeName())
);
packet.mPackedItems.emplace_back(DataItem::create<signed char>(ActorDataIDs::NametagAlwaysShow, true));

// packet.mPackedItems.emplace_back(DataItem::create<const std::string&>(ActorDataIDs::Name, iac->item().getTypeName())
// );
// packet.mPackedItems.emplace_back(DataItem::create<signed char>(ActorDataIDs::NametagAlwaysShow, true));

// return packet;
// }

// LL_AUTO_TYPE_INSTANCE_HOOK(ACTickHook, HookPriority::Normal, ItemActor, &ItemActor::postNormalTick, void) {
// origin();
// buildSetActorDataPacketPacket(this).sendToClients();
// }
packet.sendToClients();
}

0 comments on commit 1a5a39c

Please sign in to comment.