Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PacketUpdateContainer {
- private final int containerID;
- private final int containerInd;
- public PacketUpdateContainer(int containerID, int containerInd) {
- this.containerID = containerID;
- this.containerInd = containerInd;
- }
- public static void encode(PacketUpdateContainer packet, PacketBuffer packetBuffer) {
- packetBuffer.writeVarIntArray(new int[]{packet.containerID, packet.containerInd});
- }
- public static PacketUpdateContainer decode(final PacketBuffer packetBuffer) {
- return new PacketUpdateContainer(packetBuffer.readVarInt(), packetBuffer.readVarInt());
- }
- public static void handle(final PacketUpdateContainer packet, final Supplier<NetworkEvent.Context> contextSupplier) {
- final NetworkEvent.Context context = contextSupplier.get();
- context.enqueueWork(() -> {
- final ServerPlayerEntity sender = context.getSender();
- if (sender == null) {
- return;
- }
- final int containerID = packet.containerID;
- final int containerInd = packet.containerInd;
- System.out.println("Container ID: " + containerID);
- System.out.println("Container Ind: " + containerInd);
- PlayerInventory senderInv = sender.inventory;
- PacketHandler.CHANNEL.send(PacketDistributor.ALL.noArg(), new CapCompContainer(ModContainerTypes.MULTI_9X3.get(), containerID, containerInd, senderInv, 3));
- });
- context.setPacketHandled(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement