|
2 | 2 |
|
3 | 3 | import com.nxyi.addon.Addon; |
4 | 4 | import meteordevelopment.meteorclient.events.packets.PacketEvent; |
| 5 | +import meteordevelopment.meteorclient.settings.BoolSetting; |
| 6 | +import meteordevelopment.meteorclient.settings.DoubleSetting; |
| 7 | +import meteordevelopment.meteorclient.settings.Setting; |
| 8 | +import meteordevelopment.meteorclient.settings.SettingGroup; |
5 | 9 | import meteordevelopment.meteorclient.systems.modules.Categories; |
6 | 10 | import meteordevelopment.meteorclient.systems.modules.Category; |
7 | 11 | import meteordevelopment.meteorclient.systems.modules.Module; |
8 | 12 | import meteordevelopment.orbit.EventHandler; |
| 13 | +import net.minecraft.block.BedBlock; |
9 | 14 | import net.minecraft.block.Blocks; |
| 15 | +import net.minecraft.block.RespawnAnchorBlock; |
| 16 | +import net.minecraft.network.packet.c2s.handshake.HandshakeC2SPacket; |
| 17 | +import net.minecraft.network.packet.c2s.play.HandSwingC2SPacket; |
10 | 18 | import net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket; |
11 | 19 | import net.minecraft.text.Text; |
| 20 | +import net.minecraft.util.Hand; |
| 21 | +import net.minecraft.util.math.BlockPos; |
12 | 22 |
|
13 | 23 | public class AntiSpawnpoint extends Module { |
| 24 | + |
| 25 | + private final SettingGroup sgGeneral = settings.getDefaultGroup(); |
| 26 | + |
| 27 | + private final Setting<Boolean> fakeuse = sgGeneral.add(new BoolSetting.Builder() |
| 28 | + .name("Fake Use") |
| 29 | + .description("Makes it look like you interacted with the block.") |
| 30 | + .defaultValue(false) |
| 31 | + .build() |
| 32 | + ); |
14 | 33 | public AntiSpawnpoint() { |
15 | 34 | super(Addon.CATEGORY, "AntiSpawnpoint", "Stop you from setting your spawnpoint"); |
16 | 35 | } |
17 | 36 |
|
18 | 37 | @EventHandler |
19 | 38 | private void onclick(PacketEvent.Send event){ |
20 | 39 | if (event.packet instanceof PlayerInteractBlockC2SPacket packet) { |
21 | | - if (mc.world.getBlockState(packet.getBlockHitResult().getBlockPos()).getBlock().getName().contains(Text.of("Bed"))) { |
| 40 | + BlockPos blockpos = packet.getBlockHitResult().getBlockPos(); |
| 41 | + |
| 42 | + if (fakeuse.get()){ |
| 43 | + mc.player.networkHandler.sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND)); |
| 44 | + } |
| 45 | + |
| 46 | + if (mc.world.getDimension().bedWorks() && mc.world.getBlockState(blockpos).getBlock() instanceof BedBlock) { |
| 47 | + event.cancel(); |
| 48 | + } else if (mc.world.getDimension().respawnAnchorWorks() && mc.world.getBlockState(blockpos).getBlock() instanceof RespawnAnchorBlock) { |
22 | 49 | event.cancel(); |
23 | 50 | } |
24 | 51 | } |
|
0 commit comments