Advertisement
Guest User

PacketUpdateContainer

a guest
Oct 27th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. public class PacketUpdateContainer {
  2. private final int containerID;
  3. private final int containerInd;
  4.  
  5. public PacketUpdateContainer(int containerID, int containerInd) {
  6. this.containerID = containerID;
  7. this.containerInd = containerInd;
  8. }
  9.  
  10. public static void encode(PacketUpdateContainer packet, PacketBuffer packetBuffer) {
  11. packetBuffer.writeVarIntArray(new int[]{packet.containerID, packet.containerInd});
  12. }
  13.  
  14. public static PacketUpdateContainer decode(final PacketBuffer packetBuffer) {
  15. return new PacketUpdateContainer(packetBuffer.readVarInt(), packetBuffer.readVarInt());
  16. }
  17.  
  18. public static void handle(final PacketUpdateContainer packet, final Supplier<NetworkEvent.Context> contextSupplier) {
  19. final NetworkEvent.Context context = contextSupplier.get();
  20. context.enqueueWork(() -> {
  21. final ServerPlayerEntity sender = context.getSender();
  22. if (sender == null) {
  23. return;
  24. }
  25. final int containerID = packet.containerID;
  26. final int containerInd = packet.containerInd;
  27. System.out.println("Container ID: " + containerID);
  28. System.out.println("Container Ind: " + containerInd);
  29. PlayerInventory senderInv = sender.inventory;
  30. PacketHandler.CHANNEL.send(PacketDistributor.ALL.noArg(), new CapCompContainer(ModContainerTypes.MULTI_9X3.get(), containerID, containerInd, senderInv, 3));
  31. });
  32. context.setPacketHandled(true);
  33. }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement