Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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 :)

 

  • Author

Yes i want to send a server int value to the client when it joins the game

 

Sorry I just see this tutorial... i typed "minecraft forge packet handling" on Google and didn't use brain :P

 

Thx for your answer

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.