|
| 1 | +/* |
| 2 | + * Copyright (c) 2014-2025 Wurst-Imperium and contributors. |
| 3 | + * |
| 4 | + * This source code is subject to the terms of the GNU General Public |
| 5 | + * License, version 3. If a copy of the GPL was not distributed with this |
| 6 | + * file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt |
| 7 | + */ |
| 8 | +package net.wurstclient.hacks; |
| 9 | + |
| 10 | +import java.util.Optional; |
| 11 | + |
| 12 | +import net.minecraft.entity.effect.StatusEffect; |
| 13 | +import net.minecraft.entity.effect.StatusEffects; |
| 14 | +import net.minecraft.network.packet.c2s.play.UpdateBeaconC2SPacket; |
| 15 | +import net.minecraft.registry.entry.RegistryEntry; |
| 16 | +import net.wurstclient.Category; |
| 17 | +import net.wurstclient.SearchTags; |
| 18 | +import net.wurstclient.events.PacketOutputListener; |
| 19 | +import net.wurstclient.events.PacketOutputListener.PacketOutputEvent; |
| 20 | +import net.wurstclient.hack.Hack; |
| 21 | +import net.wurstclient.settings.EnumSetting; |
| 22 | +import net.wurstclient.util.ChatUtils; |
| 23 | + |
| 24 | +@SearchTags({"beacon exploit", "beacon spoofer", "regen 2"}) |
| 25 | +public final class BeaconExploitHack extends Hack |
| 26 | + implements PacketOutputListener |
| 27 | +{ |
| 28 | + |
| 29 | + private final EnumSetting<BeaconEffect> primaryEffectSetting = |
| 30 | + new EnumSetting<>("Primary Effect", |
| 31 | + "The primary effect to request from the beacon.\n" |
| 32 | + + "Set both to Regeneration for Regen II.", |
| 33 | + BeaconEffect.values(), BeaconEffect.REGENERATION); |
| 34 | + |
| 35 | + private final EnumSetting<BeaconEffect> secondaryEffectSetting = |
| 36 | + new EnumSetting<>("Secondary Effect", |
| 37 | + "The secondary effect to request from the beacon.\n" |
| 38 | + + "Set both to Regeneration for Regen II.", |
| 39 | + BeaconEffect.values(), BeaconEffect.REGENERATION); |
| 40 | + |
| 41 | + public BeaconExploitHack() |
| 42 | + { |
| 43 | + super("BeaconExploit"); |
| 44 | + setCategory(Category.OTHER); |
| 45 | + addSetting(primaryEffectSetting); |
| 46 | + addSetting(secondaryEffectSetting); |
| 47 | + } |
| 48 | + |
| 49 | + @Override |
| 50 | + protected void onEnable() |
| 51 | + { |
| 52 | + EVENTS.add(PacketOutputListener.class, this); |
| 53 | + } |
| 54 | + |
| 55 | + @Override |
| 56 | + protected void onDisable() |
| 57 | + { |
| 58 | + EVENTS.remove(PacketOutputListener.class, this); |
| 59 | + } |
| 60 | + |
| 61 | + @Override |
| 62 | + public void onSentPacket(PacketOutputEvent event) |
| 63 | + { |
| 64 | + if(!(event.getPacket() instanceof UpdateBeaconC2SPacket packet)) |
| 65 | + return; |
| 66 | + |
| 67 | + RegistryEntry<StatusEffect> primarySpoof = |
| 68 | + primaryEffectSetting.getSelected().getStatusEffectEntry(); |
| 69 | + RegistryEntry<StatusEffect> secondarySpoof = |
| 70 | + secondaryEffectSetting.getSelected().getStatusEffectEntry(); |
| 71 | + |
| 72 | + RegistryEntry<StatusEffect> primaryPacket = |
| 73 | + packet.primary().orElse(null); |
| 74 | + RegistryEntry<StatusEffect> secondaryPacket = |
| 75 | + packet.secondary().orElse(null); |
| 76 | + |
| 77 | + if(primaryPacket == primarySpoof && secondaryPacket == secondarySpoof) |
| 78 | + return; |
| 79 | + |
| 80 | + event.cancel(); |
| 81 | + |
| 82 | + Optional<RegistryEntry<StatusEffect>> primaryOpt = |
| 83 | + Optional.ofNullable(primarySpoof); |
| 84 | + Optional<RegistryEntry<StatusEffect>> secondaryOpt = |
| 85 | + Optional.ofNullable(secondarySpoof); |
| 86 | + |
| 87 | + UpdateBeaconC2SPacket spoofedPacket = |
| 88 | + new UpdateBeaconC2SPacket(primaryOpt, secondaryOpt); |
| 89 | + MC.player.networkHandler.sendPacket(spoofedPacket); |
| 90 | + |
| 91 | + ChatUtils.message("Beacon effects spoofed:\n\tPrimary: [ " |
| 92 | + + primaryEffectSetting.getSelected().getName() + " ], Secondary: [ " |
| 93 | + + secondaryEffectSetting.getSelected().getName() + " ]"); |
| 94 | + } |
| 95 | + |
| 96 | + public enum BeaconEffect |
| 97 | + { |
| 98 | + NONE("None", null), |
| 99 | + SPEED("Speed", StatusEffects.SPEED), |
| 100 | + HASTE("Haste", StatusEffects.HASTE), |
| 101 | + RESISTANCE("Resistance", StatusEffects.RESISTANCE), |
| 102 | + JUMP_BOOST("Jump Boost", StatusEffects.JUMP_BOOST), |
| 103 | + STRENGTH("Strength", StatusEffects.STRENGTH), |
| 104 | + REGENERATION("Regeneration", StatusEffects.REGENERATION); |
| 105 | + |
| 106 | + private final String name; |
| 107 | + private final RegistryEntry<StatusEffect> statusEffectEntry; |
| 108 | + |
| 109 | + BeaconEffect(String name, RegistryEntry<StatusEffect> statusEffectEntry) |
| 110 | + { |
| 111 | + this.name = name; |
| 112 | + this.statusEffectEntry = statusEffectEntry; |
| 113 | + } |
| 114 | + |
| 115 | + public String getName() |
| 116 | + { |
| 117 | + return name; |
| 118 | + } |
| 119 | + |
| 120 | + public RegistryEntry<StatusEffect> getStatusEffectEntry() |
| 121 | + { |
| 122 | + return statusEffectEntry; |
| 123 | + } |
| 124 | + |
| 125 | + @Override |
| 126 | + public String toString() |
| 127 | + { |
| 128 | + return name; |
| 129 | + } |
| 130 | + } |
| 131 | +} |
0 commit comments