package ru.dbotthepony.mc.otm.core.util

import net.minecraftforge.common.util.LazyOptional

class LOHolder<T : Any>(val value: T) {
	private var lazyOptional: LazyOptional<T> = LazyOptional.of { value }

	fun invalidate() {
		lazyOptional.invalidate()
	}

	fun revive() {
		lazyOptional.invalidate()
		lazyOptional = LazyOptional.of { value }
	}

	fun <T> get(): LazyOptional<T> {
		return lazyOptional.cast()
	}
}
