// Path: src/main/java/dev/gigaherz/enderrift/rift/IRiftChangeListener.java
// public interface IRiftChangeListener
// {
//     boolean isInvalid();
// 
//     void onRiftChanged();
// 
//     Optional<BlockPos> getLocation();
// }


import com.google.common.collect.Lists;
import dev.gigaherz.enderrift.rift.IRiftChangeListener;
import net.minecraft.nbt.Tag;
import net.minecraft.world.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.core.BlockPos;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemHandlerHelper;
import javax.annotation.Nonnull;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.util.Iterator;
import java.util.List;
import java.util.function.Consumer;
package dev.gigaherz.enderrift.rift.storage;



public class RiftInventory implements IItemHandler
{
    private final RiftStorage manager;

    final List<Reference<? extends IRiftChangeListener>> listeners = Lists.newArrayList();
    final ReferenceQueue<IRiftChangeListener> pendingRemovals = new ReferenceQueue<>();
    private final List<ItemStack> inventorySlots = Lists.newArrayList();

    RiftInventory(RiftStorage manager)
    {
        this.manager = manager;
    }

    public void addWeakListener(IRiftChangeListener e)
    {
        listeners.add(new WeakReference<>(e, pendingRemovals));
    }

// Path: src/main/java/dev/gigaherz/enderrift/rift/IRiftChangeListener.java
// public interface IRiftChangeListener
// {
//     boolean isInvalid();
// 
//     void onRiftChanged();
// 
//     Optional<BlockPos> getLocation();
// }


// Path: src/main/java/dev/gigaherz/enderrift/rift/storage/RiftInventory.java
import com.google.common.collect.Lists;
import dev.gigaherz.enderrift.rift.IRiftChangeListener;
import net.minecraft.nbt.Tag;
import net.minecraft.world.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.core.BlockPos;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemHandlerHelper;
import javax.annotation.Nonnull;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.util.Iterator;
import java.util.List;
import java.util.function.Consumer;

package dev.gigaherz.enderrift.rift.storage;



public class RiftInventory implements IItemHandler
{
    private final RiftStorage manager;

    final List<Reference<? extends IRiftChangeListener>> listeners = Lists.newArrayList();
    final ReferenceQueue<IRiftChangeListener> pendingRemovals = new ReferenceQueue<>();
    private final List<ItemStack> inventorySlots = Lists.newArrayList();

    RiftInventory(RiftStorage manager)
    {
        this.manager = manager;
    }

    public void addWeakListener(IRiftChangeListener e)
    {
        listeners.add(new WeakReference<>(e, pendingRemovals));
    }

    private void walkListeners(Consumer<IRiftChangeListener> consumer)