mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-11-15 10:45:35 +01:00
Updated VLB usage
This commit is contained in:
parent
ba3af3ae19
commit
ed3ca3d557
@ -14,7 +14,7 @@ maven_group=de.florianmichael
|
|||||||
archives_base_name=viafabricplus
|
archives_base_name=viafabricplus
|
||||||
|
|
||||||
# base lib
|
# base lib
|
||||||
vialoadingbase_version=c0c310671d
|
vialoadingbase_version=ae89fec4ab
|
||||||
raknet_transport_version=1.0.0.CR1-SNAPSHOT
|
raknet_transport_version=1.0.0.CR1-SNAPSHOT
|
||||||
|
|
||||||
# viaversion (and required) libs
|
# viaversion (and required) libs
|
||||||
|
@ -25,7 +25,7 @@ import de.florianmichael.viafabricplus.protocolhack.constants.BedrockRakNetConst
|
|||||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||||
import de.florianmichael.viafabricplus.protocolhack.PipelineInjector;
|
import de.florianmichael.viafabricplus.protocolhack.PipelineInjector;
|
||||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||||
import de.florianmichael.vialoadingbase.netty.event.PipelineReorderEvent;
|
import de.florianmichael.vialoadingbase.netty.event.CompressionReorderEvent;
|
||||||
import io.netty.channel.*;
|
import io.netty.channel.*;
|
||||||
import net.minecraft.network.ClientConnection;
|
import net.minecraft.network.ClientConnection;
|
||||||
import net.minecraft.network.encryption.PacketDecryptor;
|
import net.minecraft.network.encryption.PacketDecryptor;
|
||||||
@ -74,7 +74,7 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
|
|||||||
|
|
||||||
@Inject(method = "setCompressionThreshold", at = @At("RETURN"))
|
@Inject(method = "setCompressionThreshold", at = @At("RETURN"))
|
||||||
private void reorderCompression(int compressionThreshold, boolean rejectBad, CallbackInfo ci) {
|
private void reorderCompression(int compressionThreshold, boolean rejectBad, CallbackInfo ci) {
|
||||||
channel.pipeline().fireUserEventTriggered(new PipelineReorderEvent());
|
channel.pipeline().fireUserEventTriggered(new CompressionReorderEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "setupEncryption", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "setupEncryption", at = @At("HEAD"), cancellable = true)
|
||||||
@ -114,8 +114,8 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void viafabricplus_setupPreNettyEncryption() {
|
public void viafabricplus_setupPreNettyEncryption() {
|
||||||
this.channel.pipeline().addBefore(PreNettyConstants.HANDLER_DECODER_NAME, "decrypt", new PacketDecryptor(this.viafabricplus_decryptionCipher));
|
this.channel.pipeline().addBefore(PreNettyConstants.VIA_LEGACY_CODEC_NAME, "decrypt", new PacketDecryptor(this.viafabricplus_decryptionCipher));
|
||||||
this.channel.pipeline().addBefore(PreNettyConstants.HANDLER_ENCODER_NAME, "encrypt", new PacketEncryptor(this.viafabricplus_encryptionCipher));
|
this.channel.pipeline().addBefore(PreNettyConstants.VIA_LEGACY_CODEC_NAME, "encrypt", new PacketEncryptor(this.viafabricplus_encryptionCipher));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,11 +27,9 @@ import de.florianmichael.viafabricplus.protocolhack.platform.viabedrock.PingEnca
|
|||||||
import de.florianmichael.viafabricplus.protocolhack.platform.viabedrock.RakMessageEncapsulationCodec;
|
import de.florianmichael.viafabricplus.protocolhack.platform.viabedrock.RakMessageEncapsulationCodec;
|
||||||
import de.florianmichael.viafabricplus.protocolhack.platform.viabedrock.library_fix.FixedUnconnectedPingEncoder;
|
import de.florianmichael.viafabricplus.protocolhack.platform.viabedrock.library_fix.FixedUnconnectedPingEncoder;
|
||||||
import de.florianmichael.viafabricplus.protocolhack.platform.viabedrock.library_fix.FixedUnconnectedPongDecoder;
|
import de.florianmichael.viafabricplus.protocolhack.platform.viabedrock.library_fix.FixedUnconnectedPongDecoder;
|
||||||
import de.florianmichael.viafabricplus.protocolhack.platform.vialegacy.VFPPreNettyDecoder;
|
import de.florianmichael.viafabricplus.protocolhack.platform.vialegacy.ViaFabricPlusPreNettyLengthCodec;
|
||||||
import de.florianmichael.viafabricplus.protocolhack.platform.vialegacy.VFPPreNettyEncoder;
|
import de.florianmichael.viafabricplus.protocolhack.replacement.ViaFabricPlusVLBViaCodec;
|
||||||
import de.florianmichael.viafabricplus.protocolhack.replacement.ViaFabricPlusVLBViaDecodeHandler;
|
|
||||||
import de.florianmichael.vialoadingbase.netty.NettyConstants;
|
import de.florianmichael.vialoadingbase.netty.NettyConstants;
|
||||||
import de.florianmichael.vialoadingbase.netty.handler.VLBViaEncodeHandler;
|
|
||||||
import io.netty.bootstrap.Bootstrap;
|
import io.netty.bootstrap.Bootstrap;
|
||||||
import io.netty.channel.*;
|
import io.netty.channel.*;
|
||||||
import io.netty.channel.epoll.EpollDatagramChannel;
|
import io.netty.channel.epoll.EpollDatagramChannel;
|
||||||
@ -40,6 +38,7 @@ import io.netty.channel.socket.nio.NioDatagramChannel;
|
|||||||
import io.netty.handler.timeout.ReadTimeoutHandler;
|
import io.netty.handler.timeout.ReadTimeoutHandler;
|
||||||
import net.minecraft.network.ClientConnection;
|
import net.minecraft.network.ClientConnection;
|
||||||
import net.minecraft.network.NetworkSide;
|
import net.minecraft.network.NetworkSide;
|
||||||
|
import net.minecraft.network.SizePrepender;
|
||||||
import net.minecraft.util.Lazy;
|
import net.minecraft.util.Lazy;
|
||||||
import net.raphimc.viabedrock.netty.BatchLengthCodec;
|
import net.raphimc.viabedrock.netty.BatchLengthCodec;
|
||||||
import net.raphimc.viabedrock.netty.PacketEncapsulationCodec;
|
import net.raphimc.viabedrock.netty.PacketEncapsulationCodec;
|
||||||
@ -72,14 +71,15 @@ public class PipelineInjector {
|
|||||||
|
|
||||||
new ProtocolPipelineImpl(user);
|
new ProtocolPipelineImpl(user);
|
||||||
|
|
||||||
channel.pipeline().addBefore("encoder", NettyConstants.HANDLER_ENCODER_NAME, new VLBViaEncodeHandler(user));
|
channel.pipeline().addBefore("decoder", NettyConstants.VIA_CODEC_NAME, new ViaFabricPlusVLBViaCodec(user));
|
||||||
channel.pipeline().addBefore("decoder", NettyConstants.HANDLER_DECODER_NAME, new ViaFabricPlusVLBViaDecodeHandler(user));
|
|
||||||
|
|
||||||
if (ProtocolHack.getTargetVersion(channel).isOlderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
if (ProtocolHack.getTargetVersion(channel).isOlderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||||
user.getProtocolInfo().getPipeline().add(PreNettyBaseProtocol.INSTANCE);
|
user.getProtocolInfo().getPipeline().add(PreNettyBaseProtocol.INSTANCE);
|
||||||
|
|
||||||
channel.pipeline().addBefore("prepender", PreNettyConstants.HANDLER_ENCODER_NAME, new VFPPreNettyEncoder(user));
|
channel.pipeline().addBefore("splitter", PreNettyConstants.VIA_LEGACY_CODEC_NAME, new ViaFabricPlusPreNettyLengthCodec(user));
|
||||||
channel.pipeline().addBefore("splitter", PreNettyConstants.HANDLER_DECODER_NAME, new VFPPreNettyDecoder(user));
|
|
||||||
|
channel.pipeline().remove("prepender");
|
||||||
|
channel.pipeline().addAfter("splitter", "prepender", new SizePrepender());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,5 @@ package de.florianmichael.viafabricplus.protocolhack.constants;
|
|||||||
|
|
||||||
public class PreNettyConstants {
|
public class PreNettyConstants {
|
||||||
|
|
||||||
public static final String HANDLER_DECODER_NAME = "via-legacy-decoder";
|
public static final String VIA_LEGACY_CODEC_NAME = "via-legacy-codec";
|
||||||
public static final String HANDLER_ENCODER_NAME = "via-legacy-encoder";
|
|
||||||
}
|
}
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
|
||||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.florianmichael.viafabricplus.protocolhack.platform.vialegacy;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
|
||||||
import net.raphimc.vialegacy.netty.PreNettyDecoder;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class VFPPreNettyDecoder extends PreNettyDecoder {
|
|
||||||
|
|
||||||
public VFPPreNettyDecoder(UserConnection user) {
|
|
||||||
super(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) {
|
|
||||||
if (Via.getManager().isDebug()) {
|
|
||||||
if (!in.isReadable() || in.readableBytes() <= 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Via.getPlatform().getLogger().info("Decoding pre netty packet: " + in.copy().readUnsignedByte());
|
|
||||||
}
|
|
||||||
super.decode(ctx, in, out);
|
|
||||||
}
|
|
||||||
}
|
|
@ -22,14 +22,27 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
|||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import net.raphimc.vialegacy.netty.PreNettyEncoder;
|
import net.raphimc.vialegacy.netty.PreNettyLengthCodec;
|
||||||
|
|
||||||
public class VFPPreNettyEncoder extends PreNettyEncoder {
|
import java.util.List;
|
||||||
|
|
||||||
public VFPPreNettyEncoder(UserConnection user) {
|
public class ViaFabricPlusPreNettyLengthCodec extends PreNettyLengthCodec {
|
||||||
|
|
||||||
|
public ViaFabricPlusPreNettyLengthCodec(UserConnection user) {
|
||||||
super(user);
|
super(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) {
|
||||||
|
if (Via.getManager().isDebug()) {
|
||||||
|
if (!in.isReadable() || in.readableBytes() <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Via.getPlatform().getLogger().info("Decoding pre netty packet: " + in.copy().readUnsignedByte());
|
||||||
|
}
|
||||||
|
super.decode(ctx, in, out);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) {
|
protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) {
|
||||||
if (Via.getManager().isDebug()) {
|
if (Via.getManager().isDebug()) {
|
@ -21,16 +21,16 @@ import com.viaversion.viaversion.api.Via;
|
|||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.exception.CancelCodecException;
|
import com.viaversion.viaversion.exception.CancelCodecException;
|
||||||
import com.viaversion.viaversion.util.PipelineUtil;
|
import com.viaversion.viaversion.util.PipelineUtil;
|
||||||
import de.florianmichael.vialoadingbase.netty.handler.VLBViaDecodeHandler;
|
import de.florianmichael.vialoadingbase.netty.VLBViaCodec;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class ViaFabricPlusVLBViaDecodeHandler extends VLBViaDecodeHandler {
|
public class ViaFabricPlusVLBViaCodec extends VLBViaCodec {
|
||||||
|
|
||||||
public ViaFabricPlusVLBViaDecodeHandler(UserConnection info) {
|
public ViaFabricPlusVLBViaCodec(UserConnection info) {
|
||||||
super(info);
|
super(info);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user