|
| 1 | +package com.shaybox.rusher.modules; |
| 2 | + |
| 3 | +import net.minecraft.client.Minecraft; |
| 4 | +import net.minecraft.client.multiplayer.MultiPlayerGameMode; |
| 5 | +import net.minecraft.client.player.LocalPlayer; |
| 6 | +import net.minecraft.core.BlockPos; |
| 7 | +import net.minecraft.core.Direction; |
| 8 | +import net.minecraft.network.protocol.Packet; |
| 9 | +import net.minecraft.network.protocol.game.ClientboundBlockDestructionPacket; |
| 10 | +import org.rusherhack.client.api.events.network.EventPacket; |
| 11 | +import org.rusherhack.client.api.events.player.EventPlayerUpdate; |
| 12 | +import org.rusherhack.client.api.feature.module.ModuleCategory; |
| 13 | +import org.rusherhack.client.api.feature.module.ToggleableModule; |
| 14 | +import org.rusherhack.core.event.subscribe.Subscribe; |
| 15 | +import org.rusherhack.core.setting.BooleanSetting; |
| 16 | + |
| 17 | +public class AntiProne extends ToggleableModule { |
| 18 | + |
| 19 | + /* Minecraft */ |
| 20 | + private final Minecraft minecraft = Minecraft.getInstance(); |
| 21 | + |
| 22 | + /* Settings */ |
| 23 | + private final BooleanSetting packetOnly = new BooleanSetting("PacketOnly", "Only start mining the block", false); |
| 24 | + |
| 25 | + /* Initialize */ |
| 26 | + public AntiProne() { |
| 27 | + super("AntiProne", ModuleCategory.COMBAT); |
| 28 | + this.registerSettings(this.packetOnly); |
| 29 | + } |
| 30 | + |
| 31 | + @Subscribe |
| 32 | + private void onPacket(EventPacket.Receive event) { |
| 33 | + final MultiPlayerGameMode gameMode = this.minecraft.gameMode; |
| 34 | + final LocalPlayer player = this.minecraft.player; |
| 35 | + if (gameMode == null || player == null) return; |
| 36 | + |
| 37 | + final Packet<?> packet = event.getPacket(); |
| 38 | + if (packet instanceof ClientboundBlockDestructionPacket destructionPacket) { |
| 39 | + final BlockPos playerFeetPos = player.blockPosition(); |
| 40 | + final BlockPos playerHeadPos = playerFeetPos.offset(0, 1, 0); |
| 41 | + final BlockPos blockPos = destructionPacket.getPos(); |
| 42 | + if (!blockPos.equals(playerFeetPos)) return; |
| 43 | + |
| 44 | + gameMode.startDestroyBlock(playerHeadPos, Direction.DOWN); |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + @Subscribe |
| 49 | + private void onPlayerUpdate(EventPlayerUpdate event) { |
| 50 | + if (this.packetOnly.getValue()) return; |
| 51 | + |
| 52 | + final LocalPlayer player = event.getPlayer(); |
| 53 | + final MultiPlayerGameMode gameMode = this.minecraft.gameMode; |
| 54 | + if (gameMode == null) return; |
| 55 | + |
| 56 | + final BlockPos playerFeetPos = player.blockPosition(); |
| 57 | + final BlockPos playerHeadPos = playerFeetPos.offset(0, 1, 0); |
| 58 | + if (gameMode.isDestroying()) gameMode.continueDestroyBlock(playerHeadPos, Direction.DOWN); |
| 59 | + } |
| 60 | + |
| 61 | +} |
0 commit comments