fix: fix event api
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
#include "Global.h"
|
||||
#include <gmlib/mc/network/BinaryStream.h>
|
||||
#include <mc/world/item/NetworkItemStackDescriptor.h>
|
||||
|
||||
class LegacyScriptBinaryStreamManager {
|
||||
private:
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "Global.h"
|
||||
#include <regex>
|
||||
#include <unordered_map>
|
||||
|
||||
ActorUniqueID parseScriptUniqueID(std::string const& uniqueId) {
|
||||
return string_utils::isInteger(uniqueId) ? ActorUniqueID(std::stoll(uniqueId)) : ActorUniqueID::INVALID_ID();
|
||||
|
||||
+110
-115
@@ -161,38 +161,38 @@ void Export_Event_API() {
|
||||
,
|
||||
);
|
||||
}
|
||||
// case doHash("gmlib::PlayerStartSleepBeforeEvent"): {
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// GMLIB::Event::PlayerEvent::PlayerStartSleepBeforeEvent,
|
||||
// (Player * entity, BlockPos pos, bool isCancelled),
|
||||
// (&event.self(), event.getPosition(), event.isCancelled()),
|
||||
// event.setCancelled(result);
|
||||
// );
|
||||
// }
|
||||
// case doHash("gmlib::PlayerStartSleepAfterEvent"): {
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// GMLIB::Event::PlayerEvent::PlayerStartSleepAfterEvent,
|
||||
// (Player * entity, BlockPos pos, int result),
|
||||
// (&event.self(), event.getPosition(), (int)event.getResult()),
|
||||
// ,
|
||||
// );
|
||||
// }
|
||||
// case doHash("gmlib::PlayerStopSleepBeforeEvent"): {
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// GMLIB::Event::PlayerEvent::PlayerStopSleepBeforeEvent,
|
||||
// (Player * entity, bool forcefulWakeUp, bool updateLevelList, bool isCancelled),
|
||||
// (&event.self(), event.isForcefulWakeUp(), event.isUpdateLevelList(), event.isCancelled()),
|
||||
// event.setCancelled(result);
|
||||
// );
|
||||
// }
|
||||
// case doHash("gmlib::PlayerStopSleepAfterEvent"): {
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// GMLIB::Event::PlayerEvent::PlayerStopSleepAfterEvent,
|
||||
// (Player * entity, bool forcefulWakeUp, bool updateLevelList, bool),
|
||||
// (&event.self(), event.isForcefulWakeUp(), event.isUpdateLevelList(), false),
|
||||
// ,
|
||||
// );
|
||||
// }
|
||||
case doHash("gmlib::PlayerStartSleepBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerStartSleepBeforeEvent,
|
||||
(Player * entity, BlockPos pos, bool isCancelled),
|
||||
(&event.self(), event.pos(), event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::PlayerStartSleepAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerStartSleepAfterEvent,
|
||||
(Player * entity, BlockPos pos, int result),
|
||||
(&event.self(), event.pos(), (int)event.result()),
|
||||
,
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::PlayerStopSleepBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerStopSleepBeforeEvent,
|
||||
(Player * entity, bool forcefulWakeUp, bool updateLevelList, bool isCancelled),
|
||||
(&event.self(), event.forcefulWakeUp(), event.updateLevelList(), false),
|
||||
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::PlayerStopSleepAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerStopSleepAfterEvent,
|
||||
(Player * entity, bool forcefulWakeUp, bool updateLevelList, bool),
|
||||
(&event.self(), event.forcefulWakeUp(), event.updateLevelList(), false),
|
||||
,
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::DeathMessageAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::DeathMessageAfterEvent,
|
||||
@@ -201,21 +201,22 @@ void Export_Event_API() {
|
||||
,
|
||||
);
|
||||
}
|
||||
// case doHash("gmlib::MobHurtAfterEvent"): {
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// GMLIB::Event::EntityEvent::MobHurtAfterEvent,
|
||||
// (Actor * mob, Actor * source, float damage, int cause),
|
||||
// (&event.self(), source, -event.getDamage(), (int)damageSource.getCause()),
|
||||
// ,
|
||||
// auto& damageSource = event.getSource();
|
||||
// Actor* source = nullptr;
|
||||
// if (damageSource.isEntitySource()) {
|
||||
// auto uniqueId = damageSource.getDamagingEntityUniqueID();
|
||||
// source = ll::service::getLevel()->fetchEntity(uniqueId, false);
|
||||
// if (source->getOwner()) source = source->getOwner();
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
case doHash("gmlib::MobHurtAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::MobHealthChangeAfterEvent,
|
||||
(Actor * mob, Actor * source, float damage, int cause),
|
||||
(&event.self(), source, event.oldValue() - event.newValue(), (int)damageSource->mCause),
|
||||
,
|
||||
if (event.newValue() > event.oldValue()) return;
|
||||
auto& damageSource = event.buff().mSource;
|
||||
Actor* source = nullptr;
|
||||
if (damageSource->isEntitySource()) {
|
||||
auto uniqueId = damageSource->getDamagingEntityUniqueID();
|
||||
source = ll::service::getLevel()->fetchEntity(uniqueId, false);
|
||||
if (source->getOwner()) source = source->getOwner();
|
||||
}
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::EndermanTakeBlockBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(ila::mc::EndermanTakeBlockBeforeEvent,
|
||||
(Actor * mob, bool isCancelled),
|
||||
@@ -257,74 +258,68 @@ void Export_Event_API() {
|
||||
({event.pos(), event.blockSource().getDimensionId()}),
|
||||
);
|
||||
}
|
||||
// case doHash("gmlib::HandleRequestActionBeforeEvent"): {
|
||||
// // clang-format off
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// GMLIB::Event::PlayerEvent::HandleRequestActionBeforeEvent,
|
||||
// (
|
||||
// Player * player,
|
||||
// std::string const& actionType,
|
||||
// int count,
|
||||
// std::string const& sourceContainerNetId,
|
||||
// int sourceSlot,
|
||||
// std::string const& destinationContainerNetId,
|
||||
// int destinationSlot,
|
||||
// bool isCancelled
|
||||
// ),
|
||||
// (
|
||||
// (Player*)&event.self(),
|
||||
// magic_enum::enum_name(requestAction.mActionType).data(),
|
||||
// (int)requestAction.mAmount,
|
||||
// magic_enum::enum_name(requestAction.mSrc->mFullContainerName.mName).data(),
|
||||
// (int)requestAction.mSrc->mSlot,
|
||||
// magic_enum::enum_name(requestAction.mDst->mFullContainerName.mName).data(),
|
||||
// (int)requestAction.mDst->mSlot,
|
||||
// event.isCancelled()
|
||||
// ),
|
||||
// event.setCancelled(result);,
|
||||
// auto& requestAction = (ItemStackRequestActionTransferBase&)event.getRequestAction();
|
||||
// );
|
||||
// // clang-format on
|
||||
// }
|
||||
// case doHash("gmlib::HandleRequestActionAfterEvent"): {
|
||||
// // clang-format off
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// GMLIB::Event::PlayerEvent::HandleRequestActionAfterEvent,
|
||||
// (
|
||||
// Player * player,
|
||||
// std::string const& actionType,
|
||||
// int count,
|
||||
// std::string const& sourceContainerNetId,
|
||||
// int sourceSlot,
|
||||
// std::string const& destinationContainerNetId,
|
||||
// int destinationSlot
|
||||
// ),
|
||||
// (
|
||||
// (Player*)&event.self(),
|
||||
// magic_enum::enum_name(requestAction.mActionType).data(),
|
||||
// (int)requestAction.mAmount,
|
||||
// magic_enum::enum_name(requestAction.mSrc->mFullContainerName.mName).data(),
|
||||
// (int)requestAction.mSrc->mSlot,
|
||||
// magic_enum::enum_name(requestAction.mDst->mFullContainerName.mName).data(),
|
||||
// (int)requestAction.mDst->mSlot
|
||||
// ),
|
||||
// ,
|
||||
// auto& requestAction = (ItemStackRequestActionTransferBase&)event.getRequestAction();
|
||||
// );
|
||||
// // clang-format on
|
||||
// }
|
||||
// case doHash("gmlib::ContainerClosePacketSendAfterEvent"): {
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// GMLIB::Event::PacketEvent::ContainerClosePacketSendAfterEvent,
|
||||
// (Player * player, int containerId, bool serverInitiatedClose, bool),
|
||||
// (event.getServerNetworkHandler()
|
||||
// ._getServerPlayer(event.getNetworkIdentifier(), event.getPacket().mClientSubId),
|
||||
// (int)event.getPacket().mContainerId,
|
||||
// event.getPacket().mServerInitiatedClose,
|
||||
// false),
|
||||
// ,
|
||||
// );
|
||||
// }
|
||||
case doHash("gmlib::HandleRequestActionBeforeEvent"): {
|
||||
// clang-format off
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerRequestItemActionBeforeEvent,
|
||||
(
|
||||
Player * player,
|
||||
std::string const& actionType,
|
||||
int count,
|
||||
std::string const& sourceContainerNetId,
|
||||
int sourceSlot,
|
||||
std::string const& destinationContainerNetId,
|
||||
int destinationSlot,
|
||||
bool isCancelled
|
||||
),
|
||||
(
|
||||
(Player*)&event.self(),
|
||||
magic_enum::enum_name(event.actionType()).data(),
|
||||
event.amount(),
|
||||
magic_enum::enum_name(event.src().mFullContainerName.mName).data(),
|
||||
(int)event.src().mSlot,
|
||||
magic_enum::enum_name(event.dst().mFullContainerName.mName).data(),
|
||||
(int)event.dst().mSlot,
|
||||
event.isCancelled()
|
||||
),
|
||||
event.setCancelled(result);,
|
||||
);
|
||||
// clang-format on
|
||||
}
|
||||
case doHash("gmlib::HandleRequestActionAfterEvent"): {
|
||||
// clang-format off
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerRequestItemActionAfterEvent,
|
||||
(
|
||||
Player * player,
|
||||
std::string const& actionType,
|
||||
int count,
|
||||
std::string const& sourceContainerNetId,
|
||||
int sourceSlot,
|
||||
std::string const& destinationContainerNetId,
|
||||
int destinationSlot
|
||||
),
|
||||
(
|
||||
(Player*)&event.self(),
|
||||
magic_enum::enum_name(event.actionType()).data(),
|
||||
event.amount(),
|
||||
magic_enum::enum_name(event.src().mFullContainerName.mName).data(),
|
||||
(int)event.src().mSlot,
|
||||
magic_enum::enum_name(event.dst().mFullContainerName.mName).data(),
|
||||
(int)event.dst().mSlot
|
||||
),
|
||||
,
|
||||
);
|
||||
// clang-format on
|
||||
}
|
||||
case doHash("gmlib::ContainerClosePacketSendAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerCloseContainerAfterEvent,
|
||||
(Player * player, int containerId, bool serverInitiatedClose, bool),
|
||||
(&event.self(), (int)event.containerId(), event.serverInitiatedClose(), false),
|
||||
,
|
||||
);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
#include "Global.h"
|
||||
#include "gmlib/mod/recipe/CustomRecipeRegistry.h"
|
||||
#include <gmlib/mc/world/Level.h>
|
||||
#include <mc/world/item/crafting/RecipeIngredient.h>
|
||||
|
||||
std::unordered_set<std::string> HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"};
|
||||
|
||||
|
||||
+2
-1
@@ -20,7 +20,8 @@
|
||||
"platform": "win-x64",
|
||||
"dependencies": {
|
||||
"github.com/LiteLDev/LeviLamina": ">=1.1.1",
|
||||
"github.com/GroupMountain/GMLIB-Release": ">=1.0.0"
|
||||
"github.com/GroupMountain/GMLIB-Release": ">=1.0.0",
|
||||
"github.com/MiracleForest/iListenAttentively-Release": ">=0.4.1"
|
||||
},
|
||||
"assets": [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user