|
| 1 | +package com.dark.zewo2.modules; |
| 2 | + |
| 3 | +import com.dark.zewo2.Addon; |
| 4 | +import meteordevelopment.meteorclient.events.packets.PacketEvent; |
| 5 | +import meteordevelopment.meteorclient.events.world.TickEvent; |
| 6 | +import meteordevelopment.meteorclient.settings.*; |
| 7 | +import meteordevelopment.meteorclient.systems.modules.Module; |
| 8 | +import meteordevelopment.meteorclient.utils.player.Rotations; |
| 9 | +import meteordevelopment.orbit.EventHandler; |
| 10 | +import net.minecraft.block.Block; |
| 11 | +import net.minecraft.block.Blocks; |
| 12 | +import net.minecraft.block.SignBlock; |
| 13 | +import net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket; |
| 14 | +import net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket; |
| 15 | +import net.minecraft.network.packet.s2c.play.SignEditorOpenS2CPacket; |
| 16 | +import net.minecraft.text.Text; |
| 17 | +import net.minecraft.util.Hand; |
| 18 | +import net.minecraft.util.hit.BlockHitResult; |
| 19 | +import net.minecraft.util.math.BlockPos; |
| 20 | +import net.minecraft.util.math.Direction; |
| 21 | +import net.minecraft.util.math.Vec3d; |
| 22 | + |
| 23 | +public class SignGriefer extends Module { |
| 24 | + private final SettingGroup sgGeneral = this.settings.getDefaultGroup(); |
| 25 | + |
| 26 | + private final Setting<sides> mode = sgGeneral.add(new EnumSetting.Builder<sides>() |
| 27 | + .name("mode") |
| 28 | + .description("modes") |
| 29 | + .defaultValue(sides.front) |
| 30 | + .build() |
| 31 | + ); |
| 32 | + |
| 33 | + private final Setting<Double> reach = sgGeneral.add(new DoubleSetting.Builder() |
| 34 | + .name("range") |
| 35 | + .description("Maximum range to the sign.") |
| 36 | + .defaultValue(6) |
| 37 | + .min(1) |
| 38 | + .sliderMax(6) |
| 39 | + .build() |
| 40 | + ); |
| 41 | + |
| 42 | + private final Setting<String> line1 = sgGeneral.add( |
| 43 | + new StringSetting.Builder().name("line 1").description("line 1").defaultValue("").build()); |
| 44 | + |
| 45 | + private final Setting<String> line2 = sgGeneral.add( |
| 46 | + new StringSetting.Builder().name("line 2").description("line 2").defaultValue("").build()); |
| 47 | + private final Setting<String> line3 = sgGeneral.add( |
| 48 | + new StringSetting.Builder().name("line 3").description("line 3").defaultValue("").build()); |
| 49 | + |
| 50 | + private final Setting<String> line4 = sgGeneral.add( |
| 51 | + new StringSetting.Builder().name("line 4").description("line 4").defaultValue("").build()); |
| 52 | + public SignGriefer() { |
| 53 | + super(Addon.CATEGORY, "SignGriefer", "Grief nearby signs using new editor feature"); |
| 54 | + } |
| 55 | + |
| 56 | + @EventHandler |
| 57 | + public void ontick(TickEvent.Pre event) { |
| 58 | + int range = reach.get().intValue(); |
| 59 | + for (int x = -range; x <= range; x++){ |
| 60 | + for (int y = -range; y <= range; y++){ |
| 61 | + for (int z = -range; z <= range; z++){ |
| 62 | + BlockPos sign = mc.player.getBlockPos().add(x,y,z); |
| 63 | + Vec3d pos = mc.player.getBlockPos().add(x,y,z).toCenterPos(); |
| 64 | + |
| 65 | + if (issign(sign)){ |
| 66 | + Rotations.rotate(Rotations.getYaw(pos), Rotations.getPitch(pos)); |
| 67 | + |
| 68 | + if (mode.get().equals(sides.front)) { |
| 69 | + mc.player.networkHandler.sendPacket(new PlayerInteractBlockC2SPacket(Hand.MAIN_HAND ,new BlockHitResult(new Vec3d(sign.getX(), sign.getY(), sign.getZ()), mc.player.getHorizontalFacing(), sign, false), 1)); |
| 70 | + |
| 71 | + mc.player.networkHandler.sendPacket(new UpdateSignC2SPacket(sign, true, isempty(line1.get()), isempty(line2.get()), isempty(line3.get()), isempty(line4.get()))); |
| 72 | + } |
| 73 | + if (mode.get().equals(sides.back)) { |
| 74 | + mc.player.networkHandler.sendPacket(new PlayerInteractBlockC2SPacket(Hand.MAIN_HAND ,new BlockHitResult(new Vec3d(sign.getX(), sign.getY(), sign.getZ()), mc.player.getHorizontalFacing(), sign, false), 1)); |
| 75 | + |
| 76 | + mc.player.networkHandler.sendPacket(new UpdateSignC2SPacket(sign, false, isempty(line1.get()), isempty(line2.get()), isempty(line3.get()), isempty(line4.get()))); |
| 77 | + } |
| 78 | + |
| 79 | + if (mode.get().equals(sides.both)){ |
| 80 | + mc.player.networkHandler.sendPacket(new PlayerInteractBlockC2SPacket(Hand.MAIN_HAND ,new BlockHitResult(new Vec3d(sign.getX(), sign.getY(), sign.getZ()), mc.player.getHorizontalFacing(), sign, false), 1)); |
| 81 | + mc.player.networkHandler.sendPacket(new UpdateSignC2SPacket(sign, true, isempty(line1.get()), isempty(line2.get()), isempty(line3.get()), isempty(line4.get()))); |
| 82 | + mc.player.networkHandler.sendPacket(new PlayerInteractBlockC2SPacket(Hand.MAIN_HAND ,new BlockHitResult(new Vec3d(sign.getX(), sign.getY(), sign.getZ()), mc.player.getHorizontalFacing(), sign, false), 1)); |
| 83 | + mc.player.networkHandler.sendPacket(new UpdateSignC2SPacket(sign, false, isempty(line1.get()), isempty(line2.get()), isempty(line3.get()), isempty(line4.get()))); |
| 84 | + } |
| 85 | + } |
| 86 | + } |
| 87 | + } |
| 88 | + } |
| 89 | + } |
| 90 | + |
| 91 | + @EventHandler |
| 92 | + private void packet(PacketEvent.Receive event){ |
| 93 | + if (event.packet instanceof SignEditorOpenS2CPacket packet){ |
| 94 | + event.cancel(); |
| 95 | + } |
| 96 | + } |
| 97 | + |
| 98 | + private String isempty(String text){ |
| 99 | + return (text.isEmpty()) ? "" : text; |
| 100 | + } |
| 101 | + |
| 102 | + private boolean issign(BlockPos pos){ |
| 103 | + Block block = mc.world.getBlockState(pos).getBlock(); |
| 104 | + |
| 105 | + return block.getTranslationKey().contains("_sign"); |
| 106 | + } |
| 107 | + |
| 108 | + public enum sides{ |
| 109 | + front, |
| 110 | + back, |
| 111 | + both |
| 112 | + } |
| 113 | +} |
0 commit comments