Add debug and update ViaVersion 3.0.2, ViaFabric 0.2.4-SNAPSHOT

This commit is contained in:
creeper123123321 2020-06-25 13:56:49 -03:00
parent 7114988372
commit 7e4a526e3d
10 changed files with 113 additions and 24 deletions

View File

@ -17,7 +17,7 @@ Note: ViaVersion is not designed for modded Minecraft with registry synchronizat
**Dependencies:**
| Dependency | Download |
| --------------------------------- | --------------------------------------------------------------------- |
| ViaVersion 3.0.0+ | https://viaversion.com/ |
| ViaVersion 3.0.2+ | dev build at https://ci.viaversion.com/job/ViaVersion/ |
| Fabric Textures v0 | https://www.curseforge.com/minecraft/mc-mods/fabric-api |
| Fabric Resource Loader v0 | https://www.curseforge.com/minecraft/mc-mods/fabric-api |
| Fabric Command API v1 | https://www.curseforge.com/minecraft/mc-mods/fabric-api |

View File

@ -9,7 +9,7 @@ plugins {
group = "com.github.creeper123123321.viafabric"
val gitVersion: groovy.lang.Closure<Any> by extra
version = "0.2.3-SNAPSHOT+" + try {
version = "0.2.4-SNAPSHOT+" + try {
gitVersion()
} catch (e: Exception) {
"unknown"
@ -47,7 +47,7 @@ tasks.named<ProcessResources>("processResources") {
dependencies {
// transitive = false because Guava is conflicting on runClient
implementation("us.myles:viaversion:3.0.1-SNAPSHOT") { isTransitive = false }
implementation("us.myles:viaversion:3.0.2-SNAPSHOT") { isTransitive = false }
// Use 1.16 snapshot, probably intermediary will make it work on further versions
// https://modmuss50.me/fabric.html?&version=1.16

View File

@ -27,7 +27,6 @@ package com.github.creeper123123321.viafabric.commands;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.command.ViaCommandSender;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import java.util.UUID;
@ -50,11 +49,11 @@ public class UserCommandSender implements ViaCommandSender {
@Override
public UUID getUUID() {
return con.get(ProtocolInfo.class).getUuid();
return con.getProtocolInfo().getUuid();
}
@Override
public String getName() {
return con.get(ProtocolInfo.class).getUsername();
return con.getProtocolInfo().getUsername();
}
}

View File

@ -62,4 +62,8 @@ public class VRDecodeHandler extends MessageToMessageDecoder<ByteBuf> {
if (cause instanceof CancelCodecException) return;
super.exceptionCaught(ctx, cause);
}
public UserConnection getInfo() {
return info;
}
}

View File

@ -0,0 +1,36 @@
/*
* MIT License
*
* Copyright (c) 2018 creeper123123321 and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.creeper123123321.viafabric.mixin.client;
import io.netty.channel.Channel;
import net.minecraft.network.ClientConnection;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(ClientConnection.class)
public interface MixinClientConnectionAccessor {
@Accessor
Channel getChannel();
}

View File

@ -0,0 +1,62 @@
/*
* MIT License
*
* Copyright (c) 2018 creeper123123321 and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.creeper123123321.viafabric.mixin.client;
import com.github.creeper123123321.viafabric.handler.CommonTransformer;
import com.github.creeper123123321.viafabric.handler.clientside.VRDecodeHandler;
import io.netty.channel.ChannelHandler;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.hud.DebugHud;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import java.util.List;
@Mixin(DebugHud.class)
public class MixinDebugHud {
@Inject(at = @At("RETURN"), method = "getLeftText")
protected void getLeftText(CallbackInfoReturnable<List<String>> info) {
info.getReturnValue().add("[ViaFabric] " + Via.getManager().getConnections().size() + " injected ("
+ Via.getManager().getConnectedClients().size() + " frontend)");
ChannelHandler viaDecoder = ((MixinClientConnectionAccessor) MinecraftClient.getInstance().getNetworkHandler()
.getConnection()).getChannel().pipeline().get(CommonTransformer.HANDLER_DECODER_NAME);
if (viaDecoder instanceof VRDecodeHandler) {
ProtocolInfo protocol = ((VRDecodeHandler) viaDecoder).getInfo().getProtocolInfo();
if (protocol != null) {
ProtocolVersion serverVer = ProtocolVersion.getProtocol(protocol.getServerProtocolVersion());
String inactive = "";
if (!protocol.getUser().isActive()) {
inactive = " (inactive)";
}
info.getReturnValue().add("[ViaFabric] Client injected" + inactive + ": server is " + serverVer);
}
}
}
}

View File

@ -29,20 +29,7 @@ import us.myles.ViaVersion.api.platform.ViaConnectionManager;
public class VRConnectionManager extends ViaConnectionManager {
@Override
public void onLoginSuccess(UserConnection connection) {
if (connection instanceof VRClientSideUserConnection) {
this.connections.add(connection);
} else {
super.onLoginSuccess(connection);
}
}
@Override
public void onDisconnect(UserConnection connection) {
if (connection instanceof VRClientSideUserConnection) {
this.connections.remove(connection);
} else {
super.onDisconnect(connection);
}
public boolean isFrontEnd(UserConnection connection) {
return !(connection instanceof VRClientSideUserConnection);
}
}

View File

@ -32,7 +32,6 @@ import us.myles.ViaVersion.api.boss.BossColor;
import us.myles.ViaVersion.api.boss.BossStyle;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import java.util.SortedSet;
import java.util.TreeSet;
@ -43,7 +42,7 @@ public class VRViaAPI implements ViaAPI<UUID> {
public int getPlayerVersion(UUID uuid) {
UserConnection con = Via.getManager().getConnection(uuid);
if (con != null) {
return con.get(ProtocolInfo.class).getProtocolVersion();
return con.getProtocolInfo().getProtocolVersion();
}
try {
return Via.getManager().getInjector().getServerProtocolVersion();

View File

@ -29,7 +29,7 @@
"fabric-resource-loader-v0": "*",
"fabric-command-api-v1": "*",
"minecraft": ">1.15.2",
"viaversion": ">=3.0.0-SNAPSHOT"
"viaversion": ">=3.0.2-SNAPSHOT"
},
"conflicts": {
"fabric-registry-sync": "*"

View File

@ -7,7 +7,9 @@
"MixinServerNetworkIoChInit"
],
"client": [
"client.MixinClientConnectionAccessor",
"client.MixinClientConnectionChInit",
"client.MixinDebugHud",
"client.MixinMultiplayerScreen"
],
"injectors": {