Fix missing call to release() in the event channel handler (#4513)

(reverted from commit cd99957627)
This commit is contained in:
LexManos 2017-12-18 16:03:41 -08:00
parent 02855f7d74
commit 18609f57ac
3 changed files with 15 additions and 38 deletions

View file

@ -1,10 +1,10 @@
{
"assetIndex": {
"id": "1.12",
"sha1": "c2ba0c4da30cce204c70db2ebc32a942cea8c7dd",
"size": 169015,
"url": "https://launchermeta.mojang.com/mc/assets/1.12/c2ba0c4da30cce204c70db2ebc32a942cea8c7dd/1.12.json",
"totalSize": 127300317
"sha1": "3b666765bafa02e84e24b371d9efd7a4d1b6e188",
"size": 169254,
"url": "https://launchermeta.mojang.com/mc/assets/1.12/3b666765bafa02e84e24b371d9efd7a4d1b6e188/1.12.json",
"totalSize": 127589960
},
"assets": "1.12",
"downloads": {
@ -719,6 +719,6 @@
"minecraftArguments": "--username ${auth_player_name} --version ${version_name} --gameDir ${game_directory} --assetsDir ${assets_root} --assetIndex ${assets_index_name} --uuid ${auth_uuid} --accessToken ${auth_access_token} --userType ${user_type} --versionType ${version_type}",
"minimumLauncherVersion": 18,
"releaseTime": "2017-09-18T08:39:46+00:00",
"time": "2017-09-18T08:41:11+00:00",
"time": "2017-12-07T09:55:13+00:00",
"type": "release"
}

View file

@ -22,6 +22,8 @@ package net.minecraftforge.fml.common.network;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
import org.apache.logging.log4j.Level;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
@ -47,7 +49,6 @@ public class NetworkEventFiringHandler extends SimpleChannelInboundHandler<FMLPr
protected void channelRead0(ChannelHandlerContext ctx, FMLProxyPacket msg) throws Exception
{
eventChannel.fireRead(msg,ctx);
msg.payload().release();
}
@Override
@ -55,7 +56,6 @@ public class NetworkEventFiringHandler extends SimpleChannelInboundHandler<FMLPr
{
eventChannel.fireUserEvent(evt,ctx);
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
{

View file

@ -10,60 +10,37 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent;
import net.minecraftforge.fml.common.network.FMLEventChannel;
import net.minecraftforge.fml.common.network.FMLNetworkEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
import org.apache.logging.log4j.Logger;
import net.minecraftforge.fml.relauncher.Side;
@Mod(modid = ForgeNetworkTestMod.MOD_ID, name = ForgeNetworkTestMod.MOD_ID, version = "1.0", acceptableRemoteVersions = "*")
public class ForgeNetworkTestMod
{
private static final boolean ENABLED = false;
public static final String MOD_ID = "forge_network_test";
public static final String MOD_ID = "forgenetworktest";
private FMLEventChannel channel;
private Logger logger;
@EventHandler
public void onPreInit(FMLPreInitializationEvent e)
{
if (ENABLED)
if (ENABLED && e.getSide() == Side.SERVER)
{
MinecraftForge.EVENT_BUS.register(this);
channel = NetworkRegistry.INSTANCE.newEventDrivenChannel(MOD_ID);
channel.register(this);
logger = e.getModLog();
}
}
@SubscribeEvent
public void onPlayerLogin(PlayerLoggedInEvent e)
{
if (ENABLED)
if (channel == null)
{
PacketBuffer buffer = new PacketBuffer(Unpooled.buffer());
buffer.writeString("Welcome to the server!");
channel.sendTo(new FMLProxyPacket(buffer, MOD_ID), (EntityPlayerMP) e.player); // disconnects vanilla clients in 1.11
logger.info("Welcomed player to the server");
return;
}
}
@SubscribeEvent
public void onPacketReceived(FMLNetworkEvent.ClientCustomPacketEvent e)
{
PacketBuffer payload = new PacketBuffer(e.getPacket().payload());
logger.info("Received message from server: {}", payload.readString(64));
PacketBuffer reply = new PacketBuffer(Unpooled.buffer());
reply.writeString("Thanks!");
e.setReply(new FMLProxyPacket(reply, MOD_ID));
logger.info("Sent a reply");
}
@SubscribeEvent
public void onPacketReceived(FMLNetworkEvent.ServerCustomPacketEvent e)
{
PacketBuffer payload = new PacketBuffer(e.getPacket().payload());
logger.info("Received reply from client: {}", payload.readString(64));
PacketBuffer buffer = new PacketBuffer(Unpooled.buffer());
buffer.writeByte(0);
channel.sendTo(new FMLProxyPacket(buffer, MOD_ID), (EntityPlayerMP) e.player); // disconnects vanilla clients in 1.11
}
}