Advertisement
Gamebuster

PacketRequestFoo.class

Sep 25th, 2016
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. public class PacketRequestFOO implements IMessage{
  2.     public PacketRequestFOO(){}
  3.  
  4.     @Override
  5.     public void fromBytes(ByteBuf buf) {
  6.         //I don't need to do anything here since I have no data to transmit, right?
  7.         //I'm just signaling the server to do something
  8.        
  9.         System.out.println("X - " + SIDE);
  10.     }
  11.  
  12.     @Override
  13.     public void toBytes(ByteBuf buf) {
  14.         System.out.println("Y - " + SIDE);
  15.     };
  16.    
  17.     public static class Handler implements IMessageHandler<PacketRequestFOO, IMessage>{
  18.         @Override
  19.         public IMessage onMessage(PacketRequestFOO message, MessageContext ctx) {
  20.             if(SIDE == SERVER){
  21.                 System.out.println("PACKET RECEIVED");
  22.                 IThreadListener mainThread = (WorldServer) ctx.getServerHandler().playerEntity.worldObj;
  23.                 mainThread.addScheduledTask(new Runnable(){
  24.                     @Override
  25.                     public void run() {
  26.                         Main.getFOO().doBAR((ctx.getServerHandler().playerEntity));
  27.                     }
  28.                 });
  29.                 return null;
  30.             }
  31.             else{
  32.                 return null;
  33.             }
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement