-
-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
128 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
|
||
#include "ll/api/reflection/TypeName.h" | ||
#include "mc/nbt/CompoundTag.h" | ||
|
||
namespace ll::event { | ||
template <class T> | ||
[[nodiscard]] inline ::CompoundTag serializeRefObj(T& obj) { | ||
return ::CompoundTag{ | ||
{"_nullable_", false}, | ||
{ "_pointer_", (uintptr_t)std::addressof(obj)}, | ||
{ "_type_", reflection::type_unprefix_name_v<std::remove_cvref_t<T>>}, | ||
{ "_isconst_", std::is_const_v<T>}, | ||
}; | ||
} | ||
template <class T> | ||
[[nodiscard]] inline ::CompoundTag serializePtrObj(T* ptr) { | ||
return ::CompoundTag{ | ||
{"_nullable_", true}, | ||
{ "_pointer_", (uintptr_t)ptr}, | ||
{ "_type_", reflection::type_unprefix_name_v<std::remove_cvref_t<T>>}, | ||
{ "_isconst_", std::is_const_v<T>}, | ||
}; | ||
} | ||
[[nodiscard]] inline bool isEventSerializedObj(::CompoundTag const& tag) { | ||
return tag.contains("_type_") && tag.contains("_pointer_"); | ||
} | ||
[[nodiscard]] inline bool isEventSerializedObj(::CompoundTagVariant const& tag) { | ||
return tag.is_object() ? isEventSerializedObj(tag.get<::CompoundTag>()) : false; | ||
} | ||
} // namespace ll::event |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
#include "ll/api/event/entity/MobEvent.h" | ||
#include "ll/api/event/EventRefObjSerializer.h" | ||
|
||
#include "mc/nbt/CompoundTag.h" | ||
|
||
namespace ll::event::inline entity { | ||
|
||
void MobEvent::serialize(CompoundTag& nbt) const { | ||
ActorEvent::serialize(nbt); | ||
nbt["self"] = serializeRefObj(self()); | ||
} | ||
|
||
Mob& MobEvent::self() const { return static_cast<Mob&>(ActorEvent::self()); } | ||
|
||
} // namespace ll::event::inline entity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.