File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
src/main/kotlin/com/lambda Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ package com.lambda.module.modules.combat
1919
2020import com.lambda.context.SafeContext
2121import com.lambda.event.events.ConnectionEvent
22+ import com.lambda.event.events.PlayerEvent
2223import com.lambda.event.events.TickEvent
2324import com.lambda.event.listener.SafeListener.Companion.listen
2425import com.lambda.event.listener.SafeListener.Companion.listenConcurrently
@@ -27,6 +28,7 @@ import com.lambda.module.tag.ModuleTag
2728import com.lambda.network.mojang.getProfile
2829import com.lambda.threading.onShutdown
2930import com.lambda.util.Timer
31+ import com.lambda.util.player.FakePlayerId
3032import com.lambda.util.player.spawnFakePlayer
3133import com.mojang.authlib.GameProfile
3234import com.mojang.datafixers.util.Either
@@ -70,6 +72,10 @@ object FakePlayer : Module(
7072 cachedProfiles.getOrPut(playerName) { fetchProfile(playerName) }
7173 }
7274
75+ listen<PlayerEvent .Attack .Entity > {
76+ if (it.entity.id == FakePlayerId ) it.cancel()
77+ }
78+
7379 listen<ConnectionEvent .Connect .Pre > { disable() }
7480 onShutdown { disable() }
7581 onDisable { fakePlayer?.discard(); fakePlayer = null }
Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ import net.minecraft.network.packet.c2s.play.HandSwingC2SPacket
2929import net.minecraft.util.Hand
3030import net.minecraft.world.GameMode
3131
32+ const val FakePlayerId = - 2024 - 4 - 20
33+
3234val SafeContext .gamemode: GameMode
3335 get() = interaction.currentGameMode
3436
@@ -59,7 +61,7 @@ fun SafeContext.spawnFakePlayer(
5961 copyFrom(reference)
6062
6163 playerListEntry = PlayerListEntry (profile, false )
62- id = - 2024 - 4 - 20
64+ id = FakePlayerId
6365 }
6466
6567 if (addToWorld) world.addEntity(entity)
You can’t perform that action at this time.
0 commit comments