修复ProjectileSpawn事件

This commit is contained in:
Qiuzhizhe 2023-03-18 06:41:14 -07:00
parent 4097c5417f
commit b3c3b76551

View File

@ -1620,67 +1620,68 @@ THook(void, "?destroyBlocks@@YAXAEAVLevel@@AEBVAABB@@AEAVBlockSource@@H@Z",
// } // }
////////////// ProjectileSpawn ////////////// ////////////// ProjectileSpawn //////////////
// TClasslessInstanceHook(Actor*, TClasslessInstanceHook(Actor*,
// "?spawnProjectile@Spawner@@QEAAPEAVActor@@AEAVBlockSource@@AEBUActorDefinitionIdentifier@@PEAV2@AEBVVec3@@3@Z", "?spawnProjectile@Spawner@@QEAAPEAVActor@@AEAVBlockSource@@AEBUActorDefinitionIdentifier@@PEAV2@AEBVVec3@@3@Z",
// BlockSource* a2, ActorDefinitionIdentifier* a3, Actor* a4, Vec3* a5, Vec3* a6) { BlockSource* blockSource, ActorDefinitionIdentifier* id, Actor* actor, Vec3* position, Vec3* direction) {
// string name = a3->getCanonicalName(); string name = id->getCanonicalName();
// if (name != "minecraft:thrown_trident") { if (name != "minecraft:thrown_trident") {
// IF_LISTENED(ProjectileSpawnEvent) { IF_LISTENED(ProjectileSpawnEvent) {
// ProjectileSpawnEvent ev{}; ProjectileSpawnEvent ev{};
// ev.mShooter = a4; ev.mShooter = actor;
// ev.mIdentifier = a3; ev.mIdentifier = id;
// ev.mType = name; ev.mType = name;
// if (!ev.call()) if (!ev.call())
// return nullptr; return nullptr;
// } }
// IF_LISTENED_END(ProjectileSpawnEvent) IF_LISTENED_END(ProjectileSpawnEvent)
// } }
// auto projectile = original(this, a2, a3, a4, a5, a6); auto result = original(this, blockSource, id, actor, position, direction);
// IF_LISTENED(ProjectileCreatedEvent) { IF_LISTENED(ProjectileCreatedEvent) {
// ProjectileCreatedEvent ev{}; ProjectileCreatedEvent ev{};
// ev.mShooter = a4; ev.mShooter = actor;
// ev.mProjectile = projectile; ev.mProjectile = result;
// ev.call(); ev.call();
// } }
// IF_LISTENED_END(ProjectileCreatedEvent) IF_LISTENED_END(ProjectileCreatedEvent)
// return projectile; return result;
// } }
// #include <llapi/mc/CrossbowItem.hpp> #include <llapi/mc/CrossbowItem.hpp>
#include <llapi/mc/ActorDefinitionIdentifier.hpp> #include <llapi/mc/ActorDefinitionIdentifier.hpp>
// static_assert(sizeof(ActorDefinitionIdentifier) == 176); #include <llapi/mc/ItemInstance.hpp>
// TInstanceHook(void, "?_shootFirework@CrossbowItem@@AEBAXAEBVItemInstance@@AEAVPlayer@@@Z",
// CrossbowItem, void* a1, Player* a2) {
// IF_LISTENED(ProjectileSpawnEvent) {
// ActorDefinitionIdentifier identifier("minecraft:fireworks_rocket");
// ProjectileSpawnEvent ev{};
// ev.mShooter = a2;
// ev.mIdentifier = &identifier;
// ev.mType = this->getFullItemName();
// if (!ev.call()) TInstanceHook(void, "?_shootFirework@CrossbowItem@@AEBAXAEBVItemInstance@@AEAVPlayer@@@Z",
// return; CrossbowItem, ItemInstance* projectileInstance, Player* player) {
// } IF_LISTENED(ProjectileSpawnEvent) {
// IF_LISTENED_END(ProjectileSpawnEvent) ActorDefinitionIdentifier identifier("minecraft:fireworks_rocket");
// original(this, a1, a2); ProjectileSpawnEvent ev{};
// } ev.mShooter = player;
ev.mIdentifier = &identifier;
ev.mType = this->getFullItemName();
// TClasslessInstanceHook(void, "?releaseUsing@TridentItem@@UEBAXAEAVItemStack@@PEAVPlayer@@H@Z", if (!ev.call())
// ItemStack* a2, Player* a3, int a4) { return;
// IF_LISTENED(ProjectileSpawnEvent) { }
// ActorDefinitionIdentifier identifier("minecraft:thrown_trident"); IF_LISTENED_END(ProjectileSpawnEvent)
// ProjectileSpawnEvent ev{}; original(this, projectileInstance, player);
// ev.mShooter = a3; }
// ev.mIdentifier = &identifier;
// ev.mType = a2->getTypeName();
// if (!ev.call()) TClasslessInstanceHook(void, "?releaseUsing@TridentItem@@UEBAXAEAVItemStack@@PEAVPlayer@@H@Z",
// return; ItemStack* itemStack, Player* player, int durationLeft) {
// } IF_LISTENED(ProjectileSpawnEvent) {
// IF_LISTENED_END(ProjectileSpawnEvent) ActorDefinitionIdentifier identifier("minecraft:thrown_trident");
// return original(this, a2, a3, a4); ProjectileSpawnEvent ev{};
// } ev.mShooter = player;
ev.mIdentifier = &identifier;
ev.mType = itemStack->getTypeName();
if (!ev.call())
return;
}
IF_LISTENED_END(ProjectileSpawnEvent)
return original(this, itemStack, player, durationLeft);
}
// #include <llapi/mc/WeakEntityRef.hpp> // #include <llapi/mc/WeakEntityRef.hpp>
// #include <llapi/mc/EntityContext.hpp> // #include <llapi/mc/EntityContext.hpp>