Guest User

Untitled

a guest
Dec 7th, 2014
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. package com.Looke81.BioWarfare;
  2.  
  3. import cpw.mods.fml.common.network.ByteBufUtils;
  4. import cpw.mods.fml.common.network.simpleimpl.IMessage;
  5. import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
  6. import cpw.mods.fml.common.network.simpleimpl.MessageContext;
  7. import io.netty.buffer.ByteBuf;
  8.  
  9. public class MyMessage implements IMessage {
  10.  
  11. public static class Handler implements IMessageHandler<MyMessage, IMessage> {
  12.  
  13. @Override
  14. public IMessage onMessage(MyMessage message, MessageContext ctx) {
  15. System.out.println(String.format("Received %s from %s", message.text, ctx.getServerHandler().playerEntity.getDisplayName()));
  16. BioWarfare.Proxy.noCurrentShader(null, null);
  17. return null; // no response in this case
  18. }
  19. }
  20.  
  21.  
  22. private String text;
  23.  
  24. public MyMessage() { }
  25.  
  26. public MyMessage(String text) {
  27. this.text = text;
  28. }
  29.  
  30. @Override
  31. public void fromBytes(ByteBuf buf) {
  32. text = ByteBufUtils.readUTF8String(buf); // this class is very useful in general for writing more complex objects
  33. }
  34.  
  35. @Override
  36. public void toBytes(ByteBuf buf) {
  37. ByteBufUtils.writeUTF8String(buf, text);
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment