Creepinson

Untitled

Jun 24th, 2017
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. package me.creepinson.packet;
  2.  
  3. import io.netty.buffer.ByteBuf;
  4. import net.minecraft.entity.player.EntityPlayer;
  5. import net.minecraftforge.fml.common.network.ByteBufUtils;
  6. import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
  7.  
  8. public class CustomPacket implements IMessage {
  9. public int id;
  10. // A default constructor is always required
  11. public CustomPacket(int id) {
  12.  
  13. this.id = id;
  14.  
  15.  
  16. }
  17. public CustomPacket() {
  18.  
  19.  
  20.  
  21. }
  22.  
  23.  
  24. @Override
  25. public void toBytes(ByteBuf buf) {
  26.  
  27. buf.writeInt(id);
  28.  
  29. }
  30.  
  31. @Override
  32. public void fromBytes(ByteBuf buf) {
  33. // Reads the int back from the buf. Note that if you have multiple
  34. // values, you must read in the same order you wrote.
  35.  
  36. id = buf.readInt();
  37. }
  38. }
Add Comment
Please, Sign In to add comment