-
Notifications
You must be signed in to change notification settings - Fork 5
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
25 changed files
with
351 additions
and
86 deletions.
There are no files selected for viewing
Binary file not shown.
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,15 @@ | ||
#pragma once | ||
#include "GMLIB/GMLIB.h" | ||
#include <ll/api/event/entity/ActorEvent.h> | ||
|
||
namespace GMLIB::Event::EntityEvent { | ||
|
||
class ItemActorEvent : public ll::event::entity::ActorEvent { | ||
protected: | ||
constexpr explicit ItemActorEvent(ItemActor& itemActor) : ActorEvent(itemActor) {} | ||
|
||
public: | ||
GMLIB_API ItemActor& getItemActor() const; | ||
}; | ||
|
||
} // namespace GMLIB::Event::EntityEvent |
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,67 @@ | ||
#pragma once | ||
#include "GMLIB/Event/Entity/ItemActorEvent.h" | ||
#include "GMLIB/GMLIB.h" | ||
#include <ll/api/event/entity/ActorEvent.h> | ||
|
||
namespace GMLIB::Event::EntityEvent { | ||
|
||
class ItemActorSpawnBeforeEvent : public ll::event::Cancellable<ll::event::Event> { | ||
BlockSource const& mBlockSource; | ||
Vec3& mPosition; | ||
ItemStack& mItem; | ||
Actor* mSpawner = nullptr; | ||
int mThrowTime; | ||
|
||
public: | ||
constexpr explicit ItemActorSpawnBeforeEvent( | ||
BlockSource& blockSource, | ||
Vec3& position, | ||
ItemStack& item, | ||
Actor* spawner, | ||
int throwTime | ||
) | ||
: Cancellable(), | ||
mBlockSource(blockSource), | ||
mPosition(position), | ||
mItem(item), | ||
mSpawner(spawner), | ||
mThrowTime(throwTime) {} | ||
|
||
GMLIB_API BlockSource const& getBlockSource() const; | ||
GMLIB_API Vec3 const& getPosition() const; | ||
GMLIB_API ItemStack const& getItem() const; | ||
GMLIB_API Actor* const getSpawner() const; | ||
GMLIB_API int const& getThrowTime() const; | ||
}; | ||
|
||
class ItemActorSpawnAfterEvent : public ItemActorEvent { | ||
BlockSource const& mBlockSource; | ||
Vec3& mPosition; | ||
ItemStack& mItem; | ||
Actor* mSpawner = nullptr; | ||
int mThrowTime; | ||
|
||
public: | ||
constexpr explicit ItemActorSpawnAfterEvent( | ||
ItemActor& itemActor, | ||
BlockSource& blockSource, | ||
Vec3& position, | ||
ItemStack& item, | ||
Actor* spawner, | ||
int throwTime | ||
) | ||
: ItemActorEvent(itemActor), | ||
mBlockSource(blockSource), | ||
mPosition(position), | ||
mItem(item), | ||
mSpawner(spawner), | ||
mThrowTime(throwTime) {} | ||
|
||
GMLIB_API BlockSource const& getBlockSource() const; | ||
GMLIB_API Vec3 const& getPosition() const; | ||
GMLIB_API ItemStack const& getItem() const; | ||
GMLIB_API Actor* const getSpawner() const; | ||
GMLIB_API int const& getThrowTime() const; | ||
}; | ||
|
||
} // namespace GMLIB::Event::EntityEvent |
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,27 @@ | ||
#pragma once | ||
#include "GMLIB/GMLIB.h" | ||
#include <ll/api/event/entity/MobEvent.h> | ||
|
||
namespace GMLIB::Event::EntityEvent { | ||
|
||
class MobPickupItemBeforeEvent : public ll::event::Cancellable<ll::event::entity::MobEvent> { | ||
ItemActor& mItemActor; | ||
|
||
public: | ||
constexpr explicit MobPickupItemBeforeEvent(Mob& mob, ItemActor& itemActor) | ||
: Cancellable(mob), | ||
mItemActor(itemActor) {} | ||
|
||
GMLIB_API ItemActor const& getItemActor() const; | ||
}; | ||
|
||
class MobPickupItemAfterEvent : public ll::event::entity::MobEvent { | ||
ItemActor& mItemActor; | ||
|
||
public: | ||
constexpr explicit MobPickupItemAfterEvent(Mob& mob, ItemActor& itemActor) : MobEvent(mob), mItemActor(itemActor) {} | ||
|
||
GMLIB_API ItemActor const& getItemActor() const; | ||
}; | ||
|
||
} // namespace GMLIB::Event::EntityEvent |
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,8 @@ | ||
#include "Global.h" | ||
#include <GMLIB/Event/entity/ItemActorEvent.h> | ||
|
||
namespace GMLIB::Event::EntityEvent { | ||
|
||
ItemActor& ItemActorEvent::getItemActor() const { return static_cast<ItemActor&>(ActorEvent::self()); } | ||
|
||
} // namespace GMLIB::Event::EntityEvent |
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,43 @@ | ||
#include "Global.h" | ||
#include <GMLIB/Event/entity/ItemActorSpawnEvent.h> | ||
|
||
namespace GMLIB::Event::EntityEvent { | ||
|
||
BlockSource const& ItemActorSpawnBeforeEvent::getBlockSource() const { return mBlockSource; } | ||
Vec3 const& ItemActorSpawnBeforeEvent::getPosition() const { return mPosition; } | ||
ItemStack const& ItemActorSpawnBeforeEvent::getItem() const { return mItem; } | ||
Actor* const ItemActorSpawnBeforeEvent::getSpawner() const { return mSpawner; } | ||
int const& ItemActorSpawnBeforeEvent::getThrowTime() const { return mThrowTime; } | ||
|
||
BlockSource const& ItemActorSpawnAfterEvent::getBlockSource() const { return mBlockSource; } | ||
Vec3 const& ItemActorSpawnAfterEvent::getPosition() const { return mPosition; } | ||
ItemStack const& ItemActorSpawnAfterEvent::getItem() const { return mItem; } | ||
Actor* const ItemActorSpawnAfterEvent::getSpawner() const { return mSpawner; } | ||
int const& ItemActorSpawnAfterEvent::getThrowTime() const { return mThrowTime; } | ||
|
||
LL_AUTO_TYPE_INSTANCE_HOOK( | ||
ItemSpawnEventHook, | ||
ll::memory::HookPriority::Normal, | ||
Spawner, | ||
"?spawnItem@Spawner@@QEAAPEAVItemActor@@AEAVBlockSource@@AEBVItemStack@@PEAVActor@@AEBVVec3@@H@Z", | ||
ItemActor*, | ||
class BlockSource& region, | ||
class ItemStack& item, | ||
class Actor* spawner, | ||
class Vec3& pos, | ||
int throwTime | ||
) { | ||
auto beforeEvent = ItemActorSpawnBeforeEvent(region, pos, item, spawner, throwTime); | ||
ll::event::EventBus::getInstance().publish(beforeEvent); | ||
if (beforeEvent.isCancelled()) { | ||
return nullptr; | ||
} | ||
auto result = origin(region, item, spawner, pos, throwTime); | ||
if (result) { | ||
auto afterEvent = ItemActorSpawnAfterEvent(*result, region, pos, item, spawner, throwTime); | ||
ll::event::EventBus::getInstance().publish(afterEvent); | ||
} | ||
return result; | ||
} | ||
|
||
} // namespace GMLIB::Event::EntityEvent |
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,29 @@ | ||
#include "Global.h" | ||
#include <GMLIB/Event/entity/MobPickupItemEvent.h> | ||
|
||
namespace GMLIB::Event::EntityEvent { | ||
|
||
ItemActor const& MobPickupItemBeforeEvent::getItemActor() const { return mItemActor; } | ||
|
||
ItemActor const& MobPickupItemAfterEvent::getItemActor() const { return mItemActor; } | ||
|
||
LL_AUTO_TYPE_INSTANCE_HOOK( | ||
MobPickupItemEventHook, | ||
ll::memory::HookPriority::Normal, | ||
PickupItemsGoal, | ||
"?_pickItemUp@PickupItemsGoal@@AEAAXPEAVItemActor@@@Z", | ||
void, | ||
class ItemActor& item | ||
) { | ||
auto mob = ll::memory::dAccess<Mob*>(this, 112); // IDA: PickupItemsGoal::PickupItemsGoal() | ||
auto beforeEvent = MobPickupItemBeforeEvent(*mob, item); | ||
ll::event::EventBus::getInstance().publish(beforeEvent); | ||
if (beforeEvent.isCancelled()) { | ||
return; | ||
} | ||
origin(item); | ||
auto afterEvent = MobPickupItemAfterEvent(*mob, item); | ||
ll::event::EventBus::getInstance().publish(afterEvent); | ||
} | ||
|
||
} // namespace GMLIB::Event::EntityEvent |
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
Oops, something went wrong.