diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index a7cdfc508..edfe208b9 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -411,6 +411,10 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.PATTERN_DRIVE_NORMAL, "Pattern Drive") add(MItems.PATTERN_DRIVE_CREATIVE, "Creative Pattern Drive") + add(MItems.PATTERN_DRIVE_CREATIVE2, "Omni-Present Pattern Drive") + add(MItems.PATTERN_DRIVE_CREATIVE2, "description1", "Creative-only item") + add(MItems.PATTERN_DRIVE_CREATIVE2, "description2", "Holds pattern for every item that have matter value") + add(MItems.ZPM_BATTERY, "Zero Point Module") add(MItems.ZPM_BATTERY, "description", "Can be found in hands of those who travel between dimensions, if they ever reached different reality of origin of these constructs...") } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/CreativePatternItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/CreativePatternItem.kt new file mode 100644 index 000000000..c452b149e --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/CreativePatternItem.kt @@ -0,0 +1,71 @@ +package ru.dbotthepony.mc.otm.item + +import net.minecraft.ChatFormatting +import net.minecraft.core.Direction +import net.minecraft.nbt.CompoundTag +import net.minecraft.network.chat.Component +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Rarity +import net.minecraft.world.item.TooltipFlag +import net.minecraft.world.level.Level +import net.minecraftforge.common.capabilities.Capability +import net.minecraftforge.common.capabilities.ICapabilityProvider +import net.minecraftforge.common.util.LazyOptional +import net.minecraftforge.registries.ForgeRegistries +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.matter.IPatternState +import ru.dbotthepony.mc.otm.capability.matter.IPatternStorage +import ru.dbotthepony.mc.otm.capability.matter.PatternInsertFailure +import ru.dbotthepony.mc.otm.capability.matter.PatternInsertStatus +import ru.dbotthepony.mc.otm.capability.matter.PatternState +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.getID +import ru.dbotthepony.mc.otm.matter.derivedEntriesAccess +import ru.dbotthepony.mc.otm.matter.matterRegistryStream +import ru.dbotthepony.mc.otm.matter.rootEntriesAccess +import java.util.* +import java.util.stream.Stream + +class CreativePatternItem : Item(Properties().rarity(Rarity.EPIC).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB).stacksTo(1)) { + private object Patterns : IPatternStorage, ICapabilityProvider { + private val resolver = LazyOptional.of { this } + + override val patterns: Stream + get() = matterRegistryStream.map { PatternState(UUID(34783464838L, 4463458382L + ForgeRegistries.ITEMS.getID(it.key)), it.key, 1.0) } + + override val patternCapacity: Int + get() = rootEntriesAccess.size + derivedEntriesAccess.size + + override val storedPatterns: Int + get() = rootEntriesAccess.size + derivedEntriesAccess.size + + override fun insertPattern( + pattern: IPatternState, + onlyUpdate: Boolean, + simulate: Boolean + ): PatternInsertStatus { + return PatternInsertFailure + } + + override fun getCapability(cap: Capability, side: Direction?): LazyOptional { + return if (cap == MatteryCapability.PATTERN) resolver.cast() else LazyOptional.empty() + } + } + + override fun initCapabilities(stack: ItemStack?, nbt: CompoundTag?): ICapabilityProvider { + return Patterns + } + + override fun appendHoverText( + p_41421_: ItemStack, + p_41422_: Level?, + p_41423_: MutableList, + p_41424_: TooltipFlag + ) { + super.appendHoverText(p_41421_, p_41422_, p_41423_, p_41424_) + p_41423_.add(TranslatableComponent("$descriptionId.description1").withStyle(ChatFormatting.DARK_GRAY)) + p_41423_.add(TranslatableComponent("$descriptionId.description2").withStyle(ChatFormatting.DARK_GRAY)) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PatternStorageItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PatternStorageItem.kt index fb7bf88ab..77877853e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PatternStorageItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PatternStorageItem.kt @@ -13,6 +13,7 @@ import net.minecraft.core.Direction import net.minecraft.network.chat.Component import net.minecraft.util.Mth import net.minecraft.world.item.Item +import net.minecraft.world.item.Rarity import net.minecraft.world.level.Level import net.minecraftforge.common.capabilities.Capability import ru.dbotthepony.mc.otm.core.TranslatableComponent @@ -30,7 +31,7 @@ class PatternStorageItem : Item { isCreative = false } - constructor() : super(Properties().tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB).stacksTo(1)) { + constructor() : super(Properties().rarity(Rarity.EPIC).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB).stacksTo(1)) { isCreative = true capacity = Int.MAX_VALUE } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterRegistry.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterRegistry.kt index a904a744f..b0157e69e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterRegistry.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.matter +import com.google.common.collect.Streams import com.mojang.blaze3d.platform.InputConstants import net.minecraft.ChatFormatting import net.minecraft.client.Minecraft @@ -22,6 +23,7 @@ import ru.dbotthepony.mc.otm.network.RegistryNetworkChannel import ru.dbotthepony.mc.otm.storage.ItemStackWrapper import java.math.BigInteger import java.util.function.Supplier +import java.util.stream.Stream import kotlin.math.pow internal var building = false @@ -121,6 +123,10 @@ val derivedEntriesAccess = object : MutableMap by derivedEntr } } +val matterRegistryStream: Stream> get() { + return Streams.concat(rootEntries.entries.stream(), derivedEntries.entries.stream()) +} + fun getMatterValue(item: Item): MatterTuple { if (item is IMatterItem) return item.getMatterValue(ItemStack.EMPTY) ?: MatterTuple.ZERO diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt index 77f983277..28d824a31 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -253,6 +253,7 @@ object MItems { val PATTERN_DRIVE_NORMAL: Item by registry.register(MNames.PATTERN_DRIVE_NORMAL) { PatternStorageItem(4) } val PATTERN_DRIVE_CREATIVE: Item by registry.register(MNames.PATTERN_DRIVE_CREATIVE) { PatternStorageItem() } + val PATTERN_DRIVE_CREATIVE2: Item by registry.register(MNames.PATTERN_DRIVE_CREATIVE2) { CreativePatternItem() } val PORTABLE_CONDENSATION_DRIVE: Item by registry.register(MNames.PORTABLE_CONDENSATION_DRIVE) { PortableCondensationDriveItem(4000) } val PORTABLE_DENSE_CONDENSATION_DRIVE: Item by registry.register(MNames.PORTABLE_DENSE_CONDENSATION_DRIVE) { PortableCondensationDriveItem(25000) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index dd353eeb9..768c884e5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -89,6 +89,7 @@ object MNames { const val PATTERN_DRIVE_NORMAL = "pattern_drive_normal" const val PATTERN_DRIVE_CREATIVE = "pattern_drive_creative" + const val PATTERN_DRIVE_CREATIVE2 = "pattern_drive_creative2" const val ZPM_BATTERY = "zpm_battery"