Omni-Present pattern drive
This commit is contained in:
parent
51b2b88128
commit
526e300d5b
@ -411,6 +411,10 @@ private fun items(provider: MatteryLanguageProvider) {
|
|||||||
add(MItems.PATTERN_DRIVE_NORMAL, "Pattern Drive")
|
add(MItems.PATTERN_DRIVE_NORMAL, "Pattern Drive")
|
||||||
add(MItems.PATTERN_DRIVE_CREATIVE, "Creative 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, "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...")
|
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...")
|
||||||
}
|
}
|
||||||
|
@ -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<IPatternStorage> { this }
|
||||||
|
|
||||||
|
override val patterns: Stream<out IPatternState>
|
||||||
|
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 <T> getCapability(cap: Capability<T>, side: Direction?): LazyOptional<T> {
|
||||||
|
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<Component>,
|
||||||
|
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))
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,7 @@ import net.minecraft.core.Direction
|
|||||||
import net.minecraft.network.chat.Component
|
import net.minecraft.network.chat.Component
|
||||||
import net.minecraft.util.Mth
|
import net.minecraft.util.Mth
|
||||||
import net.minecraft.world.item.Item
|
import net.minecraft.world.item.Item
|
||||||
|
import net.minecraft.world.item.Rarity
|
||||||
import net.minecraft.world.level.Level
|
import net.minecraft.world.level.Level
|
||||||
import net.minecraftforge.common.capabilities.Capability
|
import net.minecraftforge.common.capabilities.Capability
|
||||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||||
@ -30,7 +31,7 @@ class PatternStorageItem : Item {
|
|||||||
isCreative = false
|
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
|
isCreative = true
|
||||||
capacity = Int.MAX_VALUE
|
capacity = Int.MAX_VALUE
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package ru.dbotthepony.mc.otm.matter
|
package ru.dbotthepony.mc.otm.matter
|
||||||
|
|
||||||
|
import com.google.common.collect.Streams
|
||||||
import com.mojang.blaze3d.platform.InputConstants
|
import com.mojang.blaze3d.platform.InputConstants
|
||||||
import net.minecraft.ChatFormatting
|
import net.minecraft.ChatFormatting
|
||||||
import net.minecraft.client.Minecraft
|
import net.minecraft.client.Minecraft
|
||||||
@ -22,6 +23,7 @@ import ru.dbotthepony.mc.otm.network.RegistryNetworkChannel
|
|||||||
import ru.dbotthepony.mc.otm.storage.ItemStackWrapper
|
import ru.dbotthepony.mc.otm.storage.ItemStackWrapper
|
||||||
import java.math.BigInteger
|
import java.math.BigInteger
|
||||||
import java.util.function.Supplier
|
import java.util.function.Supplier
|
||||||
|
import java.util.stream.Stream
|
||||||
import kotlin.math.pow
|
import kotlin.math.pow
|
||||||
|
|
||||||
internal var building = false
|
internal var building = false
|
||||||
@ -121,6 +123,10 @@ val derivedEntriesAccess = object : MutableMap<Item, MatterTuple> by derivedEntr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val matterRegistryStream: Stream<Map.Entry<Item, MatterTuple>> get() {
|
||||||
|
return Streams.concat(rootEntries.entries.stream(), derivedEntries.entries.stream())
|
||||||
|
}
|
||||||
|
|
||||||
fun getMatterValue(item: Item): MatterTuple {
|
fun getMatterValue(item: Item): MatterTuple {
|
||||||
if (item is IMatterItem)
|
if (item is IMatterItem)
|
||||||
return item.getMatterValue(ItemStack.EMPTY) ?: MatterTuple.ZERO
|
return item.getMatterValue(ItemStack.EMPTY) ?: MatterTuple.ZERO
|
||||||
|
@ -253,6 +253,7 @@ object MItems {
|
|||||||
|
|
||||||
val PATTERN_DRIVE_NORMAL: Item by registry.register(MNames.PATTERN_DRIVE_NORMAL) { PatternStorageItem(4) }
|
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_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_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) }
|
val PORTABLE_DENSE_CONDENSATION_DRIVE: Item by registry.register(MNames.PORTABLE_DENSE_CONDENSATION_DRIVE) { PortableCondensationDriveItem(25000) }
|
||||||
|
@ -89,6 +89,7 @@ object MNames {
|
|||||||
|
|
||||||
const val PATTERN_DRIVE_NORMAL = "pattern_drive_normal"
|
const val PATTERN_DRIVE_NORMAL = "pattern_drive_normal"
|
||||||
const val PATTERN_DRIVE_CREATIVE = "pattern_drive_creative"
|
const val PATTERN_DRIVE_CREATIVE = "pattern_drive_creative"
|
||||||
|
const val PATTERN_DRIVE_CREATIVE2 = "pattern_drive_creative2"
|
||||||
|
|
||||||
const val ZPM_BATTERY = "zpm_battery"
|
const val ZPM_BATTERY = "zpm_battery"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user