-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from VkProfi/build-fix
Предполагаемый фикс билда
- Loading branch information
Showing
8 changed files
with
93 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package ru.vkprofi.packetdoubler; | ||
|
||
import com.mojang.logging.LogUtils; | ||
import net.minecraftforge.event.server.ServerStartingEvent; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
import net.minecraftforge.fml.common.Mod; | ||
import org.slf4j.Logger; | ||
|
||
@Mod(Main.MODID) | ||
public class Main { | ||
public static final String MODID = "PackerDoubler"; | ||
private static final Logger LOGGER = LogUtils.getLogger(); | ||
|
||
@SubscribeEvent | ||
public void onServerStarting(ServerStartingEvent event) { | ||
LOGGER.info(MODID + " started"); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
src/main/java/ru/vkprofi/packetDoubler/mixin/PacketDecoderMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package ru.vkprofi.packetdoubler.mixin; | ||
|
||
import com.mojang.logging.LogUtils; | ||
import io.netty.buffer.ByteBuf; | ||
import io.netty.channel.ChannelHandlerContext; | ||
import io.netty.handler.codec.ByteToMessageDecoder; | ||
import net.minecraft.network.Connection; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.network.PacketDecoder; | ||
import net.minecraft.network.protocol.Packet; | ||
import net.minecraft.network.protocol.PacketFlow; | ||
import net.minecraft.util.profiling.jfr.JvmProfiler; | ||
import org.slf4j.Logger; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.Unique; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
@Mixin(PacketDecoder.class) | ||
public abstract class PacketDecoderMixin extends ByteToMessageDecoder { | ||
@Unique | ||
private static final Logger LOGGER = LogUtils.getLogger(); | ||
|
||
@Final @Shadow | ||
private PacketFlow flow; | ||
|
||
@Override | ||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { | ||
int i = in.readableBytes(); | ||
if (i != 0) { | ||
FriendlyByteBuf friendlybytebuf = new FriendlyByteBuf(in); | ||
int j = friendlybytebuf.readVarInt(); | ||
Packet<?> packet = ctx.channel().attr(Connection.ATTRIBUTE_PROTOCOL).get().createPacket(this.flow, j, friendlybytebuf); | ||
if (packet == null) { | ||
throw new IOException("Bad packet id " + j); | ||
} else { | ||
int k = ctx.channel().attr(Connection.ATTRIBUTE_PROTOCOL).get().getId(); | ||
JvmProfiler.INSTANCE.onPacketReceived(k, j, ctx.channel().remoteAddress(), i); | ||
if (friendlybytebuf.readableBytes() > 0) { | ||
// Разрешаем пакеты с большим количеством читаемых байтов | ||
if (friendlybytebuf.readableBytes() > 83886080) { | ||
throw new IOException("Packet " + ctx.channel().attr(Connection.ATTRIBUTE_PROTOCOL).get().getId() + "/" + j + " (" + packet.getClass().getSimpleName() + ") was larger than I expected, found " + friendlybytebuf.readableBytes() + " bytes extra whilst reading packet " + j); | ||
} | ||
} | ||
out.add(packet); | ||
if (LOGGER.isDebugEnabled()) { | ||
LOGGER.debug(Connection.PACKET_RECEIVED_MARKER, " IN: [{}:{}] {}", ctx.channel().attr(Connection.ATTRIBUTE_PROTOCOL).get(), j, packet.getClass().getName()); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
src/main/java/ru/vkprofi/packetDoubler/mixin/PacketInflaterMixin.java
This file was deleted.
Oops, something went wrong.
28 changes: 14 additions & 14 deletions
28
src/main/resources/mixins.duble.json → src/main/resources/mixins.packetdoubler.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
{ | ||
"required": true, | ||
"minVersion": "0.8", | ||
"package": "ru.vkprofi.packetDoubler.mixin", | ||
"compatibilityLevel": "JAVA_17", | ||
"mixins": [ | ||
"PacketEncoderMixin", | ||
"PacketInflaterMixin" | ||
], | ||
"client": [ | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
{ | ||
"required": true, | ||
"minVersion": "0.8", | ||
"package": "ru.vkprofi.packetdoubler.mixin", | ||
"compatibilityLevel": "JAVA_17", | ||
"mixins": [ | ||
"PacketEncoderMixin", | ||
"PacketDecoderMixin" | ||
], | ||
"client": [ | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
} |