Items requirement for research, gold plates
This commit is contained in:
parent
25a1c90012
commit
46819e82c6
@ -1,5 +1,7 @@
|
||||
package ru.dbotthepony.mc.otm.datagen
|
||||
|
||||
import net.minecraft.world.item.Items
|
||||
import net.minecraftforge.common.Tags
|
||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||
import ru.dbotthepony.mc.otm.android.AndroidResearchType
|
||||
import ru.dbotthepony.mc.otm.android.feature.ItemMagnetFeature
|
||||
@ -10,6 +12,8 @@ import ru.dbotthepony.mc.otm.core.TextComponent
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.datagen.lang.MatteryLanguageProvider
|
||||
import ru.dbotthepony.mc.otm.registry.AndroidFeatures
|
||||
import ru.dbotthepony.mc.otm.registry.MItemTags
|
||||
import ru.dbotthepony.mc.otm.registry.MItems
|
||||
import ru.dbotthepony.mc.otm.registry.MNames
|
||||
import java.util.LinkedList
|
||||
import java.util.function.Consumer
|
||||
@ -21,6 +25,8 @@ fun addResearchData(serializer: Consumer<AndroidResearchType>, lang: MatteryLang
|
||||
.addFeatureResult(AndroidFeatures.AIR_BAGS)
|
||||
.withDescription()
|
||||
.withIcon(ResearchIcons.ICON_AIR_BAGS)
|
||||
.addItem(Tags.Items.GLASS_PANES, 6)
|
||||
.addItem(MItemTags.PLATE_IRON)
|
||||
.build()
|
||||
|
||||
serializer.accept(AIR_BAGS)
|
||||
@ -29,6 +35,9 @@ fun addResearchData(serializer: Consumer<AndroidResearchType>, lang: MatteryLang
|
||||
.withExperience(20)
|
||||
.withDescription()
|
||||
.withIcon(ResearchIcons.ICON_EXTENDED_REACH)
|
||||
.addItem(MItemTags.PLATE_TRITANIUM, 3)
|
||||
.addItem(MItemTags.PLATE_IRON, 2)
|
||||
.addItem(MItemTags.GOLD_WIRES, 4)
|
||||
.build()
|
||||
|
||||
serializer.accept(IMPROVED_LIMBS)
|
||||
@ -39,6 +48,9 @@ fun addResearchData(serializer: Consumer<AndroidResearchType>, lang: MatteryLang
|
||||
.withDescription()
|
||||
.withIcon(ResearchIcons.ICON_STEP_ASSIST)
|
||||
.addPrerequisite(IMPROVED_LIMBS)
|
||||
.addItem(MItemTags.PISTONS, 2)
|
||||
.addItem(MItemTags.PLATE_TRITANIUM, 4)
|
||||
.addItem(MItemTags.COPPER_WIRES, 6)
|
||||
.build()
|
||||
|
||||
serializer.accept(STEP_ASSIST)
|
||||
@ -49,6 +61,10 @@ fun addResearchData(serializer: Consumer<AndroidResearchType>, lang: MatteryLang
|
||||
.addPrerequisite(IMPROVED_LIMBS)
|
||||
.withDescription()
|
||||
.withIcon(ResearchIcons.ICON_EXTENDED_REACH)
|
||||
.addItem(MItemTags.PISTONS, 2)
|
||||
.addItem(MItemTags.PLATE_TRITANIUM, 4)
|
||||
.addItem(MItemTags.GOLD_WIRES, 6)
|
||||
.addItem(MItems.QUANTUM_TRANSCEIVER)
|
||||
.build()
|
||||
|
||||
serializer.accept(EXTENDED_REACH)
|
||||
@ -58,6 +74,12 @@ fun addResearchData(serializer: Consumer<AndroidResearchType>, lang: MatteryLang
|
||||
.withDescription()
|
||||
.withIcon(ResearchIcons.ICON_NIGHT_VISION)
|
||||
.addFeatureResult(AndroidFeatures.NIGHT_VISION)
|
||||
.addItem(Tags.Items.GLASS_PANES_COLORLESS, 4)
|
||||
.addItem(Tags.Items.DUSTS_REDSTONE, 4)
|
||||
.addItem(MItemTags.PLATE_TRITANIUM, 2)
|
||||
.addItem(MItems.ELECTRIC_PARTS, 3)
|
||||
.addItem(MItemTags.ADVANCED_CIRCUIT)
|
||||
.addItem(Items.ENDER_EYE, 2)
|
||||
.build()
|
||||
|
||||
serializer.accept(NIGHT_VISION)
|
||||
@ -77,6 +99,8 @@ fun addResearchData(serializer: Consumer<AndroidResearchType>, lang: MatteryLang
|
||||
.addFeatureResult(OverdriveThatMatters.loc(MNames.NANOBOTS_ARMOR))
|
||||
.withIcon(ResearchIcons.ICON_ARMOR)
|
||||
.addBlocker(OverdriveThatMatters.loc(MNames.ATTACK_BOOST_1), rigid = true)
|
||||
.addItem(MItemTags.PLATE_TRITANIUM, 4)
|
||||
.addItem(MItemTags.COPPER_WIRES, 8)
|
||||
.build()
|
||||
|
||||
serializer.accept(NANOBOTS_ARMOR)
|
||||
@ -102,10 +126,12 @@ fun addResearchData(serializer: Consumer<AndroidResearchType>, lang: MatteryLang
|
||||
(i + 1) * 6
|
||||
)
|
||||
)
|
||||
.addItem(MItemTags.COPPER_WIRES, 4 + i * 2)
|
||||
.addFeatureResult(OverdriveThatMatters.loc(MNames.LIMB_OVERCLOCKING), i)
|
||||
|
||||
if (i > 0) {
|
||||
research.addPrerequisite(OverdriveThatMatters.loc(MNames.LIMB_OVERCLOCKING_LIST[i - 1]), rigid = true)
|
||||
research.addItem(MItemTags.GOLD_WIRES, i * 2)
|
||||
}
|
||||
|
||||
research.build()
|
||||
@ -145,6 +171,9 @@ fun addResearchData(serializer: Consumer<AndroidResearchType>, lang: MatteryLang
|
||||
"android_research.overdrive_that_matters.nanobots_regeneration.description"
|
||||
)
|
||||
)
|
||||
.addItem(MItems.MATTER_CAPACITOR_PARTS, 1)
|
||||
.addItem(Items.SUGAR, 2 + i * 2)
|
||||
.addItem(Tags.Items.DUSTS_REDSTONE, 2 + i * 2)
|
||||
.addFeatureResult(AndroidFeatures.NANOBOTS_REGENERATION, i)
|
||||
|
||||
if (i > 0) {
|
||||
@ -179,6 +208,8 @@ fun addResearchData(serializer: Consumer<AndroidResearchType>, lang: MatteryLang
|
||||
(i + 1) * 6
|
||||
)
|
||||
)
|
||||
.addItem(MItemTags.PLATE_TRITANIUM, 2 + i * 2)
|
||||
.addItem(Items.SUGAR, 1 + i)
|
||||
.addFeatureResult(AndroidFeatures.NANOBOTS_ARMOR, 0,
|
||||
transformersUp = listOf(NanobotsArmorFeature.STRENGTH_TRANSFORMER_UP.bind(level)),
|
||||
transformersDown = listOf(NanobotsArmorFeature.STRENGTH_TRANSFORMER_DOWN.bind(level)),
|
||||
@ -205,6 +236,7 @@ fun addResearchData(serializer: Consumer<AndroidResearchType>, lang: MatteryLang
|
||||
(i + 1) * 6
|
||||
)
|
||||
)
|
||||
.addItem(Tags.Items.DUSTS_REDSTONE, 4 + i * 4)
|
||||
.addFeatureResult(AndroidFeatures.NANOBOTS_ARMOR, 0,
|
||||
transformersUp = listOf(NanobotsArmorFeature.SPEED_TRANSFORMER_UP.bind(level)),
|
||||
transformersDown = listOf(NanobotsArmorFeature.SPEED_TRANSFORMER_DOWN.bind(level)),
|
||||
@ -227,6 +259,10 @@ fun addResearchData(serializer: Consumer<AndroidResearchType>, lang: MatteryLang
|
||||
.withIcon(ResearchIcons.ICON_SHOCKWAVE)
|
||||
.addFeatureResult(AndroidFeatures.SHOCKWAVE)
|
||||
.addPrerequisite(attackBoostList[2])
|
||||
.addItem(Tags.Items.ENDER_PEARLS)
|
||||
.addItem(Tags.Items.DUSTS_REDSTONE, 2)
|
||||
.addItem(MItemTags.GOLD_WIRES, 4)
|
||||
.addItem(MItemTags.PLATE_GOLD, 2)
|
||||
.build()
|
||||
|
||||
val ITEM_MAGNET =
|
||||
@ -237,6 +273,9 @@ fun addResearchData(serializer: Consumer<AndroidResearchType>, lang: MatteryLang
|
||||
.withIcon(ResearchIcons.ICON_ITEM_MAGNET)
|
||||
.addFeatureResult(AndroidFeatures.ITEM_MAGNET)
|
||||
.addPrerequisite(STEP_ASSIST)
|
||||
.addItem(MItems.QUANTUM_TRANSCEIVER)
|
||||
.addItem(Tags.Items.DUSTS_REDSTONE, 4)
|
||||
.addItem(Items.ENDER_EYE)
|
||||
.build()
|
||||
|
||||
serializer.accept(SHOCKWAVE)
|
||||
@ -274,11 +313,11 @@ fun addResearchData(serializer: Consumer<AndroidResearchType>, lang: MatteryLang
|
||||
add(STEP_ASSIST, "description", "Allows unit to step up whole blocks")
|
||||
|
||||
add(ITEM_MAGNET, "Item Magnet")
|
||||
add(ITEM_MAGNET, "description0", "Pulls nearby items to you while active")
|
||||
add(ITEM_MAGNET, "description0", "Pulls nearby items to unit while active")
|
||||
add(ITEM_MAGNET, "description1", "Drains energy for each item stack it pulls")
|
||||
|
||||
add(SHOCKWAVE, "Shockwave Pulsator")
|
||||
add(SHOCKWAVE, "description", "Releases a shockwave around you, damaging everything in small radius, as you quickly land on ground")
|
||||
add(SHOCKWAVE, "description", "Releases a shockwave around unit, damaging everything in small radius, as unit quickly land on ground")
|
||||
|
||||
add(attackBoostList[0], "Attack Boost %s")
|
||||
add(attackBoostList[0], "description", "Increases total melee attack strength by %s%%")
|
||||
|
@ -391,6 +391,7 @@ private fun items(provider: MatteryLanguageProvider) {
|
||||
add(MItems.MACHINE_FRAME, "Machine Frame")
|
||||
add(MItems.TRITANIUM_PLATE, "Tritanium Plate")
|
||||
add(MItems.IRON_PLATE, "Iron Plate")
|
||||
add(MItems.GOLD_PLATE, "Gold Plate")
|
||||
add(MItems.COPPER_WIRING, "Copper Wiring")
|
||||
add(MItems.GOLD_WIRING, "Gold Wiring")
|
||||
add(MItems.PORTABLE_CONDENSATION_DRIVE_CASING, "Portable Condensation Drive Casing")
|
||||
@ -458,6 +459,9 @@ private fun research(provider: MatteryLanguageProvider) {
|
||||
add("android_research.status.requires", "Requires %s to be researched")
|
||||
add("android_research.status.blocks", "Locks %s")
|
||||
add("android_research.status.blocked_by", "Locked by %s")
|
||||
add("android_research.status.requires_item", "Requires %s")
|
||||
add("android_research.status.requires_item_multiple0", "Requires %s x%s (missing %s)")
|
||||
add("android_research.status.requires_item_multiple1", "Requires %s x%s")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ fun addTags(tagsProvider: TagsProvider) {
|
||||
|
||||
tagsProvider.plates.add("tritanium", MItems.TRITANIUM_PLATE)
|
||||
tagsProvider.plates.add("iron", MItems.IRON_PLATE)
|
||||
tagsProvider.plates.add("gold", MItems.GOLD_PLATE)
|
||||
|
||||
tagsProvider.ore("tritanium", MBlocks.TRITANIUM_ORE)
|
||||
tagsProvider.ore("tritanium", MBlocks.DEEPSLATE_TRITANIUM_ORE)
|
||||
|
@ -10,19 +10,23 @@ import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraftforge.common.util.INBTSerializable
|
||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
|
||||
import ru.dbotthepony.mc.otm.capability.itemsStream
|
||||
import ru.dbotthepony.mc.otm.client.render.SkinElement
|
||||
import ru.dbotthepony.mc.otm.container.iterator
|
||||
import ru.dbotthepony.mc.otm.core.TextComponent
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.core.addAll
|
||||
import ru.dbotthepony.mc.otm.core.getCompoundList
|
||||
import ru.dbotthepony.mc.otm.core.nonEmpty
|
||||
import ru.dbotthepony.mc.otm.core.registryName
|
||||
import ru.dbotthepony.mc.otm.core.set
|
||||
import ru.dbotthepony.mc.otm.network.FieldSynchronizer
|
||||
import ru.dbotthepony.mc.otm.registry.MRegistry
|
||||
import java.io.DataInputStream
|
||||
import java.io.InputStream
|
||||
import kotlin.math.absoluteValue
|
||||
|
||||
class AndroidResearch(val type: AndroidResearchType, val capability: MatteryPlayerCapability) : INBTSerializable<CompoundTag> {
|
||||
val ply: Player get() = capability.ply
|
||||
@ -130,12 +134,12 @@ class AndroidResearch(val type: AndroidResearchType, val capability: MatteryPlay
|
||||
}
|
||||
}
|
||||
|
||||
for (item in type.items) {
|
||||
var required = item.count
|
||||
for ((tag, count) in type.items) {
|
||||
var required = count
|
||||
val iterator = capability.ply.inventory.iterator().nonEmpty()
|
||||
|
||||
for (invItem in iterator) {
|
||||
if (ItemStack.isSameItemSameTags(invItem, item)) {
|
||||
if (tag.test(invItem)) {
|
||||
val toExtract = required.coerceAtMost(invItem.count)
|
||||
required -= toExtract
|
||||
|
||||
@ -176,10 +180,12 @@ class AndroidResearch(val type: AndroidResearchType, val capability: MatteryPlay
|
||||
}
|
||||
|
||||
for (item in type.items) {
|
||||
capability.ply.inventory.add(item)
|
||||
val stack = (item.first.items.firstOrNull { it.item.registryName?.namespace == OverdriveThatMatters.MOD_ID } ?: item.first.items.first()).copy()
|
||||
stack.count = item.second
|
||||
capability.ply.inventory.add(stack)
|
||||
|
||||
if (!item.isEmpty) {
|
||||
capability.ply.spawnAtLocation(item)
|
||||
if (!stack.isEmpty) {
|
||||
capability.ply.spawnAtLocation(stack)
|
||||
}
|
||||
}
|
||||
|
||||
@ -300,32 +306,63 @@ class AndroidResearch(val type: AndroidResearchType, val capability: MatteryPlay
|
||||
|
||||
if (type.experienceLevels != 0) {
|
||||
builder.add(
|
||||
TranslatableComponent("otm.android_station.research.xp_cost", type.experienceLevels).withStyle(
|
||||
TranslatableComponent("otm.android_station.research.xp_cost", TextComponent(type.experienceLevels.toString()).withStyle(
|
||||
if (capability.ply.experienceLevel >= type.experienceLevels)
|
||||
ChatFormatting.DARK_GREEN
|
||||
else
|
||||
ChatFormatting.DARK_RED
|
||||
))
|
||||
)).withStyle(ChatFormatting.GRAY))
|
||||
}
|
||||
|
||||
for (value in this.type.flatPrerequisites) {
|
||||
val instance = capability.getResearch(value)
|
||||
|
||||
builder.add(
|
||||
TranslatableComponent("android_research.status.requires", instance.screenTooltipHeader).withStyle(
|
||||
TranslatableComponent("android_research.status.requires", instance.screenTooltipHeader.copy().withStyle(
|
||||
if (instance.isResearched)
|
||||
ChatFormatting.DARK_GREEN
|
||||
else
|
||||
ChatFormatting.DARK_RED
|
||||
))
|
||||
)).withStyle(ChatFormatting.GRAY))
|
||||
}
|
||||
|
||||
for (value in this.type.flatBlockedBy) {
|
||||
builder.add(TranslatableComponent("android_research.status.blocked_by", capability.getResearch(value).screenTooltipHeader).withStyle(ChatFormatting.DARK_RED))
|
||||
builder.add(TranslatableComponent("android_research.status.blocked_by", capability.getResearch(value).screenTooltipHeader.copy().withStyle(ChatFormatting.DARK_RED)).withStyle(ChatFormatting.GRAY))
|
||||
}
|
||||
|
||||
for (value in this.type.flatBlocking) {
|
||||
builder.add(TranslatableComponent("android_research.status.blocks", capability.getResearch(value).screenTooltipHeader).withStyle(ChatFormatting.DARK_RED))
|
||||
builder.add(TranslatableComponent("android_research.status.blocks", capability.getResearch(value).screenTooltipHeader.copy().withStyle(ChatFormatting.YELLOW)).withStyle(ChatFormatting.GRAY))
|
||||
}
|
||||
|
||||
for ((tag, count) in type.items) {
|
||||
var required = count
|
||||
val iterator = capability.ply.inventory.iterator().nonEmpty()
|
||||
|
||||
for (invItem in iterator) {
|
||||
if (tag.test(invItem)) {
|
||||
required -= required.coerceAtMost(invItem.count)
|
||||
|
||||
if (required <= 0) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val chooseItem = tag.items[((System.nanoTime() / 300_000_000L).absoluteValue % tag.items.size).toInt()]
|
||||
|
||||
if (required > 0) {
|
||||
if (count == 1) {
|
||||
builder.add(TranslatableComponent("android_research.status.requires_item", chooseItem.hoverName.copy().withStyle(ChatFormatting.DARK_RED)).withStyle(ChatFormatting.GRAY))
|
||||
} else {
|
||||
builder.add(TranslatableComponent("android_research.status.requires_item_multiple0", chooseItem.hoverName.copy().withStyle(ChatFormatting.DARK_RED), TextComponent(count.toString()).withStyle(ChatFormatting.YELLOW), TextComponent(required.toString()).withStyle(ChatFormatting.YELLOW)).withStyle(ChatFormatting.GRAY))
|
||||
}
|
||||
} else {
|
||||
if (count == 1) {
|
||||
builder.add(TranslatableComponent("android_research.status.requires_item", chooseItem.hoverName.copy().withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY))
|
||||
} else {
|
||||
builder.add(TranslatableComponent("android_research.status.requires_item_multiple1", chooseItem.hoverName.copy().withStyle(ChatFormatting.DARK_GREEN), TextComponent(count.toString()).withStyle(ChatFormatting.YELLOW)).withStyle(ChatFormatting.GRAY))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return builder
|
||||
|
@ -13,17 +13,20 @@ import net.minecraft.network.chat.ComponentContents
|
||||
import net.minecraft.network.chat.MutableComponent
|
||||
import net.minecraft.network.chat.contents.TranslatableContents
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.tags.TagKey
|
||||
import net.minecraft.world.item.Item
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.Items
|
||||
import net.minecraft.world.item.crafting.Ingredient
|
||||
import net.minecraft.world.level.ItemLike
|
||||
import net.minecraftforge.registries.ForgeRegistries
|
||||
import ru.dbotthepony.mc.otm.client.render.SkinElement
|
||||
import ru.dbotthepony.mc.otm.core.ListSet
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.core.isActuallyEmpty
|
||||
import ru.dbotthepony.mc.otm.core.registryName
|
||||
import ru.dbotthepony.mc.otm.core.set
|
||||
import ru.dbotthepony.mc.otm.core.toImmutableList
|
||||
import ru.dbotthepony.mc.otm.data.ItemStackCodec
|
||||
import ru.dbotthepony.mc.otm.data.stream
|
||||
import ru.dbotthepony.mc.otm.registry.MRegistry
|
||||
import java.util.LinkedList
|
||||
@ -76,7 +79,7 @@ class AndroidResearchType(
|
||||
prerequisites: Collection<Reference>,
|
||||
blockedBy: Collection<Reference>,
|
||||
|
||||
items: Collection<ItemStack>,
|
||||
items: Collection<Pair<Ingredient, Int>>,
|
||||
features: Collection<FeatureReference>,
|
||||
|
||||
descriptionLines: Collection<Component>,
|
||||
@ -249,12 +252,9 @@ class AndroidResearchType(
|
||||
null } })
|
||||
}
|
||||
|
||||
private val itemCollection: List<ItemStack> = items.stream().filter { !it.isEmpty }.map { it.copy() }.toList().toImmutableList()
|
||||
private val definedItems: List<Pair<Ingredient, Int>> = ImmutableList.copyOf(items)
|
||||
|
||||
/**
|
||||
* Stream containing copies of original items in list
|
||||
*/
|
||||
val items: Stream<out ItemStack> get() = itemCollection.stream().map { it.copy() }
|
||||
val items: Stream<out Pair<Ingredient, Int>> get() = definedItems.stream().filter { !it.first.isActuallyEmpty }
|
||||
|
||||
private val descriptionLines: List<MutableComponent> = ImmutableList.copyOf(descriptionLines.map { it.copy() })
|
||||
|
||||
@ -464,7 +464,7 @@ class AndroidResearchType(
|
||||
|
||||
it["prerequisites"] = JsonArray().also { for (value in prerequisites) it.add(value.toJson()) }
|
||||
it["blocked_by"] = JsonArray().also { for (value in blockedBy) it.add(value.toJson()) }
|
||||
it["required_items"] = JsonArray().also { for (item in itemCollection) it.add(ItemStackCodec.serialize(item)) }
|
||||
it["required_items"] = JsonArray().also { for (item in definedItems) it.add(JsonObject().also { it["count"] = JsonPrimitive(item.second); it["ingredient"] = item.first.toJson() }) }
|
||||
it["feature_result"] = JsonArray().also { for (feature in features) it.add(feature.toJson()) }
|
||||
it["description"] = JsonArray().also { for (line in descriptionLines) it.add(Component.Serializer.toJsonTree(line)) }
|
||||
it["description_funcs"] = JsonArray().also { for (line in descriptionSuppliers) it.add(line.toJson()) }
|
||||
@ -498,7 +498,7 @@ class AndroidResearchType(
|
||||
buff.writeUtf(id.toString())
|
||||
buff.writeCollection(prerequisites) { a, b -> b.toNetwork(a) }
|
||||
buff.writeCollection(blockedBy) { a, b -> b.toNetwork(a) }
|
||||
buff.writeCollection(itemCollection) { a, b -> a.writeItem(b) }
|
||||
buff.writeCollection(definedItems) { a, b -> b.first.toNetwork(a); a.writeVarInt(b.second) }
|
||||
buff.writeCollection(features) { a, b -> b.toNetwork(a) }
|
||||
buff.writeCollection(descriptionLines) { a, b -> a.writeComponent(b) }
|
||||
buff.writeCollection(descriptionSuppliers) { a, b -> b.toNetwork(a) }
|
||||
@ -522,7 +522,7 @@ class AndroidResearchType(
|
||||
val id = ResourceLocation(buff.readUtf())
|
||||
val prerequisites = buff.readCollection({ LinkedList() }, Reference::fromNetwork)
|
||||
val blockedBy = buff.readCollection({ LinkedList() }, Reference::fromNetwork)
|
||||
val items = buff.readCollection({ LinkedList() }, FriendlyByteBuf::readItem)
|
||||
val items = buff.readCollection({ LinkedList() }, { Ingredient.fromNetwork(it) to it.readVarInt() })
|
||||
val features = buff.readCollection({ LinkedList() }, FeatureReference::fromNetwork)
|
||||
val descriptionLines = buff.readCollection({ LinkedList() }, FriendlyByteBuf::readComponent)
|
||||
val descriptionSuppliers = buff.readCollection({ LinkedList() }, { AndroidResearchManager.descriptionFuncs.fromNetwork(it) })
|
||||
@ -590,7 +590,10 @@ class AndroidResearchType(
|
||||
prerequisites = prerequisites.stream().map { Reference.fromJson(it) }.toList(),
|
||||
blockedBy = blocked_by.stream().map { Reference.fromJson(it) }.toList(),
|
||||
features = features.stream().map { FeatureReference.fromJson(it) }.toList(),
|
||||
items = items.stream().map { ItemStackCodec.deserialize(it) }.filter { !it.isEmpty }.toList(),
|
||||
items = items.stream()
|
||||
.map { it as? JsonObject ?: throw JsonSyntaxException("One of items is not an JsonObject") }
|
||||
.map { Ingredient.fromJson(it["ingredient"] ?: throw JsonSyntaxException("Missing ingredient key")) to (it["count"]?.asInt ?: throw JsonSyntaxException("Missing count key")) }
|
||||
.toList(),
|
||||
descriptionLines = description.stream().map { Component.Serializer.fromJson(it) }.toList() as List<MutableComponent>,
|
||||
descriptionSuppliers = description_funcs.stream().map { AndroidResearchManager.descriptionFuncs.fromJson(it) }.toList() as List<ComponentSupplier>,
|
||||
experienceLevels = experience,
|
||||
@ -613,7 +616,7 @@ class AndroidResearchType(
|
||||
var skinIcon: SkinElement? = null,
|
||||
var iconText: Component? = null,
|
||||
) {
|
||||
private val items = ArrayList<ItemStack>()
|
||||
private val items = ArrayList<Pair<Ingredient, Int>>()
|
||||
private val prerequisites = LinkedList<Reference>()
|
||||
private val blockers = ArrayList<Reference>()
|
||||
|
||||
@ -802,7 +805,25 @@ class AndroidResearchType(
|
||||
}
|
||||
|
||||
fun addItem(cost: ItemStack): Builder {
|
||||
items.add(cost)
|
||||
require(!cost.isEmpty) { "Provided stack is empty" }
|
||||
items.add(Ingredient.of(cost) to cost.count)
|
||||
return this
|
||||
}
|
||||
|
||||
fun addItem(cost: ItemLike, count: Int = 1): Builder {
|
||||
items.add(Ingredient.of(cost) to count)
|
||||
return this
|
||||
}
|
||||
|
||||
fun addItem(cost: Ingredient, count: Int = 1): Builder {
|
||||
require(count >= 1) { "Invalid count $count" }
|
||||
items.add(cost to count)
|
||||
return this
|
||||
}
|
||||
|
||||
fun addItem(cost: TagKey<Item>, count: Int = 1): Builder {
|
||||
require(count >= 1) { "Invalid count $count" }
|
||||
items.add(Ingredient.of(cost) to count)
|
||||
return this
|
||||
}
|
||||
|
||||
|
@ -15,29 +15,20 @@ import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.world.entity.Entity
|
||||
import net.minecraft.world.item.Item
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.crafting.Ingredient
|
||||
import net.minecraft.world.level.BlockGetter
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.StateHolder
|
||||
import net.minecraft.world.level.block.state.properties.Property
|
||||
import net.minecraft.world.phys.Vec3
|
||||
import net.minecraftforge.common.ForgeConfigSpec
|
||||
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue
|
||||
import net.minecraftforge.common.ForgeHooks
|
||||
import net.minecraftforge.common.util.LazyOptional
|
||||
import net.minecraftforge.items.IItemHandler
|
||||
import net.minecraftforge.registries.ForgeRegistries
|
||||
import net.minecraftforge.registries.ForgeRegistry
|
||||
import net.minecraftforge.registries.IForgeRegistry
|
||||
import net.minecraftforge.registries.RegistryManager
|
||||
import ru.dbotthepony.mc.otm.ClientConfig
|
||||
import ru.dbotthepony.mc.otm.item.BatteryItem
|
||||
import java.math.BigInteger
|
||||
import java.util.Spliterator
|
||||
import java.util.Spliterators
|
||||
import java.util.function.BiConsumer
|
||||
import java.util.function.BinaryOperator
|
||||
import java.util.function.Function
|
||||
import java.util.function.Supplier
|
||||
import java.util.stream.Collector
|
||||
import java.util.stream.Stream
|
||||
import java.util.stream.StreamSupport
|
||||
import kotlin.reflect.KProperty
|
||||
@ -390,3 +381,5 @@ fun <E> Iterable<E>.stream(): Stream<out E> {
|
||||
fun <E> Iterator<E>.stream(): Stream<out E> {
|
||||
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(this, 0), false)
|
||||
}
|
||||
|
||||
val Ingredient.isActuallyEmpty: Boolean get() = ForgeHooks.hasNoElements(this)
|
||||
|
@ -272,6 +272,7 @@ object MItems {
|
||||
val MACHINE_FRAME: Item by registry.register(MNames.MACHINE_FRAME) { Item(DEFAULT_PROPERTIES) }
|
||||
val TRITANIUM_PLATE: Item by registry.register(MNames.TRITANIUM_PLATE) { Item(DEFAULT_PROPERTIES) }
|
||||
val IRON_PLATE: Item by registry.register(MNames.IRON_PLATE) { Item(DEFAULT_PROPERTIES) }
|
||||
val GOLD_PLATE: Item by registry.register(MNames.GOLD_PLATE) { Item(DEFAULT_PROPERTIES) }
|
||||
val COPPER_WIRING: Item by registry.register(MNames.COPPER_WIRING) { Item(DEFAULT_PROPERTIES) }
|
||||
val GOLD_WIRING: Item by registry.register(MNames.GOLD_WIRING) { Item(DEFAULT_PROPERTIES) }
|
||||
val PORTABLE_CONDENSATION_DRIVE_CASING: Item by registry.register(MNames.PORTABLE_CONDENSATION_DRIVE_CASING) { Item(DEFAULT_PROPERTIES) }
|
||||
@ -288,6 +289,7 @@ object MItems {
|
||||
{ ELECTRIC_PARTS },
|
||||
{ TRITANIUM_PLATE },
|
||||
{ IRON_PLATE },
|
||||
{ GOLD_PLATE },
|
||||
{ COPPER_WIRING },
|
||||
{ GOLD_WIRING },
|
||||
{ CIRCUIT_PLATING },
|
||||
|
@ -135,6 +135,7 @@ object MNames {
|
||||
const val MACHINE_FRAME = "machine_frame"
|
||||
const val TRITANIUM_PLATE = "tritanium_plate"
|
||||
const val IRON_PLATE = "iron_plate"
|
||||
const val GOLD_PLATE = "gold_plate"
|
||||
const val COPPER_WIRING = "copper_wiring"
|
||||
const val GOLD_WIRING = "gold_wiring"
|
||||
|
||||
|
@ -10,6 +10,7 @@ object MItemTags {
|
||||
val INGOT_TRITANIUM: TagKey<Item> = ItemTags.create(ResourceLocation("forge", "ingots/tritanium"))
|
||||
val PLATE_TRITANIUM: TagKey<Item> = ItemTags.create(ResourceLocation("forge", "plates/tritanium"))
|
||||
val PLATE_IRON: TagKey<Item> = ItemTags.create(ResourceLocation("forge", "plates/iron"))
|
||||
val PLATE_GOLD: TagKey<Item> = ItemTags.create(ResourceLocation("forge", "plates/gold"))
|
||||
val TRITANIUM_CRATES: TagKey<Item> = ItemTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "tritanium_crates"))
|
||||
val INDUSTRIAL_GLASS: TagKey<Item> = ItemTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "industrial_glass"))
|
||||
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
Loading…
Reference in New Issue
Block a user