From e71126d5522e8c26bfebe36b946230edc2f8d8a6 Mon Sep 17 00:00:00 2001 From: creeper123123321 Date: Thu, 24 Jan 2019 11:17:03 -0200 Subject: [PATCH] remove MixinSplitterHandler --- .../mixin/client/MixinSplitterHandler.java | 80 ------------------- src/main/resources/mixins.viafabric.main.json | 1 - 2 files changed, 81 deletions(-) delete mode 100644 src/main/java/com/github/creeper123123321/viafabric/mixin/client/MixinSplitterHandler.java diff --git a/src/main/java/com/github/creeper123123321/viafabric/mixin/client/MixinSplitterHandler.java b/src/main/java/com/github/creeper123123321/viafabric/mixin/client/MixinSplitterHandler.java deleted file mode 100644 index a23a13b..0000000 --- a/src/main/java/com/github/creeper123123321/viafabric/mixin/client/MixinSplitterHandler.java +++ /dev/null @@ -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 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"); - } -} diff --git a/src/main/resources/mixins.viafabric.main.json b/src/main/resources/mixins.viafabric.main.json index 32f043e..17d1af2 100644 --- a/src/main/resources/mixins.viafabric.main.json +++ b/src/main/resources/mixins.viafabric.main.json @@ -7,7 +7,6 @@ "client": [ "client.MixinClientConnectionChInit", "client.MixinMultiplayerGui", - "client.MixinSplitterHandler" ], "injectors": { "defaultRequire": 1