From 6c42af9f3078948626dcbd7b40747a7011f73d46 Mon Sep 17 00:00:00 2001 From: DBotThePony <dbotthepony@yandex.ru> Date: Thu, 6 Mar 2025 21:58:08 +0700 Subject: [PATCH] Provide stream() method in enhanced container --- .../ru/dbotthepony/mc/otm/container/IEnhancedContainer.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/IEnhancedContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/IEnhancedContainer.kt index 24ca9c248..6edd68823 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/IEnhancedContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/IEnhancedContainer.kt @@ -15,6 +15,8 @@ import ru.dbotthepony.mc.otm.core.collect.filter import ru.dbotthepony.mc.otm.core.collect.map import ru.dbotthepony.mc.otm.core.isNotEmpty import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport /** * "Backward-compatible" enhanced container interface, where all methods can be derived/emulated from existing [IContainer] ([Container]) code @@ -291,6 +293,10 @@ interface IEnhancedContainer : IContainer, RecipeInput, Iterable<ItemStack>, Sta return addItem(stack, false, slots, onlyIntoExisting, popTime).isEmpty } + fun stream(): Stream<ItemStack> { + return StreamSupport.stream(spliterator(), false) + } + private class Wrapper(private val parent: Container) : IEnhancedContainer { override fun clearContent() { return parent.clearContent()