Compare commits

...

3 Commits

Author SHA1 Message Date
413155d7d5 removed old infos from the README 2021-01-27 23:11:56 +01:00
4e2ead95f4 fixed disconnect screen message 2021-01-27 23:09:23 +01:00
a7b9190645 cancel sending signal if user closes the menu 2021-01-27 22:54:33 +01:00
4 changed files with 22 additions and 27 deletions

View File

@ -1,21 +1,4 @@
# AutoReconnect [1.16+][Fabric]
This mod will automatically try to reconnect you back to a server if you got disconnected.
By default, it will make 4 attempts after 3, 10, 30 and 60 seconds.
### Features
* Multiple individually delayed reconnect attempts
* Displays a countdown on the disconnect screen
* Allows you to exit the disconnect screen quickly by pressing the escape key
* Customizable
* Amount of attempts
* Delay between each attempt
* Client side commands
* `/autoreconnect reload` Reloads the config and displays the settings in chat
* `/autoreconnect config [<delayList>]` Sets the delay between each attempt<br>
`[<delayList>]` must be a Nbt List Tag containing Integers, e.g. `[3, 10, 30, 60]` or `[I;3, 10, 30, 60]`
* Support for several mods
# WolfSignal [1.16+][Fabric]
### Installation
@ -31,12 +14,6 @@ By default, it will make 4 attempts after 3, 10, 30 and 60 seconds.
* [AuthMe](https://www.curseforge.com/minecraft/mc-mods/auth-me) <br>
Cancels the countdown if you click on the Re-authenticate button to revalidate the session of the game
### Screenshots
![countdown](src/main/resources/assets/countdown.png)
![failed](src/main/resources/assets/failed.png)
### License
This mod is available under the CC0 license.

View File

@ -29,6 +29,7 @@ public class Main implements ModInitializer {
private static int cmdSignal(CommandContext<ClientCommandSource> ctx) {
signal = ctx.getArgument("signal", int.class);
disconnectedCausedByWolfSignal = true;
MinecraftClient.getInstance().world.disconnect();
signalIndex = 4;
setTick();

View File

@ -5,6 +5,7 @@ import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.screen.DisconnectedScreen;
import net.minecraft.client.util.Window;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Formatting;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@ -31,12 +32,13 @@ public class MixinDisconnectedScreen
@Inject(at = @At("RETURN"), method = "render")
private void render(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo info)
{
if(!disconnectedCausedByWolfSignal) return;
Window window = MinecraftClient.getInstance().getWindow();
TextRenderer renderer = MinecraftClient.getInstance().textRenderer;
String text = getMessage();
String text = "sending signal " + signal + "using wolfs";
renderer.draw(matrices, text,
(window.getScaledWidth() - renderer.getWidth(text)) / 2F, // centered
(window.getScaledHeight() - reasonHeight) / 2F - 9 * 4, // 9 * 2 higher than the title which is 9 * 2 higher than the disconnect reason
getColor());
Formatting.WHITE.getColorValue());
}
}
}

View File

@ -45,4 +45,19 @@ public class MixinMinecraftClient
}
}
}
@Inject(at = @At("INVOKE"), method = "openScreen")
private void openScreen(Screen newScreen, CallbackInfo info) {
// old and new screen must not be the same type, actually happens very often for some reason
if ((currentScreen == null ? null : currentScreen.getClass()) != (newScreen == null ? null : newScreen.getClass())) {
if (currentScreen instanceof DisconnectedScreen && ( // exited disconnect screen using...
newScreen instanceof MultiplayerScreen || // ...cancel button on disconnect screen
newScreen instanceof TitleScreen || // ...escape key
newScreen != null && newScreen.getClass().getSimpleName().equals("AuthScreen")) || // ...AuthMe re-authenticate button
(currentScreen instanceof ConnectScreen && !(newScreen instanceof DisconnectedScreen))) // connection successful or cancelled using cancel button on connect screen
{
ticks = -1;
disconnectedCausedByWolfSignal = false;
}
}
}
}