This commit is contained in:
DBotThePony 2023-08-04 15:07:11 +07:00
parent 6ab65c6c17
commit e83933077e
Signed by: DBot
GPG Key ID: DCC23B5715498507
3 changed files with 3 additions and 10 deletions

View File

@ -196,15 +196,6 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc
}
}
protected fun exposeItemsGlobally(value: IItemHandler) {
exposeGlobally(ForgeCapabilities.ITEM_HANDLER, value)
}
@Suppress("SuspiciousCallableReferenceInLambda")
protected fun <T> trackGlobally(capability: Capability<T>): List<LazyOptional<T>> {
return SupplierList(_sides.values.map { it.track(capability)::get })
}
interface SideListener<T> : Supplier<LazyOptional<T>> {
fun addListener(listener: Consumer<LazyOptional<T>>)
}

View File

@ -39,6 +39,7 @@ import ru.dbotthepony.mc.otm.once
/**
* Device block entity base, implementing [MenuProvider] and [IRedstoneControlled], and also tracks custom display name
*/
@Suppress("LiftReturnOrAssignment")
abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blockPos: BlockPos, blockState: BlockState)
: MatteryBlockEntity(blockEntityType, blockPos, blockState), MenuProvider, IRedstoneControlled {
var customDisplayName: Component? = null

View File

@ -25,6 +25,7 @@ import net.minecraft.world.level.storage.loot.LootParams
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets
import net.minecraft.world.level.storage.loot.parameters.LootContextParams
import net.minecraft.world.phys.Vec3
import net.minecraftforge.common.capabilities.ForgeCapabilities
import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock
import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity
import ru.dbotthepony.mc.otm.container.MatteryContainer
@ -85,7 +86,7 @@ class CargoCrateBlockEntity(
}
init {
exposeItemsGlobally(handler)
exposeGlobally(ForgeCapabilities.ITEM_HANDLER, handler)
savetablesLevel.stateful(::container, INVENTORY_KEY)
}