Advertisement
HalestormXV

Untitled

Mar 19th, 2016
68
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.halestormxv.Main.handler.network.packets;
  2.  
  3. import com.halestormxv.Main.MainRegistry;
  4. import com.halestormxv.Main.handler.network.AbstractServerMessageHandler;
  5. import com.halestormxv.item.CelestialCraft_items;
  6.  
  7. import cpw.mods.fml.common.network.simpleimpl.IMessage;
  8. import cpw.mods.fml.common.network.simpleimpl.MessageContext;
  9. import io.netty.buffer.ByteBuf;
  10. import net.minecraft.entity.player.EntityPlayer;
  11. import net.minecraft.inventory.IInventory;
  12.  
  13. public class OpenGuiPacketAlt implements IMessage {
  14.     // this will store the id of the gui to open
  15.     private int id;
  16.  
  17.     // The basic, no-argument constructor MUST be included to use the new automated handling
  18.     public OpenGuiPacketAlt() {}
  19.  
  20.     // if there are any class fields, be sure to provide a constructor that allows
  21.     // for them to be initialized, and use that constructor when sending the packet
  22.     public OpenGuiPacketAlt(int id) {
  23.         this.id = id;
  24.     }
  25.  
  26.     @Override
  27.     public void fromBytes(ByteBuf buffer) {
  28.         // basic Input/Output operations, very much like DataInputStream
  29.         id = buffer.readInt();
  30.     }
  31.  
  32.     @Override
  33.     public void toBytes(ByteBuf buffer) {
  34.         // basic Input/Output operations, very much like DataOutputStream
  35.         buffer.writeInt(id);
  36.     }
  37.  
  38.     public static class Handler extends AbstractServerMessageHandler<OpenGuiPacketAlt> {
  39.         @Override
  40.         public IMessage handleServerMessage(EntityPlayer player, OpenGuiPacketAlt message, MessageContext ctx)
  41.         {
  42.             System.out.println("Congratulations you finally created a frigen packet that works!");
  43.             player.openGui(MainRegistry.modInstance, message.id, player.worldObj, 0, 0, 0);
  44.             return null;
  45.         }
  46.     }
  47. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement