Skip to content

Commit

Permalink
~
Browse files Browse the repository at this point in the history
  • Loading branch information
hhhxiao committed Aug 17, 2022
1 parent 1ead766 commit f50f868
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/opts/ActorOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

THook(void, "?push@PushableComponent@@QEAAXAEAVActor@@AEBVVec3@@@Z", void *comp, void *a1,
const Vec3 &v) {
if (!trapdoor::mod().actorPush) {
original(comp, a1, v);
return;
}
if (v != Vec3::ZERO) {
original(comp, a1, v);
}
Expand Down
13 changes: 10 additions & 3 deletions src/opts/HopperOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,15 @@ THook(bool, "?_tryMoveItems@Hopper@@IEAA_NAEAVBlockSource@@AEAVContainer@@AEBVVe
Hopper *self, BlockSource &bs, Container &fromContainer, Vec3 const &v, int attachedFace,
bool canPushItems) {
auto *tHopper = reinterpret_cast<THopper *>(self);
// 漏斗矿车直接返回
if (tHopper->mIsEntity) return original(self, bs, fromContainer, v, attachedFace, canPushItems);

auto hma = trapdoor::mod().hopper;
if (!hma) {
return original(self, bs, fromContainer, v, attachedFace, canPushItems);
}

// 漏斗矿车直接返回

auto pos = v.toBlockPos();
auto aboveBlockPos = pos + BlockPos(0, 1, 0);
auto &aboveBlock = bs.getBlock(aboveBlockPos);
Expand Down Expand Up @@ -144,10 +151,10 @@ THook(bool, "?_tryMoveItems@Hopper@@IEAA_NAEAVBlockSource@@AEAVContainer@@AEBVVe
// }
THook(bool, "?_isFullContainer@Hopper@@IEAA_NAEAVBlockSource@@AEAVContainer@@H@Z", Hopper *hopper,
BlockSource &bs, Container &container, int face) {
if (!trapdoor::mod().hopper) {
auto hma = trapdoor::mod().hopper;
if (!hma) {
return original(hopper, bs, container, face);
}

auto sz = container.getSize();
for (int i = 0; i < sz; i++) {
auto &item = container.getItem(i);
Expand Down
4 changes: 4 additions & 0 deletions src/opts/RandomTickOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
// }

THook(bool, "?shouldRandomTick@Block@@QEBA_NXZ", Block *block) {
if (!trapdoor::mod().randomTick) {
return original(block);
}

auto id = block->getId();
/*
* -378 => minecraft:deepslate
Expand Down
21 changes: 19 additions & 2 deletions src/opts/RedstoneOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ struct TCircuitSceneGraph {
static_assert(sizeof(ComponentItem) == 32);

THook(void, "?removeComponent@CircuitSceneGraph@@AEAAXAEBVBlockPos@@@Z", void *g,
const BlockPos &p) {}
const BlockPos &p) {
if (trapdoor::mod().componentRemove) {
return;
}
original(g, p);
}

void optPendingRemoves(CircuitSceneGraph *graph) {
// rmt_ScopedCPUSample(PendingRemoveAll, 0);
Expand Down Expand Up @@ -173,6 +178,18 @@ void optPendingRemoves(CircuitSceneGraph *graph) {

THook(void, "?update@CircuitSceneGraph@@QEAAXPEAVBlockSource@@@Z", CircuitSceneGraph *self,
void *bs) {
optPendingRemoves(self);
if (trapdoor::mod().componentRemove) {
optPendingRemoves(self);
}
original(self, bs);
}

// THook(void, "?evaluateComponents@CircuitSystem@@AEAAX_N@Z", void *c, bool t) {
// if (t) {
// rmt_ScopedCPUSample(Evaluate_True, 0);
// original(c, t);
// } else {
// rmt_ScopedCPUSample(Evaluate_False, 0);
// original(c, t);
// }
// }

0 comments on commit f50f868

Please sign in to comment.