diff --git a/machine_colorizer.js b/machine_colorizer.js new file mode 100644 index 000000000..c9a09dc6d --- /dev/null +++ b/machine_colorizer.js @@ -0,0 +1,113 @@ + +// Использует Image Magick для автоматической перекраски текстур + +const fs = require('fs') +const root_main = './src/main/resources/assets/overdrive_that_matters/textures/block/' +const child_process = require('child_process') + +const args = process.argv.slice(2) + +if (args.length != 1) { + console.error('Usage: ') + process.exit(2) +} + +const colors = [ + ['white', [255, 255, 255]], + ['orange', [245, 116, 16]], + ['magenta', [186, 63, 175]], + ['light_blue', [59, 180, 219]], + ['yellow', [252, 199, 36]], + ['lime', [111, 187, 24]], + ['pink', [243, 139, 170]], + ['gray', [62, 66, 70]], + ['light_gray', [140, 140, 131]], + ['cyan', [22, 134, 145]], + ['purple', [116, 38, 169]], + ['blue', [51, 53, 155]], + ['brown', [114, 71, 40]], + ['green', [84, 109, 28]], + ['red', [156, 37, 34]], + ['black', [31, 31, 35]], +] + +process.stderr.setMaxListeners(40) +process.stdout.setMaxListeners(40) + +async function size(path) { + const identify = child_process.spawn('magick', [ + 'identify', + path, + ]) + + identify.stderr.pipe(process.stderr) + + const chunks = [] + identify.stdout.on('data', (a) => chunks.push(a)) + + await new Promise((resolve) => { + identify.on('close', () => resolve()) + }) + + const chunk = chunks[0].toString('utf-8') + const size = chunk.match(/PNG ([0-9]+)x([0-9]+)/) + const width = parseInt(size[1]) + const height = parseInt(size[2]) + + return [width, height] +} + +(async function() { + const textureOverlay = args[0] + const textureColor = textureOverlay + '_mask' + + if (!fs.existsSync(`${root_main}${textureOverlay}.png`)) { + process.stderr.write(`${textureOverlay}.png does not exist\n`) + process.exit(1) + } + + if (!fs.existsSync(`${root_main}${textureColor}.png`)) { + process.stderr.write(`${textureColor}.png does not exist\n`) + process.exit(1) + } + + try { + fs.mkdirSync(`${root_main}/${textureOverlay}`) + } catch(err) { + + } + + const [widthOverlay, heightOverlay] = await size(`${root_main}${textureOverlay}.png`) + const [width, height] = await size(`${root_main}${textureColor}.png`) + + if (widthOverlay != width || heightOverlay != height) { + process.stderr.write(`${textureColor}.png has size of ${width}x${height}, overlay has size of ${widthOverlay}x${heightOverlay}!\n`) + process.exit(3) + } + + for (const color of colors) { + const name = color[0] + const rgb = color[1] + const magick = child_process.spawn('magick', [ + 'convert', + + `${root_main}${textureOverlay}.png`, + + '(', + `${root_main}${textureColor}.png`, + '-size', `${width}x${height}`, + `xc:rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`, + '-channel', 'rgb', + '-compose', 'Multiply', + '-composite', + ')', + + '-compose', 'Over', + '-composite', + + `${root_main}${textureOverlay}/${name}.png`]) + + magick.stdout.pipe(process.stdout) + magick.stderr.pipe(process.stderr) + } +})() diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt index 4092fb1ef..f15538f74 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -36,6 +36,7 @@ import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.datagen.advancements.addAdvancements import ru.dbotthepony.mc.otm.datagen.advancements.addAndroidAdvancements import ru.dbotthepony.mc.otm.datagen.advancements.addMachineAdvancements +import ru.dbotthepony.mc.otm.datagen.blocks.addBlockModels import ru.dbotthepony.mc.otm.datagen.blocks.addBlockStates import ru.dbotthepony.mc.otm.datagen.blocks.addComplexBlockStates import ru.dbotthepony.mc.otm.datagen.items.addItemModels @@ -43,7 +44,6 @@ import ru.dbotthepony.mc.otm.datagen.lang.AddRussianLanguage import ru.dbotthepony.mc.otm.datagen.lang.MatteryLanguageProvider import ru.dbotthepony.mc.otm.datagen.loot.* import ru.dbotthepony.mc.otm.datagen.loot.LootModifiers -import ru.dbotthepony.mc.otm.datagen.models.addBlockModels import ru.dbotthepony.mc.otm.datagen.recipes.* import ru.dbotthepony.mc.otm.datagen.tags.TagsProvider import ru.dbotthepony.mc.otm.datagen.tags.addTags diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt index 36cdb7ff2..31380c0b3 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt @@ -16,15 +16,23 @@ import ru.dbotthepony.mc.otm.triggers.TakeItemOutOfReplicatorTrigger import java.util.function.Consumer private data class CraftEntry( - val item: Item, + val item: Collection, val englishName: String, val englishSuffix: String? = null, val russianName: String? = null, val russianSuffix: String? = null, ) { + constructor( + item: Item, + englishName: String, + englishSuffix: String? = null, + russianName: String? = null, + russianSuffix: String? = null, + ) : this(listOf(item), englishName, englishSuffix, russianName, russianSuffix) + fun make(serializer: Consumer, parent: AdvancementHolder, translation: MatteryLanguageProvider.MultiBuilder): AdvancementHolder { - val path = item.registryName!!.path + val path = item.first().registryName!!.path val translated = translation.add("$path.desc", "Craft a %s%s") { russian("Создайте %s%s") @@ -37,15 +45,19 @@ private data class CraftEntry( return AdvancementBuilder() .parent(parent) .display( - itemStack = ItemStack(item), + itemStack = ItemStack(item.first()), title = translation.add(path, englishName) { if (russianName != null) { russian(russianName) } }, - description = TranslatableComponent(translated.contents.key, item.description, translatedSuffix), + description = TranslatableComponent(translated.contents.key, item.first().description, translatedSuffix), ) - .addCriterion("has_machine", criterion(item)) + .also { + for ((i, item) in item.withIndex()) { + it.addCriterion(i.toString(), criterion(item)) + } + } .save(serializer, modLocation("machines/$path")) } } @@ -171,7 +183,7 @@ fun addMachineAdvancements(serializer: Consumer, lang: Matter charger.make(serializer, it, translation) } - CraftEntry(MItems.COBBLESTONE_GENERATOR, "Cobblestone: Infinity + 1", + CraftEntry(MItems.COBBLESTONE_GENERATOR.values, "Cobblestone: Infinity + 1", russianName = "Булыжник: бесконечность + 1", russianSuffix = "Смотрите, чтоб он не просыпался во все сундуки", englishSuffix = "Watch for not to spill it over all your chests").make(serializer, press, translation) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/BlockModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockModels.kt similarity index 62% rename from src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/BlockModels.kt rename to src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockModels.kt index 52418774b..315bc0f59 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/BlockModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockModels.kt @@ -1,6 +1,6 @@ -package ru.dbotthepony.mc.otm.datagen.models +package ru.dbotthepony.mc.otm.datagen.blocks -import net.minecraft.resources.ResourceLocation +import ru.dbotthepony.mc.otm.datagen.models.MatteryBlockModelProvider import ru.dbotthepony.mc.otm.registry.MBlocks fun addBlockModels(provider: MatteryBlockModelProvider) { @@ -9,5 +9,7 @@ fun addBlockModels(provider: MatteryBlockModelProvider) { resourceCubeAll(MBlocks.TRITANIUM_RAW_BLOCK) resourceCubeAll(MBlocks.DEEPSLATE_TRITANIUM_ORE) resourceCubeAll(MBlocks.TRITANIUM_INGOT_BLOCK) + + coloredMachine(MBlocks.COBBLESTONE_GENERATOR, listOf("0", "particle")) } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt index 6412255fd..6aba587d5 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt @@ -106,7 +106,7 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { provider.block(MBlocks.MATTER_RECYCLER) provider.block(MBlocks.MATTER_RECONSTRUCTOR) provider.block(MBlocks.ENERGY_SERVO) - provider.block(MBlocks.COBBLESTONE_GENERATOR) + provider.block(MBlocks.COBBLESTONE_GENERATOR.values) provider.block(MBlocks.ESSENCE_STORAGE) provider.exec { diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index 4598b73c2..6bb6f9915 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -183,7 +183,7 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.block(MItems.TWIN_PLATE_PRESS, "twin_plate_press_idle") provider.block(MItems.STORAGE_POWER_SUPPLIER, "storage_power_supplier") provider.block(MItems.MATTER_RECYCLER, "matter_recycler_working") - provider.block(MItems.COBBLESTONE_GENERATOR, "cobblestone_generator") + provider.allColoredBlock(MItems.COBBLESTONE_GENERATOR, "cobblestone_generator") provider.block(MItems.STORAGE_BUS) provider.block(MItems.STORAGE_IMPORTER) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt index ceeb59adf..e90c8448c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt @@ -4,9 +4,9 @@ import net.minecraft.data.models.ItemModelGenerators import net.minecraft.resources.ResourceLocation import net.minecraft.server.packs.PackType import net.minecraft.world.item.ArmorItem +import net.minecraft.world.item.DyeColor import net.minecraft.world.item.Item import net.minecraftforge.client.model.generators.ItemModelProvider -import net.minecraftforge.client.model.generators.ModelBuilder import net.minecraftforge.data.event.GatherDataEvent import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.core.registryName @@ -30,6 +30,27 @@ class MatteryItemModelProvider(event: GatherDataEvent) : ItemModelProvider(event fun block(item: Item) = exec { withExistingParent(item.registryName!!.path, modLocation("block/${item.registryName!!.path}")) } fun block(item: Item, path: String) = exec { withExistingParent(item.registryName!!.path, modLocation("block/$path")) } + + fun allColoredBlock(items: Map, path: String) { + block(items[DyeColor.BLACK]!!, path + "_black") + block(items[DyeColor.BLUE]!!, path + "_blue") + block(items[DyeColor.BROWN]!!, path + "_brown") + block(items[DyeColor.CYAN]!!, path + "_cyan") + block(items[DyeColor.GRAY]!!, path + "_gray") + block(items[DyeColor.GREEN]!!, path + "_green") + block(items[DyeColor.LIGHT_BLUE]!!, path + "_light_blue") + block(items[DyeColor.LIGHT_GRAY]!!, path + "_light_gray") + block(items[DyeColor.LIME]!!, path + "_lime") + block(items[DyeColor.MAGENTA]!!, path + "_magenta") + block(items[DyeColor.ORANGE]!!, path + "_orange") + block(items[DyeColor.PINK]!!, path + "_pink") + block(items[DyeColor.PURPLE]!!, path + "_purple") + block(items[DyeColor.RED]!!, path + "_red") + block(items[DyeColor.WHITE]!!, path + "_white") + block(items[DyeColor.YELLOW]!!, path + "_yellow") + block(items[null]!!, path) + } + fun blocks(vararg items: Item) = items.forEach(this::block) fun blocks(items: Collection) = items.forEach(this::block) 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 64e663807..50e35e437 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 @@ -424,7 +424,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.MATTER_BOTTLER, "Matter Bottler") add(MBlocks.DRIVE_VIEWER, "Drive Viewer") add(MBlocks.BLACK_HOLE, "Local Anomalous Spacetime Dilation Singular Point") - add(MBlocks.COBBLESTONE_GENERATOR, "Cobblestone Generator") + addBlock(MBlocks.COBBLESTONE_GENERATOR.values, "Cobblestone Generator") add(MBlocks.INFINITE_WATER_SOURCE, "Infinite Water Source") add(MBlocks.ESSENCE_STORAGE, "Essence Storage") add(MBlocks.ESSENCE_STORAGE, "desc", "Allows to store and retrieve experience levels") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/MatteryLanguageProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/MatteryLanguageProvider.kt index 9da3b9f2a..2718b807b 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/MatteryLanguageProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/MatteryLanguageProvider.kt @@ -81,8 +81,10 @@ class MatteryLanguageProvider(private val gen: DataGenerator) { fun add(key: String, value: String) = slave.add(key, value) fun add(key: Block, value: String) = slave.add(key, value) + fun addBlock(key: Collection, value: String) = key.forEach { add(it, value) } fun add(key: Block, suffix: String, value: String) = slave.add("${key.descriptionId}.${suffix}", value) fun add(key: Item, value: String) = slave.add(key, value) + fun addItem(key: Collection, value: String) = key.forEach { add(it, value) } fun add(key: Item, suffix: String, value: String) = slave.add("${key.descriptionId}.${suffix}", value) fun add(key: ItemStack, value: String) = slave.add(key, value) fun add(key: Enchantment, value: String) = slave.add(key, value) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 435a53e3f..69395a069 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -426,7 +426,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.MATTER_BOTTLER, "Бутилировщик материи") add(MBlocks.DRIVE_VIEWER, "Просмотрщик дисков конденсации") add(MBlocks.BLACK_HOLE, "Локализированная сингулярная точка аномального искажения пространства-времени") - add(MBlocks.COBBLESTONE_GENERATOR, "Генератор булыжника") + addBlock(MBlocks.COBBLESTONE_GENERATOR.values, "Генератор булыжника") add(MBlocks.INFINITE_WATER_SOURCE, "Неиссякаемый источник воды") add(MBlocks.ESSENCE_STORAGE, "Хранилище эссенции") add(MBlocks.ESSENCE_STORAGE, "desc", "Позволяет хранить очки опыта") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt index e7c9a96e5..8b9c8dea4 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt @@ -141,4 +141,14 @@ class LootTables(generator: DataGenerator) : LootTableProvider(generator.packOut }) } } + + fun tile(blocks: Collection, vararg filterTags: String) { + for (block in blocks) { + singleLootPool(LootContextParamSets.BLOCK, block.lootTable) { + add(LootItem.lootTableItem(block).also { + it.apply(CopyTileNbtFunction(filterTags.stream())) + }) + } + } + } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index afea9c71a..f78f65f44 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -130,7 +130,7 @@ fun addLootTables(lootTables: LootTables) { lootPool { item(Items.BLACK_DYE) { setCount(64) } } } - lootTables.tile(MBlocks.COBBLESTONE_GENERATOR) + lootTables.tile(MBlocks.COBBLESTONE_GENERATOR.values) lootTables.tile(MBlocks.ESSENCE_STORAGE) lootTables.tile(MBlocks.MATTER_RECONSTRUCTOR) lootTables.tile(MBlocks.FLUID_TANK) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelProvider.kt index f2cdb8a5e..246b82385 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelProvider.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.datagen.models +import net.minecraft.world.item.DyeColor import net.minecraft.world.level.block.Block import net.minecraftforge.client.model.generators.BlockModelProvider import net.minecraftforge.data.event.GatherDataEvent @@ -96,4 +97,20 @@ class MatteryBlockModelProvider(event: GatherDataEvent) : BlockModelProvider(eve } } } + + fun coloredMachine(blocks: Map, textureKeys: Collection) { + val base = blocks[null]!!.registryName!! + + for ((color, block) in blocks.entries) { + if (color == null) continue + + exec { + val model = withExistingParent(block.registryName!!.path, base) + + for (key in textureKeys) { + model.texture(key, modLocation("block/${base.path}/${color.name.lowercase()}")) + } + } + } + } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index a7db8cd40..c9e89a661 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -362,7 +362,7 @@ fun addCraftingTableRecipes(consumer: RecipeOutput) { .build(consumer) // генератор коблы - MatteryRecipe(MItems.COBBLESTONE_GENERATOR, category = machinesCategory) + MatteryRecipe(MItems.COBBLESTONE_GENERATOR[null]!!, category = machinesCategory) .row(MItemTags.HARDENED_GLASS_COLORLESS, MItems.TRITANIUM_PICKAXE, MItemTags.HARDENED_GLASS_COLORLESS) .row(Items.LAVA_BUCKET, Items.HOPPER, Items.WATER_BUCKET) .rowB(Tags.Items.CHESTS) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt index f43737eca..4294b3830 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt @@ -271,6 +271,8 @@ fun addPainterRecipes(consumer: RecipeOutput) { generate(consumer, MItems.TRITANIUM_DOOR[null]!!, MItems.TRITANIUM_DOOR) generate(consumer, MItems.TRITANIUM_TRAPDOOR[null]!!, MItems.TRITANIUM_TRAPDOOR) + generate(consumer, MItems.COBBLESTONE_GENERATOR[null]!!, MItems.COBBLESTONE_GENERATOR) + generate(consumer, MRegistry.VENT.item, MRegistry.VENT.items) generate(consumer, MRegistry.VENT_ALTERNATIVE.item, MRegistry.VENT_ALTERNATIVE.items) generate(consumer, MItems.CARGO_CRATE_MINECARTS[null]!!, MItems.CARGO_CRATE_MINECARTS) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index e70e7c839..e0e173231 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -218,7 +218,7 @@ fun addTags(tagsProvider: TagsProvider) { MBlocks.ENGINE, MBlocks.HOLO_SIGN, - MBlocks.COBBLESTONE_GENERATOR, + *MBlocks.COBBLESTONE_GENERATOR.values.toTypedArray(), MBlocks.ESSENCE_STORAGE, MBlocks.MATTER_RECONSTRUCTOR, MBlocks.FLUID_TANK, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/RotatableMatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/RotatableMatteryBlock.kt index 602ec1b99..9843a2acb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/RotatableMatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/RotatableMatteryBlock.kt @@ -47,6 +47,7 @@ abstract class RotatableMatteryBlock(properties: Properties = DEFAULT_PROPERTIES } BlockRotationFreedom.FULL -> TODO("Can't rotate with four rotation freedom yet") + BlockRotationFreedom.NONE -> defaultBlockState() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/CobblerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/CobblerBlock.kt index 5da695907..41b222bee 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/CobblerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/CobblerBlock.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.block.tech import net.minecraft.core.BlockPos +import net.minecraft.world.item.DyeColor import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.EntityBlock @@ -8,6 +9,8 @@ import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.entity.BlockEntityTicker import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock @@ -16,7 +19,7 @@ import ru.dbotthepony.mc.otm.block.entity.tech.CobblerBlockEntity import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.shapes.BlockShapes -class CobblerBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { +class CobblerBlock(val color: DyeColor?) : RotatableMatteryBlock(Properties.of().mapColor(color?.mapColor ?: MapColor.METAL).pushReaction(PushReaction.BLOCK).requiresCorrectToolForDrops().destroyTime(1.5f).explosionResistance(25.0f)), EntityBlock { override fun newBlockEntity(pPos: BlockPos, pState: BlockState): BlockEntity { return CobblerBlockEntity(pPos, pState) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt index bc23bfbce..6e5a286b9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -64,6 +64,28 @@ fun FriendlyByteBuf.writeBigInteger(value: BigInteger) { fun FriendlyByteBuf.readBigInteger(byteLimit: Int = 128) = BigInteger(readByteArray(byteLimit)) +fun Map<*, V>.asLambdaSupplierArray(): Array<() -> V> { + val result = arrayOfNulls<() -> V>(size) + var i = 0 + + for (k in keys) { + result[i++] = { this[k] ?: throw ConcurrentModificationException("Key $k is no longer present in map $this") } + } + + return result as Array<() -> V> +} + +fun Map<*, V>.asSupplierArray(): Array> { + val result = arrayOfNulls>(size) + var i = 0 + + for (k in keys) { + result[i++] = { this[k] ?: throw ConcurrentModificationException("Key $k is no longer present in map $this") } + } + + return result as Array> +} + operator fun IItemHandler.get(index: Int): ItemStack = getStackInSlot(index) operator fun JsonObject.set(s: String, value: JsonElement) = add(s, value) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/SupplierList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/SupplierList.kt index 82c637fcf..e45cb685b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/SupplierList.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/SupplierList.kt @@ -4,26 +4,22 @@ import java.util.function.Supplier import java.util.stream.Stream class SupplierList : AbstractList { - private val getters: Array<() -> T> + private val getters: Array> - constructor(vararg getters: () -> T) : super() { - this.getters = Array(getters.size) { getters[it] } - } - - constructor(getters: Collection<() -> T>) : super() { + constructor(getters: Collection>) : super() { val iterator = getters.iterator() this.getters = Array(getters.size) { iterator.next() } } - constructor(getters: Stream<() -> T>) : super() { + constructor(getters: Stream>) : super() { this.getters = getters.toArray(::arrayOfNulls) } constructor(vararg getters: Supplier) : super() { - this.getters = Array(getters.size) { getters[it]::get } + this.getters = Array(getters.size) { getters[it] } } - constructor(size: Int, provider: (Int) -> () -> T) { + constructor(size: Int, provider: (Int) -> Supplier) { this.getters = Array(size, provider) } @@ -31,6 +27,6 @@ class SupplierList : AbstractList { get() = getters.size override fun get(index: Int): T { - return getters[index].invoke() + return getters[index].get() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/SupplierMap.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/SupplierMap.kt index da61f08b2..7211301a9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/SupplierMap.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/SupplierMap.kt @@ -1,20 +1,21 @@ package ru.dbotthepony.mc.otm.core.collect import com.google.common.collect.ImmutableSet +import java.util.function.Supplier import java.util.stream.Stream class SupplierMap : AbstractMap { override val entries: Set> - constructor(vararg mValues: Pair T>) : super() { + constructor(vararg mValues: Pair>) : super() { entries = ImmutableSet.copyOf(mValues.map { Entry(it.first, it.second) }) } - constructor(mValues: Collection T>>) : super() { + constructor(mValues: Collection>>) : super() { entries = ImmutableSet.copyOf(mValues.map { Entry(it.first, it.second) }) } - constructor(mValues: Stream T>>) : super() { + constructor(mValues: Stream>>) : super() { entries = mValues.map { Entry(it.first, it.second) }.collect(ImmutableSet.toImmutableSet()) } @@ -24,9 +25,9 @@ class SupplierMap : AbstractMap { private inner class Entry( override val key: K, - private val getter: () -> T + private val getter: Supplier ) : Map.Entry { override val value: T - get() = getter.invoke() + get() = getter.get() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Ext.kt index 38286bbda..9b3ff14b8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Ext.kt @@ -1,56 +1,25 @@ package ru.dbotthepony.mc.otm.registry -import com.mojang.serialization.Lifecycle -import net.minecraft.core.Holder -import net.minecraft.core.Registry -import net.minecraft.core.WritableRegistry -import net.minecraft.resources.ResourceKey -import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.DyeColor import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.RegistryObject -import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.core.collect.SupplierMap +import java.util.function.Supplier import kotlin.reflect.KProperty operator fun RegistryObject.getValue(thisRef: Any, property: KProperty<*>): T { return get() } -private fun DeferredRegister.doColored(prefix: String, factory: (color: DyeColor, name: String) -> T): MutableCollection T>> { - return mutableListOf( - DyeColor.BLACK to register(prefix + "_black") { factory.invoke(DyeColor.BLACK, prefix + "_black") }::get, - DyeColor.BLUE to register(prefix + "_blue") { factory.invoke(DyeColor.BLUE, prefix + "_blue") }::get, - DyeColor.BROWN to register(prefix + "_brown") { factory.invoke(DyeColor.BROWN, prefix + "_brown") }::get, - DyeColor.CYAN to register(prefix + "_cyan") { factory.invoke(DyeColor.CYAN, prefix + "_cyan") }::get, - DyeColor.GRAY to register(prefix + "_gray") { factory.invoke(DyeColor.GRAY, prefix + "_gray") }::get, - DyeColor.GREEN to register(prefix + "_green") { factory.invoke(DyeColor.GREEN, prefix + "_green") }::get, - DyeColor.LIGHT_BLUE to register(prefix + "_light_blue") { factory.invoke(DyeColor.LIGHT_BLUE, prefix + "_light_blue") }::get, - DyeColor.LIGHT_GRAY to register(prefix + "_light_gray") { factory.invoke(DyeColor.LIGHT_GRAY, prefix + "_light_gray") }::get, - DyeColor.LIME to register(prefix + "_lime") { factory.invoke(DyeColor.LIME, prefix + "_lime") }::get, - DyeColor.MAGENTA to register(prefix + "_magenta") { factory.invoke(DyeColor.MAGENTA, prefix + "_magenta") }::get, - DyeColor.ORANGE to register(prefix + "_orange") { factory.invoke(DyeColor.ORANGE, prefix + "_orange") }::get, - DyeColor.PINK to register(prefix + "_pink") { factory.invoke(DyeColor.PINK, prefix + "_pink") }::get, - DyeColor.PURPLE to register(prefix + "_purple") { factory.invoke(DyeColor.PURPLE, prefix + "_purple") }::get, - DyeColor.RED to register(prefix + "_red") { factory.invoke(DyeColor.RED, prefix + "_red") }::get, - DyeColor.WHITE to register(prefix + "_white") { factory.invoke(DyeColor.WHITE, prefix + "_white") }::get, - DyeColor.YELLOW to register(prefix + "_yellow") { factory.invoke(DyeColor.YELLOW, prefix + "_yellow") }::get, - ) +internal fun DeferredRegister.colored(prefix: String, factory: (color: DyeColor, name: String) -> R): Map { + return SupplierMap(MRegistry.DYE_ORDER.map { it to register(prefix + "_" + it.name.lowercase()) { factory.invoke(it, prefix + "_" + it.name.lowercase()) } }) } -internal fun DeferredRegister.colored(prefix: String, factory: (color: DyeColor, name: String) -> T): Map { - return SupplierMap(doColored(prefix, factory)) -} +internal fun DeferredRegister.coloredWithBase(prefix: String, factory: (color: DyeColor?, name: String) -> R): Map { + val values = ArrayList>>() -@Suppress("unchecked_cast") -internal fun DeferredRegister.allColored(prefix: String, factory: (color: DyeColor?, name: String) -> T): Map { - return SupplierMap(doColored(prefix, factory).also { (it as MutableCollection T>>).add((null as DyeColor?) to register(prefix) { factory.invoke(null, prefix) }::get) }) -} + values.add(null to register(prefix) { factory.invoke(null, prefix) }) + MRegistry.DYE_ORDER.forEach { values.add(it to register(prefix + "_" + it.name.lowercase()) { factory.invoke(it, prefix + "_" + it.name.lowercase()) }) } -internal fun Registry.register(key: String, value: T): Holder { - return this.register(ResourceLocation(OverdriveThatMatters.MOD_ID, key), value) -} - -internal fun Registry.register(key: ResourceLocation, value: T): Holder { - return (this as WritableRegistry).register(ResourceKey.create(key(), key), value, Lifecycle.stable()) + return SupplierMap(values) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockColors.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockColors.kt index 85900d227..907ed0940 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockColors.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockColors.kt @@ -12,20 +12,24 @@ object MBlockColors { private const val DEFAULT_WATER_TINT: Int = 0x3F76E4 private fun registerBlockColors(event: RegisterColorHandlersEvent.Block) { - event.register({ state: BlockState, light: BlockAndTintGetter?, pos: BlockPos?, index: Int -> - if (index == 0) { - if (light == null || pos == null) - DEFAULT_WATER_TINT - else - BiomeColors.getAverageWaterColor(light, pos) - } else -1 - }, MBlocks.COBBLESTONE_GENERATOR) + for (it in MBlocks.COBBLESTONE_GENERATOR.values) { + event.register({ state: BlockState, light: BlockAndTintGetter?, pos: BlockPos?, index: Int -> + if (index == 0) { + if (light == null || pos == null) + DEFAULT_WATER_TINT + else + BiomeColors.getAverageWaterColor(light, pos) + } else -1 + }, it) + } } private fun registerItemColors(event: RegisterColorHandlersEvent.Item) { - event.register({ stack: ItemStack, index: Int -> - if (index == 0) DEFAULT_WATER_TINT else -1 - }, MBlocks.COBBLESTONE_GENERATOR) + for (it in MBlocks.COBBLESTONE_GENERATOR.values) { + event.register({ stack: ItemStack, index: Int -> + if (index == 0) DEFAULT_WATER_TINT else -1 + }, it) + } } internal fun register(bus: IEventBus) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt index 9036fc742..f345eb9ca 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt @@ -31,6 +31,7 @@ import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity import ru.dbotthepony.mc.otm.client.render.blockentity.* import ru.dbotthepony.mc.otm.config.CablesConfig +import ru.dbotthepony.mc.otm.core.asSupplierArray import ru.dbotthepony.mc.otm.core.collect.SupplierMap import ru.dbotthepony.mc.otm.core.getValue import java.util.function.Supplier @@ -56,7 +57,7 @@ object MBlockEntities { val MATTER_BOTTLER by register(MNames.MATTER_BOTTLER, ::MatterBottlerBlockEntity, MBlocks::MATTER_BOTTLER) val DRIVE_VIEWER by register(MNames.DRIVE_VIEWER, ::DriveViewerBlockEntity, MBlocks::DRIVE_VIEWER) val BLACK_HOLE by register(MNames.BLACK_HOLE, ::BlackHoleBlockEntity, MBlocks::BLACK_HOLE) - val CARGO_CRATE by registry.register(MNames.CARGO_CRATE) { BlockEntityType.Builder.of(::CargoCrateBlockEntity, *MRegistry.CARGO_CRATES.blocks.values.toTypedArray()).build(null) } + val CARGO_CRATE by register(MNames.CARGO_CRATE, ::CargoCrateBlockEntity, *MRegistry.CARGO_CRATES.blocks.asSupplierArray()) val DRIVE_RACK by register(MNames.DRIVE_RACK, ::DriveRackBlockEntity, MBlocks::DRIVE_RACK) val ITEM_MONITOR by register(MNames.ITEM_MONITOR, ::ItemMonitorBlockEntity, MBlocks::ITEM_MONITOR) val ENERGY_COUNTER by register(MNames.ENERGY_COUNTER, ::EnergyCounterBlockEntity, MBlocks::ENERGY_COUNTER) @@ -66,7 +67,7 @@ object MBlockEntities { val GRAVITATION_STABILIZER by register(MNames.GRAVITATION_STABILIZER, ::GravitationStabilizerBlockEntity, MBlocks::GRAVITATION_STABILIZER) val MATTER_RECYCLER by register(MNames.MATTER_RECYCLER, ::MatterRecyclerBlockEntity, MBlocks::MATTER_RECYCLER) val ENERGY_SERVO by register(MNames.ENERGY_SERVO, ::EnergyServoBlockEntity, MBlocks::ENERGY_SERVO) - val COBBLESTONE_GENERATOR by register(MNames.COBBLESTONE_GENERATOR, ::CobblerBlockEntity, MBlocks::COBBLESTONE_GENERATOR) + val COBBLESTONE_GENERATOR by register(MNames.COBBLESTONE_GENERATOR, ::CobblerBlockEntity, *MBlocks.COBBLESTONE_GENERATOR.asSupplierArray()) val ESSENCE_STORAGE by register(MNames.ESSENCE_STORAGE, ::EssenceStorageBlockEntity, MBlocks::ESSENCE_STORAGE) val MATTER_RECONSTRUCTOR by register(MNames.MATTER_RECONSTRUCTOR, ::MatterReconstructorBlockEntity, MBlocks::MATTER_RECONSTRUCTOR) val FLUID_TANK by register(MNames.FLUID_TANK, ::FluidTankBlockEntity, MBlocks::FLUID_TANK) @@ -81,7 +82,7 @@ object MBlockEntities { val ENERGY_CABLES: Map> = SupplierMap(CablesConfig.E.entries.map { conf -> var selfFeed: Supplier> = Supplier { TODO() } selfFeed = register("${conf.name.lowercase()}_energy_cable", { a, b -> SimpleEnergyCableBlockEntity(selfFeed.get(), a, b, conf) }) as Supplier> - conf to selfFeed::get + conf to selfFeed }) val POWERED_FURNACE: BlockEntityType by registry.register(MNames.POWERED_FURNACE) { BlockEntityType.Builder.of({ a, b -> MBlocks.POWERED_FURNACE.newBlockEntity(a, b) }, MBlocks.POWERED_FURNACE).build(null) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt index f258d76cd..634a71f79 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -84,6 +84,7 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.collect.SupplierList import ru.dbotthepony.mc.otm.core.collect.SupplierMap import ru.dbotthepony.mc.otm.shapes.BlockShapes +import java.util.function.Supplier object MBlocks { private val registry = DeferredRegister.create(ForgeRegistries.BLOCKS, OverdriveThatMatters.MOD_ID) @@ -112,7 +113,7 @@ object MBlocks { val POWERED_SMOKER: PoweredFurnaceBlock by registry.register(MNames.POWERED_SMOKER) { PoweredFurnaceBlock(MBlockEntities::POWERED_SMOKER, RecipeType.SMOKING, MRecipes::MICROWAVE, MachinesConfig.POWERED_SMOKER, BlockShapes.POWERED_SMOKER_IDLE) } val MATTER_RECYCLER: Block by registry.register(MNames.MATTER_RECYCLER) { MatterRecyclerBlock() } val ENERGY_SERVO: Block by registry.register(MNames.ENERGY_SERVO) { EnergyServoBlock() } - val COBBLESTONE_GENERATOR: Block by registry.register(MNames.COBBLESTONE_GENERATOR) { CobblerBlock() } + val COBBLESTONE_GENERATOR = registry.coloredWithBase(MNames.COBBLESTONE_GENERATOR) { color, _ -> CobblerBlock(color) } val INFINITE_WATER_SOURCE: Block by registry.register(MNames.INFINITE_WATER_SOURCE) { InfiniteWaterSourceBlock() } val ESSENCE_STORAGE: EssenceStorageBlock by registry.register(MNames.ESSENCE_STORAGE) { EssenceStorageBlock() } val MATTER_RECONSTRUCTOR: MatterReconstructorBlock by registry.register(MNames.MATTER_RECONSTRUCTOR) { MatterReconstructorBlock() } @@ -120,7 +121,7 @@ object MBlocks { val MATTER_ENTANGLER: MatterEntanglerBlock by registry.register(MNames.MATTER_ENTANGLER) { MatterEntanglerBlock() } val ENERGY_CABLES: Map = SupplierMap(CablesConfig.E.entries.map { conf -> - conf to registry.register("${conf.name.lowercase()}_energy_cable") { EnergyCableBlock { a, b -> MBlockEntities.ENERGY_CABLES[conf]!!.create(a, b)!! } }::get + conf to registry.register("${conf.name.lowercase()}_energy_cable") { EnergyCableBlock { a, b -> MBlockEntities.ENERGY_CABLES[conf]!!.create(a, b)!! } } }) val STORAGE_BUS: Block by registry.register(MNames.STORAGE_BUS) { StorageBusBlock() } @@ -216,7 +217,7 @@ object MBlocks { val TRITANIUM_ANVIL: List init { - val anvils = ArrayList<() -> Block>() + val anvils = ArrayList>() for (i in 0 until TRITANIUM_ANVIL_VARIANTS) { val props = BlockBehaviour.Properties.of() @@ -233,7 +234,7 @@ object MBlocks { TRITANIUM_ANVIL = SupplierList(anvils) } - val TRITANIUM_DOOR = registry.allColored(MNames.TRITANIUM_DOOR) { color, _ -> + val TRITANIUM_DOOR: Map = registry.coloredWithBase(MNames.TRITANIUM_DOOR) { color, _ -> object : DoorBlock( Properties.of() .mapColor(color ?: DyeColor.LIGHT_BLUE) @@ -270,7 +271,7 @@ object MBlocks { } } - val TRITANIUM_TRAPDOOR = registry.allColored(MNames.TRITANIUM_TRAPDOOR) { color, _ -> + val TRITANIUM_TRAPDOOR: Map = registry.coloredWithBase(MNames.TRITANIUM_TRAPDOOR) { color, _ -> object : TrapDoorBlock( Properties.of() .mapColor(color ?: DyeColor.LIGHT_BLUE) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MEntityTypes.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MEntityTypes.kt index 2076a4323..47cad1f74 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MEntityTypes.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MEntityTypes.kt @@ -7,10 +7,8 @@ import net.minecraft.client.renderer.entity.MinecartRenderer import net.minecraft.world.entity.Entity import net.minecraft.world.entity.EntityType import net.minecraft.world.entity.MobCategory -import net.minecraft.world.item.DyeColor import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.OverdriveThatMatters @@ -25,7 +23,7 @@ object MEntityTypes { EntityType.Builder.of({ _, level -> PlasmaProjectile(level) }, MobCategory.MISC).sized(0.4f, 0.4f).build(MNames.PLASMA) } - val CARGO_CRATE_MINECARTS = registry.allColored(MNames.MINECART_CARGO_CRATE) { color, name -> + val CARGO_CRATE_MINECARTS = registry.coloredWithBase(MNames.MINECART_CARGO_CRATE) { color, name -> EntityType.Builder.of({ it, level -> MinecartCargoCrate(it, color, level)}, MobCategory.MISC).sized(0.98F, 0.7F).clientTrackingRange(8).build(name) } 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 0d3611aaa..bab4bcba9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -21,6 +21,9 @@ import ru.dbotthepony.mc.otm.config.CablesConfig import ru.dbotthepony.mc.otm.config.ItemsConfig import ru.dbotthepony.mc.otm.core.collect.SupplierList import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.addAll +import ru.dbotthepony.mc.otm.core.asLambdaSupplierArray +import ru.dbotthepony.mc.otm.core.asSupplierArray import ru.dbotthepony.mc.otm.core.collect.SupplierMap import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.item.* @@ -39,6 +42,7 @@ import ru.dbotthepony.mc.otm.item.armor.TritaniumArmorItem import ru.dbotthepony.mc.otm.item.exopack.ExopackUpgradeItem import ru.dbotthepony.mc.otm.item.exopack.ProceduralExopackSlotUpgradeItem import ru.dbotthepony.mc.otm.item.weapon.PlasmaRifleItem +import java.util.function.Supplier object MItems { private val DEFAULT_PROPERTIES = Item.Properties() @@ -49,7 +53,7 @@ object MItems { } val ENERGY_CABLES: Map = SupplierMap(CablesConfig.E.entries.map { conf -> - conf to registry.register("${conf.name.lowercase()}_energy_cable") { BlockItem(MBlocks.ENERGY_CABLES[conf]!!, DEFAULT_PROPERTIES) }::get + conf to registry.register("${conf.name.lowercase()}_energy_cable") { BlockItem(MBlocks.ENERGY_CABLES[conf]!!, DEFAULT_PROPERTIES) } }) val ANDROID_STATION: BlockItem by registry.register(MNames.ANDROID_STATION) { BlockItem(MBlocks.ANDROID_STATION, DEFAULT_PROPERTIES) } @@ -120,8 +124,8 @@ object MItems { } } - val COBBLESTONE_GENERATOR: BlockItem by registry.register(MNames.COBBLESTONE_GENERATOR) { - object : BlockItem(MBlocks.COBBLESTONE_GENERATOR, DEFAULT_PROPERTIES) { + val COBBLESTONE_GENERATOR: Map = registry.coloredWithBase(MNames.COBBLESTONE_GENERATOR) { color, name -> + object : BlockItem(MBlocks.COBBLESTONE_GENERATOR[color]!!, DEFAULT_PROPERTIES) { override fun appendHoverText(p_40572_: ItemStack, p_40573_: Level?, p_40574_: MutableList, p_40575_: TooltipFlag) { super.appendHoverText(p_40572_, p_40573_, p_40574_, p_40575_) p_40574_.add(TranslatableComponent("otm.needs_no_power").withStyle(ChatFormatting.GRAY)) @@ -161,17 +165,49 @@ object MItems { val PAINTER: BlockItem by registry.register(MNames.PAINTER) { BlockItem(MBlocks.PAINTER, DEFAULT_PROPERTIES) } val MATTER_ENTANGLER: BlockItem by registry.register(MNames.MATTER_ENTANGLER) { BlockItem(MBlocks.MATTER_ENTANGLER, DEFAULT_PROPERTIES) } - val MACHINES = SupplierList( - ::ANDROID_STATION, ::ANDROID_CHARGER, ::BATTERY_BANK, ::MATTER_DECOMPOSER, ::MATTER_CAPACITOR_BANK, ::MATTER_CABLE, ::PATTERN_STORAGE, - ::MATTER_SCANNER, ::MATTER_PANEL, ::MATTER_REPLICATOR, ::MATTER_BOTTLER, ::MATTER_ENTANGLER, ::ENERGY_COUNTER, ::CHEMICAL_GENERATOR, - ::MATTER_RECYCLER, ::PLATE_PRESS, ::TWIN_PLATE_PRESS, ::POWERED_FURNACE, ::POWERED_BLAST_FURNACE, - ::POWERED_SMOKER, - ::STORAGE_BUS, ::STORAGE_IMPORTER, ::STORAGE_EXPORTER, ::DRIVE_VIEWER, - ::DRIVE_RACK, ::ITEM_MONITOR, ::STORAGE_CABLE, ::STORAGE_POWER_SUPPLIER, - ::ENERGY_SERVO, ::PAINTER, - ::PHANTOM_ATTRACTOR, ::GRAVITATION_STABILIZER, ::COBBLESTONE_GENERATOR, ::INFINITE_WATER_SOURCE, - ::ESSENCE_STORAGE, ::MATTER_RECONSTRUCTOR - ) + val MACHINES: List + + init { + val machines = ArrayList>() + + machines.add(::PLATE_PRESS) + machines.add(::TWIN_PLATE_PRESS) + machines.add(::POWERED_FURNACE) + machines.add(::POWERED_BLAST_FURNACE) + machines.add(::POWERED_SMOKER) + + machines.add(::ANDROID_STATION) + machines.add(::ANDROID_CHARGER) + machines.add(::BATTERY_BANK) + machines.add(::ENERGY_COUNTER) + machines.add(::CHEMICAL_GENERATOR) + machines.add(::ENERGY_SERVO) + + machines.add(::PAINTER) + machines.addAll(COBBLESTONE_GENERATOR.asSupplierArray().iterator()) + + machines.add(::MATTER_DECOMPOSER) + machines.add(::MATTER_CAPACITOR_BANK) + machines.add(::MATTER_CABLE) + machines.add(::PATTERN_STORAGE) + machines.add(::MATTER_SCANNER) + machines.add(::MATTER_PANEL) + machines.add(::MATTER_REPLICATOR) + machines.add(::MATTER_BOTTLER) + machines.add(::MATTER_ENTANGLER) + machines.add(::MATTER_RECYCLER) + + machines.add(::STORAGE_BUS) + machines.add(::STORAGE_IMPORTER) + machines.add(::STORAGE_EXPORTER) + machines.add(::DRIVE_VIEWER) + machines.add(::DRIVE_RACK) + machines.add(::ITEM_MONITOR) + machines.add(::STORAGE_CABLE) + machines.add(::STORAGE_POWER_SUPPLIER) + + MACHINES = SupplierList(machines) + } val DEBUG_EXPLOSION_SMALL: Item by registry.register(MNames.DEBUG_EXPLOSION_SMALL) { BlockItem(MBlocks.DEBUG_EXPLOSION_SMALL, Item.Properties().stacksTo(64)) } val DEBUG_SPHERE_POINTS: Item by registry.register(MNames.DEBUG_SPHERE_POINTS) { BlockItem(MBlocks.DEBUG_SPHERE_POINTS, Item.Properties().stacksTo(64)) } @@ -179,7 +215,7 @@ object MItems { val TRITANIUM_ANVIL: List init { - val props = ArrayList<() -> BlockItem>() + val props = ArrayList>() for (i in MBlocks.TRITANIUM_ANVIL.indices) { props.add(registry.register(MNames.TRITANIUM_ANVIL + i) { BlockItem(MBlocks.TRITANIUM_ANVIL[i], DEFAULT_PROPERTIES) }::get) @@ -475,8 +511,8 @@ object MItems { val ENGINE: Item by registry.register(MNames.ENGINE) { BlockItem(MBlocks.ENGINE, DEFAULT_PROPERTIES) } val HOLO_SIGN: Item by registry.register(MNames.HOLO_SIGN) { BlockItem(MBlocks.HOLO_SIGN, DEFAULT_PROPERTIES) } - val TRITANIUM_DOOR = registry.allColored(MNames.TRITANIUM_DOOR) { color, _ -> DoubleHighBlockItem(MBlocks.TRITANIUM_DOOR[color]!!, DEFAULT_PROPERTIES) } - val TRITANIUM_TRAPDOOR = registry.allColored(MNames.TRITANIUM_TRAPDOOR) { color, _ -> BlockItem(MBlocks.TRITANIUM_TRAPDOOR[color]!!, DEFAULT_PROPERTIES) } + val TRITANIUM_DOOR = registry.coloredWithBase(MNames.TRITANIUM_DOOR) { color, _ -> DoubleHighBlockItem(MBlocks.TRITANIUM_DOOR[color]!!, DEFAULT_PROPERTIES) } + val TRITANIUM_TRAPDOOR = registry.coloredWithBase(MNames.TRITANIUM_TRAPDOOR) { color, _ -> BlockItem(MBlocks.TRITANIUM_TRAPDOOR[color]!!, DEFAULT_PROPERTIES) } init { MRegistry.TRITANIUM_PRESSURE_PLATE.registerItems(registry) @@ -590,7 +626,7 @@ object MItems { ::REINFORCED_TRITANIUM_PLATE, ) - val CARGO_CRATE_MINECARTS = registry.allColored(MNames.MINECART_CARGO_CRATE) { color, _ -> MinecartCargoCrateItem(color) } + val CARGO_CRATE_MINECARTS = registry.coloredWithBase(MNames.MINECART_CARGO_CRATE) { color, _ -> MinecartCargoCrateItem(color) } val EXOPACK_PROBE: Item by registry.register(MNames.EXOPACK_PROBE, ::ExopackProbeItem) @@ -601,7 +637,7 @@ object MItems { val ENDER_UPGRADE: ExopackUpgradeItem by registry.register("exopack_ender_upgrade") { ExopackUpgradeItem(MatteryPlayerCapability.UpgradeType.ENDER_ACCESS, "ender_access_upgrade", "ender_access_installed") } val INVENTORY_UPGRADES = SupplierList(8) { - registry.register("exosuit_inventory_upgrade_$it") { ExopackSlotUpgradeItem(18, Rarity.COMMON) }::get + registry.register("exosuit_inventory_upgrade_$it") { ExopackSlotUpgradeItem(18, Rarity.COMMON) } } val INVENTORY_UPGRADE_PROCEDURAL: ProceduralExopackSlotUpgradeItem by registry.register("exosuit_inventory_upgrade_procedural") { ProceduralExopackSlotUpgradeItem() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt index 0555c6d59..bdb7615ad 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.registry +import com.google.common.collect.ImmutableList import com.google.common.collect.ImmutableSet import com.google.common.collect.Streams import net.minecraft.advancements.CriteriaTriggers @@ -11,6 +12,7 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.EntityType import net.minecraft.world.entity.ai.village.poi.PoiType import net.minecraft.world.entity.ai.village.poi.PoiTypes +import net.minecraft.world.item.DyeColor import net.minecraft.world.item.DyeableArmorItem import net.minecraft.world.item.Items import net.minecraft.world.level.BlockGetter @@ -81,6 +83,25 @@ object MRegistry { val ANDROID_FEATURES_LOCATION get() = features.location val ANDROID_FEATURES_KEY get() = features.key + val DYE_ORDER: ImmutableList = ImmutableList.of( + DyeColor.BLACK, + DyeColor.BLUE, + DyeColor.BROWN, + DyeColor.CYAN, + DyeColor.GRAY, + DyeColor.GREEN, + DyeColor.LIGHT_BLUE, + DyeColor.LIGHT_GRAY, + DyeColor.LIME, + DyeColor.MAGENTA, + DyeColor.ORANGE, + DyeColor.PINK, + DyeColor.PURPLE, + DyeColor.RED, + DyeColor.WHITE, + DyeColor.YELLOW, + ) + private fun register(event: NewRegistryEvent) { features.build(event) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/ColoredDecorativeBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/ColoredDecorativeBlock.kt index 7b5e10a4d..d12172250 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/ColoredDecorativeBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/ColoredDecorativeBlock.kt @@ -8,12 +8,13 @@ import net.minecraft.world.level.block.state.BlockBehaviour import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.RegistryObject import ru.dbotthepony.mc.otm.core.collect.SupplierMap +import ru.dbotthepony.mc.otm.registry.MRegistry import java.util.EnumMap /** * Colored only */ -@Suppress("PropertyName", "unused") +@Suppress("unused") open class ColoredDecorativeBlock( val baseName: String, private val provider: (DyeColor) -> Block, @@ -28,41 +29,15 @@ open class ColoredDecorativeBlock( protected val blockMap = EnumMap>(DyeColor::class.java) fun forEachItem(consumer: (String, DyeColor, Item) -> Unit) { - consumer.invoke("black", DyeColor.BLACK, getItem(DyeColor.BLACK)) - consumer.invoke("blue", DyeColor.BLUE, getItem(DyeColor.BLUE)) - consumer.invoke("brown", DyeColor.BROWN, getItem(DyeColor.BROWN)) - consumer.invoke("cyan", DyeColor.CYAN, getItem(DyeColor.CYAN)) - consumer.invoke("gray", DyeColor.GRAY, getItem(DyeColor.GRAY)) - consumer.invoke("green", DyeColor.GREEN, getItem(DyeColor.GREEN)) - consumer.invoke("light_blue", DyeColor.LIGHT_BLUE, getItem(DyeColor.LIGHT_BLUE)) - consumer.invoke("light_gray", DyeColor.LIGHT_GRAY, getItem(DyeColor.LIGHT_GRAY)) - consumer.invoke("lime", DyeColor.LIME, getItem(DyeColor.LIME)) - consumer.invoke("magenta", DyeColor.MAGENTA, getItem(DyeColor.MAGENTA)) - consumer.invoke("orange", DyeColor.ORANGE, getItem(DyeColor.ORANGE)) - consumer.invoke("pink", DyeColor.PINK, getItem(DyeColor.PINK)) - consumer.invoke("purple", DyeColor.PURPLE, getItem(DyeColor.PURPLE)) - consumer.invoke("red", DyeColor.RED, getItem(DyeColor.RED)) - consumer.invoke("white", DyeColor.WHITE, getItem(DyeColor.WHITE)) - consumer.invoke("yellow", DyeColor.YELLOW, getItem(DyeColor.YELLOW)) + MRegistry.DYE_ORDER.forEach { + consumer.invoke(it.name.lowercase(), it, getItem(it)) + } } fun forEachBlock(consumer: (String, DyeColor, Block) -> Unit) { - consumer.invoke("black", DyeColor.BLACK, getBlock(DyeColor.BLACK)) - consumer.invoke("blue", DyeColor.BLUE, getBlock(DyeColor.BLUE)) - consumer.invoke("brown", DyeColor.BROWN, getBlock(DyeColor.BROWN)) - consumer.invoke("cyan", DyeColor.CYAN, getBlock(DyeColor.CYAN)) - consumer.invoke("gray", DyeColor.GRAY, getBlock(DyeColor.GRAY)) - consumer.invoke("green", DyeColor.GREEN, getBlock(DyeColor.GREEN)) - consumer.invoke("light_blue", DyeColor.LIGHT_BLUE, getBlock(DyeColor.LIGHT_BLUE)) - consumer.invoke("light_gray", DyeColor.LIGHT_GRAY, getBlock(DyeColor.LIGHT_GRAY)) - consumer.invoke("lime", DyeColor.LIME, getBlock(DyeColor.LIME)) - consumer.invoke("magenta", DyeColor.MAGENTA, getBlock(DyeColor.MAGENTA)) - consumer.invoke("orange", DyeColor.ORANGE, getBlock(DyeColor.ORANGE)) - consumer.invoke("pink", DyeColor.PINK, getBlock(DyeColor.PINK)) - consumer.invoke("purple", DyeColor.PURPLE, getBlock(DyeColor.PURPLE)) - consumer.invoke("red", DyeColor.RED, getBlock(DyeColor.RED)) - consumer.invoke("white", DyeColor.WHITE, getBlock(DyeColor.WHITE)) - consumer.invoke("yellow", DyeColor.YELLOW, getBlock(DyeColor.YELLOW)) + MRegistry.DYE_ORDER.forEach { + consumer.invoke(it.name.lowercase(), it, getBlock(it)) + } } fun getItem(dyeColor: DyeColor): Item { @@ -77,33 +52,20 @@ open class ColoredDecorativeBlock( val blocks: Map by lazy { check(registeredBlocks) { "Didn't register blocks yet" } - SupplierMap(blockMap.map { it.key to it.value::get }) + SupplierMap(MRegistry.DYE_ORDER.map { it to blockMap[it]!! }) } val items: Map by lazy { check(registeredItems) { "Didn't register items yet" } - SupplierMap(itemMap.map { it.key to it.value::get }) + SupplierMap(MRegistry.DYE_ORDER.map { it to itemMap[it]!! }) } open fun registerBlocks(registry: DeferredRegister) { check(blockMap.isEmpty()) { "( ͡° ͜ʖ ͡°) No. \\(• ε •)/ ( ͠° ل͜ ͡°) ( ͠° ͟ ͟ʖ ͡°) (ง ͠° ͟ل͜ ͡°)ง ( ͡°︺͡°) ('ω')" } - blockMap[DyeColor.WHITE] = registry.register("${baseName}_white") { provider.invoke(DyeColor.WHITE) } - blockMap[DyeColor.ORANGE] = registry.register("${baseName}_orange") { provider.invoke(DyeColor.ORANGE) } - blockMap[DyeColor.MAGENTA] = registry.register("${baseName}_magenta") { provider.invoke(DyeColor.MAGENTA) } - blockMap[DyeColor.LIGHT_BLUE] = registry.register("${baseName}_light_blue") { provider.invoke(DyeColor.LIGHT_BLUE) } - blockMap[DyeColor.YELLOW] = registry.register("${baseName}_yellow") { provider.invoke(DyeColor.YELLOW) } - blockMap[DyeColor.LIME] = registry.register("${baseName}_lime") { provider.invoke(DyeColor.LIME) } - blockMap[DyeColor.PINK] = registry.register("${baseName}_pink") { provider.invoke(DyeColor.PINK) } - blockMap[DyeColor.GRAY] = registry.register("${baseName}_gray") { provider.invoke(DyeColor.GRAY) } - blockMap[DyeColor.LIGHT_GRAY] = registry.register("${baseName}_light_gray") { provider.invoke(DyeColor.LIGHT_GRAY) } - blockMap[DyeColor.CYAN] = registry.register("${baseName}_cyan") { provider.invoke(DyeColor.CYAN) } - blockMap[DyeColor.PURPLE] = registry.register("${baseName}_purple") { provider.invoke(DyeColor.PURPLE) } - blockMap[DyeColor.BLUE] = registry.register("${baseName}_blue") { provider.invoke(DyeColor.BLUE) } - blockMap[DyeColor.BROWN] = registry.register("${baseName}_brown") { provider.invoke(DyeColor.BROWN) } - blockMap[DyeColor.GREEN] = registry.register("${baseName}_green") { provider.invoke(DyeColor.GREEN) } - blockMap[DyeColor.RED] = registry.register("${baseName}_red") { provider.invoke(DyeColor.RED) } - blockMap[DyeColor.BLACK] = registry.register("${baseName}_black") { provider.invoke(DyeColor.BLACK) } + MRegistry.DYE_ORDER.forEach { + blockMap[it] = registry.register("${baseName}_${it.name.lowercase()}") { provider.invoke(it) } + } registeredBlocks = true } @@ -114,22 +76,9 @@ open class ColoredDecorativeBlock( check(itemMap.isEmpty()) { "( ͡° ͜ʖ ͡°) No. \\(• ε •)/ ( ͠° ل͜ ͡°) ( ͠° ͟ ͟ʖ ͡°) (ง ͠° ͟ل͜ ͡°)ง ( ͡°︺͡°) ('ω')" } check(registeredBlocks) { "wtffffff???????????" } - itemMap[DyeColor.WHITE] = registry.register("${baseName}_white") { BlockItem(blockMap[DyeColor.WHITE]!!.get(), properties) } - itemMap[DyeColor.ORANGE] = registry.register("${baseName}_orange") { BlockItem(blockMap[DyeColor.ORANGE]!!.get(), properties) } - itemMap[DyeColor.MAGENTA] = registry.register("${baseName}_magenta") { BlockItem(blockMap[DyeColor.MAGENTA]!!.get(), properties) } - itemMap[DyeColor.LIGHT_BLUE] = registry.register("${baseName}_light_blue") { BlockItem(blockMap[DyeColor.LIGHT_BLUE]!!.get(), properties) } - itemMap[DyeColor.YELLOW] = registry.register("${baseName}_yellow") { BlockItem(blockMap[DyeColor.YELLOW]!!.get(), properties) } - itemMap[DyeColor.LIME] = registry.register("${baseName}_lime") { BlockItem(blockMap[DyeColor.LIME]!!.get(), properties) } - itemMap[DyeColor.PINK] = registry.register("${baseName}_pink") { BlockItem(blockMap[DyeColor.PINK]!!.get(), properties) } - itemMap[DyeColor.GRAY] = registry.register("${baseName}_gray") { BlockItem(blockMap[DyeColor.GRAY]!!.get(), properties) } - itemMap[DyeColor.LIGHT_GRAY] = registry.register("${baseName}_light_gray") { BlockItem(blockMap[DyeColor.LIGHT_GRAY]!!.get(), properties) } - itemMap[DyeColor.CYAN] = registry.register("${baseName}_cyan") { BlockItem(blockMap[DyeColor.CYAN]!!.get(), properties) } - itemMap[DyeColor.PURPLE] = registry.register("${baseName}_purple") { BlockItem(blockMap[DyeColor.PURPLE]!!.get(), properties) } - itemMap[DyeColor.BLUE] = registry.register("${baseName}_blue") { BlockItem(blockMap[DyeColor.BLUE]!!.get(), properties) } - itemMap[DyeColor.BROWN] = registry.register("${baseName}_brown") { BlockItem(blockMap[DyeColor.BROWN]!!.get(), properties) } - itemMap[DyeColor.GREEN] = registry.register("${baseName}_green") { BlockItem(blockMap[DyeColor.GREEN]!!.get(), properties) } - itemMap[DyeColor.RED] = registry.register("${baseName}_red") { BlockItem(blockMap[DyeColor.RED]!!.get(), properties) } - itemMap[DyeColor.BLACK] = registry.register("${baseName}_black") { BlockItem(blockMap[DyeColor.BLACK]!!.get(), properties) } + MRegistry.DYE_ORDER.forEach { + itemMap[it] = registry.register("${baseName}_${it.name.lowercase()}") { BlockItem(blockMap[DyeColor.WHITE]!!.get(), properties) } + } registeredItems = true } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/DecorativeBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/DecorativeBlock.kt index d12237294..f5ca9181c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/DecorativeBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/DecorativeBlock.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.registry.objects +import com.google.common.collect.Streams import net.minecraft.world.item.BlockItem import net.minecraft.world.item.DyeColor import net.minecraft.world.item.Item @@ -9,6 +10,8 @@ import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.RegistryObject import ru.dbotthepony.mc.otm.core.collect.SupplierMap import ru.dbotthepony.mc.otm.core.util.WriteOnce +import ru.dbotthepony.mc.otm.registry.MRegistry +import java.util.stream.Stream /** * Base + Colored @@ -25,12 +28,12 @@ class DecorativeBlock( val allBlocks: Map by lazy { check(registeredBlocks) { "Didn't register items yet" } - SupplierMap(blockMap.map { it.key to it.value::get }.toMutableList().also { it.add(null to _block::get) }) + SupplierMap(Streams.concat(MRegistry.DYE_ORDER.stream().map { it to blockMap[it]!! }, Stream.of(null to _block))) } val allItems: Map by lazy { check(registeredItems) { "Didn't register items yet" } - SupplierMap(itemMap.map { it.key to it.value::get }.toMutableList().also { it.add(null to _item::get) }) + SupplierMap(Streams.concat(MRegistry.DYE_ORDER.stream().map { it to itemMap[it]!! }, Stream.of(null to _item))) } override fun registerBlocks(registry: DeferredRegister) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/StripedColoredDecorativeBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/StripedColoredDecorativeBlock.kt index 6e357144d..5cfe5242e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/StripedColoredDecorativeBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/StripedColoredDecorativeBlock.kt @@ -11,8 +11,9 @@ import net.minecraftforge.registries.RegistryObject import ru.dbotthepony.mc.otm.core.collect.SupplierList import ru.dbotthepony.mc.otm.core.collect.SupplierMap import java.util.EnumMap +import java.util.function.Supplier -@Suppress("PropertyName", "unused", "ReplaceGetOrSet", "ReplacePutWithAssignment") +@Suppress("unused", "ReplaceGetOrSet", "ReplacePutWithAssignment") class StripedColoredDecorativeBlock( val basename: String, val blockFactory: (colorA: DyeColor, colorB: DyeColor) -> Block, @@ -54,7 +55,7 @@ class StripedColoredDecorativeBlock( val builder = ImmutableMap.Builder>() for ((base, children) in mapItems) { - builder.put(base, SupplierMap(children.map { it.key to it.value::get })) + builder.put(base, SupplierMap(children.map { it.key to it.value })) } builder.build() @@ -65,7 +66,7 @@ class StripedColoredDecorativeBlock( val builder = ImmutableMap.Builder>() for ((base, children) in mapBlocks) { - builder.put(base, SupplierMap(children.map { it.key to it.value::get })) + builder.put(base, SupplierMap(children.map { it.key to it.value })) } builder.build() @@ -73,17 +74,17 @@ class StripedColoredDecorativeBlock( val flatItems: List by lazy { check(registeredItems) { "Didn't register items yet" } - SupplierList(mapItems.flatMap { it.value.values }.map { it::get }) + SupplierList(mapItems.flatMap { it.value.values }) } val flatBlocks: List by lazy { check(registeredBlocks) { "Didn't register items yet" } - SupplierList(mapBlocks.flatMap { it.value.values }.map { it::get }) + SupplierList(mapBlocks.flatMap { it.value.values }) } fun registerItems(registry: DeferredRegister) { - for (base in DyeColor.values()) { - for (stripe in DyeColor.values()) { + for (base in DyeColor.entries) { + for (stripe in DyeColor.entries) { if (base == stripe) { continue } @@ -97,8 +98,8 @@ class StripedColoredDecorativeBlock( } fun registerBlocks(registry: DeferredRegister) { - for (base in DyeColor.values()) { - for (stripe in DyeColor.values()) { + for (base in DyeColor.entries) { + for (stripe in DyeColor.entries) { if (base == stripe) { continue } @@ -116,7 +117,7 @@ class StripedColoredDecorativeBlock( throw IllegalStateException("Not yet registered blocks") } - val build = ImmutableList.Builder<() -> Pair>>() + val build = ImmutableList.Builder>>>() for ((base, children) in mapBlocks) { for ((stripe, registryObject) in children) { @@ -132,7 +133,7 @@ class StripedColoredDecorativeBlock( throw IllegalStateException("Not yet registered items") } - val build = ImmutableList.Builder<() -> Pair>>() + val build = ImmutableList.Builder>>>() for ((base, children) in mapItems) { for ((stripe, registryObject) in children) { diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/black.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/black.png new file mode 100644 index 000000000..b1e38a3b1 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/black.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/blue.png new file mode 100644 index 000000000..67763b0e5 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/blue.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/brown.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/brown.png new file mode 100644 index 000000000..0f41dbe7e Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/brown.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/cyan.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/cyan.png new file mode 100644 index 000000000..fbb1a09b8 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/cyan.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/gray.png new file mode 100644 index 000000000..c6bc2569b Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/gray.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/green.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/green.png new file mode 100644 index 000000000..55876af25 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/green.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/light_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/light_blue.png new file mode 100644 index 000000000..2cc1adcb5 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/light_blue.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/light_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/light_gray.png new file mode 100644 index 000000000..c1e055183 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/light_gray.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/lime.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/lime.png new file mode 100644 index 000000000..d318c423d Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/lime.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/magenta.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/magenta.png new file mode 100644 index 000000000..8ae1067a0 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/magenta.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/orange.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/orange.png new file mode 100644 index 000000000..5b37be8d5 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/orange.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/pink.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/pink.png new file mode 100644 index 000000000..a905f58c0 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/pink.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/purple.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/purple.png new file mode 100644 index 000000000..7eba85c98 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/purple.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/red.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/red.png new file mode 100644 index 000000000..14c2ffd9a Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/red.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/white.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/white.png new file mode 100644 index 000000000..71ce93dc1 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/white.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/yellow.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/yellow.png new file mode 100644 index 000000000..21eae7079 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator/yellow.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator_mask.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator_mask.png new file mode 100644 index 000000000..79df90112 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator_mask.png differ