Skip to content

Commit 84a5f3b

Browse files
Blade-uaAvanatiker
andauthored
Velocity: NoBlockPush (#435)
* Adding PushOutOfBlocksEvent * Add needed mixin for PushOutOfBlocksEvent * Add Block setting for NoPush * Block default setting off Co-authored-by: Constructor <[email protected]>
1 parent 9bb2802 commit 84a5f3b

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

src/main/java/com/lambda/mixin/player/MixinEntityPlayerSP.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.lambda.client.event.LambdaEventBus;
44
import com.lambda.client.event.events.OnUpdateWalkingPlayerEvent;
55
import com.lambda.client.event.events.PlayerMoveEvent;
6+
import com.lambda.client.event.events.PushOutOfBlocksEvent;
67
import com.lambda.client.gui.mc.LambdaGuiBeacon;
78
import com.lambda.client.manager.managers.MessageManager;
89
import com.lambda.client.manager.managers.PlayerPacketManager;
@@ -70,6 +71,15 @@ public void closeScreen(Minecraft minecraft, GuiScreen screen) {
7071
if (PortalChat.INSTANCE.isDisabled()) Wrapper.getMinecraft().displayGuiScreen(screen);
7172
}
7273

74+
@Inject(method = "pushOutOfBlocks", at = @At("HEAD"), cancellable = true)
75+
private void onPushOutOfBlocks(CallbackInfoReturnable<Boolean> callbackInfoReturnable) {
76+
PushOutOfBlocksEvent event = new PushOutOfBlocksEvent();
77+
LambdaEventBus.INSTANCE.post(event);
78+
if (event.getCancelled()) {
79+
callbackInfoReturnable.setReturnValue(false);
80+
}
81+
}
82+
7383
/**
7484
* @author TBM
7585
* Used with full permission from TBM - l1ving
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.lambda.client.event.events
2+
3+
import com.lambda.client.event.*
4+
5+
class PushOutOfBlocksEvent : Event, ICancellable by Cancellable()

src/main/kotlin/com/lambda/client/module/modules/movement/Velocity.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.lambda.client.module.modules.movement
22

33
import com.lambda.client.event.events.PacketEvent
4+
import com.lambda.client.event.events.PushOutOfBlocksEvent
45
import com.lambda.client.mixin.extension.*
56
import com.lambda.client.module.Category
67
import com.lambda.client.module.Module
@@ -31,6 +32,7 @@ object Velocity : Module(
3132
private val noPush by setting("No Push", true)
3233
private val entity by setting("Entity", true, { noPush })
3334
private val liquid by setting("Liquid", true, { noPush })
35+
private val block by setting("Block", false, { noPush })
3436

3537
init {
3638
safeListener<PacketEvent.Receive> {
@@ -57,6 +59,10 @@ object Velocity : Module(
5759
}
5860
}
5961
}
62+
63+
safeListener<PushOutOfBlocksEvent> {
64+
if (block) it.cancel()
65+
}
6066
}
6167

6268
private val isZero get() = horizontal == 0.0f && vertical == 0.0f

0 commit comments

Comments
 (0)