Skip to content

Commit

Permalink
Merge pull request #1 from VkProfi/build-fix
Browse files Browse the repository at this point in the history
Предполагаемый фикс билда
  • Loading branch information
blackysky authored Apr 12, 2024
2 parents c96bc7c + a3221b4 commit 74c79f4
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 58 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ tasks.named('jar', Jar).configure {
'Implementation-Version' : project.jar.archiveVersion,
'Implementation-Vendor' : mod_authors,
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
'MixinConfigs': 'mixins.duble.json'
'MixinConfigs': 'mixins.packetdoubler.json'
])
}

Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ mod_name=Packet size doubler InCube
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=MIT
# The mod version. See https://semver.org/
mod_version=0.1
mod_version=1.0
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
mod_group_id=ru.vkprofi.packetDoubler
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
mod_authors=VkProfi
mod_authors=VkProfi, Silke
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
mod_description=Мод добавляющий отпечатки пальца в игру маинкрафт
mod_description=Мод увеличивающий размер пакетов
23 changes: 0 additions & 23 deletions src/main/java/ru/vkprofi/packetDoubler/ExampleMod.java

This file was deleted.

18 changes: 18 additions & 0 deletions src/main/java/ru/vkprofi/packetDoubler/Main.java
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");
}
}
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());
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ru.vkprofi.packetDoubler.mixin;
package ru.vkprofi.packetdoubler.mixin;

import net.minecraft.network.PacketEncoder;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -7,9 +7,8 @@

@Mixin(PacketEncoder.class)
public class PacketEncoderMixin {
@ModifyConstant(method = "encode(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/Packet;Lio/netty/buffer/ByteBuf;)V", constant = @Constant(intValue = 8388608))
@ModifyConstant(method = "encode(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/protocol/Packet;Lio/netty/buffer/ByteBuf;)V", constant = @Constant(intValue = 8388608))
private int injected(int value) {
return value * 10;
}

}

This file was deleted.

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
}
}

0 comments on commit 74c79f4

Please sign in to comment.