From 13a9f58b74efe71c9ab53916b3fb2daa26feec92 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Tue, 12 Nov 2024 07:31:21 +0300 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=B6=D0=B8=D0=BC=D0=B0=D0=B5=D0=BC=20?= =?UTF-8?q?=D0=BA=D0=B0=D0=BF=D1=81=D1=83=D0=BB=D1=8B=20=D0=B8=20=D0=B1?= =?UTF-8?q?=D0=B0=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit сам ты жидкостная бака --- .../CondensedCreativeCompat.kt | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/condensed_creative/CondensedCreativeCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/condensed_creative/CondensedCreativeCompat.kt index 71fd9d2ae..e265f5355 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/condensed_creative/CondensedCreativeCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/condensed_creative/CondensedCreativeCompat.kt @@ -4,9 +4,15 @@ import io.wispforest.condensed_creative.entry.impl.CondensedItemEntry import io.wispforest.condensed_creative.registry.CondensedCreativeInitializer import io.wispforest.condensed_creative.registry.CondensedEntryRegistry import net.minecraft.core.RegistryAccess +import net.minecraft.core.registries.BuiltInRegistries import net.minecraft.world.item.CreativeModeTab import net.minecraft.world.item.DyeColor import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import net.minecraft.world.level.material.Fluids +import net.neoforged.neoforge.capabilities.Capabilities +import net.neoforged.neoforge.fluids.FluidStack +import net.neoforged.neoforge.fluids.capability.IFluidHandler import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.registry.MCreativeTabs import ru.dbotthepony.mc.otm.registry.MItems @@ -48,6 +54,9 @@ class CondensedCreativeCompat : CondensedCreativeInitializer { addByBase(MItems.ITEM_MONITOR, MCreativeTabs.MAIN) addByBase(MItems.STORAGE_POWER_SUPPLIER, MCreativeTabs.MAIN) + addByFluids(MItems.FLUID_CAPSULE, MCreativeTabs.MAIN) + addByFluids(MItems.FLUID_TANK, MCreativeTabs.MAIN) + addByBase(MItems.TRITANIUM_DOOR, MCreativeTabs.DECORATIVE) addByBase(MItems.TRITANIUM_TRAPDOOR, MCreativeTabs.DECORATIVE) addByBase(MRegistry.TRITANIUM_PRESSURE_PLATE.allItems, MCreativeTabs.DECORATIVE) @@ -111,4 +120,23 @@ class CondensedCreativeCompat : CondensedCreativeInitializer { tabs.forEach { builder.addToItemGroup(it) } return builder } + + private fun addByFluids(item: Item, vararg tabs: CreativeModeTab): CondensedItemEntry.Builder? { + val base = ItemStack(item, 1) + + val list = arrayListOf(base) + for (fluid in BuiltInRegistries.FLUID) { + if (fluid != Fluids.EMPTY && fluid.isSource(fluid.defaultFluidState())) { + list.add(base.copy().also { + it.getCapability(Capabilities.FluidHandler.ITEM)?.let { + it.fill(FluidStack(fluid, it.getTankCapacity(0)), IFluidHandler.FluidAction.EXECUTE) + } + }) + } + } + + val builder = CondensedEntryRegistry.fromItemStacks(item.registryName, base, list) + tabs.forEach { builder.addToItemGroup(it) } + return builder + } }