Jump to content

sirgingalot

Members
  • Posts

    5
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

sirgingalot's Achievements

Tree Puncher

Tree Puncher (2/8)

4

Reputation

  1. Noppes: Yeh, I was aware of this, I just like having my packets as self containing objects so they are responsible for their own encoding/decoding. Your method is definitely the simpler option for beginners though! In the end it's just a matter of preference really as there are pros and cons to both. You should post your example on the wiki though as the more information out there the better!
  2. AFlyingGrayson: It seems you are creating a new packet handler each time. Instead, when you create it you should store it statically somewhere and use that as a reference to send packets. In essence: 1) Create packethandler in your mod constructor, or as one of this first things in preInit. Save it to a public static variable 2) Call the methods (in the correct locations) as per "Registering the Pipeline" 3) Register your packet sync with the packet handler (likely in the init phase) 4) When you need to send packets get the public static variable and call the send methods 5) Hopefully thats it! garvek: I'm glad it worked for you! At least some of my code sees the light of day
  3. kukipett: for most normal circumstances the context is not required. It is just used to pass along the packet data further down the chain. Most of the important things performed using the channel handler context are performed upstream by cpw or by me. However, it is provided in the read packet data for completeness. If you think you will need it you can use the JD: http://docs.jboss.org/netty/3.2/api/org/jboss/netty/channel/ChannelHandlerContext.html to discover what actions are available with it.
  4. knight: If you were using my code, there was a sided error in the code that is now corrected in the wiki, however, that error seems unrelated. To be honest, if I am reading your code correctly, you have only registered the channel on the server, which just wont work as the client has no channel to receive on... libarclite: If in doubt you could register multiple channels per thread (instead of auto registering during the init phase, just create another with a different name). However, both attr() and writeAndFlush() are netty methods and netty at its core is both asynchronous and thread safe so I assume it should be fine! According to the JD: http://netty.io/4.0/api/io/netty/util/Attribute.html Attributes can be updated automatically so are thread safe.
  5. I have written a tutorial on the forge wiki that contains centralised sending commands. You could use a structure like that to send custom packets. Netty Packet Handling
×
×
  • Create New...

Important Information

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