I've got one problem: It doesn't work on server. Yea, it works fine on singleplayer but testing on server produces that error:
[18:24:06] [Netty IO #2/ERROR] [FML]: NetworkDispatcher exception
java.io.IOException: Eine vorhandene Verbindung wurde vom Remotehost geschlossen
at sun.nio.ch.SocketDispatcher.read0(Native Method) ~[?:1.7.0_51]
at sun.nio.ch.SocketDispatcher.read(Unknown Source) ~[?:1.7.0_51]
at sun.nio.ch.IOUtil.readIntoNativeBuffer(Unknown Source) ~[?:1.7.0_51]
at sun.nio.ch.IOUtil.read(Unknown Source) ~[?:1.7.0_51]
at sun.nio.ch.SocketChannelImpl.read(Unknown Source) ~[?:1.7.0_51]
at io.netty.buffer.UnpooledUnsafeDirectByteBuf.setBytes(UnpooledUnsafeDirectByteBuf.java:436) ~[unpooledUnsafeDirectByteBuf.class:?]
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:870) ~[AbstractByteBuf.class:?]
at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:208) ~[NioSocketChannel.class:?]
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:87) [AbstractNioByteChannel$NioByteUnsafe.class:?]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:480) [NioEventLoop.class:?]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:447) [NioEventLoop.class:?]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:341) [NioEventLoop.class:?]
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101) [singleThreadEventExecutor$2.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.7.0_51]
[18:24:06] [server thread/INFO]: Player949 lost connection: TranslatableComponent{key='disconnect.genericReason', args=[internal Exception: java.io.IOException: Eine vorhandene Verbindung wurde vom Remotehost geschlossen], siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null}}
[18:24:06] [server thread/INFO]: Player949 left the game
client closes and server reports the same message as eclipse
my @Mod class contains:
@EventHandler
public void serverLoad(FMLServerStartingEvent event) {
NetworkRegistry.INSTANCE.newChannel("lanceHitEntity", new PacketHandler());
NetworkRegistry.INSTANCE.newChannel("lanceHitValue", new PacketHandler());
NetworkRegistry.INSTANCE.newChannel("lanceIsForward", new PacketHandler());
}
my packet handler:
@Override
protected void channelRead0(ChannelHandlerContext ctx, FMLProxyPacket packet) throws Exception {
MinecraftServer server = MinecraftServer.getServer();
Item item = ((EntityPlayer) server.getEntityWorld().playerEntities.toArray(
[packet.payload().readInt()]).getCurrentEquippedItem().getItem();
if(item instanceof ItemLance) {
ItemLance lance = (ItemLance) item;
if (packet.channel().equals("lanceHitEntity")) {
lance.entity(packet.payload().readInt(), null, server.getEntityWorld());
} else if (packet.channel().equals("lanceHitValue")) {
float value = packet.payload().readFloat();
if (lance.hitValue < value || lance.hitTime < server.getSystemTimeMillis()) {
lance.hitValue = value;
lance.hitTime = server.getSystemTimeMillis() + 200;
}
} else if (packet.channel().equals("lanceIsForward")) {
lance.fwdTime = server.getSystemTimeMillis() + 200;
}
}
}
could anyone help me please?
thanks a lot!