-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #494 from WaitingIdly/faster-ping
Improve Server Connection Speed
- Loading branch information
Showing
8 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...va/mod/acgaming/universaltweaks/tweaks/performance/connectionspeed/UTConnectionPatch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package mod.acgaming.universaltweaks.tweaks.performance.connectionspeed; | ||
|
||
import java.net.InetAddress; | ||
import java.net.UnknownHostException; | ||
|
||
import com.google.common.net.InetAddresses; | ||
|
||
import mod.acgaming.universaltweaks.UniversalTweaks; | ||
|
||
public class UTConnectionPatch | ||
{ | ||
public static InetAddress patch(String hostName) throws UnknownHostException | ||
{ | ||
return patch(InetAddress.getByName(hostName), hostName); | ||
} | ||
|
||
@SuppressWarnings("UnstableApiUsage") | ||
public static InetAddress patch(InetAddress original, String hostName) throws UnknownHostException | ||
{ | ||
if (InetAddresses.isInetAddress(hostName)) | ||
{ | ||
InetAddress patched = InetAddress.getByAddress(original.getHostAddress(), original.getAddress()); | ||
UniversalTweaks.LOGGER.debug("Patching ip-only InetAddress from {} to {}", original, patched); | ||
return patched; | ||
} | ||
return original; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...gaming/universaltweaks/tweaks/performance/connectionspeed/mixin/UTGuiConnectingMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package mod.acgaming.universaltweaks.tweaks.performance.connectionspeed.mixin; | ||
|
||
import java.net.InetAddress; | ||
import java.net.UnknownHostException; | ||
|
||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
import mod.acgaming.universaltweaks.config.UTConfigTweaks; | ||
import mod.acgaming.universaltweaks.tweaks.performance.connectionspeed.UTConnectionPatch; | ||
|
||
// Courtesy of WaitingIdly | ||
@Mixin(targets = "net.minecraft.client.multiplayer.GuiConnecting$1") | ||
public class UTGuiConnectingMixin | ||
{ | ||
@WrapOperation(method = "run", at = @At(value = "INVOKE", target = "Ljava/net/InetAddress;getByName(Ljava/lang/String;)Ljava/net/InetAddress;")) | ||
private InetAddress utPatchInetAddress(String ip, Operation<InetAddress> original) throws UnknownHostException | ||
{ | ||
if (!UTConfigTweaks.PERFORMANCE.utImproveServerConnectionSpeed) return original.call(ip); | ||
return UTConnectionPatch.patch(ip); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...gaming/universaltweaks/tweaks/performance/connectionspeed/mixin/UTRealmsConnectMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package mod.acgaming.universaltweaks.tweaks.performance.connectionspeed.mixin; | ||
|
||
import java.net.InetAddress; | ||
import java.net.UnknownHostException; | ||
|
||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
import mod.acgaming.universaltweaks.config.UTConfigTweaks; | ||
import mod.acgaming.universaltweaks.tweaks.performance.connectionspeed.UTConnectionPatch; | ||
|
||
// Courtesy of WaitingIdly | ||
@Mixin(targets = "net.minecraft.realms.RealmsConnect$1") | ||
public class UTRealmsConnectMixin | ||
{ | ||
@WrapOperation(method = "run", at = @At(value = "INVOKE", target = "Ljava/net/InetAddress;getByName(Ljava/lang/String;)Ljava/net/InetAddress;")) | ||
private InetAddress utPatchInetAddress(String ip, Operation<InetAddress> original) throws UnknownHostException | ||
{ | ||
if (!UTConfigTweaks.PERFORMANCE.utImproveServerConnectionSpeed) return original.call(ip); | ||
return UTConnectionPatch.patch(ip); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...cgaming/universaltweaks/tweaks/performance/connectionspeed/mixin/UTServerPingerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package mod.acgaming.universaltweaks.tweaks.performance.connectionspeed.mixin; | ||
|
||
import java.net.InetAddress; | ||
import java.net.UnknownHostException; | ||
|
||
import net.minecraft.client.network.ServerPinger; | ||
|
||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
import mod.acgaming.universaltweaks.config.UTConfigTweaks; | ||
import mod.acgaming.universaltweaks.tweaks.performance.connectionspeed.UTConnectionPatch; | ||
|
||
// Courtesy of WaitingIdly | ||
@Mixin(value = ServerPinger.class) | ||
public class UTServerPingerMixin | ||
{ | ||
@WrapOperation(method = "ping", at = @At(value = "INVOKE", target = "Ljava/net/InetAddress;getByName(Ljava/lang/String;)Ljava/net/InetAddress;")) | ||
private InetAddress utPatchInetAddress(String ip, Operation<InetAddress> original) throws UnknownHostException | ||
{ | ||
if (!UTConfigTweaks.PERFORMANCE.utImproveServerConnectionSpeed) return original.call(ip); | ||
return UTConnectionPatch.patch(ip); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/resources/mixins.tweaks.performance.connectionspeed.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"package": "mod.acgaming.universaltweaks.tweaks.performance.connectionspeed.mixin", | ||
"refmap": "universaltweaks.refmap.json", | ||
"minVersion": "0.8", | ||
"compatibilityLevel": "JAVA_8", | ||
"client": ["UTGuiConnectingMixin", "UTRealmsConnectMixin", "UTServerPingerMixin"] | ||
} |