Advertisement
Creepinson

Untitled

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