mirror of
https://github.com/ViaVersion/ViaFabric.git
synced 2024-12-22 16:28:12 +01:00
remove MixinSplitterHandler
This commit is contained in:
parent
ac1cdf1b83
commit
e71126d552
@ -1,80 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.buffer.ByteBuf;
|
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
|
||||||
import io.netty.handler.codec.CorruptedFrameException;
|
|
||||||
import net.minecraft.network.SplitterHandler;
|
|
||||||
import net.minecraft.util.PacketByteBuf;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Overwrite;
|
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Mixin(SplitterHandler.class)
|
|
||||||
public class MixinSplitterHandler {
|
|
||||||
/**
|
|
||||||
* Based on https://github.com/VelocityPowered/Velocity/blob/master/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftVarintFrameDecoder.java
|
|
||||||
*
|
|
||||||
* @reason optimization
|
|
||||||
* @author creeper123123321
|
|
||||||
*/
|
|
||||||
@Overwrite(remap = false)
|
|
||||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
|
||||||
if (!in.isReadable()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int origReaderIndex = in.readerIndex();
|
|
||||||
for (int i = 0; i < 3; i++) {
|
|
||||||
if (!in.isReadable()) {
|
|
||||||
in.readerIndex(origReaderIndex);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
byte read = in.readByte();
|
|
||||||
if (read >= 0) {
|
|
||||||
// Make sure reader index of length buffer is returned to the beginning
|
|
||||||
in.readerIndex(origReaderIndex);
|
|
||||||
int packetLength = Type.VAR_INT.read(in);
|
|
||||||
if (packetLength == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in.readableBytes() < packetLength) {
|
|
||||||
in.readerIndex(origReaderIndex);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
out.add(in.readRetainedSlice(packetLength));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new CorruptedFrameException("VarInt too big");
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,7 +7,6 @@
|
|||||||
"client": [
|
"client": [
|
||||||
"client.MixinClientConnectionChInit",
|
"client.MixinClientConnectionChInit",
|
||||||
"client.MixinMultiplayerGui",
|
"client.MixinMultiplayerGui",
|
||||||
"client.MixinSplitterHandler"
|
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
|
Loading…
Reference in New Issue
Block a user