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