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 20e84e1d1..71851784c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -558,6 +558,9 @@ object DataGen { addChestLootTables(lootTableProvider) recipeProvider.exec { _, consumer -> + addToolsRecipes(consumer) + addComponentRecipes(consumer) + addStorageItemRecipes(consumer) addCraftingTableRecipes(consumer) addBlastingRecipes(consumer) addDecorativesRecipes(recipeProvider, consumer) 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 641d1d43b..e462aa226 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 @@ -90,7 +90,7 @@ fun addMachineAdvancements(serializer: Consumer, lang: Matter val press = AdvancementBuilder() .parent(chem) .display( - itemStack = ItemStack(MItems.PLATE_PRESS[null]!!), + itemStack = ItemStack(MItems.TWIN_PLATE_PRESS[null]!!), title = translation.add("plate_press", "Bending the Material") { russian("Раскатка металла") }, @@ -99,15 +99,12 @@ fun addMachineAdvancements(serializer: Consumer, lang: Matter }, ) .also { - for ((i, m) in MItems.PLATE_PRESS.values.withIndex()) + for ((i, m) in MItems.TWIN_PLATE_PRESS.values.withIndex()) it.addCriterion(i.toString(), criterion(m)) } .requirements(RequirementsStrategy.OR) .save(serializer, modLocation("machines/plate_press")) - CraftEntry(MItems.TWIN_PLATE_PRESS.values, "Twice the Thud", - russianName = "Двойной стук").make(serializer, press, translation) - CraftEntry(MItems.ENERGY_SERVO.values, "Power Goes In, Powered Things Go Out", russianName = "Энергия на вход, электроинструмент на выход").make(serializer, press, translation) 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 1400c12d9..c86a0526d 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 @@ -119,6 +119,25 @@ private fun sounds(provider: MatteryLanguageProvider) { private fun misc(provider: MatteryLanguageProvider) { with(provider.english) { + gui("double_processing", "Processes two items at once") + + misc("painted.black", "Painted Black") + misc("painted.blue", "Painted Blue") + misc("painted.brown", "Painted Brown") + misc("painted.cyan", "Painted Cyan") + misc("painted.gray", "Painted Gray") + misc("painted.green", "Painted Green") + misc("painted.light_blue", "Painted Light Blue") + misc("painted.light_gray", "Painted Light Gray") + misc("painted.lime", "Painted Lime") + misc("painted.magenta", "Painted Magenta") + misc("painted.orange", "Painted Orange") + misc("painted.pink", "Painted Pink") + misc("painted.purple", "Painted Purple") + misc("painted.red", "Painted Red") + misc("painted.white", "Painted White") + misc("painted.yellow", "Painted Yellow") + gui("shift_for_more_info", "") gui("help.slot_filters", "Hold CTRL to setup slot filters") @@ -279,7 +298,6 @@ private fun misc(provider: MatteryLanguageProvider) { misc("item.power.storage0", "Stored energy: %s") misc("item.power.throughput", "Max I/O: %s / %s") misc("item.power.throughput_mono", "Max I/O: %s") - misc("item.power.infinity", "∞ MtJ") misc("item.worker.work_ticks_mono", "Work ticks: %s") misc("item.worker.work_ticks", "Work ticks: %s / %s") @@ -293,9 +311,8 @@ private fun misc(provider: MatteryLanguageProvider) { misc("item.pattern.research.item_count", "Items: %s / %s") misc("item.pattern.research.advance", "Progress per item: %s%%") - - misc("item.matter.infinite", "Stored matter: ∞ / ∞") - misc("item.matter.normal", "Stored matter: %s / %s") + misc("item.matter.storage", "Stored matter: %s / %s") + misc("item.matter.storage0", "Stored matter: %s") misc("gui.matter_task.total", "Total: %s") misc("gui.matter_task.required", "Left to be done: %s") @@ -417,29 +434,59 @@ private fun death(provider: MatteryLanguageProvider) { private fun blocks(provider: MatteryLanguageProvider) { with(provider.english) { addBlock(MBlocks.ANDROID_STATION.values, "Android Station") + addBlock(MBlocks.ANDROID_STATION.values, "desc", "Grants access to android upgrades") + addBlock(MBlocks.ANDROID_CHARGER.values, "Wireless Charger") addBlock(MBlocks.ANDROID_CHARGER.values, "desc", "Charges nearby androids and exopacks") + addBlock(MBlocks.BATTERY_BANK.values, "Battery Bank") + addBlock(MBlocks.BATTERY_BANK.values, "desc", "Provides a way to use battery items as ordinary energy storage cell") + addBlock(MBlocks.MATTER_DECOMPOSER.values, "Matter Decomposer") + addBlock(MBlocks.MATTER_DECOMPOSER.values, "desc", "Breaks down items into pure matter") + addBlock(MBlocks.MATTER_CAPACITOR_BANK.values, "Matter Capacitor Bank") + addBlock(MBlocks.MATTER_CAPACITOR_BANK.values, "desc", "Provides matter storage for system when matter capacitors are attached to it") + add(MBlocks.MATTER_CABLE, "Matter Network Cable") + add(MBlocks.PATTERN_STORAGE, "Pattern Storage") + add(MBlocks.PATTERN_STORAGE, "desc", "Stores Patterns for system usage") + addBlock(MBlocks.MATTER_SCANNER.values, "Matter Scanner") + addBlock(MBlocks.MATTER_SCANNER.values, "desc", "Scans items into Patterns for future replication") + addBlock(MBlocks.MATTER_PANEL.values, "Pattern Monitor") + addBlock(MBlocks.MATTER_PANEL.values, "desc", "Allows to dispatch replication tasks") + addBlock(MBlocks.MATTER_REPLICATOR.values, "Matter Replicator") + addBlock(MBlocks.MATTER_REPLICATOR.values, "desc", "Executes replication tasks") + addBlock(MBlocks.MATTER_BOTTLER.values, "Matter Bottler") - addBlock(MBlocks.DRIVE_VIEWER.values, "Drive Viewer") - add(MBlocks.BLACK_HOLE, "Local Anomalous Spacetime Dilation Singular Point") - addBlock(MBlocks.COBBLESTONE_GENERATOR.values, "Cobblestone Generator") - add(MBlocks.INFINITE_WATER_SOURCE, "Infinite Water Source") + addBlock(MBlocks.MATTER_BOTTLER.values, "desc", "Exchanges matter between matter holding items") + addBlock(MBlocks.ESSENCE_STORAGE.values, "Essence Storage") addBlock(MBlocks.ESSENCE_STORAGE.values, "desc", "Allows to store and retrieve experience levels") + addBlock(MBlocks.MATTER_RECONSTRUCTOR.values, "Matter Reconstructor") addBlock(MBlocks.MATTER_RECONSTRUCTOR.values, "desc", "Repairs tools using matter") + + addBlock(MBlocks.MATTER_RECYCLER.values, "Matter Recycler") + addBlock(MBlocks.MATTER_RECYCLER.values, "desc", "Refines matter dust back into pure matter") + + add(MBlocks.MATTER_ENTANGLER, "Matter Entangler") + + addBlock(MBlocks.DRIVE_VIEWER.values, "Drive Viewer") + + add(MBlocks.BLACK_HOLE, "Local Anomalous Spacetime Dilation Singular Point") + + addBlock(MBlocks.COBBLESTONE_GENERATOR.values, "Cobblestone Generator") + add(MBlocks.INFINITE_WATER_SOURCE, "Infinite Water Source") + add(MBlocks.INFINITE_WATER_SOURCE, "desc", "Pushes water into all neighbour blocks") + add(MBlocks.DEV_CHEST, "Dev Chest") add(MBlocks.DEV_CHEST, "desc", "Contains all items present in game") add(MBlocks.PAINTER, "Painting Table") - add(MBlocks.MATTER_ENTANGLER, "Matter Entangler") add(MBlocks.LIQUID_XP, "Liquid XP") add(MItems.LIQUID_XP_BUCKET, "Liquid XP Bucket") @@ -449,26 +496,37 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.ENGINE, "Ship Engine") add(MBlocks.ENGINE, "desc", "Unfortunately, it doesn't seem to be functional anymore.") + add(MBlocks.HOLO_SIGN, "Holo Sign") + add(MBlocks.HOLO_SIGN, "desc", "Multi-line, colored and glowing, text sign") add(MBlocks.TRITANIUM_INGOT_BLOCK, "Tritanium Plating Block") addBlock(MBlocks.ENERGY_COUNTER.values, "Energy Counter") + addBlock(MBlocks.ENERGY_COUNTER.values, "desc", "Restricts energy flow;") + addBlock(MBlocks.ENERGY_COUNTER.values, "desc2", "Allows to limit energy throughput;") + addBlock(MBlocks.ENERGY_COUNTER.values, "desc3", "Collects statistics of passed energy;") + addBlock(MBlocks.ENERGY_COUNTER.values, "desc4", "Displays flow activity on its monitor") + add(MBlocks.ENERGY_COUNTER[null]!!, "facing", "Input facing: %s") add(MBlocks.ENERGY_COUNTER[null]!!, "switch", "Switch input facing") add(MBlocks.ENERGY_COUNTER[null]!!, "limit", "I/O Limit. -1 means no limit") addBlock(MBlocks.CHEMICAL_GENERATOR.values, "Chemical Generator") + addBlock(MBlocks.CHEMICAL_GENERATOR.values, "desc", "Generates power by burning solid fuels") + add(MBlocks.DRIVE_RACK, "Condensation Drive Rack") addBlock(MBlocks.ITEM_MONITOR.values, "Item Monitor") addBlock(MBlocks.PLATE_PRESS.values, "Plate Press") addBlock(MBlocks.TWIN_PLATE_PRESS.values, "Twin Plate Press") addBlock(MBlocks.POWERED_FURNACE.values, "Electric Furnace") + addBlock(MBlocks.POWERED_FURNACE.values, "desc", "Allows to smelt items using energy") addBlock(MBlocks.POWERED_SMOKER.values, "Microwave Oven") + addBlock(MBlocks.POWERED_SMOKER.values, "desc", "Allows to process smoker recipes using energy") addBlock(MBlocks.POWERED_BLAST_FURNACE.values, "Induction Furnace") + addBlock(MBlocks.POWERED_BLAST_FURNACE.values, "desc", "Allows to process blasting recipes using energy") - addBlock(MBlocks.MATTER_RECYCLER.values, "Matter Recycler") addBlock(MBlocks.ENERGY_SERVO.values, "Energy Servo") addBlock(MBlocks.ENERGY_SERVO.values, "desc", "Charges, Discharges or Exchanges energy of items") @@ -530,7 +588,7 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.EXPLOSIVE_HAMMER, "desc", "For those who feel bored") add(MItems.EXPLOSIVE_HAMMER, "primed", "Primed!") add(MItems.EXPLOSIVE_HAMMER, "not_primed0", "Not primed") - add(MItems.EXPLOSIVE_HAMMER, "not_primed1", "Prime at crafting table with little of gunpowder and nugget payload") + add(MItems.EXPLOSIVE_HAMMER, "not_primed1", "Prime with little of gunpowder and iron nugget payload in your inventory by holding RMB") add(MItems.EXOPACK_PROBE, "Exopack Probe") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_CREATIVE, "Creative Exopack Inventory Upgrade") 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 7773ed4a8..ac29a0196 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 @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.datagen.lang +import net.minecraft.world.item.DyeColor import ru.dbotthepony.mc.otm.registry.AndroidFeatures import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MEntityTypes @@ -127,6 +128,25 @@ private fun sounds(provider: MatteryLanguageProvider) { private fun misc(provider: MatteryLanguageProvider) { with(provider.russian) { + gui("double_processing", "Обрабатывает два предмета одновременно") + + misc("painted.black", "Окрашено в чёрный") + misc("painted.blue", "Окрашено в синий") + misc("painted.brown", "Окрашено в коричневый") + misc("painted.cyan", "Окрашено в бирюзовый") + misc("painted.gray", "Окрашено в серый") + misc("painted.green", "Окрашено в зелёный") + misc("painted.light_blue", "Окрашено в светло-синий") + misc("painted.light_gray", "Окрашено в светло-серый") + misc("painted.lime", "Окрашено в лаймовый") + misc("painted.magenta", "Окрашено в сиреневый") + misc("painted.orange", "Окрашено в оранжевый") + misc("painted.pink", "Окрашено в розовый") + misc("painted.purple", "Окрашено в фиолетовый") + misc("painted.red", "Окрашено в красный") + misc("painted.white", "Окрашено в белый") + misc("painted.yellow", "Окрашено в жёлтый") + gui("shift_for_more_info", "<Удерживайте SHIFT для подробностей>") gui("help.slot_filters", "Удерживайте CTRL для настройки фильтрации слотов") @@ -283,9 +303,9 @@ private fun misc(provider: MatteryLanguageProvider) { gui("power.last_tick", "Последний тик:") misc("item.power.storage", "Хранимая энергия: %s / %s") + misc("item.power.storage0", "Хранимая энергия: %s") misc("item.power.throughput", "Максимальная пропускная способность: %s / %s") misc("item.power.throughput_mono", "Максимальная пропускная способность: %s") - misc("item.power.infinity", "∞ МтДж") misc("item.worker.work_ticks_mono", "Рабочих тиков: %s") misc("item.worker.work_ticks", "Рабочих тиков: %s / %s") @@ -298,8 +318,8 @@ private fun misc(provider: MatteryLanguageProvider) { misc("item.pattern.research.item_count", "Предметы: %s / %s") misc("item.pattern.research.advance", "Исследование за предмет: %s%%") - misc("item.matter.infinite", "Хранимая материя неиссякаема") - misc("item.matter.normal", "Хранимая материя: %s / %s") + misc("item.matter.storage", "Хранимая материя: %s / %s") + misc("item.matter.storage0", "Хранимая материя: %s") misc("gui.matter_task.total", "Всего: %s") misc("gui.matter_task.required", "Осталось исполнить: %s") @@ -419,29 +439,58 @@ private fun death(provider: MatteryLanguageProvider) { private fun blocks(provider: MatteryLanguageProvider) { with(provider.russian) { addBlock(MBlocks.ANDROID_STATION.values, "Станция андроидов") + addBlock(MBlocks.ANDROID_STATION.values, "desc", "Даёт доступ к улучшениям андроида") + addBlock(MBlocks.ANDROID_CHARGER.values, "Беспроводной зарядник") addBlock(MBlocks.ANDROID_CHARGER.values, "desc", "Заряжает ближайших андроидов и экзопаки") + addBlock(MBlocks.BATTERY_BANK.values, "Банк аккумуляторов") + addBlock(MBlocks.BATTERY_BANK.values, "desc", "Позволяет использовать аккумуляторы как обычное хранилище энергии") + addBlock(MBlocks.MATTER_DECOMPOSER.values, "Декомпозитор материи") + addBlock(MBlocks.MATTER_DECOMPOSER.values, "desc", "Разбивает предметы в чистую материю") + addBlock(MBlocks.MATTER_CAPACITOR_BANK.values, "Банк накопителей материи") + addBlock(MBlocks.MATTER_CAPACITOR_BANK.values, "desc", "Является хранилищем материи для системы в связке с накопителями материи") + add(MBlocks.MATTER_CABLE, "Кабель сети материи") + add(MBlocks.PATTERN_STORAGE, "Хранилище шаблонов") + add(MBlocks.PATTERN_STORAGE, "desc", "Хранит шаблоны предметов для пользования сетью") + addBlock(MBlocks.MATTER_SCANNER.values, "Сканер материи") + addBlock(MBlocks.MATTER_SCANNER.values, "desc", "Сканирует предметы в шаблоны для будущей репликации") + addBlock(MBlocks.MATTER_PANEL.values, "Монитор шаблонов") + addBlock(MBlocks.MATTER_PANEL.values, "desc", "Позволяет создавать задачи репликации") + addBlock(MBlocks.MATTER_REPLICATOR.values, "Репликатор материи") + addBlock(MBlocks.MATTER_REPLICATOR.values, "desc", "Исполняет задачи репликации") + addBlock(MBlocks.MATTER_BOTTLER.values, "Бутилировщик материи") - addBlock(MBlocks.DRIVE_VIEWER.values, "Просмотрщик дисков конденсации") - add(MBlocks.BLACK_HOLE, "Локализированная сингулярная точка аномального искажения пространства-времени") - addBlock(MBlocks.COBBLESTONE_GENERATOR.values, "Генератор булыжника") - add(MBlocks.INFINITE_WATER_SOURCE, "Неиссякаемый источник воды") + addBlock(MBlocks.MATTER_BOTTLER.values, "desc", "Позволяет переливать материю между предметами, хранящими материю") + addBlock(MBlocks.ESSENCE_STORAGE.values, "Хранилище эссенции") addBlock(MBlocks.ESSENCE_STORAGE.values, "desc", "Позволяет хранить очки опыта") + addBlock(MBlocks.MATTER_RECONSTRUCTOR.values, "Материальный реконструктор") addBlock(MBlocks.MATTER_RECONSTRUCTOR.values, "desc", "Чинит инструменты используя материю") + + addBlock(MBlocks.MATTER_RECYCLER.values, "Перерабатыватель материи") + addBlock(MBlocks.MATTER_RECYCLER.values, "desc", "Перерабатывает материальную пыль обратно в чистую материю") + + add(MBlocks.MATTER_ENTANGLER, "Квантовый запутыватель материи") + + addBlock(MBlocks.COBBLESTONE_GENERATOR.values, "Генератор булыжника") + add(MBlocks.INFINITE_WATER_SOURCE, "Неиссякаемый источник воды") + add(MBlocks.INFINITE_WATER_SOURCE, "desc", "Выталкивает воду в соседние блоки автоматически") + add(MBlocks.BLACK_HOLE, "Локализированная сингулярная точка аномального искажения пространства-времени") + add(MBlocks.DEV_CHEST, "Сундук разработчика") add(MBlocks.DEV_CHEST, "desc", "Хранит все предметы, которые есть в игре") add(MBlocks.PAINTER, "Стол маляра") - add(MBlocks.MATTER_ENTANGLER, "Квантовый запутыватель материи") + + addBlock(MBlocks.DRIVE_VIEWER.values, "Просмотрщик дисков конденсации") add(MBlocks.LIQUID_XP, "Жидкий опыт") add(MItems.LIQUID_XP_BUCKET, "Ведро жидкого опыта") @@ -450,27 +499,38 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.FLUID_TANK, "named", "Жидкостный бак (%s)") add(MBlocks.ENGINE, "Двигатель корабля") - add(MBlocks.ENGINE, "desc", "К сожалению, он больше не выглядит рабочим.") + add(MBlocks.ENGINE, "desc", "К сожалению, он более не функционирует") + add(MBlocks.HOLO_SIGN, "Голографическая табличка") + add(MBlocks.HOLO_SIGN, "desc", "Многострочная, крашеная и светящееся, табличка") add(MBlocks.TRITANIUM_INGOT_BLOCK, "Блок слитков тритана") addBlock(MBlocks.ENERGY_COUNTER.values, "Счётчик энергии") + addBlock(MBlocks.ENERGY_COUNTER.values, "desc", "Ограничивает направление передачи энергии;") + addBlock(MBlocks.ENERGY_COUNTER.values, "desc2", "Позволяет ограничивать максимальную пропускную способность;") + addBlock(MBlocks.ENERGY_COUNTER.values, "desc3", "Собирает статистику о переданной через себя энергии;") + addBlock(MBlocks.ENERGY_COUNTER.values, "desc4", "Отображает текущую активность передачи энергии на своём экране") + add(MBlocks.ENERGY_COUNTER[null]!!, "Facing", "сторона входа: %s") add(MBlocks.ENERGY_COUNTER[null]!!, "Switch", "сменить сторону входа") add(MBlocks.ENERGY_COUNTER[null]!!, "Limit", "лимит ввода/вывода. -1 для отключения лимитов") addBlock(MBlocks.CHEMICAL_GENERATOR.values, "Химический генератор") + addBlock(MBlocks.CHEMICAL_GENERATOR.values, "desc", "Генерирует энергию сжигая твёрдое топливо") + add(MBlocks.DRIVE_RACK, "Стеллаж дисков конденсации") addBlock(MBlocks.ITEM_MONITOR.values, "Монитор предметов") addBlock(MBlocks.PLATE_PRESS.values, "Пресс пластин") addBlock(MBlocks.TWIN_PLATE_PRESS.values, "Двойной пресс пластин") addBlock(MBlocks.POWERED_FURNACE.values, "Электрическая печь") + addBlock(MBlocks.POWERED_FURNACE.values, "desc", "Позволяет обрабатывать рецепты печи используя энергию") addBlock(MBlocks.POWERED_BLAST_FURNACE.values, "Индукционная печь") + addBlock(MBlocks.POWERED_BLAST_FURNACE.values, "desc", "Позволяет обрабатывать рецепты плавильной печи используя энергию") addBlock(MBlocks.POWERED_SMOKER.values, "Микроволновая печь") + addBlock(MBlocks.POWERED_SMOKER.values, "desc", "Позволяет обрабатывать рецепты коптильни используя энергию") - addBlock(MBlocks.MATTER_RECYCLER.values, "Перерабатыватель материи") addBlock(MBlocks.ENERGY_SERVO.values, "Энергетическая помпа") addBlock(MBlocks.ENERGY_SERVO.values, "desc", "заряжает, разряжает и передаёт энергию между предметами") @@ -532,7 +592,7 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.EXPLOSIVE_HAMMER, "desc", "Для тех, кому стало скучно") add(MItems.EXPLOSIVE_HAMMER, "primed", "Заряжен!") add(MItems.EXPLOSIVE_HAMMER, "not_primed0", "Не заряжен") - add(MItems.EXPLOSIVE_HAMMER, "not_primed1", "Для зарядки добавьте немного пороха и наконечник-самородок") + add(MItems.EXPLOSIVE_HAMMER, "not_primed1", "Для зарядки необходимо немного пороха и наконечник-самородок в вашем инвентаре, и зарядите удерживая ПКМ") add(MItems.EXOPACK_PROBE, "Маяк экзопака") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_CREATIVE, "Творческое обновление инвентаря экзопака") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/ComponentRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/ComponentRecipes.kt new file mode 100644 index 000000000..391ce59bc --- /dev/null +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/ComponentRecipes.kt @@ -0,0 +1,92 @@ +package ru.dbotthepony.mc.otm.datagen.recipes + +import net.minecraft.data.recipes.RecipeCategory +import net.minecraft.data.recipes.RecipeOutput +import net.minecraft.tags.ItemTags +import net.minecraftforge.common.Tags +import ru.dbotthepony.mc.otm.registry.MItemTags +import ru.dbotthepony.mc.otm.registry.MItems + +fun addComponentRecipes(consumer: RecipeOutput) { + // Обычный рецепт + MatteryRecipe(MItems.BASIC_CONTROL_CIRCUIT, count = 3, category = RecipeCategory.MISC) + .row(MItemTags.COPPER_WIRES, Tags.Items.DUSTS_REDSTONE, MItemTags.COPPER_WIRES) + .row(MItems.CIRCUIT_PLATING, MItems.CIRCUIT_PLATING, MItems.CIRCUIT_PLATING) + .unlockedBy(MItemTags.COPPER_WIRES) + .build(consumer) + + // ручной рецепт + MatteryRecipe(MItems.BASIC_CONTROL_CIRCUIT, category = RecipeCategory.MISC) + .rowB(Tags.Items.DUSTS_REDSTONE) + .rowB(MItemTags.COPPER_WIRES) + .rowB(ItemTags.WOODEN_SLABS) + .unlockedBy(MItemTags.COPPER_WIRES) + .unlockedBy(Tags.Items.DUSTS_REDSTONE) + .build(consumer, "alt") + + MatteryRecipe(MItems.ADVANCED_CONTROL_CIRCUIT, count = 3, category = RecipeCategory.MISC) + .row(MItemTags.COPPER_WIRES, Tags.Items.GEMS_QUARTZ, MItemTags.COPPER_WIRES) + .row(MItemTags.GOLD_WIRES, Tags.Items.DUSTS_REDSTONE, MItemTags.GOLD_WIRES) + .row(MItems.CIRCUIT_PLATING, MItems.CIRCUIT_PLATING, MItems.CIRCUIT_PLATING) + .unlockedBy(MItemTags.GOLD_WIRES) + .build(consumer) + + MatteryRecipe(MItems.MACHINE_FRAME, category = RecipeCategory.MISC) + .row(MItemTags.HARDENED_GLASS, MItemTags.BASIC_CIRCUIT, MItemTags.HARDENED_GLASS) + .row(MItems.ELECTRIC_PARTS, MItemTags.TRITANIUM_PLATES, MItems.ELECTRIC_PARTS) + .rowAC(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) + .unlockedBy(MItemTags.BASIC_CIRCUIT) + .unlockedBy(MItemTags.HARDENED_GLASS) + .unlockedBy(MItems.ELECTRIC_PARTS) + .build(consumer) + + MatteryRecipe(MItems.GOLD_WIRING, count = 8, category = RecipeCategory.MISC) + .rowB(Tags.Items.INGOTS_GOLD) + .row(Tags.Items.INGOTS_GOLD, Tags.Items.RODS_WOODEN, Tags.Items.INGOTS_GOLD) + .rowB(Tags.Items.INGOTS_GOLD) + .unlockedBy(Tags.Items.INGOTS_GOLD) + .build(consumer) + + MatteryRecipe(MItems.COPPER_WIRING, count = 8, category = RecipeCategory.MISC) + .rowB(Tags.Items.INGOTS_COPPER) + .row(Tags.Items.INGOTS_COPPER, Tags.Items.RODS_WOODEN, Tags.Items.INGOTS_COPPER) + .rowB(Tags.Items.INGOTS_COPPER) + .unlockedBy(Tags.Items.INGOTS_COPPER) + .build(consumer) + + MatteryRecipe(MItems.ENERGY_BUS, count = 2, category = RecipeCategory.MISC) + .rowAB(Tags.Items.DUSTS_REDSTONE, MItems.ELECTRIC_PARTS) + .row(MItemTags.COPPER_WIRES, MItemTags.COPPER_WIRES, MItemTags.COPPER_WIRES) + .rowBC(MItems.ELECTRIC_PARTS, Tags.Items.DUSTS_REDSTONE) + .unlockedBy(MItems.ELECTRIC_PARTS) + .unlockedBy(MItemTags.COPPER_WIRES) + .unlockedBy(Tags.Items.DUSTS_REDSTONE) + .build(consumer) + + MatteryRecipe(MItems.MATTER_IO_PORT, category = RecipeCategory.MISC) + .rowB(MItems.MATTER_CABLE) + .row(MItemTags.TRITANIUM_PLATES, MItemTags.BASIC_CIRCUIT, MItemTags.TRITANIUM_PLATES) + .rowB(MItems.MATTER_CABLE) + .unlockedBy(MItems.MATTER_CABLE) + .build(consumer) + + MatteryRecipe(MItems.MATTER_TRANSFORM_MATRIX, category = RecipeCategory.MISC) + .row(Tags.Items.ENDER_PEARLS, MItems.MATTER_CABLE, Tags.Items.ENDER_PEARLS) + .row(MItemTags.TRITANIUM_PLATES, MItemTags.ADVANCED_CIRCUIT, MItemTags.TRITANIUM_PLATES) + .rowB(MItems.MATTER_CABLE) + .unlockedBy(MItems.MATTER_CABLE) + .build(consumer) + + MatteryRecipe(MItems.MATTER_CAPACITOR_PARTS, count = 3, category = RecipeCategory.MISC) + .row(MItemTags.IRON_PLATES, MItemTags.HARDENED_GLASS_PANES, MItemTags.IRON_PLATES) + .row(MItemTags.TRITANIUM_PLATES, MItemTags.HARDENED_GLASS_PANES, MItemTags.TRITANIUM_PLATES) + .rowB(MItemTags.HARDENED_GLASS_PANES) + .unlockedBy(MItems.MATTER_CABLE) + .build(consumer) + + MatteryRecipe(MItems.ELECTRIC_PARTS, count = 4, category = RecipeCategory.MISC) + .row(Tags.Items.DUSTS_REDSTONE, MItemTags.COPPER_WIRES, Tags.Items.DUSTS_REDSTONE) + .row(Tags.Items.NUGGETS_GOLD, Tags.Items.NUGGETS_IRON, Tags.Items.NUGGETS_GOLD) + .row(Tags.Items.DUSTS_REDSTONE, MItemTags.COPPER_WIRES, Tags.Items.DUSTS_REDSTONE) + .build(consumer) +} 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 155400a89..04810ad5c 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 @@ -55,32 +55,36 @@ fun addCraftingTableRecipes(consumer: RecipeOutput) { .unlockedBy(MItems.HOLO_SIGN) .save(consumer, modLocation("holo_sign_reset")) - MatteryRecipe(MBlocks.PLATE_PRESS[null]!!, category = machinesCategory) - .row(MItems.ELECTRIC_PARTS, MItems.ENERGY_BUS, MItems.ELECTRIC_PARTS) - .row(MItemTags.TRITANIUM_INGOTS, Items.BLAST_FURNACE, MItemTags.TRITANIUM_INGOTS) - .row(MItemTags.PISTONS, MItemTags.TRITANIUM_INGOTS, MItemTags.PISTONS) - .unlockedBy(MItemTags.TRITANIUM_INGOTS) - .unlockedBy(MItems.ELECTRIC_PARTS) + MatteryRecipe(MBlocks.ENERGY_COUNTER[null]!!, category = machinesCategory) + .row(MItemTags.TRITANIUM_PLATES, MItems.ENERGY_BUS, MItemTags.TRITANIUM_PLATES) + .row(MItemTags.BASIC_CIRCUIT, Tags.Items.DUSTS_GLOWSTONE, MItemTags.HARDENED_GLASS_PANES_COLORLESS) + .row(MItemTags.TRITANIUM_PLATES, MItems.ENERGY_BUS, MItemTags.TRITANIUM_PLATES) + .unlockedBy(MItems.ENERGY_BUS) .build(consumer) - MatteryRecipe(MBlocks.PLATE_PRESS[null]!!, category = machinesCategory) - .rowB(MItemTags.PISTONS) - .rowB(MItems.MACHINE_FRAME) + MatteryRecipe(MBlocks.TWIN_PLATE_PRESS[null]!!, category = machinesCategory) + .rowAC(MItems.ELECTROMOTOR, MItems.ELECTROMOTOR) + .row(MItemTags.PISTONS, MItems.MACHINE_FRAME, MItemTags.PISTONS) .unlockedBy(MItemTags.TRITANIUM_INGOTS) - .unlockedBy(MItems.ELECTRIC_PARTS) - .build(consumer, "advanced") + .unlockedBy(MItems.MACHINE_FRAME) + .build(consumer) - for ((color, press) in MBlocks.PLATE_PRESS) { + for ((color, item) in MItems.PLATE_PRESS) { MatteryRecipe(MBlocks.TWIN_PLATE_PRESS[color]!!, category = machinesCategory) - .setUpgradeSource(press) - .addUpgradeOps(UpgradeRecipe.Direct("BlockEntityTag")) - .rowB(MItemTags.PISTONS) - .rowB(press) - .rowB(MItemTags.TRITANIUM_PLATES) - .unlockedBy(MBlocks.PLATE_PRESS.values) - .build(consumer, "twin_plate_press/${color?.name?.lowercase() ?: "default"}") + .setUpgradeSource(item) + .addUpgradeOps(UpgradeRecipe.All) + .rowA(item) + .build(consumer, "plate_press_migration/${color?.name?.lowercase() ?: "default"}") } + MatteryRecipe(MBlocks.CHEMICAL_GENERATOR[null]!!, category = machinesCategory) + .rowB(MItems.ENERGY_BUS) + .row(MItemTags.TRITANIUM_INGOTS, MItemTags.FURNACES, MItemTags.TRITANIUM_INGOTS) + .rowAC(MItems.ELECTRIC_PARTS, MItems.ELECTRIC_PARTS) + .unlockedBy(MItemTags.FURNACES) + .unlockedBy(MItems.ENERGY_BUS) + .build(consumer) + MatteryRecipe(MItems.PATTERN_DRIVE_NORMAL, category = machinesCategory) .rowAC(MItemTags.ADVANCED_CIRCUIT, MItemTags.ADVANCED_CIRCUIT) .row(MItemTags.ADVANCED_CIRCUIT, MItemTags.TRITANIUM_PLATES, MItemTags.ADVANCED_CIRCUIT) @@ -280,47 +284,9 @@ fun addCraftingTableRecipes(consumer: RecipeOutput) { .unlockedBy(MItemTags.TRITANIUM_INGOTS) .build(consumer) - // простые батарейки - MatteryRecipe(MItems.BATTERY_CRUDE, category = RecipeCategory.MISC) - .rowB(Tags.Items.DUSTS_REDSTONE) - .rowB(Tags.Items.CROPS_POTATO) - .rowB(Tags.Items.INGOTS_IRON) - .build(consumer) - - MatteryRecipe(MItems.BATTERY_BASIC, category = RecipeCategory.MISC) - .rowAC(Tags.Items.DUSTS_REDSTONE, Tags.Items.DUSTS_REDSTONE) - .rowB(MItems.ELECTRIC_PARTS) - .rowB(MItemTags.IRON_PLATES) - .build(consumer) - - MatteryRecipe(MItems.BATTERY_NORMAL, category = RecipeCategory.MISC) - .rowB(MItems.ELECTRIC_PARTS) - .row(MItemTags.COPPER_WIRES, MItemTags.IRON_PLATES, MItemTags.COPPER_WIRES) - .row(Tags.Items.DUSTS_REDSTONE, Tags.Items.DUSTS_REDSTONE, Tags.Items.DUSTS_REDSTONE) - .build(consumer) - - MatteryRecipe(MItems.BATTERY_DENSE, category = RecipeCategory.MISC) - .row(Tags.Items.DUSTS_REDSTONE, MItems.ENERGY_BUS, Tags.Items.DUSTS_REDSTONE) - .row(MItemTags.GOLD_WIRES, MItemTags.TRITANIUM_PLATES, MItemTags.GOLD_WIRES) - .row(Tags.Items.DUSTS_REDSTONE, Tags.Items.DUSTS_REDSTONE, Tags.Items.DUSTS_REDSTONE) - .build(consumer) - - MatteryRecipe(MItems.BATTERY_CAPACITOR, category = RecipeCategory.MISC) - .row(Tags.Items.DUSTS_REDSTONE, MItems.ENERGY_BUS, Tags.Items.DUSTS_REDSTONE) - .row(MItemTags.GOLD_WIRES, MItemTags.TRITANIUM_PLATES, MItemTags.GOLD_WIRES) - .row(MItemTags.GOLD_WIRES, Tags.Items.DUSTS_REDSTONE, MItemTags.GOLD_WIRES) - .build(consumer) - - // накопители материи - MatteryRecipe(MItems.MATTER_CAPACITOR_DENSE, category = RecipeCategory.MISC) - .row(MItems.MATTER_CAPACITOR_PARTS, Tags.Items.GLASS, MItems.MATTER_CAPACITOR_PARTS) - .row(MItemTags.TRITANIUM_PLATES, Tags.Items.ENDER_PEARLS, MItemTags.TRITANIUM_PLATES) - .rowAC(Tags.Items.GEMS_DIAMOND, Tags.Items.GEMS_DIAMOND) - .build(consumer) - // станция андроида MatteryRecipe(MItems.ANDROID_STATION[null]!!, category = machinesCategory) - .row(MItems.ELECTRIC_PARTS, MItemTags.ADVANCED_CIRCUIT, MItems.ELECTRIC_PARTS) + .row(MItems.ELECTRIC_PARTS, MItems.QUANTUM_TRANSCEIVER, MItems.ELECTRIC_PARTS) .row(MItemTags.TRITANIUM_PLATES, MItems.MACHINE_FRAME, MItemTags.TRITANIUM_PLATES) .row(MItemTags.TRITANIUM_PLATES, MItems.ELECTRIC_PARTS, MItemTags.TRITANIUM_PLATES) .build(consumer) @@ -332,14 +298,6 @@ fun addCraftingTableRecipes(consumer: RecipeOutput) { .row(MItemTags.TRITANIUM_PLATES, MItems.MACHINE_FRAME, MItemTags.TRITANIUM_PLATES) .build(consumer) - // Энерго меч - MatteryRecipe(MItems.ENERGY_SWORD, category = RecipeCategory.COMBAT) - .rowBC(MItemTags.TRITANIUM_PLATES, MItemTags.GOLD_WIRES) - .rowBC(MItemTags.TRITANIUM_PLATES, MItemTags.GOLD_WIRES) - .row(MItems.BATTERY_CAPACITOR, MItems.TRITANIUM_SWORD, MItemTags.ADVANCED_CIRCUIT) - .unlockedBy(MItems.BATTERY_CAPACITOR) - .buildEnergetic(consumer) - // апгрейд на сетку крафта MatteryRecipe(MItems.ExopackUpgrades.CRAFTING_UPGRADE, category = RecipeCategory.TOOLS) .row(MItemTags.ADVANCED_CIRCUIT, MItemTags.ADVANCED_CIRCUIT, MItemTags.ADVANCED_CIRCUIT) @@ -416,6 +374,12 @@ fun addCraftingTableRecipes(consumer: RecipeOutput) { .build(consumer) } + MatteryRecipe(MItems.MATTER_SCANNER[null]!!, category = machinesCategory) + .row(MItems.MIRROR, MItems.MATTER_TRANSFORM_MATRIX, MItems.MIRROR) + .row(MItemTags.HARDENED_GLASS_COLORLESS, MItems.MACHINE_FRAME, MItemTags.HARDENED_GLASS_COLORLESS) + .row(MItems.MATTER_CABLE, MItemTags.ADVANCED_CIRCUIT, MItems.MATTER_CABLE) + .build(consumer) + MatteryRecipe(MItems.FLUID_CAPSULE, category = RecipeCategory.TOOLS, count = 8) .row(MItemTags.TRITANIUM_NUGGETS, MItemTags.TRITANIUM_NUGGETS, MItemTags.TRITANIUM_NUGGETS) .rowB(MItemTags.HARDENED_GLASS_PANES) 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 e94a10555..e9547011c 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 @@ -274,7 +274,6 @@ fun addPainterRecipes(consumer: RecipeOutput) { val blocks = listOf( MItems.COBBLESTONE_GENERATOR, MItems.ESSENCE_STORAGE, - MItems.PLATE_PRESS, MItems.TWIN_PLATE_PRESS, MItems.ITEM_MONITOR, MItems.MATTER_BOTTLER, diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/StorageItemRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/StorageItemRecipes.kt new file mode 100644 index 000000000..2b393dc78 --- /dev/null +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/StorageItemRecipes.kt @@ -0,0 +1,74 @@ +package ru.dbotthepony.mc.otm.datagen.recipes + +import net.minecraft.data.recipes.RecipeCategory +import net.minecraft.data.recipes.RecipeOutput +import net.minecraftforge.common.Tags +import ru.dbotthepony.mc.otm.recipe.UpgradeRecipe +import ru.dbotthepony.mc.otm.registry.MItemTags +import ru.dbotthepony.mc.otm.registry.MItems + +fun addStorageItemRecipes(consumer: RecipeOutput) { + // простые батарейки + MatteryRecipe(MItems.BATTERY_CRUDE, category = RecipeCategory.MISC) + .rowB(Tags.Items.DUSTS_REDSTONE) + .rowB(Tags.Items.CROPS_POTATO) + .rowB(Tags.Items.INGOTS_IRON) + .unlockedBy(Tags.Items.CROPS_POTATO) + .build(consumer) + + MatteryRecipe(MItems.BATTERY_BASIC, category = RecipeCategory.MISC) + .rowAC(Tags.Items.DUSTS_REDSTONE, Tags.Items.DUSTS_REDSTONE) + .rowB(MItems.ELECTRIC_PARTS) + .rowB(MItemTags.IRON_PLATES) + .unlockedBy(Tags.Items.DUSTS_REDSTONE) + .unlockedBy(MItems.ELECTRIC_PARTS) + .build(consumer) + + MatteryRecipe(MItems.BATTERY_NORMAL, category = RecipeCategory.MISC) + .setUpgradeSource(MItems.BATTERY_BASIC) + .addUpgradeOps(UpgradeRecipe.All) + .rowB(MItems.ELECTRIC_PARTS) + .row(MItemTags.COPPER_WIRES, MItems.BATTERY_BASIC, MItemTags.COPPER_WIRES) + .row(Tags.Items.DUSTS_REDSTONE, Tags.Items.DUSTS_REDSTONE, Tags.Items.DUSTS_REDSTONE) + .build(consumer) + + MatteryRecipe(MItems.BATTERY_DENSE, category = RecipeCategory.MISC) + .setUpgradeSource(MItems.BATTERY_NORMAL) + .addUpgradeOps(UpgradeRecipe.All) + .row(Tags.Items.DUSTS_REDSTONE, MItems.ENERGY_BUS, Tags.Items.DUSTS_REDSTONE) + .row(MItemTags.GOLD_WIRES, MItems.BATTERY_NORMAL, MItemTags.GOLD_WIRES) + .row(Tags.Items.DUSTS_REDSTONE, Tags.Items.DUSTS_REDSTONE, Tags.Items.DUSTS_REDSTONE) + .build(consumer) + + MatteryRecipe(MItems.BATTERY_CAPACITOR, category = RecipeCategory.MISC) + .setUpgradeSource(MItems.BATTERY_NORMAL) + .addUpgradeOps(UpgradeRecipe.All) + .row(Tags.Items.DUSTS_REDSTONE, MItems.ENERGY_BUS, Tags.Items.DUSTS_REDSTONE) + .row(MItemTags.GOLD_WIRES, MItems.BATTERY_NORMAL, MItemTags.GOLD_WIRES) + .row(MItemTags.GOLD_WIRES, Tags.Items.DUSTS_REDSTONE, MItemTags.GOLD_WIRES) + .build(consumer) + + // накопители материи + MatteryRecipe(MItems.MATTER_CAPACITOR_BASIC, category = RecipeCategory.MISC) + .row(MItemTags.IRON_PLATES, MItems.MATTER_CAPACITOR_PARTS, MItemTags.HARDENED_GLASS) + .unlockedBy(MItems.MATTER_CAPACITOR_PARTS) + .build(consumer) + + MatteryRecipe(MItems.MATTER_CAPACITOR_NORMAL, category = RecipeCategory.MISC) + .setUpgradeSource(MItems.MATTER_CAPACITOR_BASIC) + .addUpgradeOps(UpgradeRecipe.All) + .rowB(MItems.MATTER_CAPACITOR_PARTS) + .row(MItemTags.TRITANIUM_PLATES, MItems.MATTER_CAPACITOR_BASIC, MItemTags.TRITANIUM_PLATES) + .rowB(Tags.Items.GEMS_DIAMOND) + .unlockedBy(MItems.MATTER_CAPACITOR_BASIC) + .build(consumer) + + MatteryRecipe(MItems.MATTER_CAPACITOR_DENSE, category = RecipeCategory.MISC) + .setUpgradeSource(MItems.MATTER_CAPACITOR_NORMAL) + .addUpgradeOps(UpgradeRecipe.All) + .row(MItems.MATTER_CAPACITOR_PARTS, MItemTags.HARDENED_GLASS, MItems.MATTER_CAPACITOR_PARTS) + .row(MItemTags.TRITANIUM_PLATES, MItems.MATTER_CAPACITOR_NORMAL, MItemTags.TRITANIUM_PLATES) + .rowAC(Tags.Items.ENDER_PEARLS, Tags.Items.ENDER_PEARLS) + .unlockedBy(MItems.MATTER_CAPACITOR_NORMAL) + .build(consumer) +} diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/ToolsRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/ToolsRecipes.kt new file mode 100644 index 000000000..1ef382d59 --- /dev/null +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/ToolsRecipes.kt @@ -0,0 +1,58 @@ +package ru.dbotthepony.mc.otm.datagen.recipes + +import net.minecraft.data.recipes.RecipeCategory +import net.minecraft.data.recipes.RecipeOutput +import net.minecraftforge.common.Tags +import ru.dbotthepony.mc.otm.registry.MItemTags +import ru.dbotthepony.mc.otm.registry.MItems + +fun addToolsRecipes(consumer: RecipeOutput) { + MatteryRecipe(MItems.ENERGY_SWORD, category = RecipeCategory.COMBAT) + .row(MItemTags.CARBON_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.GOLD_WIRES) + .row(MItemTags.CARBON_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.GOLD_WIRES) + .row(MItems.BATTERY_CAPACITOR, MItems.TRITANIUM_SWORD, MItemTags.ADVANCED_CIRCUIT) + .unlockedBy(MItems.BATTERY_CAPACITOR) + .buildEnergetic(consumer) + + MatteryRecipe(MItems.TRITANIUM_SWORD, category = RecipeCategory.COMBAT) + .rowB(MItemTags.TRITANIUM_INGOTS) + .rowB(MItemTags.TRITANIUM_INGOTS) + .rowB(Tags.Items.RODS_WOODEN) + .unlockedBy(MItemTags.TRITANIUM_INGOTS) + .build(consumer) + + MatteryRecipe(MItems.TRITANIUM_SHOVEL, category = RecipeCategory.TOOLS) + .rowB(MItemTags.TRITANIUM_INGOTS) + .rowB(Tags.Items.RODS_WOODEN) + .rowB(Tags.Items.RODS_WOODEN) + .unlockedBy(MItemTags.TRITANIUM_INGOTS) + .build(consumer) + + MatteryRecipe(MItems.TRITANIUM_PICKAXE, category = RecipeCategory.TOOLS) + .row(MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS) + .rowB(Tags.Items.RODS_WOODEN) + .rowB(Tags.Items.RODS_WOODEN) + .unlockedBy(MItemTags.TRITANIUM_INGOTS) + .build(consumer) + + MatteryRecipe(MItems.TRITANIUM_AXE, category = RecipeCategory.TOOLS) + .rowAB(MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS) + .rowAB(MItemTags.TRITANIUM_INGOTS, Tags.Items.RODS_WOODEN) + .rowB(Tags.Items.RODS_WOODEN) + .unlockedBy(MItemTags.TRITANIUM_INGOTS) + .build(consumer) + + MatteryRecipe(MItems.TRITANIUM_AXE, category = RecipeCategory.TOOLS) + .rowBC(MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS) + .rowBC(Tags.Items.RODS_WOODEN, MItemTags.TRITANIUM_INGOTS) + .rowB(Tags.Items.RODS_WOODEN) + .unlockedBy(MItemTags.TRITANIUM_INGOTS) + .build(consumer, "alt") + + MatteryRecipe(MItems.TRITANIUM_HOE, category = RecipeCategory.TOOLS) + .rowBC(MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS) + .rowB(Tags.Items.RODS_WOODEN) + .rowB(Tags.Items.RODS_WOODEN) + .unlockedBy(MItemTags.TRITANIUM_INGOTS) + .build(consumer) +} 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 fd1615e8e..2872dfa19 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 @@ -55,6 +55,7 @@ fun addTags(tagsProvider: TagsProvider) { tagsProvider.items.Appender(MItemTags.CRAFTING_TABLES).add(Items.CRAFTING_TABLE) tagsProvider.items.Appender(MItemTags.WORKBENCHES).add(Items.CRAFTING_TABLE) tagsProvider.items.Appender(MItemTags.WORKBENCH).add(Items.CRAFTING_TABLE) + tagsProvider.items.Appender(MItemTags.FURNACES).add(Items.FURNACE) tagsProvider.blocks.Appender(MBlockTags.CRAFTING_TABLES).add(Blocks.CRAFTING_TABLE) tagsProvider.blocks.Appender(MBlockTags.WORKBENCHES).add(Blocks.CRAFTING_TABLE) tagsProvider.blocks.Appender(MBlockTags.WORKBENCH).add(Blocks.CRAFTING_TABLE) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt index 858954a4d..54865f369 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt @@ -33,9 +33,8 @@ import ru.dbotthepony.mc.otm.block.entity.IRedstoneControlled import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState -import ru.dbotthepony.mc.otm.core.ITooltippable +import ru.dbotthepony.mc.otm.core.TooltipList import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.addDescriptionFunctions import ru.dbotthepony.mc.otm.core.asSupplier import ru.dbotthepony.mc.otm.core.collect.SupplierMap import ru.dbotthepony.mc.otm.core.get @@ -84,7 +83,9 @@ fun interface INeighbourChangeListener { ) } -open class MatteryBlock(properties: Properties = DEFAULT_PROPERTIES) : Block(properties), INeighbourChangeListener, ITooltippable by ITooltippable.Impl() { +open class MatteryBlock(properties: Properties = DEFAULT_PROPERTIES) : Block(properties), INeighbourChangeListener { + val tooltips = TooltipList() + override fun setPlacedBy( level: Level, blockPos: BlockPos, @@ -262,7 +263,7 @@ open class MatteryBlock(properties: Properties = DEFAULT_PROPERTIES) : Block(pro override fun appendHoverText(itemStack: ItemStack, blockAccessor: BlockGetter?, components: MutableList, tooltipType: TooltipFlag) { super.appendHoverText(itemStack, blockAccessor, components, tooltipType) - assembleDescription(itemStack, components) + tooltips.assemble(itemStack, components) } companion object { @@ -272,5 +273,6 @@ open class MatteryBlock(properties: Properties = DEFAULT_PROPERTIES) : Block(pro } fun T.addSimpleDescription(suffix: String = "", formatting: ChatFormatting = ChatFormatting.GRAY): T { - return addDescriptionFunctions { ObjectIterators.singleton(TranslatableComponent("$descriptionId.desc$suffix").withStyle(formatting)) } + tooltips.add { TranslatableComponent("$descriptionId.desc$suffix").withStyle(formatting) } + return this } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumDoorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumDoorBlock.kt index 943606243..4c1d35c9d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumDoorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumDoorBlock.kt @@ -13,7 +13,9 @@ import net.minecraft.world.level.block.DoorBlock import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.properties.BlockSetType import net.minecraft.world.level.material.PushReaction +import ru.dbotthepony.mc.otm.core.TooltipList import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.collect.iteratorOf class TritaniumDoorBlock(val color: DyeColor?) : DoorBlock( Properties.of() @@ -25,6 +27,14 @@ class TritaniumDoorBlock(val color: DyeColor?) : DoorBlock( .requiresCorrectToolForDrops(), BlockSetType.IRON ) { + val tooltips = TooltipList() + + init { + tooltips.add { TranslatableComponent("$descriptionId.description0").withStyle(ChatFormatting.DARK_GRAY) } + tooltips.add { TranslatableComponent("$descriptionId.description1").withStyle(ChatFormatting.DARK_GRAY) } + tooltips.painted(color) + } + override fun appendHoverText( p_49816_: ItemStack, p_49817_: BlockGetter?, @@ -32,12 +42,7 @@ class TritaniumDoorBlock(val color: DyeColor?) : DoorBlock( p_49819_: TooltipFlag ) { super.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) - p_49818_.add(TranslatableComponent("$descriptionId.description0").withStyle(ChatFormatting.DARK_GRAY)) - p_49818_.add(TranslatableComponent("$descriptionId.description1").withStyle(ChatFormatting.DARK_GRAY)) - - if (color != null) { - p_49818_.add(TranslatableComponent("$descriptionId.description2").withStyle(ChatFormatting.DARK_GRAY)) - } + tooltips.assemble(p_49816_, p_49818_) } override fun canEntityDestroy( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt index 2f02e1a24..3719acfb7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt @@ -4,14 +4,11 @@ import net.minecraft.ChatFormatting import net.minecraft.core.BlockPos import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerPlayer -import net.minecraft.sounds.SoundEvents -import net.minecraft.sounds.SoundSource import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level -import net.minecraft.world.level.LevelAccessor import net.minecraft.world.level.block.BasePressurePlateBlock import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.SoundType @@ -19,22 +16,28 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.level.block.state.properties.BlockSetType import net.minecraft.world.level.block.state.properties.BlockStateProperties +import ru.dbotthepony.mc.otm.core.TooltipList import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.collect.iteratorOf import ru.dbotthepony.mc.otm.core.get class TritaniumPressurePlate(color: DyeColor?) : BasePressurePlateBlock(Properties.of().mapColor(color ?: DyeColor.LIGHT_BLUE).sound(SoundType.METAL).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), BlockSetType.IRON) { + val tooltips = TooltipList() + override fun appendHoverText( - p_49816_: ItemStack, - p_49817_: BlockGetter?, - p_49818_: MutableList, - p_49819_: TooltipFlag + itemStack: ItemStack, + level: BlockGetter?, + lines: MutableList, + tooltipType: TooltipFlag ) { - super.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) - p_49818_.add(TranslatableComponent("$descriptionId.description0").withStyle(ChatFormatting.DARK_GRAY)) - p_49818_.add(TranslatableComponent("$descriptionId.description1").withStyle(ChatFormatting.DARK_GRAY)) + super.appendHoverText(itemStack, level, lines, tooltipType) + tooltips.assemble(itemStack, lines) } init { + tooltips.add { TranslatableComponent("$descriptionId.description0").withStyle(ChatFormatting.DARK_GRAY) } + tooltips.add { TranslatableComponent("$descriptionId.description1").withStyle(ChatFormatting.DARK_GRAY) } + tooltips.painted(color) registerDefaultState(stateDefinition.any().setValue(BlockStateProperties.POWERED, false)) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumTrapdoorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumTrapdoorBlock.kt index 3a1c0de0e..0ae164804 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumTrapdoorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumTrapdoorBlock.kt @@ -13,7 +13,9 @@ import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.block.TrapDoorBlock import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.properties.BlockSetType +import ru.dbotthepony.mc.otm.core.TooltipList import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.collect.iteratorOf class TritaniumTrapdoorBlock(val color: DyeColor?) : TrapDoorBlock( Properties.of() @@ -24,6 +26,14 @@ class TritaniumTrapdoorBlock(val color: DyeColor?) : TrapDoorBlock( .isValidSpawn { _: BlockState, _: BlockGetter, _: BlockPos, _: EntityType<*>? -> false }, BlockSetType.IRON ) { + val tooltips = TooltipList() + + init { + tooltips.add { TranslatableComponent("$descriptionId.description0").withStyle(ChatFormatting.DARK_GRAY) } + tooltips.add { TranslatableComponent("$descriptionId.description1").withStyle(ChatFormatting.DARK_GRAY) } + tooltips.painted(color) + } + override fun appendHoverText( p_49816_: ItemStack, p_49817_: BlockGetter?, @@ -31,12 +41,7 @@ class TritaniumTrapdoorBlock(val color: DyeColor?) : TrapDoorBlock( p_49819_: TooltipFlag ) { super.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) - p_49818_.add(TranslatableComponent("$descriptionId.description0").withStyle(ChatFormatting.DARK_GRAY)) - p_49818_.add(TranslatableComponent("$descriptionId.description1").withStyle(ChatFormatting.DARK_GRAY)) - - if (color != null) { - p_49818_.add(TranslatableComponent("$descriptionId.description2").withStyle(ChatFormatting.DARK_GRAY)) - } + tooltips.assemble(p_49816_, p_49818_) } override fun canEntityDestroy( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt index c404ee458..e759f4afe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt @@ -51,6 +51,7 @@ import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.util.IntCounter import ru.dbotthepony.mc.otm.core.util.Savetables import ru.dbotthepony.mc.otm.core.util.TickList +import ru.dbotthepony.mc.otm.core.util.countingLazy import ru.dbotthepony.mc.otm.network.BlockEntitySyncPacket import ru.dbotthepony.mc.otm.network.GenericNetworkChannel import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer @@ -73,20 +74,39 @@ import kotlin.reflect.KProperty abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: BlockPos, p_155230_: BlockState) : BlockEntity(p_155228_, p_155229_, p_155230_), INeighbourChangeListener { private var isSynchronizing = false - /** - * "shortcut" for getting [BlockRotation] - * - * if block has no rotation, returns [BlockRotation.NORTH] - */ - open val blockRotation: BlockRotation get() { - return blockState[(blockState.block as? RotatableMatteryBlock ?: return BlockRotation.NORTH).rotationProperty] - } + private val sidelessCaps = Reference2ObjectOpenHashMap, SidelessCap<*>>() + protected val tickList = TickList() + protected val blockStateChangesCounter = IntCounter() + protected val dirtyListeners = ISubscriptable.Impl() + private val waitForServerLevel = ArrayList<() -> Unit>() private val _droppableContainers = ObjectArraySet() private val _neighbourChangeListeners = ObjectArraySet() val droppableContainers: Set = Collections.unmodifiableSet(_droppableContainers) val neighbourChangeListeners: Set = Collections.unmodifiableSet(_neighbourChangeListeners) + private val _sides = EnumMap(RelativeSide::class.java) + val sides: Map = Collections.unmodifiableMap(_sides) + + /** + * Shared savetables, written both to level storage and to item tag + */ + protected val savetables = Savetables() + + /** + * Level-only savetables, written only to level storage + */ + protected val savetablesLevel = Savetables() + + /** + * "shortcut" for getting [BlockRotation] + * + * if block has no rotation, returns [BlockRotation.NORTH] + */ + open val blockRotation: BlockRotation by countingLazy(blockStateChangesCounter) { + blockState[(blockState.block as? RotatableMatteryBlock ?: return@countingLazy BlockRotation.NORTH).rotationProperty] + } + protected fun addDroppableContainer(container: Container) { _droppableContainers.add(container) } @@ -101,27 +121,9 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc open fun beforeDroppingItems(oldBlockState: BlockState, level: Level, blockPos: BlockPos, newBlockState: BlockState, movedByPiston: Boolean) {} open fun beforeDestroyedByPlayer(level: Level, blockPos: BlockPos, blockState: BlockState, player: Player) {} - private val _sides = EnumMap(RelativeSide::class.java) - val sides: Map = Collections.unmodifiableMap(_sides) - fun side(side: RelativeSide) = sides[side]!! private data class SidelessCap(val cap: T, var optional: LazyOptional) - private val sidelessCaps = Reference2ObjectOpenHashMap, SidelessCap<*>>() - protected val tickList = TickList() - protected val blockStateChangesCounter = IntCounter() - protected val dirtyListeners = ISubscriptable.Impl() - private val waitForServerLevel = ArrayList<() -> Unit>() - - /** - * Shared savetables, written both to level storage and to item tag - */ - protected val savetables = Savetables() - - /** - * Level-only savetables, written only to level storage - */ - protected val savetablesLevel = Savetables() open fun tick() { tickList.tick() @@ -441,8 +443,8 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc @Suppress("OVERRIDE_DEPRECATION") override fun setBlockState(pBlockState: BlockState) { - blockStateChangesCounter.increment() val old = blockRotation + blockStateChangesCounter.increment() @Suppress("DEPRECATION") super.setBlockState(pBlockState) val new = blockRotation diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt index ee7854a35..290457998 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt @@ -1,25 +1,15 @@ package ru.dbotthepony.mc.otm.block.entity -import net.minecraft.ChatFormatting import net.minecraft.core.BlockPos -import net.minecraft.nbt.CompoundTag -import net.minecraft.network.chat.Component -import net.minecraft.world.item.BlockItem -import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.TooltipFlag -import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.capabilities.ForgeCapabilities -import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage -import ru.dbotthepony.mc.otm.capability.energy.ItemEnergyStorageImpl +import ru.dbotthepony.mc.otm.capability.extractEnergy import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer -import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.ifPresentK -import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.math.Decimal abstract class MatteryPoweredBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(p_155228_, p_155229_, p_155230_) { val batteryContainer = MatteryContainer(::markDirtyFast, 1).also(::addDroppableContainer) @@ -51,18 +41,4 @@ abstract class MatteryPoweredBlockEntity(p_155228_: BlockEntityType<*>, p_155229 return } } - - companion object { - fun appendHoverText(itemStack: ItemStack, blockGetter: BlockGetter?, tooltips: MutableList, flag: TooltipFlag) { - val tag = itemStack.tag?.get(BlockItem.BLOCK_ENTITY_TAG) as? CompoundTag ?: return - val container = MatteryContainer(1) - tag.map(BATTERY_KEY, container::deserializeNBT) - - if (!container[0].isEmpty) { - tooltips.add(TranslatableComponent("otm.item.block.stored_battery", container[0].displayName).withStyle(ChatFormatting.GRAY)) - - ItemEnergyStorageImpl.appendHoverText(container[0], tooltips) - } - } - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt index 45499d6fe..86c7170ac 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt @@ -160,15 +160,4 @@ abstract class MatteryWorkerBlockEntity( } } } - - companion object { - private val LOGGER = LogManager.getLogger() - - fun appendHoverText(itemStack: ItemStack, blockGetter: BlockGetter?, tooltips: MutableList, flag: TooltipFlag) { - itemStack.tag ?: return - - WorkerEnergyStorage.appendHoverText(itemStack, blockGetter, tooltips, flag) - MatteryPoweredBlockEntity.appendHoverText(itemStack, blockGetter, tooltips, flag) - } - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index 412486113..4f1e6a8fd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -100,7 +100,7 @@ class MatterBottlerBlockEntity(blockPos: BlockPos, blockState: BlockState) : battery = batteryItemHandler ) - val matter: ProfiledMatterStorage = ProfiledMatterStorage(object : MatterStorageImpl(this::markDirtyFast, FlowDirection.BI_DIRECTIONAL, upgrades.matterCapacity(MachinesConfig.MatterBottler.VALUES::matterCapacity)) { + val matter: ProfiledMatterStorage = ProfiledMatterStorage(object : MatterStorageImpl(this@MatterBottlerBlockEntity::markDirtyFast, FlowDirection.BI_DIRECTIONAL, upgrades.matterCapacity(MachinesConfig.MatterBottler.VALUES::matterCapacity)) { override val matterFlow: FlowDirection get() { return if (this@MatterBottlerBlockEntity.isBottling) FlowDirection.INPUT else FlowDirection.OUTPUT } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt index b225e7f1a..c0fa77ad3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt @@ -82,7 +82,7 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) } if (summ.isPositive && !simulate) { - gaugeLevel = (storedMatter / maxStoredMatter).toFloat() + gaugeLevel = storedMatter.percentage(maxStoredMatter) } return summ @@ -111,7 +111,7 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) } if (summ.isPositive && !simulate) { - gaugeLevel = (storedMatter / maxStoredMatter).toFloat() + gaugeLevel = storedMatter.percentage(maxStoredMatter) } return summ @@ -124,7 +124,7 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { super.setChanged(slot, new, old) capacitorStatus[slot].boolean = new.getCapability(MatteryCapability.MATTER).isPresent - gaugeLevel = (storedMatter / maxStoredMatter).toFloat() + gaugeLevel = storedMatter.percentage(maxStoredMatter) } override fun getMaxStackSize(): Int = 1 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt index af25c1045..6048a42d5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.block.entity.matter -import javax.annotation.ParametersAreNonnullByDefault import net.minecraft.core.BlockPos import net.minecraft.world.level.block.state.BlockState import ru.dbotthepony.mc.otm.container.MatteryContainer @@ -11,7 +10,6 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import ru.dbotthepony.mc.otm.menu.matter.PatternStorageMenu -import net.minecraft.MethodsReturnNonnullByDefault import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity @@ -26,8 +24,6 @@ import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode import ru.dbotthepony.mc.otm.registry.MBlockEntities import java.util.stream.Stream -@MethodsReturnNonnullByDefault -@ParametersAreNonnullByDefault class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.PATTERN_STORAGE, p_155229_, p_155230_), IPatternStorage { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt index 445f2ae6d..3fec7ce7e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt @@ -22,6 +22,7 @@ import ru.dbotthepony.mc.otm.core.nbt.getByteArrayList import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.mapPresent import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.util.countingLazy import ru.dbotthepony.mc.otm.menu.tech.EnergyCounterMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import java.util.* @@ -29,8 +30,8 @@ import java.util.* class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.ENERGY_COUNTER, p_155229_, p_155230_) { var passed by synchronizer.decimal() - override val blockRotation: BlockRotation get() { - return BlockRotation.of(blockState[EnergyCounterBlock.INPUT_DIRECTION]) + override val blockRotation: BlockRotation by countingLazy(blockStateChangesCounter) { + BlockRotation.of(blockState[EnergyCounterBlock.INPUT_DIRECTION]) } private val history = Array(10 * 20) { Decimal.ZERO } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PlatePressBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PlatePressBlockEntity.kt index 2789cdf25..798c32d67 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PlatePressBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PlatePressBlockEntity.kt @@ -24,7 +24,6 @@ import ru.dbotthepony.mc.otm.core.collect.filter import ru.dbotthepony.mc.otm.core.collect.maybe import ru.dbotthepony.mc.otm.core.value import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu -import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MRecipes @@ -56,10 +55,7 @@ class PlatePressBlockEntity( } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { - if (isTwin) - return TwinPlatePressMenu(containerID, inventory, this) - else - return PlatePressMenu(containerID, inventory, this) + return if (isTwin) PlatePressMenu.twin(containerID, inventory, this) else PlatePressMenu.single(containerID, inventory, this) } override fun onJobFinish(status: JobStatus, id: Int) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt index ab6cf9e08..906ffbbd1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt @@ -16,6 +16,7 @@ import net.minecraft.world.level.block.state.properties.BooleanProperty import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.addSimpleDescription import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity import ru.dbotthepony.mc.otm.block.getShapeForEachState @@ -24,6 +25,13 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes class MatterBottlerBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { + init { + tooltips.colored(color) + addSimpleDescription() + tooltips.blockEntityEnergy() + tooltips.blockEntityMatter() + } + override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return MatterBottlerBlockEntity(blockPos, blockState) } @@ -36,7 +44,7 @@ class MatterBottlerBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_M if (p_153212_.isClientSide || p_153214_ !== MBlockEntities.MATTER_BOTTLER) return null - return BlockEntityTicker {_, _, _, tile -> if (tile is MatterBottlerBlockEntity) tile.tick()} + return BlockEntityTicker { _, _, _, tile -> if (tile is MatterBottlerBlockEntity) tile.tick() } } override fun createBlockStateDefinition(builder: StateDefinition.Builder) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt index ff66222dd..4b5d8dfbf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt @@ -14,12 +14,18 @@ import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.tech.BatteryBankBlock import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.addSimpleDescription import ru.dbotthepony.mc.otm.block.entity.matter.MatterCapacitorBankBlockEntity import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.shapes.BlockShapes class MatterCapacitorBankBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { + init { + tooltips.colored(color) + addSimpleDescription() + } + override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return MatterCapacitorBankBlockEntity(blockPos, blockState) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt index dbaa8d39b..a53e6432d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt @@ -1,7 +1,5 @@ package ru.dbotthepony.mc.otm.block.matter -import net.minecraft.MethodsReturnNonnullByDefault -import javax.annotation.ParametersAreNonnullByDefault import net.minecraft.world.level.block.EntityBlock import net.minecraft.core.BlockPos import net.minecraft.world.item.DyeColor @@ -17,6 +15,7 @@ import net.minecraft.world.level.block.Block import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.addSimpleDescription import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get @@ -24,6 +23,13 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes class MatterDecomposerBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { + init { + tooltips.colored(color) + addSimpleDescription() + tooltips.blockEntityEnergy() + tooltips.blockEntityMatter() + } + override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return MatterDecomposerBlockEntity(blockPos, blockState) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterEntanglerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterEntanglerBlock.kt index 96bcf3b1a..9ba4d4452 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterEntanglerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterEntanglerBlock.kt @@ -11,6 +11,11 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.matter.MatterEntanglerBlockEntity class MatterEntanglerBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { + init { + tooltips.blockEntityEnergy() + tooltips.blockEntityMatter() + } + override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return MatterEntanglerBlockEntity(blockPos, blockState) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterPanelBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterPanelBlock.kt index 7de57144a..5735112de 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterPanelBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterPanelBlock.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.block.matter -import com.google.common.collect.ImmutableMap import net.minecraft.world.level.block.EntityBlock import net.minecraft.core.BlockPos import net.minecraft.core.Direction @@ -14,11 +13,17 @@ import net.minecraft.world.level.BlockGetter import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.item.context.BlockPlaceContext import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.addSimpleDescription import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom class MatterPanelBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { + init { + tooltips.colored(color) + addSimpleDescription() + } + override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return MatterPanelBlockEntity(blockPos, blockState) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReconstructorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReconstructorBlock.kt index 268b31ddc..dca3b66c0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReconstructorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReconstructorBlock.kt @@ -19,6 +19,13 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.shapes.BlockShapes class MatterReconstructorBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { + init { + tooltips.colored(color) + addSimpleDescription() + tooltips.blockEntityEnergy("energy") + tooltips.blockEntityMatter("matter") + } + override fun newBlockEntity(pPos: BlockPos, pState: BlockState): BlockEntity { return MatterReconstructorBlockEntity(pPos, pState) } @@ -30,10 +37,6 @@ class MatterReconstructorBlock(val color: DyeColor?) : RotatableMatteryBlock(DEF return BlockEntityTicker { _, _, _, pBlockEntity -> if (pBlockEntity is MatterReconstructorBlockEntity) pBlockEntity.tick() } } - init { - addSimpleDescription() - } - private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.MATTER_RECONSTRUCTOR.rotateFromNorth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt index c09532a21..195513983 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt @@ -14,6 +14,7 @@ import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.addSimpleDescription import ru.dbotthepony.mc.otm.block.entity.matter.MatterRecyclerBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.getShapeForEachState @@ -22,6 +23,13 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes class MatterRecyclerBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { + init { + tooltips.colored(color) + addSimpleDescription() + tooltips.blockEntityEnergy() + tooltips.blockEntityMatter() + } + override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return MatterRecyclerBlockEntity(p_153215_, p_153216_) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt index b20b79b6d..be7861420 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt @@ -14,6 +14,7 @@ import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.addSimpleDescription import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.getShapeForEachState @@ -22,6 +23,13 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes class MatterReplicatorBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { + init { + tooltips.colored(color) + addSimpleDescription() + tooltips.blockEntityEnergy() + tooltips.blockEntityMatter() + } + override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return MatterReplicatorBlockEntity(blockPos, blockState) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt index b7ae511aa..831363959 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt @@ -14,6 +14,7 @@ import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.addSimpleDescription import ru.dbotthepony.mc.otm.block.entity.matter.MatterScannerBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.getShapeForEachState @@ -22,6 +23,12 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes class MatterScannerBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { + init { + tooltips.colored(color) + addSimpleDescription() + tooltips.blockEntityEnergy() + } + override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return MatterScannerBlockEntity(blockPos, blockState) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt index d5f36e76a..59cd5b296 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt @@ -14,12 +14,17 @@ import net.minecraft.world.level.block.state.properties.BooleanProperty import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.addSimpleDescription import ru.dbotthepony.mc.otm.block.entity.matter.PatternStorageBlockEntity import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.shapes.BlockShapes class PatternStorageBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { + init { + addSimpleDescription() + } + override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return PatternStorageBlockEntity(blockPos, blockState) } @@ -38,25 +43,6 @@ class PatternStorageBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), E return state } - override fun onRemove( - oldBlockState: BlockState, - level: Level, - blockPos: BlockPos, - newBlockState: BlockState, - movedByPiston: Boolean - ) { - if (!oldBlockState.`is`(newBlockState.block)) { - val blockentity = level.getBlockEntity(blockPos) - - if (blockentity is PatternStorageBlockEntity) { - Containers.dropContents(level, blockPos, blockentity.container) - level.updateNeighbourForOutputSignal(blockPos, this) - } - } - - super.onRemove(oldBlockState, level, blockPos, newBlockState, movedByPiston) - } - private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.PATTERN_STORAGE.rotateFromNorth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt index 0d648cd60..ba379e5f5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt @@ -23,6 +23,10 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes class DriveRackBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { + init { + tooltips.blockEntityEnergy() + } + override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return DriveRackBlockEntity(blockPos, blockState) } @@ -38,17 +42,6 @@ class DriveRackBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), Entity return BlockEntityTicker { _, _, _, tile -> if (tile is DriveRackBlockEntity) tile.tick() } } - override fun appendHoverText( - itemStack: ItemStack, - blockAccessor: BlockGetter?, - components: MutableList, - tooltipType: TooltipFlag - ) { - super.appendHoverText(itemStack, blockAccessor, components, tooltipType) - WorkerEnergyStorage.appendHoverText(itemStack, blockAccessor, components, tooltipType) - MatteryPoweredBlockEntity.appendHoverText(itemStack, blockAccessor, components, tooltipType) - } - private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.DRIVE_RACK.rotateFromNorth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt index 7dd657190..0d1e83e2a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt @@ -29,6 +29,11 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes class DriveViewerBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { + init { + tooltips.colored(color) + tooltips.blockEntityEnergy() + } + override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return DriveViewerBlockEntity(blockPos, blockState) } @@ -50,17 +55,6 @@ class DriveViewerBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MAC builder.add(DRIVE_PRESENT) } - override fun appendHoverText( - itemStack: ItemStack, - blockAccessor: BlockGetter?, - components: MutableList, - tooltipType: TooltipFlag - ) { - super.appendHoverText(itemStack, blockAccessor, components, tooltipType) - WorkerEnergyStorage.appendHoverText(itemStack, blockAccessor, components, tooltipType) - MatteryPoweredBlockEntity.appendHoverText(itemStack, blockAccessor, components, tooltipType) - } - override fun getStateForPlacement(context: BlockPlaceContext): BlockState { return super.getStateForPlacement(context)!!.setValue(DRIVE_PRESENT, false) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt index 957dbc9e8..e675cdb58 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt @@ -24,6 +24,11 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes class ItemMonitorBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { + init { + tooltips.colored(color) + tooltips.blockEntityEnergy() + } + override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return ItemMonitorBlockEntity(blockPos, blockState) } @@ -39,17 +44,6 @@ class ItemMonitorBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MAC return BlockEntityTicker { _, _, _, tile -> if (tile is ItemMonitorBlockEntity) tile.tick() } } - override fun appendHoverText( - itemStack: ItemStack, - blockAccessor: BlockGetter?, - components: MutableList, - tooltipType: TooltipFlag - ) { - super.appendHoverText(itemStack, blockAccessor, components, tooltipType) - WorkerEnergyStorage.appendHoverText(itemStack, blockAccessor, components, tooltipType) - MatteryPoweredBlockEntity.appendHoverText(itemStack, blockAccessor, components, tooltipType) - } - private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.ITEM_MONITOR.rotateFromNorth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt index 151bfa1c9..379e4b016 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt @@ -32,6 +32,10 @@ import ru.dbotthepony.mc.otm.shapes.BlockShapes import ru.dbotthepony.mc.otm.core.math.unaryMinus class StorageBusBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { + init { + tooltips.blockEntityEnergy() + } + override fun rotationFreedom(): BlockRotationFreedom { return BlockRotationFreedom.DIRECTIONAL } @@ -54,17 +58,6 @@ class StorageBusBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), Entit return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.DIRECTIONAL.property, BlockRotation.of(-context.clickedFace)) } - override fun appendHoverText( - itemStack: ItemStack, - blockAccessor: BlockGetter?, - components: MutableList, - tooltipType: TooltipFlag - ) { - super.appendHoverText(itemStack, blockAccessor, components, tooltipType) - WorkerEnergyStorage.appendHoverText(itemStack, blockAccessor, components, tooltipType) - MatteryPoweredBlockEntity.appendHoverText(itemStack, blockAccessor, components, tooltipType) - } - override fun createBlockStateDefinition(builder: StateDefinition.Builder) { super.createBlockStateDefinition(builder) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt index b842c3d3c..697a0294a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt @@ -32,6 +32,10 @@ import ru.dbotthepony.mc.otm.shapes.BlockShapes import ru.dbotthepony.mc.otm.core.math.unaryMinus class StorageImporterBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { + init { + tooltips.blockEntityEnergy() + } + override fun rotationFreedom(): BlockRotationFreedom { return BlockRotationFreedom.DIRECTIONAL } @@ -78,17 +82,6 @@ class StorageImporterBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.DIRECTIONAL.property, BlockRotation.of(-context.clickedFace)) } - override fun appendHoverText( - itemStack: ItemStack, - blockAccessor: BlockGetter?, - components: MutableList, - tooltipType: TooltipFlag - ) { - super.appendHoverText(itemStack, blockAccessor, components, tooltipType) - WorkerEnergyStorage.appendHoverText(itemStack, blockAccessor, components, tooltipType) - MatteryPoweredBlockEntity.appendHoverText(itemStack, blockAccessor, components, tooltipType) - } - private val shapes = getShapeForEachStateMattery { Shapes.joinUnoptimized(CableBlock.getShapeFor(it, 0.185), BlockShapes.STORAGE_IMPORTER.rotateFromNorth(it[rotationProperty]).computeShape(), BooleanOp.OR) } @@ -105,6 +98,10 @@ class StorageImporterBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), } class StorageExporterBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { + init { + tooltips.blockEntityEnergy() + } + override fun rotationFreedom(): BlockRotationFreedom { return BlockRotationFreedom.DIRECTIONAL } @@ -136,17 +133,6 @@ class StorageExporterBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), ) } - override fun appendHoverText( - itemStack: ItemStack, - blockAccessor: BlockGetter?, - components: MutableList, - tooltipType: TooltipFlag - ) { - super.appendHoverText(itemStack, blockAccessor, components, tooltipType) - WorkerEnergyStorage.appendHoverText(itemStack, blockAccessor, components, tooltipType) - MatteryPoweredBlockEntity.appendHoverText(itemStack, blockAccessor, components, tooltipType) - } - override fun getTicker( p_153212_: Level, p_153213_: BlockState, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt index 90ab90cdb..144859ae6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt @@ -24,6 +24,11 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes class StoragePowerSupplierBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { + init { + tooltips.colored(color) + tooltips.blockEntityEnergy() + } + override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return StoragePowerSupplierBlockEntity(p_153215_, p_153216_) } @@ -39,17 +44,6 @@ class StoragePowerSupplierBlock(val color: DyeColor?) : RotatableMatteryBlock(DE return BlockEntityTicker { _, _, _, tile -> if (tile is StoragePowerSupplierBlockEntity) tile.tick() } } - override fun appendHoverText( - itemStack: ItemStack, - blockAccessor: BlockGetter?, - components: MutableList, - tooltipType: TooltipFlag - ) { - super.appendHoverText(itemStack, blockAccessor, components, tooltipType) - WorkerEnergyStorage.appendHoverText(itemStack, blockAccessor, components, tooltipType) - MatteryPoweredBlockEntity.appendHoverText(itemStack, blockAccessor, components, tooltipType) - } - private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.STORAGE_POWER_SUPPLIER.rotateFromNorth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AbstractPoweredFurnaceBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AbstractPoweredFurnaceBlock.kt index d6ed29b73..5211feff7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AbstractPoweredFurnaceBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AbstractPoweredFurnaceBlock.kt @@ -15,6 +15,7 @@ import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.Shapes import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.addSimpleDescription import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.entity.tech.AbstractPoweredFurnaceBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.PoweredBlastFurnaceBlockEntity @@ -30,6 +31,13 @@ sealed class AbstractPoweredFurnaceBlock T, shape: BlockShape? ) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { + init { + tooltips.painted(color) + addSimpleDescription() + tooltips.doubleProcessing() + tooltips.blockEntityEnergy() + } + override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): T { return factory(p_153215_, p_153216_) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt index d26a2b541..8938adb19 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt @@ -2,13 +2,11 @@ package ru.dbotthepony.mc.otm.block.tech import net.minecraft.ChatFormatting import net.minecraft.core.BlockPos -import net.minecraft.network.chat.Component import net.minecraft.util.StringRepresentable import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.player.Player import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.TooltipFlag import net.minecraft.world.item.context.BlockPlaceContext import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level @@ -25,12 +23,11 @@ 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 -import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity +import ru.dbotthepony.mc.otm.block.addSimpleDescription import ru.dbotthepony.mc.otm.block.entity.tech.AndroidChargerBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.AndroidChargerMiddleBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.AndroidChargerTopBlockEntity import ru.dbotthepony.mc.otm.block.getShapeForEachState -import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.gracefulBlockBreak @@ -39,6 +36,12 @@ import ru.dbotthepony.mc.otm.oncePre import ru.dbotthepony.mc.otm.shapes.BlockShapes class AndroidChargerBlock(val color: DyeColor?) : RotatableMatteryBlock(Properties.of().destroyTime(2.5f).explosionResistance(40f).pushReaction(PushReaction.BLOCK).requiresCorrectToolForDrops()), EntityBlock { + init { + tooltips.painted(color) + addSimpleDescription() + tooltips.blockEntityEnergy() + } + enum class Type : StringRepresentable { BASE, MIDDLE, @@ -140,14 +143,6 @@ class AndroidChargerBlock(val color: DyeColor?) : RotatableMatteryBlock(Properti } } - override fun appendHoverText(itemStack: ItemStack, blockAccessor: BlockGetter?, components: MutableList, tooltipType: TooltipFlag) { - super.appendHoverText(itemStack, blockAccessor, components, tooltipType) - - components.add(TranslatableComponent("$descriptionId.desc").withStyle(ChatFormatting.GRAY)) - WorkerEnergyStorage.appendHoverText(itemStack, blockAccessor, components, tooltipType) - MatteryPoweredBlockEntity.appendHoverText(itemStack, blockAccessor, components, tooltipType) - } - private val shapes = getShapeForEachState(listOf(rotationProperty, PART)) { val shape = when (it[PART]!!) { Type.BASE -> BlockShapes.ANDROID_CHARGER_BASE diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidStationBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidStationBlock.kt index 49ac0670d..2659dea5d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidStationBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidStationBlock.kt @@ -1,13 +1,10 @@ package ru.dbotthepony.mc.otm.block.tech import net.minecraft.core.BlockPos -import net.minecraft.network.chat.Component import net.minecraft.world.InteractionHand import net.minecraft.world.InteractionResult import net.minecraft.world.entity.player.Player import net.minecraft.world.item.DyeColor -import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block @@ -21,16 +18,21 @@ import net.minecraft.world.phys.BlockHitResult import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.MatteryBlock +import ru.dbotthepony.mc.otm.block.addSimpleDescription import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity -import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes class AndroidStationBlock(val color: DyeColor?) : MatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { + init { + tooltips.painted(color) + addSimpleDescription() + tooltips.blockEntityEnergy() + } + override fun use( blockState: BlockState, level: Level, @@ -52,17 +54,6 @@ class AndroidStationBlock(val color: DyeColor?) : MatteryBlock(DEFAULT_MACHINE_P builder.add(WorkerState.SEMI_WORKER_STATE) } - override fun appendHoverText( - itemStack: ItemStack, - blockAccessor: BlockGetter?, - components: MutableList, - tooltipType: TooltipFlag - ) { - super.appendHoverText(itemStack, blockAccessor, components, tooltipType) - WorkerEnergyStorage.appendHoverText(itemStack, blockAccessor, components, tooltipType) - MatteryPoweredBlockEntity.appendHoverText(itemStack, blockAccessor, components, tooltipType) - } - override fun getShape( p_151964_: BlockState, p_151965_: BlockGetter, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt index 9bee0b46c..c3aefe016 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt @@ -1,32 +1,31 @@ package ru.dbotthepony.mc.otm.block.tech -import com.google.common.collect.ImmutableList -import net.minecraft.MethodsReturnNonnullByDefault -import javax.annotation.ParametersAreNonnullByDefault -import net.minecraft.world.level.block.EntityBlock -import net.minecraft.world.item.context.BlockPlaceContext -import net.minecraft.world.level.block.state.BlockState -import net.minecraft.world.level.block.state.properties.BooleanProperty -import net.minecraft.world.level.block.entity.BlockEntity -import net.minecraft.world.level.block.entity.BlockEntityType -import net.minecraft.world.level.block.entity.BlockEntityTicker -import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.core.BlockPos import net.minecraft.world.item.DyeColor -import ru.dbotthepony.mc.otm.block.entity.tech.BatteryBankBlockEntity +import net.minecraft.world.item.context.BlockPlaceContext import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level -import net.minecraft.world.level.block.Block +import net.minecraft.world.level.block.EntityBlock +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.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.addSimpleDescription +import ru.dbotthepony.mc.otm.block.entity.tech.BatteryBankBlockEntity import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get -import ru.dbotthepony.mc.otm.oncePre import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes class BatteryBankBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { + init { + tooltips.painted(color) + addSimpleDescription() + } + override fun getTicker( level: Level, p_153213_: BlockState, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt index a70403517..fd583d471 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt @@ -1,10 +1,7 @@ package ru.dbotthepony.mc.otm.block.tech import net.minecraft.core.BlockPos -import net.minecraft.network.chat.Component import net.minecraft.world.item.DyeColor -import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block @@ -17,15 +14,21 @@ import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.addSimpleDescription import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.getShapeForEachState -import ru.dbotthepony.mc.otm.capability.energy.GeneratorEnergyStorage import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes class ChemicalGeneratorBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { + init { + tooltips.painted(color) + addSimpleDescription() + tooltips.blockEntityEnergy() + } + override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return ChemicalGeneratorBlockEntity(p_153215_, p_153216_) } @@ -46,16 +49,6 @@ class ChemicalGeneratorBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAU builder.add(WorkerState.SEMI_WORKER_STATE) } - override fun appendHoverText( - itemStack: ItemStack, - blockAccessor: BlockGetter?, - tooltips: MutableList, - tooltipType: TooltipFlag - ) { - super.appendHoverText(itemStack, blockAccessor, tooltips, tooltipType) - GeneratorEnergyStorage.appendHoverText(itemStack, blockAccessor, tooltips, tooltipType) - } - private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.CHEMICAL_GENERATOR.rotateFromNorth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") 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 112bf0bc0..84fe20bed 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 @@ -17,7 +17,6 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.block.entity.tech.CobblerBlockEntity import ru.dbotthepony.mc.otm.core.get -import ru.dbotthepony.mc.otm.core.needsNoPowerDescription import ru.dbotthepony.mc.otm.shapes.BlockShapes class CobblerBlock(val color: DyeColor?) : RotatableMatteryBlock(Properties.of().mapColor(color?.mapColor ?: MapColor.METAL).pushReaction(PushReaction.BLOCK).requiresCorrectToolForDrops().destroyTime(1.5f).explosionResistance(25.0f)), EntityBlock { @@ -38,7 +37,8 @@ class CobblerBlock(val color: DyeColor?) : RotatableMatteryBlock(Properties.of() } init { - needsNoPowerDescription() + tooltips.needsNoPower() + tooltips.painted(color) } private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.COBBLESTONE_GENERATOR.rotateFromNorth(it[rotationProperty]).computeShape() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyCounterBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyCounterBlock.kt index 818675b46..900dfce06 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyCounterBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyCounterBlock.kt @@ -19,6 +19,7 @@ import net.minecraft.world.level.block.state.properties.EnumProperty import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.MatteryBlock +import ru.dbotthepony.mc.otm.block.addSimpleDescription import ru.dbotthepony.mc.otm.block.entity.tech.EnergyCounterBlockEntity import ru.dbotthepony.mc.otm.core.asSupplier import ru.dbotthepony.mc.otm.core.collect.SupplierMap @@ -28,6 +29,14 @@ import java.util.concurrent.Callable import java.util.function.Supplier class EnergyCounterBlock(val color: DyeColor?) : MatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { + init { + tooltips.painted(color) + addSimpleDescription() + addSimpleDescription("2") + addSimpleDescription("3") + addSimpleDescription("4") + } + override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return EnergyCounterBlockEntity(blockPos, blockState) } @@ -124,7 +133,7 @@ class EnergyCounterBlock(val color: DyeColor?) : MatteryBlock(DEFAULT_MACHINE_PR } companion object { - @JvmField val INPUT_DIRECTION: EnumProperty = EnumProperty.create("input", Direction::class.java) - @JvmField val IF_DIRECTION: EnumProperty = EnumProperty.create("if", Direction::class.java) + val INPUT_DIRECTION: EnumProperty = EnumProperty.create("input", Direction::class.java) + val IF_DIRECTION: EnumProperty = EnumProperty.create("if", Direction::class.java) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt index df08c8bfd..76ef73673 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt @@ -22,6 +22,11 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes class EnergyServoBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { + init { + tooltips.painted(color) + addSimpleDescription() + } + override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return EnergyServoBlockEntity(p_153215_, p_153216_) } @@ -38,10 +43,6 @@ class EnergyServoBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MAC return null } - init { - addSimpleDescription() - } - private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.ENERGY_SERVO.rotateFromNorth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EssenceStorageBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EssenceStorageBlock.kt index e57d06360..c87982755 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EssenceStorageBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EssenceStorageBlock.kt @@ -1,6 +1,8 @@ package ru.dbotthepony.mc.otm.block.tech +import net.minecraft.ChatFormatting import net.minecraft.core.BlockPos +import net.minecraft.nbt.LongTag import net.minecraft.world.InteractionHand import net.minecraft.world.InteractionResult import net.minecraft.world.entity.player.Player @@ -21,11 +23,29 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.addSimpleDescription import ru.dbotthepony.mc.otm.block.entity.tech.EssenceStorageBlockEntity import ru.dbotthepony.mc.otm.block.getShapeForEachState +import ru.dbotthepony.mc.otm.client.isShiftDown +import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.core.util.getLevelFromXp import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.shapes.BlockShapes class EssenceStorageBlock(val color: DyeColor?) : RotatableMatteryBlock(Properties.of().mapColor(color?.mapColor ?: MapColor.METAL).pushReaction(PushReaction.BLOCK).requiresCorrectToolForDrops().destroyTime(1.5f).explosionResistance(60.0f)), EntityBlock { + init { + tooltips.painted(color) + + addSimpleDescription() + + tooltips.blockEntityData("experienceStored") { _, l, acceptor -> + if (minecraft.window.isShiftDown) { + acceptor(TranslatableComponent("otm.gui.experience", l.asLong).withStyle(ChatFormatting.GRAY)) + } else { + acceptor(TranslatableComponent("otm.gui.experience_levels", getLevelFromXp(l.asLong)).withStyle(ChatFormatting.GRAY)) + } + } + } + override fun newBlockEntity(pPos: BlockPos, pState: BlockState): BlockEntity { return EssenceStorageBlockEntity(pPos, pState) } @@ -47,10 +67,6 @@ class EssenceStorageBlock(val color: DyeColor?) : RotatableMatteryBlock(Properti return super.use(blockState, level, blockPos, ply, hand, blockHitResult) } - init { - addSimpleDescription() - } - private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.ESSENCE_STORAGE.rotateFromNorth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt index fb79e1f1a..88de99688 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt @@ -33,7 +33,6 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.math.times -import ru.dbotthepony.mc.otm.core.needsNoPowerDescription import ru.dbotthepony.mc.otm.core.runInBackground import ru.dbotthepony.mc.otm.oncePre import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -44,6 +43,13 @@ import kotlin.math.PI private val props = BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BLUE).sound(SoundType.METAL).pushReaction(PushReaction.BLOCK).requiresCorrectToolForDrops().strength(3f, 600.0f) class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock { + init { + addSimpleDescription() + tooltips.needsNoPower(ChatFormatting.DARK_GRAY) + addSimpleDescription("2", ChatFormatting.DARK_GRAY) + addSimpleDescription("3", ChatFormatting.DARK_GRAY) + } + override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return GravitationStabilizerBlockEntity(p_153215_, p_153216_) } @@ -145,13 +151,6 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock { return shapes[p_60555_[BlockRotationFreedom.DIRECTIONAL].ordinal] } - init { - addSimpleDescription() - needsNoPowerDescription(ChatFormatting.DARK_GRAY) - addSimpleDescription("2", ChatFormatting.DARK_GRAY) - addSimpleDescription("3", ChatFormatting.DARK_GRAY) - } - companion object { private val shapes = SupplierList.ofFuture( runInBackground { BlockShapes.GRAVITATION_STABILIZER.rotateAroundX(PI / 2).computeShape() }, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt index 54f6b1bc1..d5b11d0f8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt @@ -32,12 +32,16 @@ import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.minus import ru.dbotthepony.mc.otm.core.math.plus -import ru.dbotthepony.mc.otm.core.needsNoPowerDescription import ru.dbotthepony.mc.otm.once import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.shapes.BlockShapes class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of().mapColor(MapColor.COLOR_BLUE).sound(SoundType.METAL).pushReaction(PushReaction.BLOCK).destroyTime(3f).explosionResistance(12f).randomTicks()) { + init { + addSimpleDescription() + tooltips.needsNoPower() + } + @Suppress("OVERRIDE_DEPRECATION") override fun randomTick( blockState: BlockState, @@ -136,9 +140,4 @@ class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of().mapColor(Map } } } - - init { - addSimpleDescription() - needsNoPowerDescription() - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt index 8bafde210..cc6606a5e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt @@ -1,10 +1,7 @@ package ru.dbotthepony.mc.otm.block.tech import net.minecraft.core.BlockPos -import net.minecraft.network.chat.Component import net.minecraft.world.item.DyeColor -import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block @@ -19,14 +16,19 @@ 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 -import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity -import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.shapes.BlockShapes class PlatePressBlock(val color: DyeColor?, val isTwin: Boolean = false) : RotatableMatteryBlock(Properties.of().mapColor(color?.mapColor ?: MapColor.METAL).pushReaction(PushReaction.BLOCK).requiresCorrectToolForDrops().destroyTime(1.5f).explosionResistance(25.0f)), EntityBlock { + init { + tooltips.colored(color) + if (isTwin) tooltips.doubleProcessing() + tooltips.blockEntityEnergy() + } + override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return PlatePressBlockEntity(p_153215_, p_153216_, isTwin) } @@ -47,16 +49,6 @@ class PlatePressBlock(val color: DyeColor?, val isTwin: Boolean = false) : Rotat builder.add(WorkerState.WORKER_STATE) } - override fun appendHoverText( - itemStack: ItemStack, - blockAccessor: BlockGetter?, - components: MutableList, - tooltipType: TooltipFlag - ) { - super.appendHoverText(itemStack, blockAccessor, components, tooltipType) - MatteryWorkerBlockEntity.appendHoverText(itemStack, blockAccessor, components, tooltipType) - } - private val shapes = getShapeForEachState(rotationProperty) { (if (isTwin) BlockShapes.TWIN_PLATE_PRESS_IDLE else BlockShapes.PLATE_PRESS_IDLE).rotateFromNorth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt index f7e7c73a4..ecc314620 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt @@ -289,13 +289,13 @@ fun moveEnergy(source: IEnergyStorage, destination: IEnergyStorage, amount: Deci return Decimal.ZERO } -internal fun IFluidHandler.fluidLevel(tooltips: MutableList) { +internal fun IFluidHandler.fluidLevel(tooltips: (Component) -> Unit) { val fluid = getFluidInTank(0) if (fluid.isEmpty) { - tooltips.add(formatFluidLevel(0, getTankCapacity(0), formatAsReadable = ShiftPressedCond).withStyle(ChatFormatting.GRAY)) + tooltips(formatFluidLevel(0, getTankCapacity(0), formatAsReadable = ShiftPressedCond).withStyle(ChatFormatting.GRAY)) } else { - tooltips.add(formatFluidLevel(fluid.amount, getTankCapacity(0), fluid.displayName, formatAsReadable = ShiftPressedCond).withStyle(ChatFormatting.GRAY)) + tooltips(formatFluidLevel(fluid.amount, getTankCapacity(0), fluid.displayName, formatAsReadable = ShiftPressedCond).withStyle(ChatFormatting.GRAY)) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt index 759743990..0bccbbc74 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt @@ -93,72 +93,72 @@ interface IMatteryUpgrade { private val positiveBound = Decimal("0.01") private val negativeBound = Decimal("-0.01") -fun IMatteryUpgrade.addUpgradeTooltipLines(tooltips: MutableCollection) { +fun IMatteryUpgrade.addUpgradeTooltipLines(tooltips: (Component) -> Unit) { if (upgradeTypes.isNotEmpty() && ShiftPressedCond.asBoolean) { - tooltips.add(TranslatableComponent("otm.gui.upgrade_type.list").withStyle(ChatFormatting.GRAY)) + tooltips(TranslatableComponent("otm.gui.upgrade_type.list").withStyle(ChatFormatting.GRAY)) for (upgrade in upgradeTypes) { - tooltips.add(upgrade.component.copy().withStyle(ChatFormatting.GRAY)) + tooltips(upgrade.component.copy().withStyle(ChatFormatting.GRAY)) } - tooltips.add(TextComponent("")) + tooltips(TextComponent("")) } val actualSpeedBonus = speedBonus.coerceIn(MachinesConfig.Upgrades.MIN_SPEED, MachinesConfig.Upgrades.MAX_SPEED) val speedBonusLimit = if (actualSpeedBonus == MachinesConfig.Upgrades.MIN_SPEED || actualSpeedBonus == MachinesConfig.Upgrades.MAX_SPEED) "_limit" else "" if (speedBonus >= 0.01) { - tooltips.add(TranslatableComponent("otm.gui.upgrade.speed$speedBonusLimit", TextComponent("+" + (actualSpeedBonus * 100.0).toInt().toString()).withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) + tooltips(TranslatableComponent("otm.gui.upgrade.speed$speedBonusLimit", TextComponent("+" + (actualSpeedBonus * 100.0).toInt().toString()).withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) } else if (speedBonus <= -0.01) { - tooltips.add(TranslatableComponent("otm.gui.upgrade.speed$speedBonusLimit", TextComponent((actualSpeedBonus * 100.0).toInt().toString()).withStyle(ChatFormatting.DARK_RED)).withStyle(ChatFormatting.GRAY)) + tooltips(TranslatableComponent("otm.gui.upgrade.speed$speedBonusLimit", TextComponent((actualSpeedBonus * 100.0).toInt().toString()).withStyle(ChatFormatting.DARK_RED)).withStyle(ChatFormatting.GRAY)) } if (processingItems != 0) { - tooltips.add(TranslatableComponent("otm.gui.upgrade.processing_items", TextComponent(processingItems.toString()).withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) + tooltips(TranslatableComponent("otm.gui.upgrade.processing_items", TextComponent(processingItems.toString()).withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) } if (energyStorageFlat != Decimal.ZERO) { - tooltips.add(TranslatableComponent("otm.gui.upgrade.energy_storage_flat", energyStorageFlat.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) + tooltips(TranslatableComponent("otm.gui.upgrade.energy_storage_flat", energyStorageFlat.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) } if (energyStorage != Decimal.ZERO) { - tooltips.add(TranslatableComponent("otm.gui.upgrade.energy_storage", TextComponent((energyStorage * 100).toString(0)).withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) + tooltips(TranslatableComponent("otm.gui.upgrade.energy_storage", TextComponent((energyStorage * 100).toString(0)).withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) } if (matterStorageFlat != Decimal.ZERO) { - tooltips.add(TranslatableComponent("otm.gui.upgrade.matter_storage_flat", matterStorageFlat.formatMatter(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) + tooltips(TranslatableComponent("otm.gui.upgrade.matter_storage_flat", matterStorageFlat.formatMatter(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) } if (matterStorage != Decimal.ZERO) { - tooltips.add(TranslatableComponent("otm.gui.upgrade.matter_storage", TextComponent((matterStorage * 100).toString(0)).withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) + tooltips(TranslatableComponent("otm.gui.upgrade.matter_storage", TextComponent((matterStorage * 100).toString(0)).withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) } val actualEnergyConsumed = energyConsumed.coerceIn(MachinesConfig.Upgrades.MIN_ENERGY, MachinesConfig.Upgrades.MAX_ENERGY) val consumedLimit = if (actualEnergyConsumed == MachinesConfig.Upgrades.MIN_ENERGY || actualEnergyConsumed == MachinesConfig.Upgrades.MAX_ENERGY) "_limit" else "" if (energyConsumed >= positiveBound) { - tooltips.add(TranslatableComponent("otm.gui.upgrade.energy_consumed$consumedLimit", TextComponent("+" + (actualEnergyConsumed * 100).toString(0)).withStyle(ChatFormatting.DARK_RED)).withStyle(ChatFormatting.GRAY)) + tooltips(TranslatableComponent("otm.gui.upgrade.energy_consumed$consumedLimit", TextComponent("+" + (actualEnergyConsumed * 100).toString(0)).withStyle(ChatFormatting.DARK_RED)).withStyle(ChatFormatting.GRAY)) } else if (energyConsumed <= negativeBound) { - tooltips.add(TranslatableComponent("otm.gui.upgrade.energy_consumed$consumedLimit", TextComponent((actualEnergyConsumed * 100).toString(0)).withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) + tooltips(TranslatableComponent("otm.gui.upgrade.energy_consumed$consumedLimit", TextComponent((actualEnergyConsumed * 100).toString(0)).withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) } if (energyThroughputFlat != Decimal.ZERO) { - tooltips.add(TranslatableComponent("otm.gui.upgrade.energy_throughput_flat", energyThroughputFlat.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) + tooltips(TranslatableComponent("otm.gui.upgrade.energy_throughput_flat", energyThroughputFlat.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) } if (energyThroughput != Decimal.ZERO) { - tooltips.add(TranslatableComponent("otm.gui.upgrade.energy_throughput", TextComponent((energyThroughput * 100).toString(0)).withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) + tooltips(TranslatableComponent("otm.gui.upgrade.energy_throughput", TextComponent((energyThroughput * 100).toString(0)).withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) } if (failureMultiplier >= 1.01) { - tooltips.add(TranslatableComponent("otm.gui.upgrade.failsafe", TextComponent("+" + ((failureMultiplier - 1) * 100).toInt().toString()).withStyle(ChatFormatting.DARK_RED)).withStyle(ChatFormatting.GRAY)) + tooltips(TranslatableComponent("otm.gui.upgrade.failsafe", TextComponent("+" + ((failureMultiplier - 1) * 100).toInt().toString()).withStyle(ChatFormatting.DARK_RED)).withStyle(ChatFormatting.GRAY)) } else if (failureMultiplier <= 0.99) { - tooltips.add(TranslatableComponent("otm.gui.upgrade.failsafe", TextComponent(((failureMultiplier.coerceAtLeast(0.0) - 1) * 100).toInt().toString()).withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) + tooltips(TranslatableComponent("otm.gui.upgrade.failsafe", TextComponent(((failureMultiplier.coerceAtLeast(0.0) - 1) * 100).toInt().toString()).withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) } } fun IMatteryUpgrade.getUpgradeTooltipLines(): MutableList { - return ArrayList().also { addUpgradeTooltipLines(it) } + return ArrayList().also { addUpgradeTooltipLines(it::add) } } interface ITieredUpgradeSet { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt index 0c9dd586a..997474504 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt @@ -4,21 +4,12 @@ package ru.dbotthepony.mc.otm.capability.energy import net.minecraft.nbt.CompoundTag -import net.minecraft.network.chat.Component -import net.minecraft.world.item.BlockItem -import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.TooltipFlag -import net.minecraft.world.level.BlockGetter -import net.minecraft.world.level.block.entity.BlockEntity -import net.minecraftforge.common.ForgeConfigSpec import net.minecraftforge.common.util.INBTSerializable import net.minecraftforge.common.util.LazyOptional -import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity +import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.config.EnergyBalanceValues import ru.dbotthepony.mc.otm.config.VerboseEnergyBalanceValues -import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.core.nbt.mapPresent import ru.dbotthepony.mc.otm.core.nbt.set @@ -158,19 +149,6 @@ open class WorkerEnergyStorage( listener: () -> Unit, values: VerboseEnergyBalanceValues ) : this(listener, values::energyCapacity, values::maxEnergyReceive, values::maxEnergyExtract) - - companion object { - fun appendHoverText(itemStack: ItemStack, tooltips: MutableList) { - val tag = (itemStack.tag?.get(BlockItem.BLOCK_ENTITY_TAG) as? CompoundTag)?.get(MatteryBlockEntity.ENERGY_KEY) as? CompoundTag ?: return - val cap = WorkerEnergyStorage({}, { DEFAULT_MAX_CAPACITY }) - cap.deserializeNBT(tag) - batteryLevel(cap, tooltips, false) - } - - fun appendHoverText(itemStack: ItemStack, blockGetter: BlockGetter?, tooltips: MutableList, flag: TooltipFlag) { - return appendHoverText(itemStack, tooltips) - } - } } open class GeneratorEnergyStorage( @@ -188,19 +166,6 @@ open class GeneratorEnergyStorage( listener: () -> Unit, values: VerboseEnergyBalanceValues ) : this(listener, values::energyCapacity, values::maxEnergyReceive, values::maxEnergyExtract) - - companion object { - fun appendHoverText(itemStack: ItemStack, tooltips: MutableList) { - val tag = (itemStack.tag?.get(BlockItem.BLOCK_ENTITY_TAG) as? CompoundTag)?.get(MatteryBlockEntity.ENERGY_KEY) as? CompoundTag ?: return - val cap = GeneratorEnergyStorage({}, { DEFAULT_MAX_CAPACITY }) - cap.deserializeNBT(tag) - batteryLevel(cap, tooltips) - } - - fun appendHoverText(itemStack: ItemStack, blockGetter: BlockGetter?, tooltips: MutableList, flag: TooltipFlag) { - return appendHoverText(itemStack, tooltips) - } - } } open class CapacitorEnergyStorage( @@ -218,17 +183,4 @@ open class CapacitorEnergyStorage( listener: () -> Unit, values: VerboseEnergyBalanceValues ) : this(listener, values::energyCapacity, values::maxEnergyReceive, values::maxEnergyExtract) - - companion object { - fun appendHoverText(itemStack: ItemStack, tooltips: MutableList) { - val tag = (itemStack.tag?.get(BlockItem.BLOCK_ENTITY_TAG) as? CompoundTag)?.get(MatteryBlockEntity.ENERGY_KEY) as? CompoundTag ?: return - val cap = CapacitorEnergyStorage({}, { DEFAULT_MAX_CAPACITY }) - cap.deserializeNBT(tag) - batteryLevel(cap, tooltips) - } - - fun appendHoverText(itemStack: ItemStack, blockGetter: BlockGetter?, tooltips: MutableList, flag: TooltipFlag) { - return appendHoverText(itemStack, tooltips) - } - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt index 9903b26db..9cbf683af 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt @@ -14,8 +14,8 @@ sealed interface IEnergyStorageImpl { val maxOutput: Decimal? } -internal fun batteryLevel(it: IEnergyStorage, tooltips: MutableList) { - tooltips.add( +internal fun batteryLevel(it: IEnergyStorage, tooltips: (Component) -> Unit) { + tooltips( TranslatableComponent( "otm.item.power.storage", it.energyStored.formatPower(formatAsReadable = ShiftPressedCond), @@ -23,16 +23,16 @@ internal fun batteryLevel(it: IEnergyStorage, tooltips: MutableList) ).withStyle(ChatFormatting.GRAY)) } -internal fun batteryLevel(it: IMatteryEnergyStorage, tooltips: MutableList, displayMaxLevel: Boolean = true) { +internal fun batteryLevel(it: IMatteryEnergyStorage, tooltips: (Component) -> Unit, displayMaxLevel: Boolean = true) { if (displayMaxLevel) - tooltips.add( + tooltips( TranslatableComponent( "otm.item.power.storage", it.batteryLevel.formatPower(formatAsReadable = ShiftPressedCond), it.maxBatteryLevel.formatPower(formatAsReadable = ShiftPressedCond) ).withStyle(ChatFormatting.GRAY)) else - tooltips.add( + tooltips( TranslatableComponent( "otm.item.power.storage0", it.batteryLevel.formatPower(formatAsReadable = ShiftPressedCond) @@ -41,68 +41,20 @@ internal fun batteryLevel(it: IMatteryEnergyStorage, tooltips: MutableList { - if (it.maxInput != null) { - tooltips.add( - TranslatableComponent("otm.item.power.throughput_mono", it.maxInput!!.formatPower(formatAsReadable = ShiftPressedCond)).withStyle( - ChatFormatting.GRAY - )) - } else { - tooltips.add( - TranslatableComponent( - "otm.item.power.throughput_mono", - TranslatableComponent("otm.item.power.infinity").withStyle(ChatFormatting.GRAY) - ).withStyle(ChatFormatting.GRAY)) - } + tooltips(TranslatableComponent("otm.item.power.throughput_mono", (it.maxInput ?: Decimal.POSITIVE_INFINITY).formatPower(formatAsReadable = ShiftPressedCond)).withStyle(ChatFormatting.GRAY)) } FlowDirection.OUTPUT -> { - if (it.maxOutput != null) { - tooltips.add( - TranslatableComponent("otm.item.power.throughput_mono", it.maxOutput!!.formatPower(formatAsReadable = ShiftPressedCond)).withStyle( - ChatFormatting.GRAY - )) - } else { - tooltips.add( - TranslatableComponent( - "otm.item.power.throughput_mono", - TranslatableComponent("otm.item.power.infinity").withStyle(ChatFormatting.GRAY) - ).withStyle(ChatFormatting.GRAY)) - } + tooltips(TranslatableComponent("otm.item.power.throughput_mono", (it.maxOutput ?: Decimal.POSITIVE_INFINITY).formatPower(formatAsReadable = ShiftPressedCond)).withStyle(ChatFormatting.GRAY)) } FlowDirection.BI_DIRECTIONAL -> { - val maxInput = it.maxInput - val maxOutput = it.maxOutput - - if (maxInput != null && maxOutput != null) { - tooltips.add( - TranslatableComponent( - "otm.item.power.throughput", - maxInput.formatPower(formatAsReadable = ShiftPressedCond), - maxOutput.formatPower(formatAsReadable = ShiftPressedCond) - ).withStyle(ChatFormatting.GRAY)) - } else if (maxInput != null) { - tooltips.add( - TranslatableComponent( - "otm.item.power.throughput", - maxInput.formatPower(formatAsReadable = ShiftPressedCond), - TranslatableComponent("otm.item.power.infinity").withStyle(ChatFormatting.GRAY) - ).withStyle(ChatFormatting.GRAY)) - } else if (maxOutput != null) { - tooltips.add( - TranslatableComponent( - "otm.item.power.throughput", - TranslatableComponent("otm.item.power.infinity").withStyle(ChatFormatting.GRAY), - maxOutput.formatPower(formatAsReadable = ShiftPressedCond), - ).withStyle(ChatFormatting.GRAY)) - } else { - tooltips.add( - TranslatableComponent( - "otm.item.power.throughput", - TranslatableComponent("otm.item.power.infinity").withStyle(ChatFormatting.GRAY), - TranslatableComponent("otm.item.power.infinity").withStyle(ChatFormatting.GRAY), - ).withStyle(ChatFormatting.GRAY)) - } + tooltips( + TranslatableComponent( + "otm.item.power.throughput", + (it.maxInput ?: Decimal.POSITIVE_INFINITY).formatPower(formatAsReadable = ShiftPressedCond), + (it.maxOutput ?: Decimal.POSITIVE_INFINITY).formatPower(formatAsReadable = ShiftPressedCond) + ).withStyle(ChatFormatting.GRAY)) } FlowDirection.NONE -> {} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt index 86b0916eb..44268e9ab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt @@ -12,6 +12,7 @@ import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy +import ru.dbotthepony.mc.otm.core.TooltipList import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set @@ -73,20 +74,6 @@ abstract class ItemEnergyStorageImpl(val itemStack: ItemStack) : IMatteryEnergyS companion object { const val ENERGY_KEY = "energy" - - fun appendHoverText(itemStack: ItemStack, level: Level?, tooltips: MutableList, flag: TooltipFlag) { - appendHoverText(itemStack, tooltips) - } - - fun appendHoverText(itemStack: ItemStack, tooltips: MutableList) { - val energy = itemStack.energy ?: return - - if (energy is IMatteryEnergyStorage) { - batteryLevel(energy, tooltips) - } else { - batteryLevel(energy, tooltips) - } - } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt index f15c6780c..dbcb66cee 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt @@ -8,7 +8,7 @@ import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.nbt.set -open class MatterStorageImpl @JvmOverloads constructor( +open class MatterStorageImpl( protected val listener: Runnable?, override val matterFlow: FlowDirection, protected val maxStoredMatterSupplier: () -> Decimal, @@ -93,7 +93,7 @@ open class MatterStorageImpl @JvmOverloads constructor( override fun serializeNBT(): CompoundTag { return CompoundTag().also { - it["stored"] = storedMatter.serializeNBT() + it[MATTER_STORED_KEY] = storedMatter.serializeNBT() //it["max_storage"] = maxStoredMatter.serializeNBT() //if (maxReceive != null) it["max_receive"] = maxReceive.serializeNBT() //if (maxExtract != null) it["max_extract"] = maxExtract.serializeNBT() @@ -102,9 +102,13 @@ open class MatterStorageImpl @JvmOverloads constructor( override fun deserializeNBT(tag: CompoundTag?) { if (tag == null) return - storedMatter = Decimal.deserializeNBT(tag["stored"]) + storedMatter = Decimal.deserializeNBT(tag[MATTER_STORED_KEY]) //maxStoredMatter = ImpreciseFraction.deserializeNBT(tag["max_storage"]) //maxReceive = if (tag.contains("max_receive")) ImpreciseFraction.deserializeNBT(tag["max_receive"]) else null //maxExtract = if (tag.contains("max_extract")) ImpreciseFraction.deserializeNBT(tag["max_extract"]) else null } + + companion object { + const val MATTER_STORED_KEY = "stored" + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt index 84d7d1da4..806da8d41 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt @@ -3,13 +3,11 @@ package ru.dbotthepony.mc.otm.client.render import com.mojang.blaze3d.platform.GlStateManager import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.* -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.renderer.GameRenderer import net.minecraft.client.renderer.RenderStateShard import net.minecraft.client.renderer.RenderStateShard.LineStateShard import net.minecraft.client.renderer.RenderType import net.minecraft.client.renderer.ShaderInstance -import net.minecraft.client.renderer.texture.TextureAtlasSprite import net.minecraft.resources.ResourceLocation import net.minecraft.server.packs.resources.ResourceProvider import org.apache.logging.log4j.LogManager @@ -294,9 +292,15 @@ fun drawLine( tess.end() } -data class ScissorRect(val x: Int, val y: Int, val width: Int, val height: Int, val lock: Boolean = false) { +data class ScissorRect(val xStart: Int, val yStart: Int, val xEnd: Int, val yEnd: Int, val lock: Boolean = false) { + val width: Int + get() = (xEnd - xStart).coerceAtLeast(0) + + val height: Int + get() = (yEnd - yStart).coerceAtLeast(0) + fun withinBounds(x: Int, y: Int): Boolean { - return (x in this.x .. this.x + width) && (y in this.y .. this.y + height) + return (x in this.xStart .. xEnd) && (y in this.yStart .. yEnd) } fun cross(x: Int, y: Int, width: Int, height: Int): Boolean { @@ -306,18 +310,18 @@ data class ScissorRect(val x: Int, val y: Int, val width: Int, val height: Int, } // crossing at least one line - if (y in this.y .. this.y + height) { - if (x < this.x && x + width > this.x + this.width) { + if (y in this.yStart .. this.yStart + height) { + if (x < this.xStart && x + width > this.xEnd) { return true } - } else if (x in this.x .. this.x + width) { - if (y < this.y && y + height > this.y + this.height) { + } else if (x in this.xStart .. this.xStart + width) { + if (y < this.yStart && y + height > this.yEnd) { return true } } // final test: check if scissor rect is completely inside provided rect - return this.x in x .. x + width && this.y in y .. y + height + return this.xStart in x .. x + width && this.yStart in y .. y + height } fun crossScaled(x: Float, y: Float, width: Float, height: Float): Boolean { @@ -329,17 +333,20 @@ data class ScissorRect(val x: Int, val y: Int, val width: Int, val height: Int, val scale = minecraft.window.guiScale return cross((x * scale).roundToInt(), (y * scale).roundToInt(), (width * scale).roundToInt(), (height * scale).roundToInt()) } + + fun apply() { + RenderSystem.enableScissor(xStart, minecraft.window.height - yStart - height, width, height) + } } private val scissorStack = ArrayDeque() -@Suppress("NAME_SHADOWING") @JvmOverloads fun pushScissorRect(x: Int, y: Int, width: Int, height: Int, lock: Boolean = false) { - var x = x - var y = y - var width = width - var height = height + var xStart = x + var yStart = y + var xEnd = x + width + var yEnd = y + height val peek = scissorStack.lastOrNull() @@ -349,34 +356,31 @@ fun pushScissorRect(x: Int, y: Int, width: Int, height: Int, lock: Boolean = fal return } - x = x.coerceAtLeast(peek.x) - y = y.coerceAtLeast(peek.y) - width = width.coerceAtMost(peek.width) - height = height.coerceAtMost(peek.height) + xStart = xStart.coerceAtLeast(peek.xStart) + yStart = yStart.coerceAtLeast(peek.yStart) + xEnd = xEnd.coerceAtMost(peek.xEnd) + yEnd = yEnd.coerceAtMost(peek.yEnd) - if (peek.x == x && peek.y == y && peek.width == width && peek.height == height) { + if (peek.xStart == xStart && peek.yStart == yStart && peek.xEnd == xEnd && peek.yEnd == yEnd) { scissorStack.add(peek) return } } - scissorStack.add(ScissorRect(x, y, width, height, lock)) - y = minecraft.window.height - y - height - RenderSystem.enableScissor(x, y, width, height) + val new = ScissorRect(xStart, yStart, xEnd, yEnd, lock) + scissorStack.add(new) + new.apply() } fun popScissorRect() { scissorStack.removeLast() - val peek = scissorStack.lastOrNull() if (peek == null) { RenderSystem.disableScissor() - return + } else { + peek.apply() } - - val y = minecraft.window.height - peek.y - peek.height - RenderSystem.enableScissor(peek.x, y, peek.width, peek.height) } val currentScissorRect get() = scissorStack.lastOrNull() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt index 533c5b2b0..4294e9a7f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt @@ -233,6 +233,12 @@ open class EditablePanel( parent?.boundsInvalidated = true } + val effectiveWidth: Float + get() = width - dockPadding.horizontal + + val effectiveHeight: Float + get() = height - dockPadding.vertical + /** * Width of this panel as considered by docking code, updated inside [performLayout] * @@ -1147,7 +1153,7 @@ open class EditablePanel( if (child.dockResize.changeHeight) child.height = child.dockedHeight else if (child.height != child.dockedHeight) - child.y += child.dockedHeight / 2f - child.height / 2f + child.y += (child.dockedHeight / 2f - child.height / 2f).roundToInt().toFloat() } Dock.RIGHT -> { @@ -1161,7 +1167,7 @@ open class EditablePanel( if (child.dockResize.changeHeight) child.height = child.dockedHeight else if (child.height != child.dockedHeight) - child.y += child.dockedHeight / 2f - child.height / 2f + child.y += (child.dockedHeight / 2f - child.height / 2f).roundToInt().toFloat() } Dock.TOP -> { @@ -1175,7 +1181,7 @@ open class EditablePanel( if (child.dockResize.changeWidth) child.width = child.dockedWidth else if (child.width != child.dockedWidth) - child.x += child.dockedWidth / 2f - child.width / 2f + child.x += (child.dockedWidth / 2f - child.width / 2f).roundToInt().toFloat() } Dock.BOTTOM -> { @@ -1189,7 +1195,7 @@ open class EditablePanel( if (child.dockResize.changeWidth) child.width = child.dockedWidth else if (child.width != child.dockedWidth) - child.x += child.dockedWidth / 2f - child.width / 2f + child.x += (child.dockedWidth / 2f - child.width / 2f).roundToInt().toFloat() } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/Buttons.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/Buttons.kt index 9d6c1ded8..84bf87450 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/Buttons.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/Buttons.kt @@ -502,7 +502,7 @@ class DeviceControls>( } val i = it.size - upgrades.currentStats.addUpgradeTooltipLines(it) + upgrades.currentStats.addUpgradeTooltipLines(it::add) if (it.size != i) { it.add(i, TranslatableComponent("otm.gui.upgrades.current").withStyle(ChatFormatting.GRAY)) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/BackgroundPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/BackgroundPanel.kt index c2f416be8..5a6955b6f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/BackgroundPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/BackgroundPanel.kt @@ -19,8 +19,17 @@ open class BackgroundPanel( dockPadding = DockProperty(3f, 3f, 3f, 3f) } + var drawBackground = true + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { - RECTANGLE.render(graphics, width = width, height = height) + if (drawBackground) { + RECTANGLE.render(graphics, width = width, height = height) + } + } + + fun removeBackground() { + dockPadding = DockProperty.EMPTY + drawBackground = false } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/AbstractProcessingMachineScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/AbstractProcessingMachineScreen.kt new file mode 100644 index 000000000..87cbf79c8 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/AbstractProcessingMachineScreen.kt @@ -0,0 +1,83 @@ +package ru.dbotthepony.mc.otm.client.screen.tech + +import net.minecraft.network.chat.Component +import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.Dock +import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.ScrollbarBackgroundPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls +import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel +import ru.dbotthepony.mc.otm.compat.jei.isJeiLoaded +import ru.dbotthepony.mc.otm.menu.tech.AbstractProcessingMachineMenu +import kotlin.math.roundToInt + +open class AbstractProcessingMachineScreen(menu: M, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { + override fun makeMainFrame(): FramePanel> { + val frame = super.makeMainFrame()!! + + WideProfiledPowerGaugePanel(this, frame, menu.profiledEnergy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) + BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) + + val height = menu.processingTuples.size * (AbstractSlotPanel.SIZE + 2f) - 2f + + val progressPanels = ArrayList>() + + val parentTarget = if (height >= frame.effectiveHeight - 10f) { + val parent = ScrollbarBackgroundPanel(this, frame) + parent.removeBackground() + parent.dock = Dock.FILL + parent.dockLeft = 50f + parent.dockRight = 4f + parent.canvas + } else { + val parent = EditablePanel(this, frame) + parent.dock = Dock.FILL + frame.performLayout() + parent.dockPaddingTop = ((parent.effectiveHeight - height) / 2f).roundToInt().toFloat() + parent.dockLeft = 50f + parent + } + + for ((input, output, progress) in menu.processingTuples) { + val row = EditablePanel(this, parentTarget, height = AbstractSlotPanel.SIZE) + row.dock = Dock.TOP + row.dockBottom = 2f + + SlotPanel(this, row, input).also { + it.dock = Dock.LEFT + } + + progressPanels.add(ProgressGaugePanel(this, row, progress).also { + it.dock = Dock.LEFT + it.dockLeft = 4f + it.dockRight = 4f + it.dockResize = DockResizeMode.NONE + }) + + SlotPanel(this, row, output).also { + it.dock = Dock.LEFT + } + } + + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig, balanceInputs = menu.balanceInputs, upgrades = menu.upgrades) + + if (isJeiLoaded) { + val recipeTypes = menu.recipeTypes + + if (recipeTypes != null) { + progressPanels.forEach { + it.setRecipeType(recipeTypes) + } + } + } + + return frame + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt deleted file mode 100644 index 8fd28ea77..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt +++ /dev/null @@ -1,31 +0,0 @@ -package ru.dbotthepony.mc.otm.client.screen.tech - -import net.minecraft.network.chat.Component -import net.minecraft.world.entity.player.Inventory -import ru.dbotthepony.mc.otm.client.screen.MatteryScreen -import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel -import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel -import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls -import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel -import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel -import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel -import ru.dbotthepony.mc.otm.compat.jei.PlatePressRecipeCategory -import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu - -class PlatePressScreen(menu: PlatePressMenu, inventory: Inventory, title: Component) : - MatteryScreen(menu, inventory, title) { - override fun makeMainFrame(): FramePanel> { - val frame = super.makeMainFrame()!! - - WideProfiledPowerGaugePanel(this, frame, menu.profiledEnergy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) - BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) - - SlotPanel(this, frame, menu.inputSlot, 56f, PROGRESS_SLOT_TOP) - ProgressGaugePanel(this, frame, menu.progressGauge, 78f, PROGRESS_ARROW_TOP).setRecipeType { listOf(PlatePressRecipeCategory.recipeType) } - SlotPanel(this, frame, menu.outputSlot, 104f, PROGRESS_SLOT_TOP) - - makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig, upgrades = menu.upgrades) - - return frame - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PoweredFurnaceScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PoweredFurnaceScreen.kt deleted file mode 100644 index 11892fdd2..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PoweredFurnaceScreen.kt +++ /dev/null @@ -1,54 +0,0 @@ -package ru.dbotthepony.mc.otm.client.screen.tech - -import mezz.jei.api.constants.RecipeTypes -import net.minecraft.network.chat.Component -import net.minecraft.world.entity.player.Inventory -import ru.dbotthepony.mc.otm.client.screen.MatteryScreen -import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel -import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel -import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls -import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel -import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel -import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel -import ru.dbotthepony.mc.otm.compat.jei.MicrowaveRecipeCategory -import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu -import ru.dbotthepony.mc.otm.registry.MMenus - -class PoweredFurnaceScreen(menu: PoweredFurnaceMenu, inventory: Inventory, title: Component) : - MatteryScreen(menu, inventory, title) { - override fun makeMainFrame(): FramePanel> { - val frame = super.makeMainFrame()!! - - WideProfiledPowerGaugePanel(this, frame, menu.profiledEnergy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) - BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) - - SlotPanel(this, frame, menu.inputSlots[0], 56f, PROGRESS_SLOT_TOP - 10f) - val a = ProgressGaugePanel(this, frame, menu.progressGauge[0], 78f, PROGRESS_ARROW_TOP - 10f) - SlotPanel(this, frame, menu.outputSlots[0], 104f, PROGRESS_SLOT_TOP - 10f) - - SlotPanel(this, frame, menu.inputSlots[1], 56f, PROGRESS_SLOT_TOP + 10f) - val b = ProgressGaugePanel(this, frame, menu.progressGauge[1], 78f, PROGRESS_ARROW_TOP + 10f) - SlotPanel(this, frame, menu.outputSlots[1], 104f, PROGRESS_SLOT_TOP + 10f) - - makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig, balanceInputs = menu.balanceInputs, upgrades = menu.upgrades) - - when (menu.type) { - MMenus.POWERED_FURNACE -> { - a.setRecipeType { listOf(RecipeTypes.SMELTING) } - b.setRecipeType { listOf(RecipeTypes.SMELTING) } - } - - MMenus.POWERED_BLAST_FURNACE -> { - a.setRecipeType { listOf(RecipeTypes.BLASTING) } - b.setRecipeType { listOf(RecipeTypes.BLASTING) } - } - - MMenus.POWERED_SMOKER -> { - a.setRecipeType { listOf(MicrowaveRecipeCategory.recipeType, RecipeTypes.SMOKING) } - b.setRecipeType { listOf(MicrowaveRecipeCategory.recipeType, RecipeTypes.SMOKING) } - } - } - - return frame - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/TwinPlatePressScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/TwinPlatePressScreen.kt deleted file mode 100644 index a762523c2..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/TwinPlatePressScreen.kt +++ /dev/null @@ -1,35 +0,0 @@ -package ru.dbotthepony.mc.otm.client.screen.tech - -import net.minecraft.network.chat.Component -import net.minecraft.world.entity.player.Inventory -import ru.dbotthepony.mc.otm.client.screen.MatteryScreen -import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel -import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel -import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls -import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel -import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel -import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel -import ru.dbotthepony.mc.otm.compat.jei.PlatePressRecipeCategory -import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu - -class TwinPlatePressScreen(menu: TwinPlatePressMenu, inventory: Inventory, title: Component) : - MatteryScreen(menu, inventory, title) { - override fun makeMainFrame(): FramePanel> { - val frame = super.makeMainFrame()!! - - WideProfiledPowerGaugePanel(this, frame, menu.profiledEnergy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) - BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) - - SlotPanel(this, frame, menu.inputSlots[0], 56f, PROGRESS_SLOT_TOP - 10f) - ProgressGaugePanel(this, frame, menu.progressGauge0, 78f, PROGRESS_ARROW_TOP - 10f).setRecipeType { listOf(PlatePressRecipeCategory.recipeType) } - SlotPanel(this, frame, menu.outputSlots[0], 104f, PROGRESS_SLOT_TOP - 10f) - - SlotPanel(this, frame, menu.inputSlots[1], 56f, PROGRESS_SLOT_TOP + 10f) - ProgressGaugePanel(this, frame, menu.progressGauge1, 78f, PROGRESS_ARROW_TOP + 10f).setRecipeType { listOf(PlatePressRecipeCategory.recipeType) } - SlotPanel(this, frame, menu.outputSlots[1], 104f, PROGRESS_SLOT_TOP + 10f) - - makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig, balanceInputs = menu.balanceInputs, upgrades = menu.upgrades) - - return frame - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt index 8db071907..ab56416a0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt @@ -7,7 +7,6 @@ import mezz.jei.api.constants.VanillaTypes import mezz.jei.api.forge.ForgeTypes import mezz.jei.api.gui.handlers.IGuiContainerHandler import mezz.jei.api.helpers.IJeiHelpers -import mezz.jei.api.ingredients.ITypedIngredient import mezz.jei.api.registration.IGuiHandlerRegistration import mezz.jei.api.registration.IRecipeCatalystRegistration import mezz.jei.api.registration.IRecipeCategoryRegistration @@ -18,7 +17,6 @@ import mezz.jei.api.runtime.IJeiRuntime import net.minecraft.client.renderer.Rect2i import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.ItemStack -import net.minecraftforge.fluids.FluidStack import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.screen.MatteryScreen @@ -34,7 +32,6 @@ import ru.dbotthepony.mc.otm.menu.decorative.PainterMenu import ru.dbotthepony.mc.otm.menu.matter.MatterEntanglerMenu import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu -import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu import ru.dbotthepony.mc.otm.recipe.PainterRecipe import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRecipes @@ -77,7 +74,6 @@ class JEIPlugin : IModPlugin { MItems.POWERED_SMOKER.values.forEach { registration.addRecipeCatalyst(ItemStack(it), MicrowaveRecipeCategory.recipeType) } registration.addRecipeCatalyst(ItemStack(MItems.ExopackUpgrades.CRAFTING_UPGRADE), RecipeTypes.CRAFTING) registration.addRecipeCatalyst(ItemStack(MItems.ITEM_MONITOR[null]!!), RecipeTypes.CRAFTING) - MItems.PLATE_PRESS.values.forEach { registration.addRecipeCatalyst(ItemStack(it), PlatePressRecipeCategory.recipeType) } MItems.TWIN_PLATE_PRESS.values.forEach { registration.addRecipeCatalyst(ItemStack(it), PlatePressRecipeCategory.recipeType) } registration.addRecipeCatalyst(ItemStack(MItems.PAINTER), PainterRecipeCategory.recipeType) registration.addRecipeCatalyst(ItemStack(MItems.MATTER_ENTANGLER), MatterEntanglerRecipeCategory.recipeType) @@ -114,8 +110,7 @@ class JEIPlugin : IModPlugin { registration.addRecipeTransferHandler(ExopackInventoryTransferHandler(helper), RecipeTypes.CRAFTING) registration.addRecipeTransferHandler(simpleTransferInfo(MatterEntanglerRecipeCategory.recipeType, MatterEntanglerMenu::inputs)) registration.addRecipeTransferHandler(simpleTransferInfo0(PainterRecipeCategory.recipeType, PainterMenu::inputSlot)) - registration.addRecipeTransferHandler(simpleTransferInfo0(PlatePressRecipeCategory.recipeType, PlatePressMenu::inputSlot)) - registration.addRecipeTransferHandler(simpleTransferInfo(PlatePressRecipeCategory.recipeType, TwinPlatePressMenu::inputSlots)) + registration.addRecipeTransferHandler(simpleTransferInfo(PlatePressRecipeCategory.recipeType, PlatePressMenu::inputSlots)) registration.addRecipeTransferHandler(simpleTransferInfo(MicrowaveRecipeCategory.recipeType, PoweredFurnaceMenu::inputSlots)) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt index c2be97082..6d8dddd76 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt @@ -42,7 +42,7 @@ object PlatePressRecipeCategory : IRecipeCategory, IDrawable { } override fun getTitle(): Component { - return MItems.PLATE_PRESS[null]!!.description + return MItems.TWIN_PLATE_PRESS[null]!!.description } override fun draw(graphics: GuiGraphics, xOffset: Int, yOffset: Int) { @@ -96,7 +96,7 @@ object PlatePressRecipeCategory : IRecipeCategory, IDrawable { } private val iconField by lazy { - JEIPlugin.helpers.guiHelper.createDrawableItemStack(ItemStack(MItems.PLATE_PRESS[null]!!)) + JEIPlugin.helpers.guiHelper.createDrawableItemStack(ItemStack(MItems.TWIN_PLATE_PRESS[null]!!)) } override fun getIcon(): IDrawable { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt index d4ce32b41..a654d49a0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt @@ -4,6 +4,10 @@ import net.minecraftforge.fml.config.ModConfig object ClientConfig : AbstractConfig("client", ModConfig.Type.CLIENT) { + var HIDE_DESCRIPTION: Boolean by builder + .comment("Description of items require SHIFT to be pressed.") + .define("HIDE_DESCRIPTION", false) + var JUMP_BOOST_LOOK_ANGLE: Double by builder .comment("If looking below this angle (actually, looking 'above' as you see in game, but not as you expect it, check with debug screen), Crouch + Jump will trigger jump boost android ability") .defineInRange("JUMP_BOOST_LOOK_ANGLE", 30.0, -180.0, 180.0) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt index 2bc71c21a..aa6c8cbc4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt @@ -14,7 +14,7 @@ object ItemsConfig : AbstractConfig("items") { val BASIC = batteryValues(MNames.BATTERY_BASIC, Decimal(400_000), Decimal(600)) val NORMAL = batteryValues(MNames.BATTERY_NORMAL, Decimal(2_000_000), Decimal(1_000)) val DENSE = batteryValues(MNames.BATTERY_DENSE, Decimal(10_000_000), Decimal(2_000)) - val CAPACITOR = batteryValues(MNames.BATTERY_CAPACITOR, Decimal(500_000), Decimal(50_000)) + val CAPACITOR = batteryValues(MNames.BATTERY_CAPACITOR, Decimal(2_000_000), Decimal(50_000)) val QUANTUM_BATTERY = conciseValues(MNames.QUANTUM_BATTERY, Decimal(40_000_000), Decimal(10_000)) val QUANTUM_CAPACITOR = conciseValues(MNames.QUANTUM_CAPACITOR, Decimal(1_000_000), Decimal(200_000)) @@ -36,7 +36,7 @@ object ItemsConfig : AbstractConfig("items") { object Capacitors { val BASIC by builder.defineDecimal(MNames.MATTER_CAPACITOR_BASIC, Decimal(2_500), minimum = Decimal.ONE_TENTH) val NORMAL by builder.defineDecimal(MNames.MATTER_CAPACITOR_NORMAL, Decimal(10_000), minimum = Decimal.ONE_TENTH) - val DENSE by builder.defineDecimal(MNames.MATTER_CAPACITOR_DENSE, Decimal(25_000), minimum = Decimal.ONE_TENTH) + val DENSE by builder.defineDecimal(MNames.MATTER_CAPACITOR_DENSE, Decimal(40_000), minimum = Decimal.ONE_TENTH) } init { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/ITooltippable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/ITooltippable.kt deleted file mode 100644 index 94234f21a..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/ITooltippable.kt +++ /dev/null @@ -1,100 +0,0 @@ -package ru.dbotthepony.mc.otm.core - -import it.unimi.dsi.fastutil.objects.ObjectIterators -import net.minecraft.ChatFormatting -import net.minecraft.network.chat.Component -import net.minecraft.world.item.ItemStack -import ru.dbotthepony.mc.otm.client.isShiftDown -import ru.dbotthepony.mc.otm.client.minecraft -import java.util.stream.Stream - -interface ITooltippable { - fun addDescriptionLinesInternal(lines: Stream) { - addDescriptionFunctionsInternal(lines.map { c -> { ObjectIterators.singleton(c.copy()) } }) - } - - fun addDescriptionLinesInternal(vararg lines: Component) { - lines.forEach { c -> - addDescriptionFunctionsInternal({ ObjectIterators.singleton(c.copy()) }) - } - } - - fun addDescriptionLinesInternal(lines: Collection) { - lines.forEach { c -> - addDescriptionFunctionsInternal({ ObjectIterators.singleton(c.copy()) }) - } - } - - fun addDescriptionFunctionsInternal(lines: Stream Iterator>) - fun addDescriptionFunctionsInternal(vararg lines: (ItemStack) -> Iterator) - fun addDescriptionFunctionsInternal(lines: Collection<(ItemStack) -> Iterator>) - - fun assembleDescription(itemStack: ItemStack, into: MutableCollection) - - class Impl : ITooltippable { - private val descriptionLines = ArrayList<(ItemStack) -> Iterator>() - - override fun addDescriptionFunctionsInternal(lines: Stream Iterator>) { - lines.forEach { descriptionLines.add(it) } - } - - override fun addDescriptionFunctionsInternal(vararg lines: (ItemStack) -> Iterator) { - lines.forEach { descriptionLines.add(it) } - } - - override fun addDescriptionFunctionsInternal(lines: Collection<(ItemStack) -> Iterator>) { - lines.forEach { descriptionLines.add(it) } - } - - override fun assembleDescription(itemStack: ItemStack, into: MutableCollection) { - if (descriptionLines.isNotEmpty()) { - if (!minecraft.window.isShiftDown) { - into.add(TranslatableComponent("otm.gui.shift_for_more_info").withStyle(ChatFormatting.GRAY).withStyle(ChatFormatting.ITALIC)) - } else { - for (lines in descriptionLines) { - into.addAll(lines.invoke(itemStack)) - } - } - } - } - } -} - -fun T.addDescriptionLines(lines: Stream): T { - addDescriptionLinesInternal(lines) - return this -} - -fun T.addDescriptionLines(vararg lines: Component): T { - addDescriptionLinesInternal(lines.stream()) - return this -} - -fun T.addDescriptionLines(lines: Collection): T { - addDescriptionLinesInternal(lines) - return this -} - -fun T.addDescriptionFunctions(lines: Stream Iterator>): T { - addDescriptionFunctionsInternal(lines) - return this -} - -fun T.addDescriptionFunctions(vararg lines: (ItemStack) -> Iterator): T { - addDescriptionFunctionsInternal(lines.stream()) - return this -} - -fun T.addDescriptionFunctions(line: (ItemStack) -> Iterator): T { - addDescriptionFunctionsInternal(line) - return this -} - -fun T.addDescriptionFunctions(lines: Collection<(ItemStack) -> Iterator>): T { - addDescriptionFunctionsInternal(lines) - return this -} - -fun T.needsNoPowerDescription(formatting: ChatFormatting = ChatFormatting.GRAY): T { - return addDescriptionLines(TranslatableComponent("otm.needs_no_power").withStyle(formatting)) -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/TooltipList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/TooltipList.kt new file mode 100644 index 000000000..cff6c59ac --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/TooltipList.kt @@ -0,0 +1,151 @@ +package ru.dbotthepony.mc.otm.core + +import net.minecraft.ChatFormatting +import net.minecraft.nbt.CompoundTag +import net.minecraft.nbt.Tag +import net.minecraft.network.chat.Component +import net.minecraft.world.item.BlockItem +import net.minecraft.world.item.DyeColor +import net.minecraft.world.item.ItemStack +import net.minecraftforge.common.capabilities.ForgeCapabilities +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity +import ru.dbotthepony.mc.otm.capability.energy +import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl +import ru.dbotthepony.mc.otm.capability.energy.CapacitorEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.GeneratorEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.ItemEnergyStorageImpl +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.batteryLevel +import ru.dbotthepony.mc.otm.capability.fluidLevel +import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl +import ru.dbotthepony.mc.otm.client.ShiftPressedCond +import ru.dbotthepony.mc.otm.client.isShiftDown +import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.config.ClientConfig +import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.mapPresent +import ru.dbotthepony.mc.otm.core.util.formatMatter +import ru.dbotthepony.mc.otm.core.util.formatPower + +class TooltipList { + private val descriptionLines = ArrayList<(itemStack: ItemStack, acceptor: (text: Component) -> Unit) -> Unit>() + + fun assemble(itemStack: ItemStack, into: (Component) -> Unit) { + if (descriptionLines.isNotEmpty()) { + if (ClientConfig.HIDE_DESCRIPTION && !minecraft.window.isShiftDown && descriptionLines.any { var flag = false; it.invoke(itemStack) { flag = true }; flag }) { + into.invoke(TranslatableComponent("otm.gui.shift_for_more_info").withStyle(ChatFormatting.GRAY).withStyle(ChatFormatting.ITALIC)) + } else { + for (lines in descriptionLines) { + lines.invoke(itemStack, into) + } + } + } + } + + fun assemble(itemStack: ItemStack, into: MutableCollection) { + assemble(itemStack, into::add) + } + + fun addNormal(function: (itemStack: ItemStack, acceptor: (text: Component) -> Unit) -> Unit) { + descriptionLines.add(function) + } + + @JvmName("addPlain") + fun add(component: Component) { + descriptionLines.add { _, result -> result.invoke(component.copy()) } + } + + @JvmName("addFunction2Component") + fun add(component: () -> Component) { + descriptionLines.add { _, result -> result.invoke(component.invoke()) } + } + + fun needsNoPower(formatting: ChatFormatting = ChatFormatting.GRAY) { + add(TranslatableComponent("otm.needs_no_power").withStyle(formatting)) + } + + fun painted(color: DyeColor?) { + if (color != null) { + add(TranslatableComponent("otm.painted.${color.name.lowercase()}").withStyle(ChatFormatting.DARK_GRAY)) + } + } + + fun colored(color: DyeColor?) = painted(color) + + inline fun blockEntityData(key: String, noinline callback: (itemStack: ItemStack, data: T, acceptor: (line: Component) -> Unit) -> Unit) { + addNormal { itemStack, acceptor -> + val tag = (itemStack.tag?.get(BlockItem.BLOCK_ENTITY_TAG) as? CompoundTag)?.get(key) as? T ?: return@addNormal + callback(itemStack, tag, acceptor) + } + } + + fun blockEntityEnergy(energyKey: String = MatteryBlockEntity.ENERGY_KEY, batteryKey: String = MatteryBlockEntity.BATTERY_KEY) { + blockEntityData(energyKey) { _, tag, acceptor -> + val stored = tag.mapPresent(BlockEnergyStorageImpl.ENERGY_STORED_KEY, Decimal::deserializeNBT) + + if (stored != null) { + acceptor( + TranslatableComponent( + "otm.item.power.storage0", + stored.formatPower(formatAsReadable = ShiftPressedCond) + ).withStyle(ChatFormatting.GRAY)) + } + + val container = MatteryContainer(1) + tag.map(batteryKey, container::deserializeNBT) + + if (!container[0].isEmpty) { + acceptor(TranslatableComponent("otm.item.block.stored_battery", container[0].displayName).withStyle(ChatFormatting.GRAY)) + + val energy = container[0].energy ?: return@blockEntityData + + if (energy is IMatteryEnergyStorage) { + batteryLevel(energy, acceptor) + } else { + batteryLevel(energy, acceptor) + } + } + } + } + + fun blockEntityMatter(matterKey: String = MatteryBlockEntity.MATTER_STORAGE_KEY) { + blockEntityData(matterKey) { _, tag, acceptor -> + val stored = tag.mapPresent(MatterStorageImpl.MATTER_STORED_KEY, Decimal::deserializeNBT) + + if (stored != null) { + acceptor( + TranslatableComponent( + "otm.item.matter.storage0", + stored.formatMatter(formatAsReadable = ShiftPressedCond) + ).withStyle(ChatFormatting.GRAY)) + } + } + } + + fun itemEnergy() { + addNormal { itemStack, acceptor -> + val energy = itemStack.energy ?: return@addNormal + + if (energy is IMatteryEnergyStorage) { + batteryLevel(energy, acceptor) + } else { + batteryLevel(energy, acceptor) + } + } + } + + fun doubleProcessing() { + add(TranslatableComponent("otm.gui.double_processing").withStyle(ChatFormatting.GRAY)) + } + + fun itemFluid() { + addNormal { itemStack, acceptor -> + itemStack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK { + it.fluidLevel(acceptor) + } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt index cc7aa3289..089d6c5da 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt @@ -380,6 +380,14 @@ fun emptyIterator(): MutableIterator { return ObjectIterators.emptyIterator() } +fun iteratorOf(value: T): MutableIterator { + return ObjectIterators.singleton(value) +} + +fun iteratorOf(vararg value: T): MutableIterator { + return ObjectIterators.wrap(value) +} + fun Iterator.toStream(): Stream { return StreamSupport.stream(Spliterators.spliteratorUnknownSize(this, 0), false) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt index 4115d724e..183d94078 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt @@ -29,7 +29,7 @@ import ru.dbotthepony.mc.otm.registry.MatteryDamageSource import ru.dbotthepony.mc.otm.runIfClient import kotlin.math.roundToInt -open class BatteryItem : Item { +open class BatteryItem : MatteryItem { val _capacity: () -> Decimal val _receive: () -> Decimal val _extract: () -> Decimal @@ -103,14 +103,8 @@ open class BatteryItem : Item { return p_150901_.matteryEnergy?.getBarColor() ?: super.getBarColor(p_150901_) } - override fun appendHoverText( - stack: ItemStack, - p_41422_: Level?, - p_41423_: MutableList, - p_41424_: TooltipFlag - ) { - super.appendHoverText(stack, p_41422_, p_41423_, p_41424_) - ItemEnergyStorageImpl.appendHoverText(stack, p_41423_) + init { + tooltips.itemEnergy() } override fun initCapabilities(stack: ItemStack, nbt: CompoundTag?): ICapabilityProvider { @@ -119,19 +113,14 @@ open class BatteryItem : Item { } class CrudeBatteryItem : BatteryItem(ItemsConfig.Batteries.CRUDE) { - override fun appendHoverText( - stack: ItemStack, - p_41422_: Level?, - p_41423_: MutableList, - p_41424_: TooltipFlag - ) { - super.appendHoverText(stack, p_41422_, p_41423_, p_41424_) + init { + tooltips.addNormal { itemStack, acceptor -> + val isAndroid = runIfClient(false) { minecraft.player?.matteryPlayer?.isAndroid ?: false } - val isAndroid = runIfClient(false) { minecraft.player?.matteryPlayer?.isAndroid ?: false } - - if (isAndroid) { - p_41423_.add(TranslatableComponent("otm.gui.crude_battery.replace_in_world").withStyle(ChatFormatting.GRAY)) - p_41423_.add(TranslatableComponent("otm.gui.crude_battery.replace_in_world_warning").withStyle(ChatFormatting.DARK_RED)) + if (isAndroid) { + acceptor(TranslatableComponent("otm.gui.crude_battery.replace_in_world").withStyle(ChatFormatting.GRAY)) + acceptor(TranslatableComponent("otm.gui.crude_battery.replace_in_world_warning").withStyle(ChatFormatting.DARK_RED)) + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt index d41260d93..c07aeabe2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt @@ -46,7 +46,7 @@ import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.orNull import java.util.function.IntSupplier -class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(64)) { +class FluidCapsuleItem(val capacity: IntSupplier) : MatteryItem(Properties().stacksTo(64)) { // TODO: Так как использование предмета заблокировано за player.abilities.canBuild // капсулу нельзя использовать в режиме приключения // почему же можно использовать вёдра на котлах? @@ -72,12 +72,8 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6 return super.getName(pStack) } - override fun appendHoverText(pStack: ItemStack, pLevel: Level?, pTooltipComponents: MutableList, pIsAdvanced: TooltipFlag) { - super.appendHoverText(pStack, pLevel, pTooltipComponents, pIsAdvanced) - - pStack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK { - it.fluidLevel(pTooltipComponents) - } + init { + tooltips.itemFluid() } override fun initCapabilities(stack: ItemStack, nbt: CompoundTag?): ICapabilityProvider { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidTankItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidTankItem.kt index 911e44120..c8f8f5753 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidTankItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidTankItem.kt @@ -17,12 +17,19 @@ import ru.dbotthepony.mc.otm.block.entity.decorative.FluidTankBlockEntity import ru.dbotthepony.mc.otm.capability.fluid.BlockMatteryFluidHandler import ru.dbotthepony.mc.otm.capability.fluidLevel import ru.dbotthepony.mc.otm.client.render.blockentity.FluidTankRenderer +import ru.dbotthepony.mc.otm.core.TooltipList import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.ifPresentK import java.util.function.Consumer import java.util.function.IntSupplier class FluidTankItem(block: FluidTankBlock, properties: Properties, val capacity: IntSupplier) : BlockItem(block, properties) { + val tooltips = TooltipList() + + init { + tooltips.itemFluid() + } + override fun initCapabilities(stack: ItemStack, nbt: CompoundTag?): ICapabilityProvider { return BlockMatteryFluidHandler.Item(stack, capacity, FluidTankBlockEntity.FLUID_KEY) } @@ -53,10 +60,7 @@ class FluidTankItem(block: FluidTankBlock, properties: Properties, val capacity: override fun appendHoverText(pStack: ItemStack, pLevel: Level?, pTooltip: MutableList, pFlag: TooltipFlag) { super.appendHoverText(pStack, pLevel, pTooltip, pFlag) - - pStack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK { - it.fluidLevel(pTooltip) - } + tooltips.assemble(pStack, pTooltip::add) } override fun initializeClient(consumer: Consumer) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatteryItem.kt index 85f0ea45d..d74a6294c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatteryItem.kt @@ -7,22 +7,19 @@ import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.Level -import ru.dbotthepony.mc.otm.client.isShiftDown -import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.core.ITooltippable +import ru.dbotthepony.mc.otm.core.TooltipList import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.addAll -import ru.dbotthepony.mc.otm.core.addDescriptionFunctions -import ru.dbotthepony.mc.otm.core.addDescriptionLines -import java.util.stream.Stream -open class MatteryItem(properties: Properties) : Item(properties), ITooltippable by ITooltippable.Impl() { +open class MatteryItem(properties: Properties) : Item(properties) { + val tooltips = TooltipList() + override fun appendHoverText(itemStack: ItemStack, level: Level?, components: MutableList, tooltipType: TooltipFlag) { super.appendHoverText(itemStack, level, components, tooltipType) - assembleDescription(itemStack, components) + tooltips.assemble(itemStack, components) } } fun T.addSimpleDescription(suffix: String = "", formatting: ChatFormatting = ChatFormatting.GRAY): T { - return addDescriptionFunctions { ObjectIterators.singleton(TranslatableComponent("$descriptionId.desc$suffix").withStyle(formatting)) } + tooltips.add { TranslatableComponent("$descriptionId.desc$suffix").withStyle(formatting) } + return this } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MinecartCargoCrateItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MinecartCargoCrateItem.kt index 25b520997..5c07ecbc1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MinecartCargoCrateItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MinecartCargoCrateItem.kt @@ -18,8 +18,9 @@ import net.minecraft.world.level.gameevent.GameEvent import ru.dbotthepony.mc.otm.entity.MinecartCargoCrate import ru.dbotthepony.mc.otm.registry.MEntityTypes -class MinecartCargoCrateItem(val color: DyeColor?) : Item(Properties().stacksTo(16)) { +class MinecartCargoCrateItem(val color: DyeColor?) : MatteryItem(Properties().stacksTo(16)) { init { + tooltips.painted(color) DispenserBlock.registerBehavior(this, Companion) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PillItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PillItem.kt index 3fc956300..8b0f17bb1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PillItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PillItem.kt @@ -18,21 +18,14 @@ enum class PillType { BECOME_ANDROID, BECOME_HUMANE, OBLIVION } -class HealPillItem : Item(Properties().stacksTo(64).rarity(Rarity.UNCOMMON)) { - override fun getUseDuration(p_41454_: ItemStack): Int { +class HealPillItem : MatteryItem(Properties().stacksTo(64).rarity(Rarity.UNCOMMON)) { + override fun getUseDuration(itemStack: ItemStack): Int { return 24 } - override fun appendHoverText( - p_41421_: ItemStack, - p_41422_: Level?, - p_41423_: MutableList, - p_41424_: TooltipFlag - ) { - super.appendHoverText(p_41421_, p_41422_, p_41423_, p_41424_) - - p_41423_.add(TranslatableComponent("otm.pill.heal").withStyle(ChatFormatting.GRAY)) - p_41423_.add(TranslatableComponent("otm.pill.heal_android").withStyle(ChatFormatting.GRAY)) + init { + tooltips.add(TranslatableComponent("otm.pill.heal").withStyle(ChatFormatting.GRAY)) + tooltips.add(TranslatableComponent("otm.pill.heal_android").withStyle(ChatFormatting.GRAY)) } override fun use(level: Level, ply: Player, hand: InteractionHand): InteractionResultHolder { @@ -62,33 +55,24 @@ class HealPillItem : Item(Properties().stacksTo(64).rarity(Rarity.UNCOMMON)) { override fun getUseAnimation(p_41452_: ItemStack): UseAnim = UseAnim.EAT } -class PillItem(val pillType: PillType) : - Item(Properties().stacksTo(64).rarity(Rarity.UNCOMMON)) { +class PillItem(val pillType: PillType) : MatteryItem(Properties().stacksTo(64).rarity(Rarity.UNCOMMON)) { + init { + when (pillType) { + PillType.BECOME_ANDROID -> tooltips.add(TranslatableComponent("otm.pill.android").withStyle(ChatFormatting.GRAY)) + + PillType.BECOME_HUMANE -> { + tooltips.add(TranslatableComponent("otm.pill.humane").withStyle(ChatFormatting.GRAY)) + tooltips.add(TranslatableComponent("otm.pill.warning").withStyle(ChatFormatting.RED)) + } + + PillType.OBLIVION -> tooltips.add(TranslatableComponent("otm.pill.oblivion").withStyle(ChatFormatting.GRAY)) + } + } override fun getUseDuration(p_41454_: ItemStack): Int { return 32 } - override fun appendHoverText( - p_41421_: ItemStack, - p_41422_: Level?, - p_41423_: MutableList, - p_41424_: TooltipFlag - ) { - super.appendHoverText(p_41421_, p_41422_, p_41423_, p_41424_) - - when (pillType) { - PillType.BECOME_ANDROID -> p_41423_.add(TranslatableComponent("otm.pill.android").withStyle(ChatFormatting.GRAY)) - - PillType.BECOME_HUMANE -> { - p_41423_.add(TranslatableComponent("otm.pill.humane").withStyle(ChatFormatting.GRAY)) - p_41423_.add(TranslatableComponent("otm.pill.warning").withStyle(ChatFormatting.RED)) - } - - PillType.OBLIVION -> p_41423_.add(TranslatableComponent("otm.pill.oblivion").withStyle(ChatFormatting.GRAY)) - } - } - override fun use(level: Level, ply: Player, hand: InteractionHand): InteractionResultHolder { val resolver = ply.getCapability(MatteryCapability.MATTERY_PLAYER).resolve() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralBatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralBatteryItem.kt index 0932bc8d4..3b67cbbb1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralBatteryItem.kt @@ -29,7 +29,7 @@ import ru.dbotthepony.mc.otm.data.DecimalProvider import ru.dbotthepony.mc.otm.registry.MItemFunctionTypes import java.util.Optional -class ProceduralBatteryItem : Item(Properties().stacksTo(1)) { +class ProceduralBatteryItem : MatteryItem(Properties().stacksTo(1)) { class Cap(stack: ItemStack) : ItemEnergyStorageImpl(stack) { override var maxInput: Decimal get() = itemStack.tag?.mapPresent("maxInput", Decimal.Companion::deserializeNBT) ?: Decimal.ZERO @@ -62,16 +62,16 @@ class ProceduralBatteryItem : Item(Properties().stacksTo(1)) { return p_150901_.matteryEnergy?.getBarColor() ?: super.getBarColor(p_150901_) } - override fun appendHoverText(p_41421_: ItemStack, p_41422_: Level?, p_41423_: MutableList, p_41424_: TooltipFlag) { - super.appendHoverText(p_41421_, p_41422_, p_41423_, p_41424_) + init { + tooltips.addNormal { itemStack, acceptor -> + val energy = itemStack.matteryEnergy - val energy = p_41421_.matteryEnergy - - if (energy is Cap) { - if (energy.maxInput.isZero && energy.maxOutput.isZero && energy.maxBatteryLevel.isZero) { - p_41423_.add(TranslatableComponent("$descriptionId.desc").withStyle(ChatFormatting.GRAY)) - } else { - batteryLevel(energy, p_41423_) + if (energy is Cap) { + if (energy.maxInput.isZero && energy.maxOutput.isZero && energy.maxBatteryLevel.isZero) { + acceptor(TranslatableComponent("$descriptionId.desc").withStyle(ChatFormatting.GRAY)) + } else { + batteryLevel(energy, acceptor) + } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/SimpleUpgrade.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/SimpleUpgrade.kt index ff1acb9e2..bdee5e757 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/SimpleUpgrade.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/SimpleUpgrade.kt @@ -30,7 +30,7 @@ class SimpleUpgrade( override val matterStorage: Decimal = Decimal.ZERO, override val matterStorageFlat: Decimal = Decimal.ZERO, override val failureMultiplier: Double = 1.0, -) : Item(properties), IMatteryUpgrade, ICapabilityProvider { +) : MatteryItem(properties), IMatteryUpgrade, ICapabilityProvider { private val resolver = LazyOptional.of { this } override fun getCapability(cap: Capability, side: Direction?): LazyOptional { @@ -41,9 +41,10 @@ class SimpleUpgrade( return LazyOptional.empty() } - override fun appendHoverText(p_41421_: ItemStack, p_41422_: Level?, p_41423_: MutableList, p_41424_: TooltipFlag) { - super.appendHoverText(p_41421_, p_41422_, p_41423_, p_41424_) - addUpgradeTooltipLines(p_41423_) + init { + tooltips.addNormal { _, acceptor -> + addUpgradeTooltipLines(acceptor) + } } override fun initCapabilities(stack: ItemStack, nbt: CompoundTag?): ICapabilityProvider { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt index 5750b2004..a1e4f6d2d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt @@ -23,22 +23,16 @@ open class SingleUseBatteryItem( private val _capacity: () -> Decimal, private val _throughput: () -> Decimal? = { null }, properties: Properties = Properties().stacksTo(1) -) : Item(properties) { +) : MatteryItem(properties) { constructor(values: EnergyBalanceValues, properties: Properties = Properties().stacksTo(1)) : this(values::energyCapacity, values::energyThroughput, properties) constructor(storage: Decimal, throughput: Decimal? = null, properties: Properties = Properties().stacksTo(1)) : this({ storage }, { throughput }, properties) val capacity get() = _capacity.invoke() val throughput get() = _throughput.invoke() - override fun appendHoverText( - itemStack: ItemStack, - p_41422_: Level?, - list: MutableList, - p_41424_: TooltipFlag - ) { - super.appendHoverText(itemStack, p_41422_, list, p_41424_) - list.add(TranslatableComponent("otm.battery.single_use").withStyle(ChatFormatting.GRAY)) - ItemEnergyStorageImpl.appendHoverText(itemStack, list) + init { + tooltips.add(TranslatableComponent("otm.battery.single_use").withStyle(ChatFormatting.GRAY)) + tooltips.itemEnergy() } override fun initCapabilities(stack: ItemStack, nbt: CompoundTag?): ICapabilityProvider { @@ -59,13 +53,7 @@ open class SingleUseBatteryItem( } class ZPMItem : SingleUseBatteryItem(ItemsConfig.Batteries.ZPM, Properties().stacksTo(1).rarity(Rarity.EPIC)) { - override fun appendHoverText( - itemStack: ItemStack, - p_41422_: Level?, - list: MutableList, - p_41424_: TooltipFlag - ) { - super.appendHoverText(itemStack, p_41422_, list, p_41424_) - list.add(TranslatableComponent("$descriptionId.description").withStyle(ChatFormatting.DARK_GRAY)) + init { + tooltips.add(TranslatableComponent("$descriptionId.description").withStyle(ChatFormatting.DARK_GRAY)) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/MatterCapacitorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/MatterCapacitorItem.kt index c2ef417ad..6d4e9a693 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/MatterCapacitorItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/MatterCapacitorItem.kt @@ -1,15 +1,10 @@ package ru.dbotthepony.mc.otm.item.matter import net.minecraft.ChatFormatting -import net.minecraft.MethodsReturnNonnullByDefault import net.minecraft.core.Direction import net.minecraft.nbt.CompoundTag -import net.minecraft.network.chat.Component -import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Rarity -import net.minecraft.world.item.TooltipFlag -import net.minecraft.world.level.Level import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ICapabilityProvider import net.minecraftforge.common.util.LazyOptional @@ -23,11 +18,9 @@ import ru.dbotthepony.mc.otm.core.util.formatMatter import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.tagNotNull -import javax.annotation.ParametersAreNonnullByDefault +import ru.dbotthepony.mc.otm.item.MatteryItem -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault -class MatterCapacitorItem : Item { +class MatterCapacitorItem : MatteryItem { private inner class Matter(private val stack: ItemStack) : ICapabilityProvider, IMatterStorage { private val resolver = LazyOptional.of { this } @@ -37,7 +30,7 @@ class MatterCapacitorItem : Item { override var storedMatter: Decimal get() { - if (isCreative) return Decimal.LONG_MAX_VALUE + if (isCreative) return Decimal.POSITIVE_INFINITY return stack.tag?.map("matter", Decimal.Companion::deserializeNBT) ?: Decimal.ZERO } set(value) { @@ -49,7 +42,7 @@ class MatterCapacitorItem : Item { } override val missingMatter: Decimal get() { - return if (isCreative) Decimal.LONG_MAX_VALUE else super.missingMatter + return if (isCreative) Decimal.POSITIVE_INFINITY else super.missingMatter } override fun receiveMatter(howMuch: Decimal, simulate: Boolean): Decimal { @@ -96,7 +89,7 @@ class MatterCapacitorItem : Item { constructor() : super(Properties().stacksTo(1).rarity(Rarity.EPIC)) { isCreative = true - _capacity = { Decimal.LONG_MAX_VALUE } + _capacity = { Decimal.POSITIVE_INFINITY } } override fun isBarVisible(p_150899_: ItemStack): Boolean { @@ -120,20 +113,12 @@ class MatterCapacitorItem : Item { return p_150901_.matter?.getBarColor() ?: super.getBarColor(p_150901_) } - override fun appendHoverText( - stack: ItemStack, - p_41422_: Level?, - p_41423_: MutableList, - p_41424_: TooltipFlag - ) { - super.appendHoverText(stack, p_41422_, p_41423_, p_41424_) - if (isCreative) { - p_41423_.add(INFINITE_STORAGE) - } else { - stack.getCapability(MatteryCapability.MATTER).ifPresentK { - p_41423_.add( + init { + tooltips.addNormal { itemStack, acceptor -> + itemStack.getCapability(MatteryCapability.MATTER).ifPresentK { + acceptor( TranslatableComponent( - "otm.item.matter.normal", + "otm.item.matter.storage", it.storedMatter.formatMatter(formatAsReadable = ShiftPressedCond), capacity.formatMatter(formatAsReadable = ShiftPressedCond) ).withStyle(ChatFormatting.GRAY) @@ -147,10 +132,7 @@ class MatterCapacitorItem : Item { } companion object { - private val maxInput = Decimal.LONG_MAX_VALUE - private val maxOutput = Decimal.LONG_MAX_VALUE - - private val INFINITE_STORAGE: Component = - TranslatableComponent("otm.item.matter.infinite").withStyle(ChatFormatting.GRAY) + private val maxInput = Decimal.POSITIVE_INFINITY + private val maxOutput = Decimal.POSITIVE_INFINITY } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt index 5c8a81d7d..eb629aabe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt @@ -40,6 +40,7 @@ import ru.dbotthepony.mc.otm.core.nbt.ints import ru.dbotthepony.mc.otm.core.nbt.uuids import ru.dbotthepony.mc.otm.core.tagNotNull import ru.dbotthepony.mc.otm.core.util.formatPower +import ru.dbotthepony.mc.otm.item.MatteryItem import ru.dbotthepony.mc.otm.network.MNetworkContext import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.WeaponNetworkChannel @@ -136,7 +137,7 @@ open class WeaponDataTable(val tag: CompoundTag) { } } -abstract class AbstractWeaponItem(val tables: KClass, properties: Properties = Properties().stacksTo(1).rarity(Rarity.RARE)) : Item(properties) { +abstract class AbstractWeaponItem(val tables: KClass, properties: Properties = Properties().stacksTo(1).rarity(Rarity.RARE)) : MatteryItem(properties) { fun makeDataTable(tag: CompoundTag) = tables.primaryConstructor!!.call(tag) /** diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt index b36d1bc2e..b641267cb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt @@ -45,10 +45,12 @@ import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.math.nextVariance import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.core.util.WriteOnce +import ru.dbotthepony.mc.otm.item.MatteryItem +import ru.dbotthepony.mc.otm.item.addSimpleDescription import ru.dbotthepony.mc.otm.registry.MDamageTypes import ru.dbotthepony.mc.otm.registry.MatteryDamageSource -class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vanishable { +class EnergySwordItem : MatteryItem(Properties().stacksTo(1).rarity(Rarity.RARE)), Vanishable { val chargedAttributes: Multimap val dischargedAttributes: Multimap @@ -135,20 +137,13 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani return p_150901_.matteryEnergy?.getBarColor() ?: super.getBarColor(p_150901_) } - override fun appendHoverText( - itemStack: ItemStack, - p_41422_: Level?, - p_41423_: MutableList, - p_41424_: TooltipFlag - ) { - super.appendHoverText(itemStack, p_41422_, p_41423_, p_41424_) + init { + tooltips.itemEnergy() - ItemEnergyStorageImpl.appendHoverText(itemStack, p_41423_) - - p_41423_.add(DESCRIPTION) - p_41423_.add(DESCRIPTION2) - p_41423_.add(DESCRIPTION3) - p_41423_.add(DESCRIPTION4) + addSimpleDescription() + addSimpleDescription("2") + addSimpleDescription("3") + addSimpleDescription("4") } override fun mineBlock( @@ -249,10 +244,5 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani return null } - - private val DESCRIPTION = TranslatableComponent("item.overdrive_that_matters.energy_sword.desc").withStyle(ChatFormatting.DARK_GRAY) - private val DESCRIPTION2 = TranslatableComponent("item.overdrive_that_matters.energy_sword.desc2").withStyle(ChatFormatting.DARK_GRAY) - private val DESCRIPTION3 = TranslatableComponent("item.overdrive_that_matters.energy_sword.desc3").withStyle(ChatFormatting.DARK_GRAY) - private val DESCRIPTION4 = TranslatableComponent("item.overdrive_that_matters.energy_sword.desc4").withStyle(ChatFormatting.DARK_GRAY) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt index 54e499f64..d593ec91e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt @@ -174,15 +174,8 @@ open class PlasmaWeaponDataTable(tag: CompoundTag) : WeaponDataTable(tag) { } abstract class PlasmaWeaponItem(tables: KClass, private val energyCapacity: Decimal) : AbstractWeaponItem(tables) { - override fun appendHoverText( - itemStack: ItemStack, - p_41422_: Level?, - p_41423_: MutableList, - p_41424_: TooltipFlag - ) { - super.appendHoverText(itemStack, p_41422_, p_41423_, p_41424_) - - ItemEnergyStorageImpl.appendHoverText(itemStack, p_41423_) + init { + tooltips.itemEnergy() } fun energyData(itemStack: ItemStack) = itemStack.matteryEnergy as PlasmaWeaponEnergy diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AbstractProcessingMachineMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AbstractProcessingMachineMenu.kt new file mode 100644 index 000000000..f3ba2b63b --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AbstractProcessingMachineMenu.kt @@ -0,0 +1,43 @@ +package ru.dbotthepony.mc.otm.menu.tech + +import mezz.jei.api.recipe.RecipeType +import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.inventory.MenuType +import net.minecraft.world.inventory.Slot +import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity +import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu +import ru.dbotthepony.mc.otm.menu.UpgradeSlots +import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget +import java.util.function.Supplier + +abstract class AbstractProcessingMachineMenu( + type: MenuType<*>, + containerID: Int, + inventory: Inventory, + tile: MatteryPoweredBlockEntity? = null +) : MatteryPoweredMenu(type, containerID, inventory, tile) { + data class ProcessingTuple( + val input: Slot, + val output: Slot, + val progress: ProgressGaugeWidget + ) + + abstract val processingTuples: List + + abstract val itemConfig: ItemConfigPlayerInput? + abstract val energyConfig: EnergyConfigPlayerInput? + abstract val profiledEnergy: ProfiledLevelGaugeWidget<*> + abstract val balanceInputs: BooleanInputWithFeedback? + abstract val upgrades: UpgradeSlots? + + open val recipeTypes: Supplier>>? + get() = null + + init { + addInventorySlots() + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt index c5f0cc91b..6b92edd50 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt @@ -7,7 +7,6 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.enchantment.Enchantments import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.block.entity.tech.EssenceStorageBlockEntity -import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.core.util.getTotalXpRequiredForLevel import ru.dbotthepony.mc.otm.item.EssenceCapsuleItem import ru.dbotthepony.mc.otm.item.EssenceServoItem @@ -19,7 +18,7 @@ import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MMenus -class EssenceStorageMenu @JvmOverloads constructor( +class EssenceStorageMenu( containerID: Int, inventory: Inventory, tile: EssenceStorageBlockEntity? = null @@ -88,18 +87,10 @@ class EssenceStorageMenu @JvmOverloads constructor( } init { - storeLevels.filter { - it.isCreative || it.matteryPlayer?.isAndroid == true || servoSlot.item.item == MItems.ESSENCE_SERVO //|| it.itemsStream(true).anyMatch { it.item == MItems.ESSENCE_SERVO } - } - storeLevels.filter { it.experienceProgress > 0f || it.experienceLevel > 0 } - dispenseLevels.filter { - it.isCreative || it.matteryPlayer?.isAndroid == true || servoSlot.item.item == MItems.ESSENCE_SERVO //|| it.itemsStream(true).anyMatch { it.item == MItems.ESSENCE_SERVO } - } - dispenseLevels.filter { (tile?.experienceStored ?: experienceStored) > 0L } if (tile != null) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt index 35269557b..72a1c768c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt @@ -1,36 +1,64 @@ package ru.dbotthepony.mc.otm.menu.tech +import mezz.jei.api.recipe.RecipeType import net.minecraft.server.level.ServerPlayer import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.inventory.MenuType import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity +import ru.dbotthepony.mc.otm.compat.jei.PlatePressRecipeCategory +import ru.dbotthepony.mc.otm.compat.jei.isJeiLoaded +import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.menu.OutputSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.makeSlots import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus +import java.util.function.Supplier class PlatePressMenu( + type: MenuType<*>, containerID: Int, inventory: Inventory, - tile: PlatePressBlockEntity? = null -) : MatteryPoweredMenu(MMenus.PLATE_PRESS, containerID, inventory, tile) { - val inputSlot = MatterySlot(tile?.inputContainer ?: SimpleContainer(1), 0) - val outputSlot = OutputSlot(tile?.outputContainer ?: SimpleContainer(1), 0) { tile?.experience?.popExperience(player as ServerPlayer) } + tile: PlatePressBlockEntity? = null, + isTwin: Boolean +) : AbstractProcessingMachineMenu(type, containerID, inventory, tile) { + val inputSlots = makeSlots(tile?.inputContainer ?: SimpleContainer(if (isTwin) 2 else 1), ::MatterySlot) + val outputSlots = makeSlots(tile?.outputContainer ?: SimpleContainer(if (isTwin) 2 else 1)) { a, b -> OutputSlot(a, b) { tile?.experience?.popExperience(player as ServerPlayer) } } + val gauges = immutableList(if (isTwin) 2 else 1) { ProgressGaugeWidget(this, tile?.jobEventLoops?.get(it)) } - val progressGauge = ProgressGaugeWidget(this, tile) - val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig, allowPush = true) - val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPull = true) - val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) + override val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig, allowPush = true) + override val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPull = true) + override val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) - val upgrades = makeUpgradeSlots(3, tile?.upgrades) + override val balanceInputs = if (isTwin) BooleanInputWithFeedback(this) else null + override val upgrades = makeUpgradeSlots(if (isTwin) 4 else 3, tile?.upgrades) + + override val processingTuples: List = immutableList(if (isTwin) 2 else 1) { + ProcessingTuple(inputSlots[it], outputSlots[it], gauges[it]) + } + + override val recipeTypes: Supplier>> + get() = Supplier { listOf(PlatePressRecipeCategory.recipeType) } init { - addStorageSlot(inputSlot) - addStorageSlot(outputSlot) - addInventorySlots() + if (tile != null) balanceInputs?.with(tile::balanceInputs) + addStorageSlot(inputSlots) + addStorageSlot(outputSlots) + } + + companion object { + fun single(containerID: Int, inventory: Inventory, tile: PlatePressBlockEntity? = null): PlatePressMenu { + return PlatePressMenu(MMenus.PLATE_PRESS, containerID, inventory, tile, false) + } + + fun twin(containerID: Int, inventory: Inventory, tile: PlatePressBlockEntity? = null): PlatePressMenu { + return PlatePressMenu(MMenus.TWIN_PLATE_PRESS, containerID, inventory, tile, true) + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PoweredFurnaceMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PoweredFurnaceMenu.kt index 8f4f57e8e..06fb5781f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PoweredFurnaceMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PoweredFurnaceMenu.kt @@ -1,5 +1,7 @@ package ru.dbotthepony.mc.otm.menu.tech +import mezz.jei.api.constants.RecipeTypes +import mezz.jei.api.recipe.RecipeType import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.inventory.MenuType @@ -7,6 +9,8 @@ import ru.dbotthepony.mc.otm.block.entity.tech.AbstractPoweredFurnaceBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.PoweredBlastFurnaceBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.PoweredFurnaceBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.PoweredSmokerBlockEntity +import ru.dbotthepony.mc.otm.compat.jei.MicrowaveRecipeCategory +import ru.dbotthepony.mc.otm.compat.jei.isJeiLoaded import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.menu.OutputSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu @@ -18,30 +22,42 @@ import ru.dbotthepony.mc.otm.menu.makeSlots import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus +import java.util.function.Supplier class PoweredFurnaceMenu( type: MenuType, containerID: Int, inventory: Inventory, tile: AbstractPoweredFurnaceBlockEntity<*, *>? = null -) : MatteryPoweredMenu(type, containerID, inventory, tile) { +) : AbstractProcessingMachineMenu(type, containerID, inventory, tile) { val inputSlots = makeSlots(tile?.inputs, 2, ::MatterySlot) val outputSlots = makeSlots(tile?.outputs, 2) { c, s -> OutputSlot(c, s) { tile?.experience?.popExperience(player as ServerPlayer) } } - val progressGauge = immutableList(2) { ProgressGaugeWidget(this, tile?.jobEventLoops?.get(it)) } - val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig, allowPush = true) - val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPull = true) - val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) - val balanceInputs = BooleanInputWithFeedback(this) + override val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig, allowPush = true) + override val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPull = true) + override val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) + override val balanceInputs = BooleanInputWithFeedback(this) + override val upgrades = makeUpgradeSlots(2, tile?.upgrades) - val upgrades = makeUpgradeSlots(2, tile?.upgrades) + override val processingTuples: List = immutableList(2) { + ProcessingTuple(inputSlots[it], outputSlots[it], progressGauge[it]) + } + + override val recipeTypes: Supplier>>? + get() { + return when (type) { + MMenus.POWERED_FURNACE -> Supplier { listOf(RecipeTypes.SMELTING) } + MMenus.POWERED_BLAST_FURNACE -> Supplier { listOf(RecipeTypes.BLASTING) } + MMenus.POWERED_SMOKER -> Supplier { listOf(MicrowaveRecipeCategory.recipeType, RecipeTypes.SMOKING) } + else -> null + } + } init { if (tile != null) balanceInputs.with(tile::balanceInputs) addStorageSlot(inputSlots) addStorageSlot(outputSlots) - addInventorySlots() } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/TwinPlatePressMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/TwinPlatePressMenu.kt deleted file mode 100644 index 244b9bc13..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/TwinPlatePressMenu.kt +++ /dev/null @@ -1,47 +0,0 @@ -package ru.dbotthepony.mc.otm.menu.tech - -import net.minecraft.server.level.ServerPlayer -import net.minecraft.world.SimpleContainer -import net.minecraft.world.entity.player.Inventory -import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity -import ru.dbotthepony.mc.otm.menu.OutputSlot -import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu -import ru.dbotthepony.mc.otm.menu.MatterySlot -import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback -import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput -import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput -import ru.dbotthepony.mc.otm.menu.makeSlots -import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget -import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget -import ru.dbotthepony.mc.otm.registry.MMenus - -class TwinPlatePressMenu( - containerID: Int, - inventory: Inventory, - tile: PlatePressBlockEntity? = null -) : MatteryPoweredMenu(MMenus.TWIN_PLATE_PRESS, containerID, inventory, tile) { - val inputSlots = makeSlots(tile?.inputContainer ?: SimpleContainer(2), ::MatterySlot) - val outputSlots = makeSlots(tile?.outputContainer ?: SimpleContainer(2)) { a, b -> OutputSlot(a, b) { tile?.experience?.popExperience(player as ServerPlayer) } } - - val progressGauge0 = ProgressGaugeWidget(this, tile?.jobEventLoops?.get(0)) - val progressGauge1 = ProgressGaugeWidget(this, tile?.jobEventLoops?.get(1)) - val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig, allowPush = true) - val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPull = true) - val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) - - val balanceInputs = BooleanInputWithFeedback(this) - - val upgrades = makeUpgradeSlots(4, tile?.upgrades) - - init { - if (tile != null) { - balanceInputs.with(tile::balanceInputs) - } - } - - init { - addStorageSlot(inputSlots) - addStorageSlot(outputSlots) - addInventorySlots() - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt index 412326e38..aa0a174fe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt @@ -81,7 +81,7 @@ class PlatePressRecipe( override fun getType(): RecipeType = MRecipes.PLATE_PRESS override fun getToastSymbol(): ItemStack { - return ItemStack(MItems.PLATE_PRESS[null]!!) + return ItemStack(MItems.TWIN_PLATE_PRESS[null]!!) } fun toFinished() = SERIALIZER.toFinished(this) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt index a946509eb..a9e8ae4a8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt @@ -25,6 +25,7 @@ import ru.dbotthepony.mc.otm.core.tagNotNull import ru.dbotthepony.mc.otm.data.Codec2RecipeSerializer import ru.dbotthepony.mc.otm.data.RecipePair import ru.dbotthepony.mc.otm.data.codec +import ru.dbotthepony.mc.otm.data.SingletonCodec import java.util.stream.Stream class UpgradeRecipe( @@ -89,14 +90,19 @@ class UpgradeRecipe( Codec.STRING.fieldOf("path").forGetter(Direct::path) ).apply(it, ::Direct) } - }, INDIRECT { + }, + INDIRECT { override val codec: Codec = RecordCodecBuilder.create { it.group( Codec.STRING.fieldOf("source").forGetter(Indirect::pathSource), Codec.STRING.fieldOf("destination").forGetter(Indirect::pathDestination), ).apply(it, ::Indirect) } - }; + }, + ALL { + override val codec: Codec by lazy { SingletonCodec(All) } + }, + ; override fun getSerializedName(): String { return name.lowercase() @@ -182,6 +188,17 @@ class UpgradeRecipe( } } + object All : Op() { + override val type: OpType + get() = OpType.ALL + + override fun apply(source: CompoundTag, destination: CompoundTag) { + source.allKeys.forEach { + destination[it] = source[it]!! + } + } + } + val copyPaths: ImmutableList = copyPaths.collect(ImmutableList.toImmutableList()) override fun assemble(pInv: CraftingContainer, registryAccess: RegistryAccess): ItemStack { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockTags.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockTags.kt new file mode 100644 index 000000000..57b04b64b --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockTags.kt @@ -0,0 +1,59 @@ +package ru.dbotthepony.mc.otm.registry + +import net.minecraft.resources.ResourceLocation +import net.minecraft.tags.BlockTags +import net.minecraft.tags.TagKey +import net.minecraft.world.level.block.Block +import ru.dbotthepony.mc.otm.OverdriveThatMatters + +@Suppress("unused") +object MBlockTags { + val CARGO_CRATES: TagKey = BlockTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "cargo_crates")) + val INDUSTRIAL_GLASS: TagKey = BlockTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "industrial_glass")) + + val CRAFTING_TABLES: TagKey = BlockTags.create(ResourceLocation("forge", "crafting_tables")) + val WORKBENCHES: TagKey = BlockTags.create(ResourceLocation("forge", "workbenches")) + val WORKBENCH: TagKey = BlockTags.create(ResourceLocation("forge", "workbench")) + + val REQUIRES_TRITANIUM_TOOL: TagKey = BlockTags.create(ResourceLocation("minecraft", "requires_tritanium_tool")) + + val HARDENED_GLASS_PANES: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes")) + val HARDENED_GLASS_PANES_BLACK: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/black")) + val HARDENED_GLASS_PANES_BLUE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/blue")) + val HARDENED_GLASS_PANES_BROWN: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/brown")) + val HARDENED_GLASS_PANES_COLORLESS: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/colorless")) + val HARDENED_GLASS_PANES_CYAN: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/cyan")) + val HARDENED_GLASS_PANES_GRAY: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/gray")) + val HARDENED_GLASS_PANES_GREEN: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/green")) + val HARDENED_GLASS_PANES_LIGHT_BLUE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/light_blue")) + val HARDENED_GLASS_PANES_LIGHT_GRAY: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/light_gray")) + val HARDENED_GLASS_PANES_LIME: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/lime")) + val HARDENED_GLASS_PANES_MAGENTA: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/magenta")) + val HARDENED_GLASS_PANES_ORANGE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/orange")) + val HARDENED_GLASS_PANES_PINK: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/pink")) + val HARDENED_GLASS_PANES_PURPLE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/purple")) + val HARDENED_GLASS_PANES_RED: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/red")) + val HARDENED_GLASS_PANES_WHITE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/white")) + val HARDENED_GLASS_PANES_YELLOW: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/yellow")) + + val HARDENED_GLASS: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass")) + val HARDENED_GLASS_BLACK: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/black")) + val HARDENED_GLASS_BLUE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/blue")) + val HARDENED_GLASS_BROWN: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/brown")) + val HARDENED_GLASS_COLORLESS: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/colorless")) + val HARDENED_GLASS_CYAN: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/cyan")) + val HARDENED_GLASS_GRAY: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/gray")) + val HARDENED_GLASS_GREEN: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/green")) + val HARDENED_GLASS_LIGHT_BLUE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/light_blue")) + val HARDENED_GLASS_LIGHT_GRAY: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/light_gray")) + val HARDENED_GLASS_LIME: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/lime")) + val HARDENED_GLASS_MAGENTA: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/magenta")) + val HARDENED_GLASS_ORANGE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/orange")) + val HARDENED_GLASS_PINK: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/pink")) + val HARDENED_GLASS_PURPLE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/purple")) + val HARDENED_GLASS_RED: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/red")) + val HARDENED_GLASS_WHITE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/white")) + val HARDENED_GLASS_YELLOW: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/yellow")) + + val MACHINES: TagKey = BlockTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "machines")) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItemTags.kt similarity index 58% rename from src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItemTags.kt index 86a49364c..cf19f67a7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItemTags.kt @@ -1,11 +1,9 @@ package ru.dbotthepony.mc.otm.registry import net.minecraft.resources.ResourceLocation -import net.minecraft.tags.BlockTags import net.minecraft.tags.ItemTags import net.minecraft.tags.TagKey import net.minecraft.world.item.Item -import net.minecraft.world.level.block.Block import ru.dbotthepony.mc.otm.OverdriveThatMatters @Suppress("unused") @@ -38,6 +36,7 @@ object MItemTags { val GOLD_WIRES: TagKey = ItemTags.create(ResourceLocation("forge", "wires/gold")) val PISTONS: TagKey = ItemTags.create(ResourceLocation("forge", "pistons")) + val FURNACES: TagKey = ItemTags.create(ResourceLocation("forge", "furnaces")) val TOOLS_HAMMERS: TagKey = ItemTags.create(ResourceLocation("forge", "tools/hammers")) @@ -82,54 +81,3 @@ object MItemTags { val MACHINES: TagKey = ItemTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "machines")) } -@Suppress("unused") -object MBlockTags { - val CARGO_CRATES: TagKey = BlockTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "cargo_crates")) - val INDUSTRIAL_GLASS: TagKey = BlockTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "industrial_glass")) - - val CRAFTING_TABLES: TagKey = BlockTags.create(ResourceLocation("forge", "crafting_tables")) - val WORKBENCHES: TagKey = BlockTags.create(ResourceLocation("forge", "workbenches")) - val WORKBENCH: TagKey = BlockTags.create(ResourceLocation("forge", "workbench")) - - val REQUIRES_TRITANIUM_TOOL: TagKey = BlockTags.create(ResourceLocation("minecraft", "requires_tritanium_tool")) - - val HARDENED_GLASS_PANES: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes")) - val HARDENED_GLASS_PANES_BLACK: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/black")) - val HARDENED_GLASS_PANES_BLUE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/blue")) - val HARDENED_GLASS_PANES_BROWN: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/brown")) - val HARDENED_GLASS_PANES_COLORLESS: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/colorless")) - val HARDENED_GLASS_PANES_CYAN: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/cyan")) - val HARDENED_GLASS_PANES_GRAY: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/gray")) - val HARDENED_GLASS_PANES_GREEN: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/green")) - val HARDENED_GLASS_PANES_LIGHT_BLUE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/light_blue")) - val HARDENED_GLASS_PANES_LIGHT_GRAY: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/light_gray")) - val HARDENED_GLASS_PANES_LIME: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/lime")) - val HARDENED_GLASS_PANES_MAGENTA: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/magenta")) - val HARDENED_GLASS_PANES_ORANGE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/orange")) - val HARDENED_GLASS_PANES_PINK: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/pink")) - val HARDENED_GLASS_PANES_PURPLE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/purple")) - val HARDENED_GLASS_PANES_RED: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/red")) - val HARDENED_GLASS_PANES_WHITE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/white")) - val HARDENED_GLASS_PANES_YELLOW: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/yellow")) - - val HARDENED_GLASS: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass")) - val HARDENED_GLASS_BLACK: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/black")) - val HARDENED_GLASS_BLUE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/blue")) - val HARDENED_GLASS_BROWN: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/brown")) - val HARDENED_GLASS_COLORLESS: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/colorless")) - val HARDENED_GLASS_CYAN: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/cyan")) - val HARDENED_GLASS_GRAY: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/gray")) - val HARDENED_GLASS_GREEN: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/green")) - val HARDENED_GLASS_LIGHT_BLUE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/light_blue")) - val HARDENED_GLASS_LIGHT_GRAY: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/light_gray")) - val HARDENED_GLASS_LIME: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/lime")) - val HARDENED_GLASS_MAGENTA: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/magenta")) - val HARDENED_GLASS_ORANGE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/orange")) - val HARDENED_GLASS_PINK: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/pink")) - val HARDENED_GLASS_PURPLE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/purple")) - val HARDENED_GLASS_RED: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/red")) - val HARDENED_GLASS_WHITE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/white")) - val HARDENED_GLASS_YELLOW: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/yellow")) - - val MACHINES: TagKey = BlockTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "machines")) -} 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 fe24d64a2..04411e1ea 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -115,7 +115,6 @@ object MItems { init { val machines = ArrayList>() - machines.addAll(PLATE_PRESS.asSupplierArray()) machines.addAll(TWIN_PLATE_PRESS.asSupplierArray()) machines.addAll(POWERED_FURNACE.asSupplierArray()) machines.addAll(POWERED_BLAST_FURNACE.asSupplierArray()) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt index 9bbf88352..abbb2dd6b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt @@ -5,9 +5,7 @@ import net.minecraft.world.flag.FeatureFlags import net.minecraft.world.inventory.MenuType import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent -import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.ForgeRegistries -import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.block.entity.tech.AndroidChargerBlockEntity import ru.dbotthepony.mc.otm.client.screen.decorative.CargoCrateScreen import ru.dbotthepony.mc.otm.client.screen.decorative.FluidTankScreen @@ -38,9 +36,7 @@ import ru.dbotthepony.mc.otm.client.screen.tech.EnergyCounterScreen import ru.dbotthepony.mc.otm.client.screen.tech.EnergyServoScreen import ru.dbotthepony.mc.otm.client.screen.tech.EssenceStorageScreen import ru.dbotthepony.mc.otm.client.screen.decorative.PainterScreen -import ru.dbotthepony.mc.otm.client.screen.tech.PlatePressScreen -import ru.dbotthepony.mc.otm.client.screen.tech.PoweredFurnaceScreen -import ru.dbotthepony.mc.otm.client.screen.tech.TwinPlatePressScreen +import ru.dbotthepony.mc.otm.client.screen.tech.AbstractProcessingMachineScreen import ru.dbotthepony.mc.otm.menu.decorative.CargoCrateMenu import ru.dbotthepony.mc.otm.menu.decorative.FluidTankMenu import ru.dbotthepony.mc.otm.menu.decorative.HoloSignMenu @@ -72,7 +68,6 @@ import ru.dbotthepony.mc.otm.menu.tech.EssenceStorageMenu import ru.dbotthepony.mc.otm.menu.decorative.PainterMenu import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu -import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu object MMenus { private val registry = MDeferredRegister(ForgeRegistries.MENU_TYPES) @@ -94,11 +89,11 @@ object MMenus { val ITEM_MONITOR by registry.register(MNames.ITEM_MONITOR) { MenuType(::ItemMonitorMenu, FeatureFlags.VANILLA_SET) } val ENERGY_COUNTER by registry.register(MNames.ENERGY_COUNTER) { MenuType(::EnergyCounterMenu, FeatureFlags.VANILLA_SET) } val CHEMICAL_GENERATOR by registry.register(MNames.CHEMICAL_GENERATOR) { MenuType(::ChemicalGeneratorMenu, FeatureFlags.VANILLA_SET) } - val PLATE_PRESS by registry.register(MNames.PLATE_PRESS) { MenuType(::PlatePressMenu, FeatureFlags.VANILLA_SET) } + val PLATE_PRESS by registry.register(MNames.PLATE_PRESS) { MenuType(PlatePressMenu::single, FeatureFlags.VANILLA_SET) } val POWERED_FURNACE by registry.register(MNames.POWERED_FURNACE) { MenuType(PoweredFurnaceMenu::furnace, FeatureFlags.VANILLA_SET) } val POWERED_BLAST_FURNACE by registry.register(MNames.POWERED_BLAST_FURNACE) { MenuType(PoweredFurnaceMenu::blasting, FeatureFlags.VANILLA_SET) } val POWERED_SMOKER by registry.register(MNames.POWERED_SMOKER) { MenuType(PoweredFurnaceMenu::smoking, FeatureFlags.VANILLA_SET) } - val TWIN_PLATE_PRESS by registry.register(MNames.TWIN_PLATE_PRESS) { MenuType(::TwinPlatePressMenu, FeatureFlags.VANILLA_SET) } + val TWIN_PLATE_PRESS by registry.register(MNames.TWIN_PLATE_PRESS) { MenuType(PlatePressMenu::twin, FeatureFlags.VANILLA_SET) } val MATTER_RECYCLER by registry.register(MNames.MATTER_RECYCLER) { MenuType(::MatterRecyclerMenu, FeatureFlags.VANILLA_SET) } val ENERGY_SERVO by registry.register(MNames.ENERGY_SERVO) { MenuType(::EnergyServoMenu, FeatureFlags.VANILLA_SET) } val HOLO_SIGN by registry.register(MNames.HOLO_SIGN) { MenuType(::HoloSignMenu, FeatureFlags.VANILLA_SET) } @@ -137,8 +132,8 @@ object MMenus { MenuScreens.register(ITEM_MONITOR, ::ItemMonitorScreen) MenuScreens.register(ENERGY_COUNTER, ::EnergyCounterScreen) MenuScreens.register(CHEMICAL_GENERATOR, ::ChemicalGeneratorScreen) - MenuScreens.register(PLATE_PRESS, ::PlatePressScreen) - MenuScreens.register(TWIN_PLATE_PRESS, ::TwinPlatePressScreen) + MenuScreens.register(PLATE_PRESS, ::AbstractProcessingMachineScreen) + MenuScreens.register(TWIN_PLATE_PRESS, ::AbstractProcessingMachineScreen) MenuScreens.register(MATTER_RECYCLER, ::MatterRecyclerScreen) MenuScreens.register(STORAGE_BUS, ::StorageBusScreen) MenuScreens.register(STORAGE_IMPORTER_EXPORTER, ::StorageImporterExporterScreen) @@ -149,9 +144,9 @@ object MMenus { MenuScreens.register(ESSENCE_STORAGE, ::EssenceStorageScreen) MenuScreens.register(ITEM_REPAIER, ::MatterReconstructorScreen) MenuScreens.register(FLUID_TANK, ::FluidTankScreen) - MenuScreens.register(POWERED_FURNACE, ::PoweredFurnaceScreen) - MenuScreens.register(POWERED_BLAST_FURNACE, ::PoweredFurnaceScreen) - MenuScreens.register(POWERED_SMOKER, ::PoweredFurnaceScreen) + MenuScreens.register(POWERED_FURNACE, ::AbstractProcessingMachineScreen) + MenuScreens.register(POWERED_BLAST_FURNACE, ::AbstractProcessingMachineScreen) + MenuScreens.register(POWERED_SMOKER, ::AbstractProcessingMachineScreen) MenuScreens.register(PAINTER, ::PainterScreen) MenuScreens.register(MATTER_ENTANGLER, ::MatterEntanglerScreen) } 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 9ef2fd7b4..5d5214fe2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -15,7 +15,7 @@ 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.Item -import net.minecraft.world.item.Items +import net.minecraft.world.item.ShieldItem import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.block.* import net.minecraft.world.level.block.state.BlockBehaviour @@ -30,7 +30,7 @@ import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent import net.minecraftforge.fml.loading.FMLEnvironment -import net.minecraftforge.registries.DeferredRegister +import net.minecraftforge.registries.ForgeRegistries import net.minecraftforge.registries.NewRegistryEvent import net.minecraftforge.registries.RegisterEvent import ru.dbotthepony.mc.otm.OverdriveThatMatters @@ -406,7 +406,10 @@ object MRegistry : IBlockItemRegistryAcceptor { } private fun registerItemDecorators(event: RegisterItemDecorationsEvent) { - event.register(Items.SHIELD, MatteryGUI::renderShieldCooldownOverlay) - event.register(MItems.TRITANIUM_SHIELD, MatteryGUI::renderShieldCooldownOverlay) + ForgeRegistries.ITEMS.forEach { + if (it is ShieldItem) { + event.register(it, MatteryGUI::renderShieldCooldownOverlay) + } + } } } diff --git a/src/main/resources/data/overdrive_that_matters/recipes/components/advanced_control_circuit.json b/src/main/resources/data/overdrive_that_matters/recipes/components/advanced_control_circuit.json deleted file mode 100644 index a4aa2b39b..000000000 --- a/src/main/resources/data/overdrive_that_matters/recipes/components/advanced_control_circuit.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - - "pattern": [ - "R R", - "GCG", - "PPP" - ], - - "key": { - "C": { - "tag": "forge:wires/copper" - }, - - "R": { - "tag": "forge:dusts/redstone" - }, - - "G": { - "tag": "forge:wires/gold" - }, - - "P": { - "item": "overdrive_that_matters:circuit_plating" - } - }, - - "result": { - "item": "overdrive_that_matters:advanced_control_circuit", - "count": 3 - } -} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/recipes/components/basic_control_circuit.json b/src/main/resources/data/overdrive_that_matters/recipes/components/basic_control_circuit.json deleted file mode 100644 index d01f51295..000000000 --- a/src/main/resources/data/overdrive_that_matters/recipes/components/basic_control_circuit.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - - "pattern": [ - "CRC", - "PPP" - ], - - "key": { - "C": { - "tag": "forge:wires/copper" - }, - - "R": { - "tag": "forge:dusts/redstone" - }, - - "P": { - "item": "overdrive_that_matters:circuit_plating" - } - }, - - "result": { - "item": "overdrive_that_matters:basic_control_circuit", - "count": 3 - } -} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/recipes/components/copper_wiring.json b/src/main/resources/data/overdrive_that_matters/recipes/components/copper_wiring.json deleted file mode 100644 index e2e685ca6..000000000 --- a/src/main/resources/data/overdrive_that_matters/recipes/components/copper_wiring.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - - "pattern": [ - " # ", - "#@#", - " # " - ], - - "key": { - "#": { - "tag": "forge:ingots/copper" - }, - - "@": { - "tag": "forge:rods/wooden" - } - }, - - "result": { - "item": "overdrive_that_matters:copper_wiring", - "count": 8 - } -} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/recipes/components/electric_parts.json b/src/main/resources/data/overdrive_that_matters/recipes/components/electric_parts.json deleted file mode 100644 index 389dc23f3..000000000 --- a/src/main/resources/data/overdrive_that_matters/recipes/components/electric_parts.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - - "pattern": [ - "RCR", - "GIG", - "RCR" - ], - - "key": { - "R": { - "tag": "forge:dusts/redstone" - }, - - "I": { - "tag": "forge:ingots/iron" - }, - - "G": { - "tag": "forge:nuggets/gold" - }, - - "C": { - "tag": "forge:wires/copper" - } - }, - - "result": { - "item": "overdrive_that_matters:electric_parts", - "count": 4 - } -} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/recipes/components/energy_bus.json b/src/main/resources/data/overdrive_that_matters/recipes/components/energy_bus.json deleted file mode 100644 index a2d567555..000000000 --- a/src/main/resources/data/overdrive_that_matters/recipes/components/energy_bus.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - - "pattern": [ - " R ", - "CPC", - " R " - ], - - "key": { - "R": { - "tag": "forge:dusts/redstone" - }, - - "P": { - "item": "overdrive_that_matters:electric_parts" - }, - - "C": { - "tag": "forge:wires/copper" - } - }, - - "result": { - "item": "overdrive_that_matters:energy_bus", - "count": 1 - } -} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/recipes/components/gold_wiring.json b/src/main/resources/data/overdrive_that_matters/recipes/components/gold_wiring.json deleted file mode 100644 index d6f0ca235..000000000 --- a/src/main/resources/data/overdrive_that_matters/recipes/components/gold_wiring.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - - "pattern": [ - " # ", - "#@#", - " # " - ], - - "key": { - "#": { - "tag": "forge:ingots/gold" - }, - - "@": { - "tag": "forge:rods/wooden" - } - }, - - "result": { - "item": "overdrive_that_matters:gold_wiring", - "count": 8 - } -} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/recipes/components/machine_frame.json b/src/main/resources/data/overdrive_that_matters/recipes/components/machine_frame.json deleted file mode 100644 index 962530355..000000000 --- a/src/main/resources/data/overdrive_that_matters/recipes/components/machine_frame.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - - "pattern": [ - "BGB", - "PEP", - "TET" - ], - - "key": { - "G": { - "tag": "forge:glass" - }, - - "B": { - "item": "overdrive_that_matters:energy_bus" - }, - - "E": { - "item": "overdrive_that_matters:electric_parts" - }, - - "P": { - "tag": "forge:plates/iron" - }, - - "T": { - "tag": "forge:plates/tritanium" - } - }, - - "result": { - "item": "overdrive_that_matters:machine_frame", - "count": 2 - } -} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/recipes/components/matter_capacitor_parts.json b/src/main/resources/data/overdrive_that_matters/recipes/components/matter_capacitor_parts.json deleted file mode 100644 index 3b655e42b..000000000 --- a/src/main/resources/data/overdrive_that_matters/recipes/components/matter_capacitor_parts.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - - "pattern": [ - "IGI", - "PGP", - " G " - ], - - "key": { - "P": { - "tag": "forge:plates/tritanium" - }, - - "I": { - "tag": "forge:plates/iron" - }, - - "G": { - "tag": "forge:glass" - } - }, - - "result": { - "item": "overdrive_that_matters:matter_capacitor_parts", - "count": 3 - } -} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/recipes/components/matter_io_port.json b/src/main/resources/data/overdrive_that_matters/recipes/components/matter_io_port.json deleted file mode 100644 index 826fb794e..000000000 --- a/src/main/resources/data/overdrive_that_matters/recipes/components/matter_io_port.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - - "pattern": [ - " # ", - "L@L", - " # " - ], - - "key": { - "#": { - "item": "overdrive_that_matters:matter_cable" - }, - - "@": { - "tag": "forge:circuits/basic" - }, - - "L": { - "tag": "forge:plates/tritanium" - } - }, - - "result": { - "item": "overdrive_that_matters:matter_io_port", - "count": 1 - } -} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/recipes/components/matter_transform_matrix.json b/src/main/resources/data/overdrive_that_matters/recipes/components/matter_transform_matrix.json deleted file mode 100644 index 12e1f0bf3..000000000 --- a/src/main/resources/data/overdrive_that_matters/recipes/components/matter_transform_matrix.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - - "pattern": [ - " C ", - "PEP", - " M " - ], - - "key": { - "M": { - "item": "overdrive_that_matters:matter_cable" - }, - - "C": { - "tag": "forge:circuits/advanced" - }, - - "E": { - "tag": "forge:ender_pearls" - }, - - "P": { - "tag": "forge:plates/tritanium" - } - }, - - "result": { - "item": "overdrive_that_matters:matter_transform_matrix", - "count": 1 - } -} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/recipes/items/matter_capacitor_basic.json b/src/main/resources/data/overdrive_that_matters/recipes/items/matter_capacitor_basic.json deleted file mode 100644 index c9312e371..000000000 --- a/src/main/resources/data/overdrive_that_matters/recipes/items/matter_capacitor_basic.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - - "pattern": [ - "IPG" - ], - - "key": { - "I": { - "tag": "forge:plates/iron" - }, - - "G": { - "tag": "forge:glass" - }, - - "P": { - "item": "overdrive_that_matters:matter_capacitor_parts" - } - }, - - "result": { - "item": "overdrive_that_matters:matter_capacitor_basic", - "count": 1 - } -} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/recipes/items/matter_capacitor_normal.json b/src/main/resources/data/overdrive_that_matters/recipes/items/matter_capacitor_normal.json deleted file mode 100644 index c53a87220..000000000 --- a/src/main/resources/data/overdrive_that_matters/recipes/items/matter_capacitor_normal.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - - "pattern": [ - " G ", - "IPI", - " D " - ], - - "key": { - "I": { - "tag": "forge:plates/tritanium" - }, - - "D": { - "tag": "forge:gems/diamond" - }, - - "G": { - "tag": "forge:glass" - }, - - "P": { - "item": "overdrive_that_matters:matter_capacitor_parts" - } - }, - - "result": { - "item": "overdrive_that_matters:matter_capacitor_normal", - "count": 1 - } -} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/recipes/items/tritanium_axe.json b/src/main/resources/data/overdrive_that_matters/recipes/items/tritanium_axe.json deleted file mode 100644 index 993ec9a4e..000000000 --- a/src/main/resources/data/overdrive_that_matters/recipes/items/tritanium_axe.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - - "pattern": [ - "II ", - "IS ", - " S " - ], - - "key": { - "S": {"tag": "forge:rods/wooden"}, - "I": {"tag": "forge:ingots/tritanium"} - }, - - "result": { - "item": "overdrive_that_matters:tritanium_axe", - "count": 1 - } -} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/recipes/items/tritanium_axe_alt.json b/src/main/resources/data/overdrive_that_matters/recipes/items/tritanium_axe_alt.json deleted file mode 100644 index fb348002b..000000000 --- a/src/main/resources/data/overdrive_that_matters/recipes/items/tritanium_axe_alt.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - - "pattern": [ - " II", - " SI", - " S " - ], - - "key": { - "S": {"tag": "forge:rods/wooden"}, - "I": {"tag": "forge:ingots/tritanium"} - }, - - "result": { - "item": "overdrive_that_matters:tritanium_axe", - "count": 1 - } -} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/recipes/items/tritanium_hoe.json b/src/main/resources/data/overdrive_that_matters/recipes/items/tritanium_hoe.json deleted file mode 100644 index c08f497a0..000000000 --- a/src/main/resources/data/overdrive_that_matters/recipes/items/tritanium_hoe.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - - "pattern": [ - "II ", - " S ", - " S " - ], - - "key": { - "S": {"tag": "forge:rods/wooden"}, - "I": {"tag": "forge:ingots/tritanium"} - }, - - "result": { - "item": "overdrive_that_matters:tritanium_hoe", - "count": 1 - } -} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/recipes/items/tritanium_pickaxe.json b/src/main/resources/data/overdrive_that_matters/recipes/items/tritanium_pickaxe.json deleted file mode 100644 index eb3d9d7a0..000000000 --- a/src/main/resources/data/overdrive_that_matters/recipes/items/tritanium_pickaxe.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - - "pattern": [ - "III", - " S ", - " S " - ], - - "key": { - "S": {"tag": "forge:rods/wooden"}, - "I": {"tag": "forge:ingots/tritanium"} - }, - - "result": { - "item": "overdrive_that_matters:tritanium_pickaxe", - "count": 1 - } -} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/recipes/items/tritanium_shovel.json b/src/main/resources/data/overdrive_that_matters/recipes/items/tritanium_shovel.json deleted file mode 100644 index d6084d99b..000000000 --- a/src/main/resources/data/overdrive_that_matters/recipes/items/tritanium_shovel.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - - "pattern": [ - " I ", - " S ", - " S " - ], - - "key": { - "S": {"tag": "forge:rods/wooden"}, - "I": {"tag": "forge:ingots/tritanium"} - }, - - "result": { - "item": "overdrive_that_matters:tritanium_shovel", - "count": 1 - } -} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/recipes/items/tritanium_sword.json b/src/main/resources/data/overdrive_that_matters/recipes/items/tritanium_sword.json deleted file mode 100644 index fa0a58b97..000000000 --- a/src/main/resources/data/overdrive_that_matters/recipes/items/tritanium_sword.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - - "pattern": [ - " I ", - " I ", - " S " - ], - - "key": { - "S": {"tag": "forge:rods/wooden"}, - "I": {"tag": "forge:ingots/tritanium"} - }, - - "result": { - "item": "overdrive_that_matters:tritanium_sword", - "count": 1 - } -} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/recipes/machines/chemical_generator.json b/src/main/resources/data/overdrive_that_matters/recipes/machines/chemical_generator.json deleted file mode 100644 index 97f69538a..000000000 --- a/src/main/resources/data/overdrive_that_matters/recipes/machines/chemical_generator.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - - "pattern": [ - " B ", - "IFI", - "E E" - ], - - "key": { - "F": {"item": "minecraft:furnace"}, - "I": {"tag": "forge:ingots/iron"}, - "E": {"item": "overdrive_that_matters:electric_parts"}, - "B": {"item": "overdrive_that_matters:energy_bus"} - }, - - "result": { - "item": "overdrive_that_matters:chemical_generator", - "count": 1 - } -} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/recipes/machines/energy_counter.json b/src/main/resources/data/overdrive_that_matters/recipes/machines/energy_counter.json deleted file mode 100644 index 3cb6bbdf3..000000000 --- a/src/main/resources/data/overdrive_that_matters/recipes/machines/energy_counter.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - - "pattern": [ - "PIP", - "CSg", - "PIP" - ], - - "key": { - "I": {"item": "overdrive_that_matters:energy_bus"}, - "S": {"tag": "forge:dusts/glowstone"}, - "g": {"tag": "forge:glass_panes"}, - "C": {"tag": "forge:circuits/basic"}, - "P": {"tag": "forge:plates/iron"} - }, - - "result": { - "item": "overdrive_that_matters:energy_counter", - "count": 1 - } -} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/recipes/machines/matter_scanner.json b/src/main/resources/data/overdrive_that_matters/recipes/machines/matter_scanner.json deleted file mode 100644 index b624900ca..000000000 --- a/src/main/resources/data/overdrive_that_matters/recipes/machines/matter_scanner.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - - "pattern": [ - "CMC", - "TFT", - "-I-" - ], - - "key": { - "M": {"item": "overdrive_that_matters:matter_transform_matrix"}, - "F": {"item": "overdrive_that_matters:machine_frame"}, - "-": {"item": "overdrive_that_matters:matter_cable"}, - "T": {"tag": "forge:plates/iron"}, - "C": {"tag": "forge:circuits/basic"}, - "I": {"tag": "forge:circuits/advanced"} - }, - - "result": { - "item": "overdrive_that_matters:matter_scanner", - "count": 1 - } -} \ No newline at end of file