Guest User

Untitled

a guest
Sep 28th, 2019
47
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package fr.feloria.felmod.common.network;
  2.  
  3. import net.minecraft.network.PacketBuffer;
  4. import net.minecraftforge.fml.network.NetworkEvent;
  5.  
  6. import java.util.function.Supplier;
  7.  
  8. public class FeloriaPacket {
  9.  
  10. private int value;
  11.  
  12. public FeloriaPacket(int value)
  13. {
  14. this.value = value;
  15. }
  16.  
  17. public static void encode(FeloriaPacket packet, PacketBuffer buffer)
  18. {
  19. buffer.writeInt(packet.value);
  20. }
  21.  
  22. public static FeloriaPacket decode(PacketBuffer buffer)
  23. {
  24. int value = buffer.readInt();
  25. FeloriaPacket instance = new FeloriaPacket(value);
  26. return instance;
  27. }
  28.  
  29. public static void handle(FeloriaPacket packet, Supplier<NetworkEvent.Context> ctx)
  30. {
  31. System.out.println(packet.value);
  32. ctx.get().setPacketHandled(true);
  33. }
  34. }
RAW Paste Data