fix: fix event api
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
class LegacyScriptBinaryStreamManager {
|
class LegacyScriptBinaryStreamManager {
|
||||||
private:
|
private:
|
||||||
int64 mNextBinaryStreamId = 0;
|
int64 mNextBinaryStreamId = 0;
|
||||||
std::unordered_map<uint64, std::shared_ptr<GMBinaryStream>> mBinaryStream;
|
std::unordered_map<uint64, std::shared_ptr<GMBinaryStream>> mBinaryStream;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -15,7 +15,7 @@ public:
|
|||||||
uint64 copyBinaryStream(uint id) {
|
uint64 copyBinaryStream(uint id) {
|
||||||
auto nextId = getNextId();
|
auto nextId = getNextId();
|
||||||
cretateBinaryStream(nextId);
|
cretateBinaryStream(nextId);
|
||||||
if(auto bs = getBinaryStream(nextId); bs !=nullptr){
|
if (auto bs = getBinaryStream(nextId); bs != nullptr) {
|
||||||
getBinaryStream(nextId)->mBuffer = getBinaryStream(id)->mBuffer;
|
getBinaryStream(nextId)->mBuffer = getBinaryStream(id)->mBuffer;
|
||||||
}
|
}
|
||||||
return nextId;
|
return nextId;
|
||||||
|
|||||||
+41
-37
@@ -15,18 +15,18 @@ void Export_Compatibility_API() {
|
|||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> double {
|
RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> double {
|
||||||
return GMLevel::getInstance().transform(
|
return GMLevel::getInstance().transform(
|
||||||
[](GMLevel& level) -> double { return level.getServerMspt(); }
|
[](GMLevel& level) -> double { return level.getServerMspt(); }
|
||||||
).value_or(0.0);
|
).value_or(0.0);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getServerCurrentTps", []() -> float {
|
RemoteCall::exportAs("GMLIB_API", "getServerCurrentTps", []() -> float {
|
||||||
return GMLevel::getInstance()
|
return GMLevel::getInstance().transform(
|
||||||
.transform([](GMLevel& level) -> float { return level.getServerCurrentTps(); })
|
[](GMLevel& level) -> float { return level.getServerCurrentTps(); }
|
||||||
.value_or(0.0);
|
).value_or(0.0);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getServerAverageTps", []() -> double {
|
RemoteCall::exportAs("GMLIB_API", "getServerAverageTps", []() -> double {
|
||||||
return GMLevel::getInstance()
|
return GMLevel::getInstance().transform(
|
||||||
.transform([](GMLevel& level) -> double { return level.getServerAverageTps(); })
|
[](GMLevel& level) -> double { return level.getServerAverageTps(); }
|
||||||
.value_or(0.0);
|
).value_or(0.0);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getAllPlayerUuids", []() -> std::vector<std::string> {
|
RemoteCall::exportAs("GMLIB_API", "getAllPlayerUuids", []() -> std::vector<std::string> {
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
@@ -116,7 +116,7 @@ void Export_Compatibility_API() {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "removeFloatingTextFromPlayer", [](uint64 id, Player* pl) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "removeFloatingTextFromPlayer", [](uint64 id, Player* pl) -> bool {
|
||||||
if (auto ft = FloatingTextManager::getInstance().get(id); !ft.expired()){
|
if (auto ft = FloatingTextManager::getInstance().get(id); !ft.expired()) {
|
||||||
ft.lock()->removeFrom((GMPlayer&)*pl);
|
ft.lock()->removeFrom((GMPlayer&)*pl);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -143,9 +143,13 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "isVersionMatched", [](std::uint16_t a, std::uint16_t b, std::uint16_t c) -> bool {
|
RemoteCall::exportAs(
|
||||||
return LIB_VERSION >= ll::data::Version(a, b, c, "", "");
|
"GMLIB_API",
|
||||||
});
|
"isVersionMatched",
|
||||||
|
[](std::uint16_t a, std::uint16_t b, std::uint16_t c) -> bool {
|
||||||
|
return LIB_VERSION >= ll::data::Version(a, b, c, "", "");
|
||||||
|
}
|
||||||
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "getVersion_LRCA", []() -> std::string { return LIB_VERSION.to_string(); });
|
RemoteCall::exportAs("GMLIB_API", "getVersion_LRCA", []() -> std::string { return LIB_VERSION.to_string(); });
|
||||||
RemoteCall::exportAs("GMLIB_API", "getVersion_GMLIB", []() -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getVersion_GMLIB", []() -> std::string {
|
||||||
return GMLIB_VERSION_TO_STRING(GMLIB_VERSION_MAJOR) "." GMLIB_VERSION_TO_STRING(GMLIB_VERSION_MINOR
|
return GMLIB_VERSION_TO_STRING(GMLIB_VERSION_MAJOR) "." GMLIB_VERSION_TO_STRING(GMLIB_VERSION_MINOR
|
||||||
@@ -406,7 +410,7 @@ void Export_Compatibility_API() {
|
|||||||
std::vector<std::unordered_map<std::string, std::string>> result;
|
std::vector<std::unordered_map<std::string, std::string>> result;
|
||||||
for (auto& player : GMScoreboard::getInstance()->getAllPlayers()) {
|
for (auto& player : GMScoreboard::getInstance()->getAllPlayers()) {
|
||||||
result.push_back({
|
result.push_back({
|
||||||
{"Type", "Player" },
|
{"Type", "Player" },
|
||||||
{"Uuid", player.getUUID().asString()}
|
{"Uuid", player.getUUID().asString()}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -418,7 +422,7 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
for (auto& uniqueId : GMScoreboard::getInstance()->getAllEntities()) {
|
for (auto& uniqueId : GMScoreboard::getInstance()->getAllEntities()) {
|
||||||
result.push_back({
|
result.push_back({
|
||||||
{"Type", "Entity" },
|
{"Type", "Entity" },
|
||||||
{"UniqueId", std::to_string(uniqueId.rawID)}
|
{"UniqueId", std::to_string(uniqueId.rawID)}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -440,10 +444,10 @@ void Export_Compatibility_API() {
|
|||||||
RemoteCall::exportAs("GMLIB_API", "setWorldSpawn", [](std::pair<BlockPos, int> pos) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "setWorldSpawn", [](std::pair<BlockPos, int> pos) -> bool {
|
||||||
if (pos.second != 0) return false;
|
if (pos.second != 0) return false;
|
||||||
GMLevel::getInstance()->getLevelData().setSpawnPos(pos.first);
|
GMLevel::getInstance()->getLevelData().setSpawnPos(pos.first);
|
||||||
auto pkt = SetSpawnPositionPacket();
|
auto pkt = SetSpawnPositionPacket();
|
||||||
pkt.mSpawnBlockPos = NetworkBlockPosition(pos.first);
|
pkt.mSpawnBlockPos = NetworkBlockPosition(pos.first);
|
||||||
pkt.mDimensionType = 0;
|
pkt.mDimensionType = 0;
|
||||||
pkt.mSpawnPosType = SpawnPositionType::WorldSpawn;
|
pkt.mSpawnPosType = SpawnPositionType::WorldSpawn;
|
||||||
pkt.sendToClients();
|
pkt.sendToClients();
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
@@ -483,21 +487,21 @@ void Export_Compatibility_API() {
|
|||||||
return UserCache::getNameByXuid(xuid).value_or("");
|
return UserCache::getNameByXuid(xuid).value_or("");
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getUuidByXuid", [](std::string const& xuid) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getUuidByXuid", [](std::string const& xuid) -> std::string {
|
||||||
return UserCache::getUuidByXuid(xuid)
|
return UserCache::getUuidByXuid(xuid).transform(
|
||||||
.transform([](mce::UUID&& uuid) -> std::string { return uuid.asString(); })
|
[](mce::UUID&& uuid) -> std::string { return uuid.asString(); }
|
||||||
.value_or("");
|
).value_or("");
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getUuidByName", [](std::string const& name) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getUuidByName", [](std::string const& name) -> std::string {
|
||||||
return UserCache::getUuidByName(name)
|
return UserCache::getUuidByName(name).transform(
|
||||||
.transform([](mce::UUID&& uuid) -> std::string { return uuid.asString(); })
|
[](mce::UUID&& uuid) -> std::string { return uuid.asString(); }
|
||||||
.value_or("");
|
).value_or("");
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"getAllPlayerInfo",
|
"getAllPlayerInfo",
|
||||||
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
|
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
|
||||||
std::vector<std::unordered_map<std::string, std::string>> result;
|
std::vector<std::unordered_map<std::string, std::string>> result;
|
||||||
for (auto entry : UserCache::entries()){
|
for (auto entry : UserCache::entries()) {
|
||||||
result.push_back({
|
result.push_back({
|
||||||
{"Name", entry.mName },
|
{"Name", entry.mName },
|
||||||
{"Xuid", entry.mXuid },
|
{"Xuid", entry.mXuid },
|
||||||
@@ -607,22 +611,22 @@ void Export_Compatibility_API() {
|
|||||||
switch (gameRule.mType) {
|
switch (gameRule.mType) {
|
||||||
case GameRule::Type::Bool:
|
case GameRule::Type::Bool:
|
||||||
result.push_back({
|
result.push_back({
|
||||||
{"Name", gameRule.mName },
|
{"Name", gameRule.mName },
|
||||||
{"Type", "Bool" },
|
{"Type", "Bool" },
|
||||||
{"Value", std::to_string(gameRule.mValue->mUnk29fff1.as<bool>())}
|
{"Value", std::to_string(gameRule.mValue->mUnk29fff1.as<bool>())}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case GameRule::Type::Float:
|
case GameRule::Type::Float:
|
||||||
result.push_back({
|
result.push_back({
|
||||||
{"Name", gameRule.mName },
|
{"Name", gameRule.mName },
|
||||||
{"Type", "Float" },
|
{"Type", "Float" },
|
||||||
{"Value", std::to_string(gameRule.mValue->mUnk768db5.as<float>())}
|
{"Value", std::to_string(gameRule.mValue->mUnk768db5.as<float>())}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case GameRule::Type::Int:
|
case GameRule::Type::Int:
|
||||||
result.push_back({
|
result.push_back({
|
||||||
{"Name", gameRule.mName },
|
{"Name", gameRule.mName },
|
||||||
{"Type", "Int" },
|
{"Type", "Int" },
|
||||||
{"Value", std::to_string(gameRule.mValue->mUnk2ab4f3.as<int>())}
|
{"Value", std::to_string(gameRule.mValue->mUnk2ab4f3.as<int>())}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@@ -634,7 +638,7 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEnchantTypeNameFromId", [](size_t id) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getEnchantTypeNameFromId", [](size_t id) -> std::string {
|
||||||
if (id < Enchant::mEnchants().size()){
|
if (id < Enchant::mEnchants().size()) {
|
||||||
return Enchant::mEnchants()[id]->mStringId->getString();
|
return Enchant::mEnchants()[id]->mStringId->getString();
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
@@ -651,9 +655,7 @@ void Export_Compatibility_API() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "removeEnchants", [](ItemStack* item) -> void {
|
RemoteCall::exportAs("GMLIB_API", "removeEnchants", [](ItemStack* item) -> void { item->removeEnchants(); });
|
||||||
item->removeEnchants();
|
|
||||||
});
|
|
||||||
RemoteCall::exportAs("GMLIB_API", "hasEnchant", [](ItemStack* item, std::string const& typeName) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "hasEnchant", [](ItemStack* item, std::string const& typeName) -> bool {
|
||||||
return EnchantUtils::hasEnchant(Enchant::mEnchantNameToType()[HashedString(typeName)], *item);
|
return EnchantUtils::hasEnchant(Enchant::mEnchantNameToType()[HashedString(typeName)], *item);
|
||||||
});
|
});
|
||||||
@@ -694,8 +696,8 @@ void Export_Compatibility_API() {
|
|||||||
auto nbt = ((GMItemStack*)item)->getNbt();
|
auto nbt = ((GMItemStack*)item)->getNbt();
|
||||||
if (value) {
|
if (value) {
|
||||||
(*nbt)["tags"]["minecraft:keep_on_death"] = true;
|
(*nbt)["tags"]["minecraft:keep_on_death"] = true;
|
||||||
}else{
|
} else {
|
||||||
if (nbt->contains("tags") && (*nbt)["tags"].contains("minecraft:keep_on_death")){
|
if (nbt->contains("tags") && (*nbt)["tags"].contains("minecraft:keep_on_death")) {
|
||||||
(*nbt)["tags"].get<CompoundTag>().erase("minecraft:keep_on_death");
|
(*nbt)["tags"].get<CompoundTag>().erase("minecraft:keep_on_death");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -766,7 +768,7 @@ void Export_Compatibility_API() {
|
|||||||
return entity->getOwnerId().rawID;
|
return entity->getOwnerId().rawID;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getItemCategoryName", [](ItemStack const* item) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getItemCategoryName", [](ItemStack const* item) -> std::string {
|
||||||
if (auto item2 = item->mItem){
|
if (auto item2 = item->mItem) {
|
||||||
return item2->buildCategoryDescriptionName();
|
return item2->buildCategoryDescriptionName();
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
@@ -775,7 +777,7 @@ void Export_Compatibility_API() {
|
|||||||
return item->getCustomName();
|
return item->getCustomName();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getItemEffecName", [](ItemStack const* item) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getItemEffecName", [](ItemStack const* item) -> std::string {
|
||||||
if (auto item2 = item->mItem){
|
if (auto item2 = item->mItem) {
|
||||||
return item2->buildEffectDescriptionName(*item);
|
return item2->buildEffectDescriptionName(*item);
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
@@ -803,7 +805,9 @@ void Export_Compatibility_API() {
|
|||||||
return magic_enum::enum_name(container->mContainerType).data();
|
return magic_enum::enum_name(container->mContainerType).data();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "hasPlayerNbt", [](std::string const& uuid) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "hasPlayerNbt", [](std::string const& uuid) -> bool {
|
||||||
return OfflinePlayer::getOfflinePlayer(mce::UUID::fromString(uuid)).transform([&](auto&& player) -> bool { return player.hasNbt(); }).value_or(false);
|
return OfflinePlayer::getOfflinePlayer(mce::UUID::fromString(uuid))
|
||||||
|
.transform([&](auto&& player) -> bool { return player.hasNbt(); })
|
||||||
|
.value_or(false);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getItemMaxCount", [](ItemStack const* item) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getItemMaxCount", [](ItemStack const* item) -> int {
|
||||||
return item->getMaxStackSize();
|
return item->getMaxStackSize();
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ bool LegacyRemoteCallApi::load() {
|
|||||||
Export_Legacy_GMLib_ServerAPI();
|
Export_Legacy_GMLib_ServerAPI();
|
||||||
Export_Compatibility_API();
|
Export_Compatibility_API();
|
||||||
ExportPAPI();
|
ExportPAPI();
|
||||||
// Export_Event_API();
|
Export_Event_API();
|
||||||
Export_BinaryStream_API();
|
Export_BinaryStream_API();
|
||||||
// Export_Form_API();
|
// Export_Form_API();
|
||||||
auto logger = ll::io::LoggerRegistry::getInstance().getOrCreate(PLUGIN_NAME);
|
auto logger = ll::io::LoggerRegistry::getInstance().getOrCreate(PLUGIN_NAME);
|
||||||
|
|||||||
+94
-115
@@ -88,10 +88,7 @@ void Export_Event_API() {
|
|||||||
std::string const& uuid,
|
std::string const& uuid,
|
||||||
std::string const& serverXuid,
|
std::string const& serverXuid,
|
||||||
std::string const& clientXuid),
|
std::string const& clientXuid),
|
||||||
(event.realName(),
|
(event.realName(), event.uuid().asString(), event.serverAuthXuid(), event.clientAuthXuid()),
|
||||||
event.uuid().asString(),
|
|
||||||
event.serverAuthXuid(),
|
|
||||||
event.clientAuthXuid()),
|
|
||||||
if (result) event.disConnectClient();
|
if (result) event.disConnectClient();
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -116,12 +113,10 @@ void Export_Event_API() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("gmlib::MobPickupItemBeforeEvent"): {
|
case doHash("gmlib::MobPickupItemBeforeEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(ila::mc::ActorPickupItemBeforeEvent,
|
||||||
ila::mc::ActorPickupItemBeforeEvent,
|
(Actor * mob, Actor * item, bool isCancelled),
|
||||||
(Actor * mob, Actor * item, bool isCancelled),
|
(&event.self(), (Actor*)&event.itemActor(), event.isCancelled()),
|
||||||
(&event.self(), (Actor*)&event.itemActor(), event.isCancelled()),
|
event.setCancelled(result););
|
||||||
event.setCancelled(result);
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
case doHash("gmlib::MobPickupItemAfterEvent"): {
|
case doHash("gmlib::MobPickupItemAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
@@ -153,12 +148,10 @@ void Export_Event_API() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("gmlib::ActorChangeDimensionBeforeEvent"): {
|
case doHash("gmlib::ActorChangeDimensionBeforeEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(ila::mc::ActorChangeDimensionBeforeEvent,
|
||||||
ila::mc::ActorChangeDimensionBeforeEvent,
|
(Actor * entity, int toDimId, bool isCancelled),
|
||||||
(Actor * entity, int toDimId, bool isCancelled),
|
(&event.self(), event.toDimensionId(), event.isCancelled()),
|
||||||
(&event.self(), event.toDimensionId(), event.isCancelled()),
|
event.setCancelled(result););
|
||||||
event.setCancelled(result);
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
case doHash("gmlib::ActorChangeDimensionAfterEvent"): {
|
case doHash("gmlib::ActorChangeDimensionAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
@@ -224,37 +217,25 @@ void Export_Event_API() {
|
|||||||
// );
|
// );
|
||||||
// }
|
// }
|
||||||
case doHash("gmlib::EndermanTakeBlockBeforeEvent"): {
|
case doHash("gmlib::EndermanTakeBlockBeforeEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(ila::mc::EndermanTakeBlockBeforeEvent,
|
||||||
ila::mc::EndermanTakeBlockBeforeEvent,
|
(Actor * mob, bool isCancelled),
|
||||||
(Actor * mob, bool isCancelled),
|
(&event.self(), event.isCancelled()),
|
||||||
(&event.self(), event.isCancelled()),
|
event.setCancelled(result););
|
||||||
event.setCancelled(result);
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
case doHash("gmlib::DragonRespawnBeforeEvent"): {
|
case doHash("gmlib::DragonRespawnBeforeEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(ila::mc::DragonRespawnBeforeEvent,
|
||||||
ila::mc::DragonRespawnBeforeEvent,
|
(bool isCancelled),
|
||||||
(bool isCancelled),
|
(event.isCancelled()),
|
||||||
(event.isCancelled()),
|
event.setCancelled(result););
|
||||||
event.setCancelled(result);
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
case doHash("gmlib::DragonRespawnAfterEvent"): {
|
case doHash("gmlib::DragonRespawnAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(ila::mc::DragonRespawnAfterEvent, (Actor * mob), (&event.self()), );
|
||||||
ila::mc::DragonRespawnAfterEvent,
|
|
||||||
(Actor * mob),
|
|
||||||
(&event.self()),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
case doHash("gmlib::ProjectileCreateBeforeEvent"): {
|
case doHash("gmlib::ProjectileCreateBeforeEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(ila::mc::ProjectileCreateBeforeEvent,
|
||||||
ila::mc::ProjectileCreateBeforeEvent,
|
(Actor * mob, int64 uniqueId, bool isCancelled),
|
||||||
(Actor * mob, int64 uniqueId, bool isCancelled),
|
(&event.self(), event.self().getOwnerId().rawID, event.isCancelled()),
|
||||||
(&event.self(),
|
event.setCancelled(result););
|
||||||
event.self().getOwnerId().rawID,
|
|
||||||
event.isCancelled()),
|
|
||||||
event.setCancelled(result);
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
case doHash("gmlib::ProjectileCreateAfterEvent"): {
|
case doHash("gmlib::ProjectileCreateAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
@@ -264,12 +245,10 @@ void Export_Event_API() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("gmlib::SpawnWanderingTraderBeforeEvent"): {
|
case doHash("gmlib::SpawnWanderingTraderBeforeEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(ila::mc::SpawnWanderingTraderBeforeEvent,
|
||||||
ila::mc::SpawnWanderingTraderBeforeEvent,
|
(std::pair<BlockPos, int> pos, bool isCancelled),
|
||||||
(std::pair<BlockPos, int> pos, bool isCancelled),
|
({event.pos(), event.blockSource().getDimensionId()}, event.isCancelled()),
|
||||||
({event.pos(), event.blockSource().getDimensionId()}, event.isCancelled()),
|
event.setCancelled(result););
|
||||||
event.setCancelled(result);
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
case doHash("gmlib::SpawnWanderingTraderAfterEvent"): {
|
case doHash("gmlib::SpawnWanderingTraderAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
@@ -278,74 +257,74 @@ void Export_Event_API() {
|
|||||||
({event.pos(), event.blockSource().getDimensionId()}),
|
({event.pos(), event.blockSource().getDimensionId()}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// case doHash("gmlib::HandleRequestActionBeforeEvent"): {
|
// case doHash("gmlib::HandleRequestActionBeforeEvent"): {
|
||||||
// // clang-format off
|
// // clang-format off
|
||||||
// REGISTER_EVENT_LISTEN(
|
// REGISTER_EVENT_LISTEN(
|
||||||
// GMLIB::Event::PlayerEvent::HandleRequestActionBeforeEvent,
|
// GMLIB::Event::PlayerEvent::HandleRequestActionBeforeEvent,
|
||||||
// (
|
// (
|
||||||
// Player * player,
|
// Player * player,
|
||||||
// std::string const& actionType,
|
// std::string const& actionType,
|
||||||
// int count,
|
// int count,
|
||||||
// std::string const& sourceContainerNetId,
|
// std::string const& sourceContainerNetId,
|
||||||
// int sourceSlot,
|
// int sourceSlot,
|
||||||
// std::string const& destinationContainerNetId,
|
// std::string const& destinationContainerNetId,
|
||||||
// int destinationSlot,
|
// int destinationSlot,
|
||||||
// bool isCancelled
|
// bool isCancelled
|
||||||
// ),
|
// ),
|
||||||
// (
|
// (
|
||||||
// (Player*)&event.self(),
|
// (Player*)&event.self(),
|
||||||
// magic_enum::enum_name(requestAction.mActionType).data(),
|
// magic_enum::enum_name(requestAction.mActionType).data(),
|
||||||
// (int)requestAction.mAmount,
|
// (int)requestAction.mAmount,
|
||||||
// magic_enum::enum_name(requestAction.mSrc->mFullContainerName.mName).data(),
|
// magic_enum::enum_name(requestAction.mSrc->mFullContainerName.mName).data(),
|
||||||
// (int)requestAction.mSrc->mSlot,
|
// (int)requestAction.mSrc->mSlot,
|
||||||
// magic_enum::enum_name(requestAction.mDst->mFullContainerName.mName).data(),
|
// magic_enum::enum_name(requestAction.mDst->mFullContainerName.mName).data(),
|
||||||
// (int)requestAction.mDst->mSlot,
|
// (int)requestAction.mDst->mSlot,
|
||||||
// event.isCancelled()
|
// event.isCancelled()
|
||||||
// ),
|
// ),
|
||||||
// event.setCancelled(result);,
|
// event.setCancelled(result);,
|
||||||
// auto& requestAction = (ItemStackRequestActionTransferBase&)event.getRequestAction();
|
// auto& requestAction = (ItemStackRequestActionTransferBase&)event.getRequestAction();
|
||||||
// );
|
// );
|
||||||
// // clang-format on
|
// // clang-format on
|
||||||
// }
|
// }
|
||||||
// case doHash("gmlib::HandleRequestActionAfterEvent"): {
|
// case doHash("gmlib::HandleRequestActionAfterEvent"): {
|
||||||
// // clang-format off
|
// // clang-format off
|
||||||
// REGISTER_EVENT_LISTEN(
|
// REGISTER_EVENT_LISTEN(
|
||||||
// GMLIB::Event::PlayerEvent::HandleRequestActionAfterEvent,
|
// GMLIB::Event::PlayerEvent::HandleRequestActionAfterEvent,
|
||||||
// (
|
// (
|
||||||
// Player * player,
|
// Player * player,
|
||||||
// std::string const& actionType,
|
// std::string const& actionType,
|
||||||
// int count,
|
// int count,
|
||||||
// std::string const& sourceContainerNetId,
|
// std::string const& sourceContainerNetId,
|
||||||
// int sourceSlot,
|
// int sourceSlot,
|
||||||
// std::string const& destinationContainerNetId,
|
// std::string const& destinationContainerNetId,
|
||||||
// int destinationSlot
|
// int destinationSlot
|
||||||
// ),
|
// ),
|
||||||
// (
|
// (
|
||||||
// (Player*)&event.self(),
|
// (Player*)&event.self(),
|
||||||
// magic_enum::enum_name(requestAction.mActionType).data(),
|
// magic_enum::enum_name(requestAction.mActionType).data(),
|
||||||
// (int)requestAction.mAmount,
|
// (int)requestAction.mAmount,
|
||||||
// magic_enum::enum_name(requestAction.mSrc->mFullContainerName.mName).data(),
|
// magic_enum::enum_name(requestAction.mSrc->mFullContainerName.mName).data(),
|
||||||
// (int)requestAction.mSrc->mSlot,
|
// (int)requestAction.mSrc->mSlot,
|
||||||
// magic_enum::enum_name(requestAction.mDst->mFullContainerName.mName).data(),
|
// magic_enum::enum_name(requestAction.mDst->mFullContainerName.mName).data(),
|
||||||
// (int)requestAction.mDst->mSlot
|
// (int)requestAction.mDst->mSlot
|
||||||
// ),
|
// ),
|
||||||
// ,
|
// ,
|
||||||
// auto& requestAction = (ItemStackRequestActionTransferBase&)event.getRequestAction();
|
// auto& requestAction = (ItemStackRequestActionTransferBase&)event.getRequestAction();
|
||||||
// );
|
// );
|
||||||
// // clang-format on
|
// // clang-format on
|
||||||
// }
|
// }
|
||||||
// case doHash("gmlib::ContainerClosePacketSendAfterEvent"): {
|
// case doHash("gmlib::ContainerClosePacketSendAfterEvent"): {
|
||||||
// REGISTER_EVENT_LISTEN(
|
// REGISTER_EVENT_LISTEN(
|
||||||
// GMLIB::Event::PacketEvent::ContainerClosePacketSendAfterEvent,
|
// GMLIB::Event::PacketEvent::ContainerClosePacketSendAfterEvent,
|
||||||
// (Player * player, int containerId, bool serverInitiatedClose, bool),
|
// (Player * player, int containerId, bool serverInitiatedClose, bool),
|
||||||
// (event.getServerNetworkHandler()
|
// (event.getServerNetworkHandler()
|
||||||
// ._getServerPlayer(event.getNetworkIdentifier(), event.getPacket().mClientSubId),
|
// ._getServerPlayer(event.getNetworkIdentifier(), event.getPacket().mClientSubId),
|
||||||
// (int)event.getPacket().mContainerId,
|
// (int)event.getPacket().mContainerId,
|
||||||
// event.getPacket().mServerInitiatedClose,
|
// event.getPacket().mServerInitiatedClose,
|
||||||
// false),
|
// false),
|
||||||
// ,
|
// ,
|
||||||
// );
|
// );
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user