Alright, I followed what you said and changed my code to the following:
@Override
public INBT serializeNBT() {
return CapabilityRestraintsInventory.INVENTORY.getStorage().writeNBT(CapabilityRestraintsInventory.INVENTORY, lazyInitialisionSupplier.orElseThrow(() -> new IllegalArgumentException("LazyOptional is empty!")), null);
}
@Override
public void deserializeNBT(INBT nbt) {
CapabilityRestraintsInventory.INVENTORY.getStorage().readNBT(CapabilityRestraintsInventory.INVENTORY, lazyInitialisionSupplier.orElseThrow(() -> new IllegalArgumentException("LazyOptional is empty!")), null, nbt);
}
It still seems to act like a trash can, and it says it will produce an NPE on running .getStorage() on my capability, but I dont seem to get an NPE when going into the game. Does that have anything to do with the cap variable never being equal to my capability?