Jump to content

[1.7.10] PacketPipeline / AbstactPacket troubles


toss

Recommended Posts

Hey guys, i just followed the tutorial based on Packet handling with netty, but i'm having a problem.

 

I copy / pasted PacketPipeline / AbstactPacket (and modified it properly i guess)

 

So i created a Packet to send an int to the player when it joins the game:

package fr.toss.network.packet;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import net.minecraft.entity.player.EntityPlayer;

public class PacketLogIn extends AbstractPacket {

public int id;

public PacketLogIn(int p_id)
{
	this.id = p_id;
}

@Override
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) 
{
	buffer.writeInt(this.id);
}

@Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) 
{
	this.id = buffer.readInt();
}

@Override
public void handleClientSide(EntityPlayer player) 
{
	System.out.println("Client");
}

@Override
public void handleServerSide(EntityPlayer player)
{
	System.out.println("Server");
}

}

 

+ The join event:

	
@SubscribeEvent
    public void onPlayerLog(PlayerEvent.PlayerLoggedInEvent event)
    {
	System.out.println("PLAYER LOG");
	Main.packetPipeline.sendToServer(new PacketLogIn(1));
    }

 

Main class:

    @EventHandler
    public void initialise(FMLPostInitializationEvent evt) 
    {
        packetPipeline.initialise();
    }

    @EventHandler
    public void postInitialise(FMLPostInitializationEvent evt) 
    {
        packetPipeline.postInitialise();
        packetPipeline.registerPacket(PacketLogIn.class);
    }

 

So when a player join the game, the only message appearing in the console is: "PLAYER LOG"

Which mean nor handleClientSide() or handleServerSide() is called...

 

Thanks you :)

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.