implements #75, remove Shadow workaround

This commit is contained in:
creeper123123321 2020-11-14 17:33:04 -03:00
parent 7a74f411a4
commit e463c2bfb8
16 changed files with 79 additions and 38 deletions

View File

@ -23,7 +23,7 @@
* SOFTWARE.
*/
package com.github.creeper123123321.viafabric.mixin.client;
package com.github.creeper123123321.viafabric.mixin.address.client;
import com.github.creeper123123321.viafabric.ViaFabricAddress;
import org.spongepowered.asm.mixin.Mixin;
@ -33,10 +33,10 @@ import org.spongepowered.asm.mixin.injection.Redirect;
import java.net.InetAddress;
import java.net.UnknownHostException;
@Mixin(targets = "net/minecraft/client/gui/screen/ConnectScreen$1", priority = 2000) // don't know if it will work with MinerParty mod
@Mixin(targets = "net/minecraft/client/gui/screen/ConnectScreen$1", priority = 2000)
public class MixinConnectScreenThread {
@Redirect(method = "run()V", at = @At(value = "INVOKE",
target = "Ljava/net/InetAddress;getByName(Ljava/lang/String;)Ljava/net/InetAddress;"))
target = "Ljava/net/InetAddress;getByName(Ljava/lang/String;)Ljava/net/InetAddress;"))
private InetAddress resolveViaFabricAddr(String address) throws UnknownHostException {
ViaFabricAddress viaAddr = new ViaFabricAddress().parse(address);
if (viaAddr.viaSuffix == null) {
@ -46,5 +46,4 @@ public class MixinConnectScreenThread {
InetAddress resolved = InetAddress.getByName(viaAddr.realAddress);
return InetAddress.getByAddress(resolved.getHostName() + "." + viaAddr.viaSuffix, resolved.getAddress());
}
}

View File

@ -23,7 +23,7 @@
* SOFTWARE.
*/
package com.github.creeper123123321.viafabric.mixin.client;
package com.github.creeper123123321.viafabric.mixin.address.client;
import com.github.creeper123123321.viafabric.ViaFabricAddress;
import com.mojang.datafixers.util.Pair;
@ -35,13 +35,18 @@ import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(ServerAddress.class)
public abstract class MixinServerAddress {
@Shadow
private static Pair<String, Integer> resolveServer(String address) {
throw new AssertionError();
}
@Redirect(method = "parse", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ServerAddress;resolveServer(Ljava/lang/String;)Lcom/mojang/datafixers/util/Pair;"))
private static Pair<String, Integer> modifySrvAddr(String address) {
ViaFabricAddress viaAddr = new ViaFabricAddress().parse(address);
if (viaAddr.viaSuffix == null) {
return ServerAddress.resolveServer(address);
return resolveServer(address);
}
return ServerAddress.resolveServer(viaAddr.realAddress).mapFirst(it -> it.replaceAll("\\.$", "") + "." + viaAddr.viaSuffix);
return resolveServer(viaAddr.realAddress).mapFirst(it -> it.replaceAll("\\.$", "") + "." + viaAddr.viaSuffix);
}
}

View File

@ -23,7 +23,7 @@
* SOFTWARE.
*/
package com.github.creeper123123321.viafabric.mixin.client;
package com.github.creeper123123321.viafabric.mixin.address.client;
import com.github.creeper123123321.viafabric.ViaFabricAddress;
import net.minecraft.client.network.MultiplayerServerListPinger;

View File

@ -23,7 +23,7 @@
* SOFTWARE.
*/
package com.github.creeper123123321.viafabric.mixin.client;
package com.github.creeper123123321.viafabric.mixin.debug.client;
import io.netty.channel.Channel;
import net.minecraft.network.ClientConnection;

View File

@ -23,7 +23,7 @@
* SOFTWARE.
*/
package com.github.creeper123123321.viafabric.mixin.client;
package com.github.creeper123123321.viafabric.mixin.debug.client;
import com.github.creeper123123321.viafabric.handler.CommonTransformer;
import com.github.creeper123123321.viafabric.handler.clientside.VRDecodeHandler;

View File

@ -23,7 +23,7 @@
* SOFTWARE.
*/
package com.github.creeper123123321.viafabric.mixin.client;
package com.github.creeper123123321.viafabric.mixin.gui.client;
import com.github.creeper123123321.viafabric.ViaFabric;
import com.github.creeper123123321.viafabric.gui.ViaConfigScreen;

View File

@ -23,7 +23,7 @@
* SOFTWARE.
*/
package com.github.creeper123123321.viafabric.mixin;
package com.github.creeper123123321.viafabric.mixin.pipeline;
import com.github.creeper123123321.viafabric.handler.CommonTransformer;
import io.netty.channel.ChannelHandler;

View File

@ -23,7 +23,7 @@
* SOFTWARE.
*/
package com.github.creeper123123321.viafabric.mixin;
package com.github.creeper123123321.viafabric.mixin.pipeline;
import com.github.creeper123123321.viafabric.handler.CommonTransformer;
import com.github.creeper123123321.viafabric.handler.serverside.FabricDecodeHandler;

View File

@ -23,7 +23,7 @@
* SOFTWARE.
*/
package com.github.creeper123123321.viafabric.mixin.client;
package com.github.creeper123123321.viafabric.mixin.pipeline.client;
import com.github.creeper123123321.viafabric.ViaFabric;
import com.github.creeper123123321.viafabric.handler.CommonTransformer;

View File

@ -83,7 +83,10 @@
},
"icon": "assets/viafabric/textures/logo.png",
"mixins": [
"mixins.viafabric.json"
"mixins.viafabric.address.json",
"mixins.viafabric.gui.json",
"mixins.viafabric.debug.json",
"mixins.viafabric.pipeline.json"
],
"accessWidener": "viafabric.accesswidener"
}

View File

@ -0,0 +1,15 @@
{
"required": true,
"compatibilityLevel": "JAVA_8",
"package": "com.github.creeper123123321.viafabric.mixin.address",
"mixins": [
],
"client": [
"client.MixinConnectScreenThread",
"client.MixinServerAddress",
"client.MixinServerPinger"
],
"injectors": {
"defaultRequire": 1
}
}

View File

@ -0,0 +1,14 @@
{
"required": true,
"compatibilityLevel": "JAVA_8",
"package": "com.github.creeper123123321.viafabric.mixin.debug",
"mixins": [
],
"client": [
"client.MixinClientConnectionAccessor",
"client.MixinDebugHud"
],
"injectors": {
"defaultRequire": 0
}
}

View File

@ -0,0 +1,13 @@
{
"required": true,
"compatibilityLevel": "JAVA_8",
"package": "com.github.creeper123123321.viafabric.mixin.gui",
"mixins": [
],
"client": [
"client.MixinMultiplayerScreen"
],
"injectors": {
"defaultRequire": 0
}
}

View File

@ -1,21 +0,0 @@
{
"required": true,
"compatibilityLevel": "JAVA_8",
"package": "com.github.creeper123123321.viafabric.mixin",
"mixins": [
"MixinClientConnection",
"MixinServerNetworkIoChInit"
],
"client": [
"client.MixinClientConnectionAccessor",
"client.MixinClientConnectionChInit",
"client.MixinConnectScreenThread",
"client.MixinDebugHud",
"client.MixinMultiplayerScreen",
"client.MixinServerAddress",
"client.MixinServerPinger"
],
"injectors": {
"defaultRequire": 1
}
}

View File

@ -0,0 +1,15 @@
{
"required": true,
"compatibilityLevel": "JAVA_8",
"package": "com.github.creeper123123321.viafabric.mixin.pipeline",
"mixins": [
"MixinClientConnection",
"MixinServerNetworkIoChInit"
],
"client": [
"client.MixinClientConnectionChInit"
],
"injectors": {
"defaultRequire": 1
}
}

View File

@ -1,4 +1,2 @@
accessWidener v1 named
# @Shadow bug workaround https://github.com/FabricMC/fabric-loom/issues/279
accessible method net/minecraft/network/ServerAddress resolveServer (Ljava/lang/String;)Lcom/mojang/datafixers/util/Pair;