generated from LiteLDev/levilamina-mod-template
-
Notifications
You must be signed in to change notification settings - Fork 1
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
16 changed files
with
468 additions
and
109 deletions.
There are no files selected for viewing
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,45 @@ | ||
#include "Summary.h" | ||
|
||
#include <ll/api/memory/Hook.h> | ||
|
||
#include <mc/world/AutomaticID.h> | ||
#include <mc/world/actor/ai/goal/FollowOwnerGoal.h> | ||
#include <mc/world/actor/player/Player.h> | ||
|
||
namespace bbf { | ||
|
||
LL_TYPE_INSTANCE_HOOK( | ||
FollowOwnerGoalHook, | ||
ll::memory::HookPriority::Normal, | ||
FollowOwnerGoal, | ||
//&FollowOwnerGoal::onPlayerDimensionChanged, | ||
"?onPlayerDimensionChanged@FollowOwnerGoal@@UEAAXPEAVPlayer@@V?$AutomaticID@" | ||
"VDimension@@H@@1@Z", | ||
void, | ||
Player* player, | ||
DimensionType fromDimension, | ||
DimensionType toDimension | ||
) { | ||
auto& mob = ll::memory::dAccess<Mob>(this, 7 * 8); | ||
if (mob.isType(ActorType::Allay)) { | ||
return; | ||
} | ||
origin(player, fromDimension, toDimension); | ||
} | ||
|
||
struct AllayTeleportBugFix::Impl { | ||
ll::memory::HookRegistrar<FollowOwnerGoalHook> r; | ||
}; | ||
|
||
void AllayTeleportBugFix::call(bool enable) { | ||
if (enable) { | ||
if (!impl) impl = std::make_unique<Impl>(); | ||
} else { | ||
impl.reset(); | ||
} | ||
} | ||
|
||
AllayTeleportBugFix::AllayTeleportBugFix() = default; | ||
AllayTeleportBugFix::~AllayTeleportBugFix() = default; | ||
|
||
} // namespace bbf |
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,76 @@ | ||
#include "Summary.h" | ||
|
||
#include <ll/api/memory/Hook.h> | ||
|
||
#include <mc/math/Vec3.h> | ||
#include <mc/world/AutomaticID.h> | ||
#include <mc/world/actor/ActorDefinitionTrigger.h> | ||
#include <mc/world/actor/ActorFilterGroup.h> | ||
#include <mc/world/actor/ai/goal/MoveToBlockGoal.h> | ||
#include <mc/world/actor/player/Player.h> | ||
#include <mc/world/item/ItemDescriptor.h> | ||
|
||
namespace bbf { | ||
|
||
LL_TYPE_INSTANCE_HOOK( | ||
MoveToBlockGoalHook, | ||
ll::memory::HookPriority::Normal, | ||
MoveToBlockGoal, | ||
//&MoveToBlockGoal::onPlayerDimensionChanged, | ||
"??0MoveToBlockGoal@@QEAA@AEAVMob@@MHHHHMVVec3@@MW4TargetSelectionMethod@@V?$vector@" | ||
"VActorDefinitionTrigger@@V?$allocator@VActorDefinitionTrigger@@@std@@@std@@3V?$" | ||
"vector@VItemDescriptor@@V?$allocator@VItemDescriptor@@@std@@@5@AEBVActorFilterGroup@" | ||
"@@Z", | ||
MoveToBlockGoal*, | ||
Mob& mob, | ||
float speedModifier, | ||
int searchRange, | ||
int searchHeight, | ||
int tickInterval, | ||
int stayDurationTicks, | ||
float goalRadius, | ||
Vec3 targetPositionOffset, | ||
float chanceToStart, | ||
::TargetSelectionMethod targetSelectionMethod, | ||
std::vector<ActorDefinitionTrigger> onReachTriggers, | ||
std::vector<ActorDefinitionTrigger> onStayCompletedTriggers, | ||
std::vector<ItemDescriptor> targetBlocks, | ||
ActorFilterGroup const& filterGroup | ||
) { | ||
if (mob.isType(ActorType::Bee)) { | ||
targetSelectionMethod = TargetSelectionMethod::Nearest; | ||
} | ||
return origin( | ||
mob, | ||
speedModifier, | ||
searchRange, | ||
searchHeight, | ||
tickInterval, | ||
stayDurationTicks, | ||
goalRadius, | ||
targetPositionOffset, | ||
chanceToStart, | ||
targetSelectionMethod, | ||
std::move(onReachTriggers), | ||
std::move(onStayCompletedTriggers), | ||
std::move(targetBlocks), | ||
filterGroup | ||
); | ||
} | ||
|
||
struct BeeBugsFix::Impl { | ||
ll::memory::HookRegistrar<MoveToBlockGoalHook> r; | ||
}; | ||
|
||
void BeeBugsFix::call(bool enable) { | ||
if (enable) { | ||
if (!impl) impl = std::make_unique<Impl>(); | ||
} else { | ||
impl.reset(); | ||
} | ||
} | ||
|
||
BeeBugsFix::BeeBugsFix() = default; | ||
BeeBugsFix::~BeeBugsFix() = default; | ||
|
||
} // namespace bbf |
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,111 @@ | ||
#include "Summary.h" | ||
|
||
#include <ll/api/memory/Hook.h> | ||
|
||
#include <mc/entity/WeakEntityRef.h> | ||
#include <mc/math/Vec3.h> | ||
#include <mc/world/Container.h> | ||
#include <mc/world/actor/Actor.h> | ||
#include <mc/world/actor/Hopper.h> | ||
#include <mc/world/actor/item/ItemActor.h> | ||
#include <mc/world/level/BlockSource.h> | ||
#include <mc/world/level/ChunkPos.h> | ||
#include <mc/world/level/block/Block.h> | ||
#include <mc/world/level/block/utils/VanillaBlockTypeIds.h> | ||
#include <mc/world/level/chunk/LevelChunk.h> | ||
#include <mc/world/phys/AABB.h> | ||
|
||
namespace bbf { | ||
|
||
LL_TYPE_INSTANCE_HOOK( | ||
HopperTryAddItemHook, | ||
ll::memory::HookPriority::Normal, | ||
Hopper, | ||
&Hopper::_tryAddItemsFromPos, | ||
bool, | ||
BlockSource& blockSource, | ||
Container& container, | ||
Vec3 const& pos | ||
) { | ||
AABB aabb; | ||
|
||
if (mIsEntity) { | ||
aabb.min = pos - Vec3{0.5f, 0.0f, 0.5f}; | ||
aabb.max = pos + Vec3{0.5f, 1.0f, 0.5f}; | ||
} else { | ||
aabb.min = pos; | ||
aabb.min.y -= 0.375f; | ||
aabb.max = pos + 1; | ||
} | ||
|
||
ChunkPos minChunk( | ||
((int)std::floor(aabb.min.x - 0.125f)) >> 4, | ||
((int)std::floor(aabb.min.z - 0.125f)) >> 4 | ||
); | ||
ChunkPos maxChunk( | ||
((int)std::floor(aabb.max.x + 0.125f)) >> 4, | ||
((int)std::floor(aabb.max.z + 0.125f)) >> 4 | ||
); | ||
|
||
for (int x = minChunk.x; x <= maxChunk.x; x++) | ||
for (int z = minChunk.z; z <= maxChunk.z; z++) { | ||
auto* chunk = blockSource.getChunk({x, z}); | ||
if (!chunk) { | ||
continue; | ||
} | ||
for (auto& weakEntityRef : chunk->getChunkEntities()) { | ||
auto* actor = weakEntityRef.tryUnwrap<Actor>().as_ptr(); | ||
if (!actor || !actor->isType(ActorType::ItemEntity) | ||
|| !aabb.intersects(actor->getAABB()) || actor->isRemoved()) { | ||
continue; | ||
} | ||
auto& item = static_cast<ItemActor*>(actor)->item(); | ||
if (item.isNull()) { | ||
continue; | ||
} | ||
if (_addItem(blockSource, container, item, -1, item.mCount)) { | ||
if (item.mCount != 0) { | ||
_addItem( | ||
blockSource, | ||
container, | ||
item, | ||
-1, | ||
item.mCount | ||
); // need to add twice | ||
} | ||
if (item.mCount == 0) { | ||
actor->remove(); | ||
} | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
LL_TYPE_INSTANCE_HOOK( | ||
IsContainerBlockHook, | ||
ll::memory::HookPriority::Normal, | ||
Block, | ||
&Block::isContainerBlock, | ||
bool | ||
) { | ||
return getName() == VanillaBlockTypeIds::Composter || origin(); | ||
} | ||
|
||
struct HopperBugsFix::Impl { | ||
ll::memory::HookRegistrar<HopperTryAddItemHook, IsContainerBlockHook> r; | ||
}; | ||
|
||
void HopperBugsFix::call(bool enable) { | ||
if (enable) { | ||
if (!impl) impl = std::make_unique<Impl>(); | ||
} else { | ||
impl.reset(); | ||
} | ||
} | ||
|
||
HopperBugsFix::HopperBugsFix() = default; | ||
HopperBugsFix::~HopperBugsFix() = default; | ||
|
||
} // namespace bbf |
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,30 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
|
||
namespace bbf { | ||
struct HopperBugsFix { | ||
struct Impl; | ||
std::unique_ptr<Impl> impl; | ||
|
||
void call(bool); | ||
HopperBugsFix(); | ||
~HopperBugsFix(); | ||
}; | ||
struct BeeBugsFix { | ||
struct Impl; | ||
std::unique_ptr<Impl> impl; | ||
|
||
void call(bool); | ||
BeeBugsFix(); | ||
~BeeBugsFix(); | ||
}; | ||
struct AllayTeleportBugFix { | ||
struct Impl; | ||
std::unique_ptr<Impl> impl; | ||
|
||
void call(bool); | ||
AllayTeleportBugFix(); | ||
~AllayTeleportBugFix(); | ||
}; | ||
} // namespace bbf |
Oops, something went wrong.