Skip to content

Commit

Permalink
Added 'Illegal Disconnect' functionality to Meteor's built-in AutoLog…
Browse files Browse the repository at this point in the history
… module.

Also added a config setting which adds a dedicated illegal disconnect button to the pause menu.
  • Loading branch information
0xTas committed Oct 1, 2024
1 parent 2959972 commit b37ecf6
Show file tree
Hide file tree
Showing 8 changed files with 265 additions and 17 deletions.
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Stardust ✨
# ✨ Stardust

Stardust is an addon for [Meteor Client](https://meteorclient.com) designed for use on the
anarchy Minecraft server [2b2t](https://2b2t.org).<br>
Expand All @@ -9,32 +9,41 @@ It contains original modules to enhance your experience on old server, with a fo

- **Stats2b2t, LastSeen2b2t, FirstSeen2b2t, Playtime2b2t** - *Self explanatory commands. Use your meteor prefix.* Credit to [rfresh](https://github.com/rfresh2) for the current best [2b2t stats api](https://api.2b2t.vc).
- **Panorama** - *Takes a panorama screenshot and automatically assembles it into a resource pack for the main menu screen.* Usage: `.panorama [name]`
<br><br>

#### Modules
- **ChatSigns** - *Read nearby signs in your chat.* Can also highlight and ESP potentially old signs placed before version 1.8 (January 2015 on 2b2t.)*
- **SignatureSign** - *An AutoSign module that's actually good.* Fully customizable template mode, & story mode for long input files over multiple signs.
- **SignHistorian** - *Record and restore broken or modified signs that you previously visited.* Since 1.19, creepers have been a real problem for sign boards everywhere. Now even if they blow that shit up, all is not lost.
- **AxolotlTools** - *Variant ESP, auto-collector & auto-breeder for axolotls.* Can also catch buckets of tropical fish, with or without a farm setup. I used this to get blue axolotls on 2b2t because interacting with them normally pisses me off.
- **RocketMan** - *Makes flying with fireworks much easier (and faster!) \[bring lots of rockets!\]* RocketMan is a versatile and highly-configurable firework efly module with many useful capabilities.
- **StashBrander** - *Automatically rename desired items in bulk when using anvils.*
- **AutoDoors** - *Automatically interacts with doors.* Includes an insufferable door spammer mode as well (complete with client-side mute option).
- **AutoSmith** - *Automatically upgrades gear or trims armor sets when interacting with smithing tables.*
- **AntiToS** - *Censors player-generated text on render, like signs, books, chat, and more, according to a customizable content blacklist.*
- **LoreLocator** - *Slot highlighter for rare, unique, and anomalous items.* Capable of highlighting renamed items, items with illegal enchants, zero durability items, and more.
- **AxolotlTools** - *Variant ESP, auto-collector & auto-breeder for axolotls.* Can also catch buckets of tropical fish, with or without a farm setup. I used this to get blue axolotls on 2b2t because interacting with them normally pisses me off.
- **AutoDrawDistance** - *Automatically adjusts your render distance to maintain an FPS target.* Some biomes/areas can drop my fps by half, so I occasionally find this useful.
- **AutoDyeShulkers** - *Automatically dye shulker boxes a desired color in crafting grids.*
- **LoreLocator** - *Slot highlighter for rare, unique, and anomalous items.* Capable of highlighting renamed items, items with illegal enchants, zero durability items, and more.
- **BannerData** - *Right-click banners to display their pattern and color data.* Looks cool, gives you the base color without any fuss. Can also copy the raw nbt to your clipboard.
- **BookTools** - *Enhancements for working with books.* Adds buttons for inserting color & formatting codes into writable books, and adds a deobfuscation button to written books containing obfuscated/magic text.
- **StashBrander** - *Automatically rename desired items in bulk when using anvils.*
- **PagePirate** - *Pirates books held by other players* (displays their contents in your chat, and optionally makes a local copy using a book & quill).
- **TreasureESP** - *An ESP module for buried treasure chests.* Finding buried treasure is the only way of obtaining Hearts of the Sea, and Conduits by extension.
- **MusicTweaks** - *Lets you tweak various things relating to the background music.* Change the pitch, volume, or cooldown between songs, or even choose and view which soundtracks play during your session.
- **RocketMan** - *Makes flying with fireworks much easier (and faster!) \[bring lots of rockets!\]* RocketMan is a versatile and highly-configurable firework efly module with many useful capabilities.
- **MusicTweaks** - *Lets you tweak various things relating to the background music.* Change the pitch, volume, or cooldown between songs, or even choose and view which soundtracks play during your session.
- **Honker** - *Automatically uses goat horns when a player enters your render distance.* You can select your preferred horn type, or choose random for a surprise pick from your inventory each time.
- **Updraft** - *Automatically enhances your jumps with wind charges.* Wind charges seem to be nerfed on Paper compared to Vanilla, but maybe someone would still find this fun or useful.
- **WaxAura** - *Automatically waxes signs within your reach.* On 2b2t, sign editing has been disabled "for now™". This module makes it easy to wax as many signs as possible before it gets enabled.
- **ChatSigns** - *Read nearby signs in your chat.* Can also highlight and ESP potentially old signs placed before version 1.8 (January 2015 on 2b2t.)*
<br><br>

#### Miscellaneous
- **Illegal Disconnect** - *Adds "Illegal Disconnect" functionality to Meteor's built-in AutoLog module.* Enable this in the AutoLog module's settings. Also adds a config setting to put a dedicated Illegal Disconnect button on the pause menu.
- **Title Screen Tweaks** - *2b2t-themed changes to the title screen.* Adds config settings to make the splash texts green, to cycle them randomly, and to add a 2b2t direct-connect button to the title screen.
- **Themed Category Icons** - *Enable module category icons in your config settings to see a random Stardust/2b2t-themed icon for the Stardust modules category.* Randomly picks a new icon each time you open your game!

>*OldSigns: <br>
Ever since 2b2t updated to 1.19, the NBT tag artifact that separates pre-1.8 from post-1.8 signs is missing on newly-placed signs.<br>
This means that false positives are now *unavoidable*, but should be limited to *oak signs placed after 1.19 in old (pre-1.8) chunks that do not contain dates after 2015*.<br>
Use your best judgement to further identify false positives or fakes.
Use your best judgement to further identify false positives or fakes.<br>
OldSigns functionality can be accessed in the ChatSigns module settings.
<br>

### Installation
Expand All @@ -54,8 +63,7 @@ Use your best judgement to further identify false positives or fakes.
5. Select the appropriate sources Jar from the list (usually named something like `net.minecraft:minecraft-merged-...-sources.jar`) and hit `Ok`.
6. Now you can contribute or modify code with those mappings as a reference (ctrl+click to view the source for any class.)

>Issues and pull requests are welcome if you would like to submit them.<br>
If needed, you can get in touch with me through the [Meteor Client Discord Server](https://discord.com/invite/bBGQZvd).
>Issues and pull requests are welcome if you would like to submit them.
<br>
### Credits
Expand Down
33 changes: 27 additions & 6 deletions src/main/java/dev/stardust/Stardust.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
import meteordevelopment.meteorclient.commands.Commands;
import meteordevelopment.meteorclient.addons.MeteorAddon;
import meteordevelopment.meteorclient.settings.BoolSetting;
import meteordevelopment.meteorclient.settings.EnumSetting;
import meteordevelopment.meteorclient.systems.config.Config;
import meteordevelopment.meteorclient.settings.SettingGroup;
import dev.stardust.util.StardustUtil.IllegalDisconnectMethod;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.Category;

Expand All @@ -26,6 +29,8 @@ public class Stardust extends MeteorAddon {
public static Setting<Boolean> greenSplashTextSetting = new BoolSetting.Builder().build();
public static Setting<Boolean> rotateSplashTextSetting = new BoolSetting.Builder().build();
public static Setting<Boolean> directConnectButtonSetting = new BoolSetting.Builder().build();
public static Setting<Boolean> illegalDisconnectButtonSetting = new BoolSetting.Builder().build();
public static Setting<IllegalDisconnectMethod> illegalDisconnectMethodSetting = new EnumSetting.Builder<IllegalDisconnectMethod>().defaultValue(IllegalDisconnectMethod.Slot).build();

@Override
public void onInitialize() {
Expand Down Expand Up @@ -55,30 +60,46 @@ public void onInitialize() {
Modules.get().add(new SignHistorian());
Modules.get().add(new AutoDyeShulkers());
Modules.get().add(new AutoDrawDistance());
SettingGroup sgStardust = Config.get().settings.createGroup("Stardust");

// See SplashTextRendererMixin.java
greenSplashTextSetting = Config.get().settings.getGroup("Visual").add(
greenSplashTextSetting = sgStardust.add(
new BoolSetting.Builder()
.name("Green Splash Text")
.name("green-splash-text")
.description(">Makes the title splash texts green.")
.defaultValue(false)
.build()
);
// See TitleScreenMixin.java
rotateSplashTextSetting = Config.get().settings.getGroup("Visual").add(
rotateSplashTextSetting = sgStardust.add(
new BoolSetting.Builder()
.name("Rotate Splash Text")
.name("rotate-splash-text")
.description("Picks a new random splash text every 20 seconds.")
.defaultValue(false)
.build()
);
directConnectButtonSetting = Config.get().settings.getGroup("Visual").add(
directConnectButtonSetting = sgStardust.add(
new BoolSetting.Builder()
.name("Direct Connect Button")
.name("direct-connect-button")
.description("Adds a button to the main menu that directly connects you to 2b2t.org")
.defaultValue(false)
.build()
);
// See GameMenuScreenMixin.java
illegalDisconnectButtonSetting = sgStardust.add(
new BoolSetting.Builder()
.name("illegal-disconnect-button")
.description("Adds a button to the main menu that forces the server to kick you when pressed.")
.defaultValue(false)
.build()
);
illegalDisconnectMethodSetting = sgStardust.add(
new EnumSetting.Builder<IllegalDisconnectMethod>()
.name("illegal-disconnect-method")
.description("The method to use to cause the server to kick you.")
.defaultValue(IllegalDisconnectMethod.Slot)
.build()
);

LOG.info("<✨> Stardust initialized.");
}
Expand Down
99 changes: 99 additions & 0 deletions src/main/java/dev/stardust/mixin/AutoLogMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package dev.stardust.mixin;

import dev.stardust.Stardust;
import net.minecraft.text.Text;
import javax.annotation.Nullable;
import dev.stardust.util.StardustUtil;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import meteordevelopment.orbit.EventHandler;
import org.spongepowered.asm.mixin.injection.At;
import meteordevelopment.meteorclient.utils.Utils;
import meteordevelopment.meteorclient.MeteorClient;
import org.spongepowered.asm.mixin.injection.Inject;
import meteordevelopment.meteorclient.settings.Setting;
import meteordevelopment.meteorclient.settings.BoolSetting;
import meteordevelopment.meteorclient.settings.SettingGroup;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.systems.modules.Category;
import meteordevelopment.meteorclient.events.packets.PacketEvent;
import meteordevelopment.meteorclient.systems.modules.misc.AutoLog;
import net.minecraft.network.packet.s2c.common.DisconnectS2CPacket;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

/**
* @author Tas [0xTas] <[email protected]>
*
* Adds "Illegal Disconnect" functionality to Meteor's built-in AutoLog module.
**/
@Mixin(value = AutoLog.class, remap = false)
public abstract class AutoLogMixin extends Module {
public AutoLogMixin(Category category, String name, String description) {
super(category, name, description);
MeteorClient.EVENT_BUS.subscribe(this); // TODO: sus
}

@Shadow
@Final
private SettingGroup sgGeneral;
@Shadow
@Final
private Setting<Boolean> toggleOff;

@Unique
private boolean didLog = false;
@Unique
@Nullable
private Text disconnectReason = null;
@Unique
@Nullable
private Setting<Boolean> forceKick = null;

@Override
public void onDeactivate() {
if (toggleOff.get() && didLog) {
MeteorClient.EVENT_BUS.subscribe(this);
}
}

@Inject(method = "<init>", at = @At(value = "FIELD", target = "Lmeteordevelopment/meteorclient/systems/modules/misc/AutoLog;entities:Lmeteordevelopment/meteorclient/settings/Setting;"))
private void addIllegalDisconnectSetting(CallbackInfo ci) {
forceKick = sgGeneral.add(
new BoolSetting.Builder()
.name("illegal-disconnect")
.description("Tip: Change the illegal disconnect method in your Meteor config settings (Stardust category.)")
.defaultValue(false)
.build()
);
}

@Inject(method = "onTick",at = @At("HEAD"), cancellable = true)
private void preventNullPointerExceptions(CallbackInfo ci) {
if (!Utils.canUpdate()) ci.cancel();
}

@Inject(method = "disconnect", at = @At("HEAD"), cancellable = true)
private void maybeForceKick(String reason, CallbackInfo ci) {
if (forceKick != null && forceKick.get()) {
ci.cancel();
didLog = true;
if (toggleOff.get()) toggle();
disconnectReason = Text.literal("§8[§aAutoLog§8] §f" + reason);
StardustUtil.illegalDisconnect(true, Stardust.illegalDisconnectMethodSetting.get());
}
}

@Unique
@EventHandler
private void onPacketReceive(PacketEvent.Receive event) {
if (disconnectReason == null || !(event.packet instanceof DisconnectS2CPacket packet)) return;
if (didLog) {
((DisconnectS2CPacketAccessor)(Object) packet).setReason(disconnectReason);
MeteorClient.EVENT_BUS.unsubscribe(this);
disconnectReason = null;
didLog = false;
}
}
}
14 changes: 14 additions & 0 deletions src/main/java/dev/stardust/mixin/ClientConnectionAccessor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package dev.stardust.mixin;

import javax.annotation.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.PacketCallbacks;
import net.minecraft.network.ClientConnection;
import org.spongepowered.asm.mixin.gen.Invoker;

@Mixin(ClientConnection.class)
public interface ClientConnectionAccessor {
@Invoker("sendImmediately")
void invokeSendImmediately(Packet<?> packet, @Nullable PacketCallbacks callbacks, boolean flush);
}
14 changes: 14 additions & 0 deletions src/main/java/dev/stardust/mixin/DisconnectS2CPacketAccessor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package dev.stardust.mixin;

import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor;
import net.minecraft.network.packet.s2c.common.DisconnectS2CPacket;

@Mixin(DisconnectS2CPacket.class)
public interface DisconnectS2CPacketAccessor {
@Mutable
@Accessor("reason")
void setReason(Text reason);
}
35 changes: 35 additions & 0 deletions src/main/java/dev/stardust/mixin/GameMenuScreenMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package dev.stardust.mixin;

import dev.stardust.Stardust;
import net.minecraft.text.Text;
import dev.stardust.util.StardustUtil;
import org.spongepowered.asm.mixin.Mixin;
import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.client.gui.screen.Screen;
import org.spongepowered.asm.mixin.injection.At;
import net.minecraft.client.gui.widget.GridWidget;
import org.spongepowered.asm.mixin.injection.Inject;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.screen.GameMenuScreen;
import static meteordevelopment.meteorclient.MeteorClient.mc;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

/**
* @author Tas [0xTas] <[email protected]>
**/
@Mixin(GameMenuScreen.class)
public class GameMenuScreenMixin extends Screen {
protected GameMenuScreenMixin(Text title) {
super(title);
}

@Inject(method = "initWidgets", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/GridWidget;refreshPositions()V"))
private void addIllegalDisconnectButton(CallbackInfo ci, @Local GridWidget.Adder adder) {
if (Stardust.illegalDisconnectButtonSetting.get() && !mc.isInSingleplayer()) {
adder.add(ButtonWidget.builder(Text.literal("§cIllegal Disconnect"), button -> {
button.active = false;
StardustUtil.illegalDisconnect(false, Stardust.illegalDisconnectMethodSetting.get());
}).width(204).build(), 2);
}
}
}
Loading

0 comments on commit b37ecf6

Please sign in to comment.