Skip to content
This repository has been archived by the owner on Jul 6, 2024. It is now read-only.

Commit

Permalink
anti-tps
Browse files Browse the repository at this point in the history
  • Loading branch information
JustS-js committed Dec 29, 2021
1 parent 4461a59 commit c9f49b0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
16 changes: 9 additions & 7 deletions src/main/java/net/just_s/ctpmod/CTPMod.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package net.just_s.ctpmod;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.just_s.ctpmod.config.ConfigParser;
import net.just_s.ctpmod.config.Point;
import net.just_s.ctpmod.util.ReconnectThread;
import net.minecraft.client.gui.screen.ConnectScreen;
import net.minecraft.client.gui.screen.DisconnectedScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.gui.screen.*;
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
import net.minecraft.client.network.ServerInfo;
import net.minecraft.client.network.ServerAddress;
Expand All @@ -20,6 +19,7 @@

import java.util.Objects;

@Environment(EnvType.CLIENT)
public class CTPMod implements ClientModInitializer {
public static final String MOD_ID = "ctpmod";
public static final MinecraftClient MC = MinecraftClient.getInstance();
Expand Down Expand Up @@ -132,10 +132,12 @@ public void startReconnect(Point point) {
Objects.requireNonNull(MC.getNetworkHandler()).getConnection().disconnect(
new LiteralText("§8[§6CatTeleport§8]"));
MC.disconnect();
reconnectThread = new ReconnectThread(server, point.getStartPeriod());
reconnectThread = new ReconnectThread(server, point.getStartPeriod(), point.getEndPeriod());
reconnectThread.start();
Screen newScr = new DisconnectedScreen(new MultiplayerScreen(new TitleScreen()), new LiteralText("§8[§6CatTeleport§8]"), new LiteralText("startReconnect"));
//Screen newScr = new MultiplayerScreen(new TitleScreen());
Screen newScr = new DisconnectedScreen(
new MultiplayerScreen(new TitleScreen()),
new LiteralText("§8[§6CatTeleport§8]"),
new LiteralText("startReconnect"));
MC.setScreen(newScr);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/just_s/ctpmod/config/ConfigScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import me.shedaniel.clothconfig2.api.*;
import net.just_s.ctpmod.CTPMod;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.text.LiteralText;

import java.util.ArrayList;
import java.util.List;


public class ConfigScreen {
public static ConfigCategory mainCategory;
public static ConfigEntryBuilder entryBuilder;
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/net/just_s/ctpmod/util/ReconnectThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@
import java.io.IOException;
import java.net.Socket;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;

@Environment(EnvType.CLIENT)
public class ReconnectThread extends Thread {
private final int secondsToReconnect;
private final ServerAddress serverAddress;

public ReconnectThread(ServerInfo serverInfo, int secondsToReconnect) {
public ReconnectThread(ServerInfo serverInfo, int start, int end) {
super();
this.secondsToReconnect = secondsToReconnect;
this.secondsToReconnect = (end - start) / 2 + start;
this.serverAddress = ServerAddress.parse(serverInfo.address);
}

Expand Down

0 comments on commit c9f49b0

Please sign in to comment.