Guest User

Untitled

a guest
Jul 18th, 2016
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. package fr.impuuu.havenrp.packets;
  2.  
  3. import cpw.mods.fml.common.network.ByteBufUtils;
  4. import fr.impuuu.havenrp.message.AfficheMessage;
  5. import fr.impuuu.havenrp.message.MessageOverlay;
  6. import io.netty.buffer.ByteBuf;
  7. import io.netty.channel.ChannelHandlerContext;
  8. import net.minecraft.entity.player.EntityPlayer;
  9.  
  10. public class PacketMessage
  11. extends AbstractPacketHelper
  12. {
  13. String message;
  14. String subMessage;
  15. int time;
  16.  
  17. public void addInformations(String title, String subTitle, int time)
  18. {
  19. this.message = title;
  20. this.subMessage = subTitle;
  21. this.time = time;
  22. }
  23.  
  24. public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer)
  25. {
  26. ByteBufUtils.writeUTF8String(buffer, this.message);
  27. ByteBufUtils.writeUTF8String(buffer, this.subMessage);
  28. buffer.writeInt(this.time);
  29. }
  30.  
  31. public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer)
  32. {
  33. this.message = ByteBufUtils.readUTF8String(buffer);
  34. this.subMessage = ByteBufUtils.readUTF8String(buffer);
  35. this.time = buffer.readInt();
  36. }
  37.  
  38. public void handleClientSide(EntityPlayer player)
  39. {
  40. AfficheMessage message = new AfficheMessage(this.message, this.subMessage, this.time);
  41. MessageOverlay.addMessageToQueue(message);
  42. }
  43.  
  44. public void handleServerSide(EntityPlayer player) {}
  45. }
Add Comment
Please, Sign In to add comment