This commit is contained in:
DBotThePony 2024-01-12 21:17:44 +07:00
commit 5552be70d5
Signed by: DBot
GPG Key ID: DCC23B5715498507
117 changed files with 1323 additions and 1660 deletions

View File

@ -558,6 +558,9 @@ object DataGen {
addChestLootTables(lootTableProvider) addChestLootTables(lootTableProvider)
recipeProvider.exec { _, consumer -> recipeProvider.exec { _, consumer ->
addToolsRecipes(consumer)
addComponentRecipes(consumer)
addStorageItemRecipes(consumer)
addCraftingTableRecipes(consumer) addCraftingTableRecipes(consumer)
addBlastingRecipes(consumer) addBlastingRecipes(consumer)
addDecorativesRecipes(recipeProvider, consumer) addDecorativesRecipes(recipeProvider, consumer)

View File

@ -90,7 +90,7 @@ fun addMachineAdvancements(serializer: Consumer<AdvancementHolder>, lang: Matter
val press = AdvancementBuilder() val press = AdvancementBuilder()
.parent(chem) .parent(chem)
.display( .display(
itemStack = ItemStack(MItems.PLATE_PRESS[null]!!), itemStack = ItemStack(MItems.TWIN_PLATE_PRESS[null]!!),
title = translation.add("plate_press", "Bending the Material") { title = translation.add("plate_press", "Bending the Material") {
russian("Раскатка металла") russian("Раскатка металла")
}, },
@ -99,15 +99,12 @@ fun addMachineAdvancements(serializer: Consumer<AdvancementHolder>, lang: Matter
}, },
) )
.also { .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)) it.addCriterion(i.toString(), criterion(m))
} }
.requirements(RequirementsStrategy.OR) .requirements(RequirementsStrategy.OR)
.save(serializer, modLocation("machines/plate_press")) .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", CraftEntry(MItems.ENERGY_SERVO.values, "Power Goes In, Powered Things Go Out",
russianName = "Энергия на вход, электроинструмент на выход").make(serializer, press, translation) russianName = "Энергия на вход, электроинструмент на выход").make(serializer, press, translation)

View File

@ -119,6 +119,25 @@ private fun sounds(provider: MatteryLanguageProvider) {
private fun misc(provider: MatteryLanguageProvider) { private fun misc(provider: MatteryLanguageProvider) {
with(provider.english) { 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", "<Hold SHIFT for more info>") gui("shift_for_more_info", "<Hold SHIFT for more info>")
gui("help.slot_filters", "Hold CTRL to setup slot filters") 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.storage0", "Stored energy: %s")
misc("item.power.throughput", "Max I/O: %s / %s") misc("item.power.throughput", "Max I/O: %s / %s")
misc("item.power.throughput_mono", "Max I/O: %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_mono", "Work ticks: %s")
misc("item.worker.work_ticks", "Work ticks: %s / %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.item_count", "Items: %s / %s")
misc("item.pattern.research.advance", "Progress per item: %s%%") misc("item.pattern.research.advance", "Progress per item: %s%%")
misc("item.matter.storage", "Stored matter: %s / %s")
misc("item.matter.infinite", "Stored matter: ∞ / ∞") misc("item.matter.storage0", "Stored matter: %s")
misc("item.matter.normal", "Stored matter: %s / %s")
misc("gui.matter_task.total", "Total: %s") misc("gui.matter_task.total", "Total: %s")
misc("gui.matter_task.required", "Left to be done: %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) { private fun blocks(provider: MatteryLanguageProvider) {
with(provider.english) { with(provider.english) {
addBlock(MBlocks.ANDROID_STATION.values, "Android Station") 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, "Wireless Charger")
addBlock(MBlocks.ANDROID_CHARGER.values, "desc", "Charges nearby androids and exopacks") addBlock(MBlocks.ANDROID_CHARGER.values, "desc", "Charges nearby androids and exopacks")
addBlock(MBlocks.BATTERY_BANK.values, "Battery Bank") 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, "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, "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.MATTER_CABLE, "Matter Network Cable")
add(MBlocks.PATTERN_STORAGE, "Pattern Storage") 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, "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, "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, "Matter Replicator")
addBlock(MBlocks.MATTER_REPLICATOR.values, "desc", "Executes replication tasks")
addBlock(MBlocks.MATTER_BOTTLER.values, "Matter Bottler") addBlock(MBlocks.MATTER_BOTTLER.values, "Matter Bottler")
addBlock(MBlocks.DRIVE_VIEWER.values, "Drive Viewer") addBlock(MBlocks.MATTER_BOTTLER.values, "desc", "Exchanges matter between matter holding items")
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.ESSENCE_STORAGE.values, "Essence Storage") addBlock(MBlocks.ESSENCE_STORAGE.values, "Essence Storage")
addBlock(MBlocks.ESSENCE_STORAGE.values, "desc", "Allows to store and retrieve experience levels") 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, "Matter Reconstructor")
addBlock(MBlocks.MATTER_RECONSTRUCTOR.values, "desc", "Repairs tools using matter") 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, "Dev Chest")
add(MBlocks.DEV_CHEST, "desc", "Contains all items present in game") add(MBlocks.DEV_CHEST, "desc", "Contains all items present in game")
add(MBlocks.PAINTER, "Painting Table") add(MBlocks.PAINTER, "Painting Table")
add(MBlocks.MATTER_ENTANGLER, "Matter Entangler")
add(MBlocks.LIQUID_XP, "Liquid XP") add(MBlocks.LIQUID_XP, "Liquid XP")
add(MItems.LIQUID_XP_BUCKET, "Liquid XP Bucket") 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, "Ship Engine")
add(MBlocks.ENGINE, "desc", "Unfortunately, it doesn't seem to be functional anymore.") add(MBlocks.ENGINE, "desc", "Unfortunately, it doesn't seem to be functional anymore.")
add(MBlocks.HOLO_SIGN, "Holo Sign") 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") add(MBlocks.TRITANIUM_INGOT_BLOCK, "Tritanium Plating Block")
addBlock(MBlocks.ENERGY_COUNTER.values, "Energy Counter") 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]!!, "facing", "Input facing: %s")
add(MBlocks.ENERGY_COUNTER[null]!!, "switch", "Switch input facing") add(MBlocks.ENERGY_COUNTER[null]!!, "switch", "Switch input facing")
add(MBlocks.ENERGY_COUNTER[null]!!, "limit", "I/O Limit. -1 means no limit") 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, "Chemical Generator")
addBlock(MBlocks.CHEMICAL_GENERATOR.values, "desc", "Generates power by burning solid fuels")
add(MBlocks.DRIVE_RACK, "Condensation Drive Rack") add(MBlocks.DRIVE_RACK, "Condensation Drive Rack")
addBlock(MBlocks.ITEM_MONITOR.values, "Item Monitor") addBlock(MBlocks.ITEM_MONITOR.values, "Item Monitor")
addBlock(MBlocks.PLATE_PRESS.values, "Plate Press") addBlock(MBlocks.PLATE_PRESS.values, "Plate Press")
addBlock(MBlocks.TWIN_PLATE_PRESS.values, "Twin Plate Press") addBlock(MBlocks.TWIN_PLATE_PRESS.values, "Twin Plate Press")
addBlock(MBlocks.POWERED_FURNACE.values, "Electric Furnace") 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, "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, "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, "Energy Servo")
addBlock(MBlocks.ENERGY_SERVO.values, "desc", "Charges, Discharges or Exchanges energy of items") 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, "desc", "For those who feel bored")
add(MItems.EXPLOSIVE_HAMMER, "primed", "Primed!") add(MItems.EXPLOSIVE_HAMMER, "primed", "Primed!")
add(MItems.EXPLOSIVE_HAMMER, "not_primed0", "Not 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.EXOPACK_PROBE, "Exopack Probe")
add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_CREATIVE, "Creative Exopack Inventory Upgrade") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_CREATIVE, "Creative Exopack Inventory Upgrade")

View File

@ -1,5 +1,6 @@
package ru.dbotthepony.mc.otm.datagen.lang 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.AndroidFeatures
import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MBlocks
import ru.dbotthepony.mc.otm.registry.MEntityTypes import ru.dbotthepony.mc.otm.registry.MEntityTypes
@ -127,6 +128,25 @@ private fun sounds(provider: MatteryLanguageProvider) {
private fun misc(provider: MatteryLanguageProvider) { private fun misc(provider: MatteryLanguageProvider) {
with(provider.russian) { 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("shift_for_more_info", "<Удерживайте SHIFT для подробностей>")
gui("help.slot_filters", "Удерживайте CTRL для настройки фильтрации слотов") gui("help.slot_filters", "Удерживайте CTRL для настройки фильтрации слотов")
@ -283,9 +303,9 @@ private fun misc(provider: MatteryLanguageProvider) {
gui("power.last_tick", "Последний тик:") gui("power.last_tick", "Последний тик:")
misc("item.power.storage", "Хранимая энергия: %s / %s") misc("item.power.storage", "Хранимая энергия: %s / %s")
misc("item.power.storage0", "Хранимая энергия: %s")
misc("item.power.throughput", "Максимальная пропускная способность: %s / %s") misc("item.power.throughput", "Максимальная пропускная способность: %s / %s")
misc("item.power.throughput_mono", "Максимальная пропускная способность: %s") misc("item.power.throughput_mono", "Максимальная пропускная способность: %s")
misc("item.power.infinity", "∞ МтДж")
misc("item.worker.work_ticks_mono", "Рабочих тиков: %s") misc("item.worker.work_ticks_mono", "Рабочих тиков: %s")
misc("item.worker.work_ticks", "Рабочих тиков: %s / %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.item_count", "Предметы: %s / %s")
misc("item.pattern.research.advance", "Исследование за предмет: %s%%") misc("item.pattern.research.advance", "Исследование за предмет: %s%%")
misc("item.matter.infinite", "Хранимая материя неиссякаема") misc("item.matter.storage", "Хранимая материя: %s / %s")
misc("item.matter.normal", "Хранимая материя: %s / %s") misc("item.matter.storage0", "Хранимая материя: %s")
misc("gui.matter_task.total", "Всего: %s") misc("gui.matter_task.total", "Всего: %s")
misc("gui.matter_task.required", "Осталось исполнить: %s") misc("gui.matter_task.required", "Осталось исполнить: %s")
@ -419,29 +439,58 @@ private fun death(provider: MatteryLanguageProvider) {
private fun blocks(provider: MatteryLanguageProvider) { private fun blocks(provider: MatteryLanguageProvider) {
with(provider.russian) { with(provider.russian) {
addBlock(MBlocks.ANDROID_STATION.values, "Станция андроидов") addBlock(MBlocks.ANDROID_STATION.values, "Станция андроидов")
addBlock(MBlocks.ANDROID_STATION.values, "desc", "Даёт доступ к улучшениям андроида")
addBlock(MBlocks.ANDROID_CHARGER.values, "Беспроводной зарядник") addBlock(MBlocks.ANDROID_CHARGER.values, "Беспроводной зарядник")
addBlock(MBlocks.ANDROID_CHARGER.values, "desc", "Заряжает ближайших андроидов и экзопаки") addBlock(MBlocks.ANDROID_CHARGER.values, "desc", "Заряжает ближайших андроидов и экзопаки")
addBlock(MBlocks.BATTERY_BANK.values, "Банк аккумуляторов") addBlock(MBlocks.BATTERY_BANK.values, "Банк аккумуляторов")
addBlock(MBlocks.BATTERY_BANK.values, "desc", "Позволяет использовать аккумуляторы как обычное хранилище энергии")
addBlock(MBlocks.MATTER_DECOMPOSER.values, "Декомпозитор материи") addBlock(MBlocks.MATTER_DECOMPOSER.values, "Декомпозитор материи")
addBlock(MBlocks.MATTER_DECOMPOSER.values, "desc", "Разбивает предметы в чистую материю")
addBlock(MBlocks.MATTER_CAPACITOR_BANK.values, "Банк накопителей материи") addBlock(MBlocks.MATTER_CAPACITOR_BANK.values, "Банк накопителей материи")
addBlock(MBlocks.MATTER_CAPACITOR_BANK.values, "desc", "Является хранилищем материи для системы в связке с накопителями материи")
add(MBlocks.MATTER_CABLE, "Кабель сети материи") add(MBlocks.MATTER_CABLE, "Кабель сети материи")
add(MBlocks.PATTERN_STORAGE, "Хранилище шаблонов") add(MBlocks.PATTERN_STORAGE, "Хранилище шаблонов")
add(MBlocks.PATTERN_STORAGE, "desc", "Хранит шаблоны предметов для пользования сетью")
addBlock(MBlocks.MATTER_SCANNER.values, "Сканер материи") addBlock(MBlocks.MATTER_SCANNER.values, "Сканер материи")
addBlock(MBlocks.MATTER_SCANNER.values, "desc", "Сканирует предметы в шаблоны для будущей репликации")
addBlock(MBlocks.MATTER_PANEL.values, "Монитор шаблонов") addBlock(MBlocks.MATTER_PANEL.values, "Монитор шаблонов")
addBlock(MBlocks.MATTER_PANEL.values, "desc", "Позволяет создавать задачи репликации")
addBlock(MBlocks.MATTER_REPLICATOR.values, "Репликатор материи") addBlock(MBlocks.MATTER_REPLICATOR.values, "Репликатор материи")
addBlock(MBlocks.MATTER_REPLICATOR.values, "desc", "Исполняет задачи репликации")
addBlock(MBlocks.MATTER_BOTTLER.values, "Бутилировщик материи") addBlock(MBlocks.MATTER_BOTTLER.values, "Бутилировщик материи")
addBlock(MBlocks.DRIVE_VIEWER.values, "Просмотрщик дисков конденсации") addBlock(MBlocks.MATTER_BOTTLER.values, "desc", "Позволяет переливать материю между предметами, хранящими материю")
add(MBlocks.BLACK_HOLE, "Локализированная сингулярная точка аномального искажения пространства-времени")
addBlock(MBlocks.COBBLESTONE_GENERATOR.values, "Генератор булыжника")
add(MBlocks.INFINITE_WATER_SOURCE, "Неиссякаемый источник воды")
addBlock(MBlocks.ESSENCE_STORAGE.values, "Хранилище эссенции") addBlock(MBlocks.ESSENCE_STORAGE.values, "Хранилище эссенции")
addBlock(MBlocks.ESSENCE_STORAGE.values, "desc", "Позволяет хранить очки опыта") addBlock(MBlocks.ESSENCE_STORAGE.values, "desc", "Позволяет хранить очки опыта")
addBlock(MBlocks.MATTER_RECONSTRUCTOR.values, "Материальный реконструктор") addBlock(MBlocks.MATTER_RECONSTRUCTOR.values, "Материальный реконструктор")
addBlock(MBlocks.MATTER_RECONSTRUCTOR.values, "desc", "Чинит инструменты используя материю") 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, "Сундук разработчика")
add(MBlocks.DEV_CHEST, "desc", "Хранит все предметы, которые есть в игре") add(MBlocks.DEV_CHEST, "desc", "Хранит все предметы, которые есть в игре")
add(MBlocks.PAINTER, "Стол маляра") add(MBlocks.PAINTER, "Стол маляра")
add(MBlocks.MATTER_ENTANGLER, "Квантовый запутыватель материи")
addBlock(MBlocks.DRIVE_VIEWER.values, "Просмотрщик дисков конденсации")
add(MBlocks.LIQUID_XP, "Жидкий опыт") add(MBlocks.LIQUID_XP, "Жидкий опыт")
add(MItems.LIQUID_XP_BUCKET, "Ведро жидкого опыта") add(MItems.LIQUID_XP_BUCKET, "Ведро жидкого опыта")
@ -450,27 +499,38 @@ private fun blocks(provider: MatteryLanguageProvider) {
add(MBlocks.FLUID_TANK, "named", "Жидкостный бак (%s)") add(MBlocks.FLUID_TANK, "named", "Жидкостный бак (%s)")
add(MBlocks.ENGINE, "Двигатель корабля") add(MBlocks.ENGINE, "Двигатель корабля")
add(MBlocks.ENGINE, "desc", "К сожалению, он больше не выглядит рабочим.") add(MBlocks.ENGINE, "desc", "К сожалению, он более не функционирует")
add(MBlocks.HOLO_SIGN, "Голографическая табличка") add(MBlocks.HOLO_SIGN, "Голографическая табличка")
add(MBlocks.HOLO_SIGN, "desc", "Многострочная, крашеная и светящееся, табличка")
add(MBlocks.TRITANIUM_INGOT_BLOCK, "Блок слитков тритана") add(MBlocks.TRITANIUM_INGOT_BLOCK, "Блок слитков тритана")
addBlock(MBlocks.ENERGY_COUNTER.values, "Счётчик энергии") 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]!!, "Facing", "сторона входа: %s")
add(MBlocks.ENERGY_COUNTER[null]!!, "Switch", "сменить сторону входа") add(MBlocks.ENERGY_COUNTER[null]!!, "Switch", "сменить сторону входа")
add(MBlocks.ENERGY_COUNTER[null]!!, "Limit", "лимит ввода/вывода. -1 для отключения лимитов") add(MBlocks.ENERGY_COUNTER[null]!!, "Limit", "лимит ввода/вывода. -1 для отключения лимитов")
addBlock(MBlocks.CHEMICAL_GENERATOR.values, "Химический генератор") addBlock(MBlocks.CHEMICAL_GENERATOR.values, "Химический генератор")
addBlock(MBlocks.CHEMICAL_GENERATOR.values, "desc", "Генерирует энергию сжигая твёрдое топливо")
add(MBlocks.DRIVE_RACK, "Стеллаж дисков конденсации") add(MBlocks.DRIVE_RACK, "Стеллаж дисков конденсации")
addBlock(MBlocks.ITEM_MONITOR.values, "Монитор предметов") addBlock(MBlocks.ITEM_MONITOR.values, "Монитор предметов")
addBlock(MBlocks.PLATE_PRESS.values, "Пресс пластин") addBlock(MBlocks.PLATE_PRESS.values, "Пресс пластин")
addBlock(MBlocks.TWIN_PLATE_PRESS.values, "Двойной пресс пластин") addBlock(MBlocks.TWIN_PLATE_PRESS.values, "Двойной пресс пластин")
addBlock(MBlocks.POWERED_FURNACE.values, "Электрическая печь") addBlock(MBlocks.POWERED_FURNACE.values, "Электрическая печь")
addBlock(MBlocks.POWERED_FURNACE.values, "desc", "Позволяет обрабатывать рецепты печи используя энергию")
addBlock(MBlocks.POWERED_BLAST_FURNACE.values, "Индукционная печь") addBlock(MBlocks.POWERED_BLAST_FURNACE.values, "Индукционная печь")
addBlock(MBlocks.POWERED_BLAST_FURNACE.values, "desc", "Позволяет обрабатывать рецепты плавильной печи используя энергию")
addBlock(MBlocks.POWERED_SMOKER.values, "Микроволновая печь") 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, "Энергетическая помпа")
addBlock(MBlocks.ENERGY_SERVO.values, "desc", "заряжает, разряжает и передаёт энергию между предметами") addBlock(MBlocks.ENERGY_SERVO.values, "desc", "заряжает, разряжает и передаёт энергию между предметами")
@ -532,7 +592,7 @@ private fun items(provider: MatteryLanguageProvider) {
add(MItems.EXPLOSIVE_HAMMER, "desc", "Для тех, кому стало скучно") add(MItems.EXPLOSIVE_HAMMER, "desc", "Для тех, кому стало скучно")
add(MItems.EXPLOSIVE_HAMMER, "primed", "Заряжен!") add(MItems.EXPLOSIVE_HAMMER, "primed", "Заряжен!")
add(MItems.EXPLOSIVE_HAMMER, "not_primed0", "Не заряжен") add(MItems.EXPLOSIVE_HAMMER, "not_primed0", "Не заряжен")
add(MItems.EXPLOSIVE_HAMMER, "not_primed1", "Для зарядки добавьте немного пороха и наконечник-самородок") add(MItems.EXPLOSIVE_HAMMER, "not_primed1", "Для зарядки необходимо немного пороха и наконечник-самородок в вашем инвентаре, и зарядите удерживая ПКМ")
add(MItems.EXOPACK_PROBE, "Маяк экзопака") add(MItems.EXOPACK_PROBE, "Маяк экзопака")
add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_CREATIVE, "Творческое обновление инвентаря экзопака") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_CREATIVE, "Творческое обновление инвентаря экзопака")

View File

@ -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)
}

View File

@ -55,32 +55,36 @@ fun addCraftingTableRecipes(consumer: RecipeOutput) {
.unlockedBy(MItems.HOLO_SIGN) .unlockedBy(MItems.HOLO_SIGN)
.save(consumer, modLocation("holo_sign_reset")) .save(consumer, modLocation("holo_sign_reset"))
MatteryRecipe(MBlocks.PLATE_PRESS[null]!!, category = machinesCategory) MatteryRecipe(MBlocks.ENERGY_COUNTER[null]!!, category = machinesCategory)
.row(MItems.ELECTRIC_PARTS, MItems.ENERGY_BUS, MItems.ELECTRIC_PARTS) .row(MItemTags.TRITANIUM_PLATES, MItems.ENERGY_BUS, MItemTags.TRITANIUM_PLATES)
.row(MItemTags.TRITANIUM_INGOTS, Items.BLAST_FURNACE, MItemTags.TRITANIUM_INGOTS) .row(MItemTags.BASIC_CIRCUIT, Tags.Items.DUSTS_GLOWSTONE, MItemTags.HARDENED_GLASS_PANES_COLORLESS)
.row(MItemTags.PISTONS, MItemTags.TRITANIUM_INGOTS, MItemTags.PISTONS) .row(MItemTags.TRITANIUM_PLATES, MItems.ENERGY_BUS, MItemTags.TRITANIUM_PLATES)
.unlockedBy(MItemTags.TRITANIUM_INGOTS) .unlockedBy(MItems.ENERGY_BUS)
.unlockedBy(MItems.ELECTRIC_PARTS)
.build(consumer) .build(consumer)
MatteryRecipe(MBlocks.PLATE_PRESS[null]!!, category = machinesCategory) MatteryRecipe(MBlocks.TWIN_PLATE_PRESS[null]!!, category = machinesCategory)
.rowB(MItemTags.PISTONS) .rowAC(MItems.ELECTROMOTOR, MItems.ELECTROMOTOR)
.rowB(MItems.MACHINE_FRAME) .row(MItemTags.PISTONS, MItems.MACHINE_FRAME, MItemTags.PISTONS)
.unlockedBy(MItemTags.TRITANIUM_INGOTS) .unlockedBy(MItemTags.TRITANIUM_INGOTS)
.unlockedBy(MItems.ELECTRIC_PARTS) .unlockedBy(MItems.MACHINE_FRAME)
.build(consumer, "advanced") .build(consumer)
for ((color, press) in MBlocks.PLATE_PRESS) { for ((color, item) in MItems.PLATE_PRESS) {
MatteryRecipe(MBlocks.TWIN_PLATE_PRESS[color]!!, category = machinesCategory) MatteryRecipe(MBlocks.TWIN_PLATE_PRESS[color]!!, category = machinesCategory)
.setUpgradeSource(press) .setUpgradeSource(item)
.addUpgradeOps(UpgradeRecipe.Direct("BlockEntityTag")) .addUpgradeOps(UpgradeRecipe.All)
.rowB(MItemTags.PISTONS) .rowA(item)
.rowB(press) .build(consumer, "plate_press_migration/${color?.name?.lowercase() ?: "default"}")
.rowB(MItemTags.TRITANIUM_PLATES)
.unlockedBy(MBlocks.PLATE_PRESS.values)
.build(consumer, "twin_plate_press/${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) MatteryRecipe(MItems.PATTERN_DRIVE_NORMAL, category = machinesCategory)
.rowAC(MItemTags.ADVANCED_CIRCUIT, MItemTags.ADVANCED_CIRCUIT) .rowAC(MItemTags.ADVANCED_CIRCUIT, MItemTags.ADVANCED_CIRCUIT)
.row(MItemTags.ADVANCED_CIRCUIT, MItemTags.TRITANIUM_PLATES, 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) .unlockedBy(MItemTags.TRITANIUM_INGOTS)
.build(consumer) .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) 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.MACHINE_FRAME, MItemTags.TRITANIUM_PLATES)
.row(MItemTags.TRITANIUM_PLATES, MItems.ELECTRIC_PARTS, MItemTags.TRITANIUM_PLATES) .row(MItemTags.TRITANIUM_PLATES, MItems.ELECTRIC_PARTS, MItemTags.TRITANIUM_PLATES)
.build(consumer) .build(consumer)
@ -332,14 +298,6 @@ fun addCraftingTableRecipes(consumer: RecipeOutput) {
.row(MItemTags.TRITANIUM_PLATES, MItems.MACHINE_FRAME, MItemTags.TRITANIUM_PLATES) .row(MItemTags.TRITANIUM_PLATES, MItems.MACHINE_FRAME, MItemTags.TRITANIUM_PLATES)
.build(consumer) .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) MatteryRecipe(MItems.ExopackUpgrades.CRAFTING_UPGRADE, category = RecipeCategory.TOOLS)
.row(MItemTags.ADVANCED_CIRCUIT, MItemTags.ADVANCED_CIRCUIT, MItemTags.ADVANCED_CIRCUIT) .row(MItemTags.ADVANCED_CIRCUIT, MItemTags.ADVANCED_CIRCUIT, MItemTags.ADVANCED_CIRCUIT)
@ -416,6 +374,12 @@ fun addCraftingTableRecipes(consumer: RecipeOutput) {
.build(consumer) .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) MatteryRecipe(MItems.FLUID_CAPSULE, category = RecipeCategory.TOOLS, count = 8)
.row(MItemTags.TRITANIUM_NUGGETS, MItemTags.TRITANIUM_NUGGETS, MItemTags.TRITANIUM_NUGGETS) .row(MItemTags.TRITANIUM_NUGGETS, MItemTags.TRITANIUM_NUGGETS, MItemTags.TRITANIUM_NUGGETS)
.rowB(MItemTags.HARDENED_GLASS_PANES) .rowB(MItemTags.HARDENED_GLASS_PANES)

View File

@ -274,7 +274,6 @@ fun addPainterRecipes(consumer: RecipeOutput) {
val blocks = listOf( val blocks = listOf(
MItems.COBBLESTONE_GENERATOR, MItems.COBBLESTONE_GENERATOR,
MItems.ESSENCE_STORAGE, MItems.ESSENCE_STORAGE,
MItems.PLATE_PRESS,
MItems.TWIN_PLATE_PRESS, MItems.TWIN_PLATE_PRESS,
MItems.ITEM_MONITOR, MItems.ITEM_MONITOR,
MItems.MATTER_BOTTLER, MItems.MATTER_BOTTLER,

View File

@ -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)
}

View File

@ -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)
}

View File

@ -55,6 +55,7 @@ fun addTags(tagsProvider: TagsProvider) {
tagsProvider.items.Appender(MItemTags.CRAFTING_TABLES).add(Items.CRAFTING_TABLE) tagsProvider.items.Appender(MItemTags.CRAFTING_TABLES).add(Items.CRAFTING_TABLE)
tagsProvider.items.Appender(MItemTags.WORKBENCHES).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.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.CRAFTING_TABLES).add(Blocks.CRAFTING_TABLE)
tagsProvider.blocks.Appender(MBlockTags.WORKBENCHES).add(Blocks.CRAFTING_TABLE) tagsProvider.blocks.Appender(MBlockTags.WORKBENCHES).add(Blocks.CRAFTING_TABLE)
tagsProvider.blocks.Appender(MBlockTags.WORKBENCH).add(Blocks.CRAFTING_TABLE) tagsProvider.blocks.Appender(MBlockTags.WORKBENCH).add(Blocks.CRAFTING_TABLE)

View File

@ -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.MatteryBlockEntity
import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity
import ru.dbotthepony.mc.otm.block.entity.WorkerState 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.TranslatableComponent
import ru.dbotthepony.mc.otm.core.addDescriptionFunctions
import ru.dbotthepony.mc.otm.core.asSupplier import ru.dbotthepony.mc.otm.core.asSupplier
import ru.dbotthepony.mc.otm.core.collect.SupplierMap import ru.dbotthepony.mc.otm.core.collect.SupplierMap
import ru.dbotthepony.mc.otm.core.get 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( override fun setPlacedBy(
level: Level, level: Level,
blockPos: BlockPos, blockPos: BlockPos,
@ -262,7 +263,7 @@ open class MatteryBlock(properties: Properties = DEFAULT_PROPERTIES) : Block(pro
override fun appendHoverText(itemStack: ItemStack, blockAccessor: BlockGetter?, components: MutableList<Component>, tooltipType: TooltipFlag) { override fun appendHoverText(itemStack: ItemStack, blockAccessor: BlockGetter?, components: MutableList<Component>, tooltipType: TooltipFlag) {
super.appendHoverText(itemStack, blockAccessor, components, tooltipType) super.appendHoverText(itemStack, blockAccessor, components, tooltipType)
assembleDescription(itemStack, components) tooltips.assemble(itemStack, components)
} }
companion object { companion object {
@ -272,5 +273,6 @@ open class MatteryBlock(properties: Properties = DEFAULT_PROPERTIES) : Block(pro
} }
fun <T : MatteryBlock> T.addSimpleDescription(suffix: String = "", formatting: ChatFormatting = ChatFormatting.GRAY): T { fun <T : MatteryBlock> 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
} }

View File

@ -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.BlockState
import net.minecraft.world.level.block.state.properties.BlockSetType import net.minecraft.world.level.block.state.properties.BlockSetType
import net.minecraft.world.level.material.PushReaction 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.TranslatableComponent
import ru.dbotthepony.mc.otm.core.collect.iteratorOf
class TritaniumDoorBlock(val color: DyeColor?) : DoorBlock( class TritaniumDoorBlock(val color: DyeColor?) : DoorBlock(
Properties.of() Properties.of()
@ -25,6 +27,14 @@ class TritaniumDoorBlock(val color: DyeColor?) : DoorBlock(
.requiresCorrectToolForDrops(), .requiresCorrectToolForDrops(),
BlockSetType.IRON 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( override fun appendHoverText(
p_49816_: ItemStack, p_49816_: ItemStack,
p_49817_: BlockGetter?, p_49817_: BlockGetter?,
@ -32,12 +42,7 @@ class TritaniumDoorBlock(val color: DyeColor?) : DoorBlock(
p_49819_: TooltipFlag p_49819_: TooltipFlag
) { ) {
super.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) super.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_)
p_49818_.add(TranslatableComponent("$descriptionId.description0").withStyle(ChatFormatting.DARK_GRAY)) tooltips.assemble(p_49816_, p_49818_)
p_49818_.add(TranslatableComponent("$descriptionId.description1").withStyle(ChatFormatting.DARK_GRAY))
if (color != null) {
p_49818_.add(TranslatableComponent("$descriptionId.description2").withStyle(ChatFormatting.DARK_GRAY))
}
} }
override fun canEntityDestroy( override fun canEntityDestroy(

View File

@ -4,14 +4,11 @@ import net.minecraft.ChatFormatting
import net.minecraft.core.BlockPos import net.minecraft.core.BlockPos
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.server.level.ServerPlayer 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.DyeColor
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.TooltipFlag import net.minecraft.world.item.TooltipFlag
import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.Level 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.BasePressurePlateBlock
import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.SoundType 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.StateDefinition
import net.minecraft.world.level.block.state.properties.BlockSetType import net.minecraft.world.level.block.state.properties.BlockSetType
import net.minecraft.world.level.block.state.properties.BlockStateProperties 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.TranslatableComponent
import ru.dbotthepony.mc.otm.core.collect.iteratorOf
import ru.dbotthepony.mc.otm.core.get 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) { 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( override fun appendHoverText(
p_49816_: ItemStack, itemStack: ItemStack,
p_49817_: BlockGetter?, level: BlockGetter?,
p_49818_: MutableList<Component>, lines: MutableList<Component>,
p_49819_: TooltipFlag tooltipType: TooltipFlag
) { ) {
super.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) super.appendHoverText(itemStack, level, lines, tooltipType)
p_49818_.add(TranslatableComponent("$descriptionId.description0").withStyle(ChatFormatting.DARK_GRAY)) tooltips.assemble(itemStack, lines)
p_49818_.add(TranslatableComponent("$descriptionId.description1").withStyle(ChatFormatting.DARK_GRAY))
} }
init { 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)) registerDefaultState(stateDefinition.any().setValue(BlockStateProperties.POWERED, false))
} }

View File

@ -13,7 +13,9 @@ import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.block.TrapDoorBlock import net.minecraft.world.level.block.TrapDoorBlock
import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.block.state.properties.BlockSetType 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.TranslatableComponent
import ru.dbotthepony.mc.otm.core.collect.iteratorOf
class TritaniumTrapdoorBlock(val color: DyeColor?) : TrapDoorBlock( class TritaniumTrapdoorBlock(val color: DyeColor?) : TrapDoorBlock(
Properties.of() Properties.of()
@ -24,6 +26,14 @@ class TritaniumTrapdoorBlock(val color: DyeColor?) : TrapDoorBlock(
.isValidSpawn { _: BlockState, _: BlockGetter, _: BlockPos, _: EntityType<*>? -> false }, .isValidSpawn { _: BlockState, _: BlockGetter, _: BlockPos, _: EntityType<*>? -> false },
BlockSetType.IRON 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( override fun appendHoverText(
p_49816_: ItemStack, p_49816_: ItemStack,
p_49817_: BlockGetter?, p_49817_: BlockGetter?,
@ -31,12 +41,7 @@ class TritaniumTrapdoorBlock(val color: DyeColor?) : TrapDoorBlock(
p_49819_: TooltipFlag p_49819_: TooltipFlag
) { ) {
super.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) super.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_)
p_49818_.add(TranslatableComponent("$descriptionId.description0").withStyle(ChatFormatting.DARK_GRAY)) tooltips.assemble(p_49816_, p_49818_)
p_49818_.add(TranslatableComponent("$descriptionId.description1").withStyle(ChatFormatting.DARK_GRAY))
if (color != null) {
p_49818_.add(TranslatableComponent("$descriptionId.description2").withStyle(ChatFormatting.DARK_GRAY))
}
} }
override fun canEntityDestroy( override fun canEntityDestroy(

View File

@ -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.IntCounter
import ru.dbotthepony.mc.otm.core.util.Savetables import ru.dbotthepony.mc.otm.core.util.Savetables
import ru.dbotthepony.mc.otm.core.util.TickList 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.BlockEntitySyncPacket
import ru.dbotthepony.mc.otm.network.GenericNetworkChannel import ru.dbotthepony.mc.otm.network.GenericNetworkChannel
import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer 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 { abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: BlockPos, p_155230_: BlockState) : BlockEntity(p_155228_, p_155229_, p_155230_), INeighbourChangeListener {
private var isSynchronizing = false private var isSynchronizing = false
/** private val sidelessCaps = Reference2ObjectOpenHashMap<Capability<*>, SidelessCap<*>>()
* "shortcut" for getting [BlockRotation] protected val tickList = TickList()
* protected val blockStateChangesCounter = IntCounter()
* if block has no rotation, returns [BlockRotation.NORTH] protected val dirtyListeners = ISubscriptable.Impl<Unit>()
*/ private val waitForServerLevel = ArrayList<() -> Unit>()
open val blockRotation: BlockRotation get() {
return blockState[(blockState.block as? RotatableMatteryBlock ?: return BlockRotation.NORTH).rotationProperty]
}
private val _droppableContainers = ObjectArraySet<Container>() private val _droppableContainers = ObjectArraySet<Container>()
private val _neighbourChangeListeners = ObjectArraySet<INeighbourChangeListener>() private val _neighbourChangeListeners = ObjectArraySet<INeighbourChangeListener>()
val droppableContainers: Set<Container> = Collections.unmodifiableSet(_droppableContainers) val droppableContainers: Set<Container> = Collections.unmodifiableSet(_droppableContainers)
val neighbourChangeListeners: Set<INeighbourChangeListener> = Collections.unmodifiableSet(_neighbourChangeListeners) val neighbourChangeListeners: Set<INeighbourChangeListener> = Collections.unmodifiableSet(_neighbourChangeListeners)
private val _sides = EnumMap<RelativeSide, Side>(RelativeSide::class.java)
val sides: Map<RelativeSide, Side> = 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) { protected fun addDroppableContainer(container: Container) {
_droppableContainers.add(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 beforeDroppingItems(oldBlockState: BlockState, level: Level, blockPos: BlockPos, newBlockState: BlockState, movedByPiston: Boolean) {}
open fun beforeDestroyedByPlayer(level: Level, blockPos: BlockPos, blockState: BlockState, player: Player) {} open fun beforeDestroyedByPlayer(level: Level, blockPos: BlockPos, blockState: BlockState, player: Player) {}
private val _sides = EnumMap<RelativeSide, Side>(RelativeSide::class.java)
val sides: Map<RelativeSide, Side> = Collections.unmodifiableMap(_sides)
fun side(side: RelativeSide) = sides[side]!! fun side(side: RelativeSide) = sides[side]!!
private data class SidelessCap<T : Any>(val cap: T, var optional: LazyOptional<T>) private data class SidelessCap<T : Any>(val cap: T, var optional: LazyOptional<T>)
private val sidelessCaps = Reference2ObjectOpenHashMap<Capability<*>, SidelessCap<*>>()
protected val tickList = TickList()
protected val blockStateChangesCounter = IntCounter()
protected val dirtyListeners = ISubscriptable.Impl<Unit>()
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() { open fun tick() {
tickList.tick() tickList.tick()
@ -441,8 +443,8 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc
@Suppress("OVERRIDE_DEPRECATION") @Suppress("OVERRIDE_DEPRECATION")
override fun setBlockState(pBlockState: BlockState) { override fun setBlockState(pBlockState: BlockState) {
blockStateChangesCounter.increment()
val old = blockRotation val old = blockRotation
blockStateChangesCounter.increment()
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
super.setBlockState(pBlockState) super.setBlockState(pBlockState)
val new = blockRotation val new = blockRotation

View File

@ -1,25 +1,15 @@
package ru.dbotthepony.mc.otm.block.entity package ru.dbotthepony.mc.otm.block.entity
import net.minecraft.ChatFormatting
import net.minecraft.core.BlockPos 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.entity.BlockEntityType
import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.BlockState
import net.minecraftforge.common.capabilities.ForgeCapabilities 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.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.HandlerFilter
import ru.dbotthepony.mc.otm.container.MatteryContainer 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.ifPresentK
import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.Decimal
import ru.dbotthepony.mc.otm.core.nbt.map
abstract class MatteryPoweredBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(p_155228_, p_155229_, p_155230_) { 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) val batteryContainer = MatteryContainer(::markDirtyFast, 1).also(::addDroppableContainer)
@ -51,18 +41,4 @@ abstract class MatteryPoweredBlockEntity(p_155228_: BlockEntityType<*>, p_155229
return return
} }
} }
companion object {
fun appendHoverText(itemStack: ItemStack, blockGetter: BlockGetter?, tooltips: MutableList<Component>, 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)
}
}
}
} }

View File

@ -160,15 +160,4 @@ abstract class MatteryWorkerBlockEntity<JobType : IJob>(
} }
} }
} }
companion object {
private val LOGGER = LogManager.getLogger()
fun appendHoverText(itemStack: ItemStack, blockGetter: BlockGetter?, tooltips: MutableList<Component>, flag: TooltipFlag) {
itemStack.tag ?: return
WorkerEnergyStorage.appendHoverText(itemStack, blockGetter, tooltips, flag)
MatteryPoweredBlockEntity.appendHoverText(itemStack, blockGetter, tooltips, flag)
}
}
} }

View File

@ -100,7 +100,7 @@ class MatterBottlerBlockEntity(blockPos: BlockPos, blockState: BlockState) :
battery = batteryItemHandler battery = batteryItemHandler
) )
val matter: ProfiledMatterStorage<MatterStorageImpl> = ProfiledMatterStorage(object : MatterStorageImpl(this::markDirtyFast, FlowDirection.BI_DIRECTIONAL, upgrades.matterCapacity(MachinesConfig.MatterBottler.VALUES::matterCapacity)) { val matter: ProfiledMatterStorage<MatterStorageImpl> = ProfiledMatterStorage(object : MatterStorageImpl(this@MatterBottlerBlockEntity::markDirtyFast, FlowDirection.BI_DIRECTIONAL, upgrades.matterCapacity(MachinesConfig.MatterBottler.VALUES::matterCapacity)) {
override val matterFlow: FlowDirection get() { override val matterFlow: FlowDirection get() {
return if (this@MatterBottlerBlockEntity.isBottling) FlowDirection.INPUT else FlowDirection.OUTPUT return if (this@MatterBottlerBlockEntity.isBottling) FlowDirection.INPUT else FlowDirection.OUTPUT
} }

View File

@ -82,7 +82,7 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState)
} }
if (summ.isPositive && !simulate) { if (summ.isPositive && !simulate) {
gaugeLevel = (storedMatter / maxStoredMatter).toFloat() gaugeLevel = storedMatter.percentage(maxStoredMatter)
} }
return summ return summ
@ -111,7 +111,7 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState)
} }
if (summ.isPositive && !simulate) { if (summ.isPositive && !simulate) {
gaugeLevel = (storedMatter / maxStoredMatter).toFloat() gaugeLevel = storedMatter.percentage(maxStoredMatter)
} }
return summ return summ
@ -124,7 +124,7 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState)
override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) {
super.setChanged(slot, new, old) super.setChanged(slot, new, old)
capacitorStatus[slot].boolean = new.getCapability(MatteryCapability.MATTER).isPresent capacitorStatus[slot].boolean = new.getCapability(MatteryCapability.MATTER).isPresent
gaugeLevel = (storedMatter / maxStoredMatter).toFloat() gaugeLevel = storedMatter.percentage(maxStoredMatter)
} }
override fun getMaxStackSize(): Int = 1 override fun getMaxStackSize(): Int = 1

View File

@ -1,6 +1,5 @@
package ru.dbotthepony.mc.otm.block.entity.matter package ru.dbotthepony.mc.otm.block.entity.matter
import javax.annotation.ParametersAreNonnullByDefault
import net.minecraft.core.BlockPos import net.minecraft.core.BlockPos
import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.BlockState
import ru.dbotthepony.mc.otm.container.MatteryContainer 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.entity.player.Player
import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.inventory.AbstractContainerMenu
import ru.dbotthepony.mc.otm.menu.matter.PatternStorageMenu import ru.dbotthepony.mc.otm.menu.matter.PatternStorageMenu
import net.minecraft.MethodsReturnNonnullByDefault
import net.minecraft.world.level.Level import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.Block
import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity 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 ru.dbotthepony.mc.otm.registry.MBlockEntities
import java.util.stream.Stream import java.util.stream.Stream
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
MatteryDeviceBlockEntity(MBlockEntities.PATTERN_STORAGE, p_155229_, p_155230_), IPatternStorage { MatteryDeviceBlockEntity(MBlockEntities.PATTERN_STORAGE, p_155229_, p_155230_), IPatternStorage {

View File

@ -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.map
import ru.dbotthepony.mc.otm.core.nbt.mapPresent import ru.dbotthepony.mc.otm.core.nbt.mapPresent
import ru.dbotthepony.mc.otm.core.nbt.set 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.menu.tech.EnergyCounterMenu
import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlockEntities
import java.util.* 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_) { class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.ENERGY_COUNTER, p_155229_, p_155230_) {
var passed by synchronizer.decimal() var passed by synchronizer.decimal()
override val blockRotation: BlockRotation get() { override val blockRotation: BlockRotation by countingLazy(blockStateChangesCounter) {
return BlockRotation.of(blockState[EnergyCounterBlock.INPUT_DIRECTION]) BlockRotation.of(blockState[EnergyCounterBlock.INPUT_DIRECTION])
} }
private val history = Array(10 * 20) { Decimal.ZERO } private val history = Array(10 * 20) { Decimal.ZERO }

View File

@ -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.collect.maybe
import ru.dbotthepony.mc.otm.core.value import ru.dbotthepony.mc.otm.core.value
import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu 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.MBlockEntities
import ru.dbotthepony.mc.otm.registry.MRecipes import ru.dbotthepony.mc.otm.registry.MRecipes
@ -56,10 +55,7 @@ class PlatePressBlockEntity(
} }
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
if (isTwin) return if (isTwin) PlatePressMenu.twin(containerID, inventory, this) else PlatePressMenu.single(containerID, inventory, this)
return TwinPlatePressMenu(containerID, inventory, this)
else
return PlatePressMenu(containerID, inventory, this)
} }
override fun onJobFinish(status: JobStatus<ItemJob>, id: Int) { override fun onJobFinish(status: JobStatus<ItemJob>, id: Int) {

View File

@ -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.CollisionContext
import net.minecraft.world.phys.shapes.VoxelShape import net.minecraft.world.phys.shapes.VoxelShape
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock 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.WorkerState
import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity
import ru.dbotthepony.mc.otm.block.getShapeForEachState 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 import ru.dbotthepony.mc.otm.shapes.BlockShapes
class MatterBottlerBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { 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 { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity {
return MatterBottlerBlockEntity(blockPos, blockState) 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) if (p_153212_.isClientSide || p_153214_ !== MBlockEntities.MATTER_BOTTLER)
return null 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<Block, BlockState>) { override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {

View File

@ -14,12 +14,18 @@ import net.minecraft.world.phys.shapes.CollisionContext
import net.minecraft.world.phys.shapes.VoxelShape import net.minecraft.world.phys.shapes.VoxelShape
import ru.dbotthepony.mc.otm.block.tech.BatteryBankBlock import ru.dbotthepony.mc.otm.block.tech.BatteryBankBlock
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock 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.entity.matter.MatterCapacitorBankBlockEntity
import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.block.getShapeForEachState
import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.get
import ru.dbotthepony.mc.otm.shapes.BlockShapes import ru.dbotthepony.mc.otm.shapes.BlockShapes
class MatterCapacitorBankBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { class MatterCapacitorBankBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock {
init {
tooltips.colored(color)
addSimpleDescription()
}
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity {
return MatterCapacitorBankBlockEntity(blockPos, blockState) return MatterCapacitorBankBlockEntity(blockPos, blockState)
} }

View File

@ -1,7 +1,5 @@
package ru.dbotthepony.mc.otm.block.matter 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.world.level.block.EntityBlock
import net.minecraft.core.BlockPos import net.minecraft.core.BlockPos
import net.minecraft.world.item.DyeColor 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.CollisionContext
import net.minecraft.world.phys.shapes.VoxelShape import net.minecraft.world.phys.shapes.VoxelShape
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock 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.WorkerState
import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.block.getShapeForEachState
import ru.dbotthepony.mc.otm.core.get 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 import ru.dbotthepony.mc.otm.shapes.BlockShapes
class MatterDecomposerBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { 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 { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity {
return MatterDecomposerBlockEntity(blockPos, blockState) return MatterDecomposerBlockEntity(blockPos, blockState)
} }

View File

@ -11,6 +11,11 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
import ru.dbotthepony.mc.otm.block.entity.matter.MatterEntanglerBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterEntanglerBlockEntity
class MatterEntanglerBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { class MatterEntanglerBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock {
init {
tooltips.blockEntityEnergy()
tooltips.blockEntityMatter()
}
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity {
return MatterEntanglerBlockEntity(blockPos, blockState) return MatterEntanglerBlockEntity(blockPos, blockState)
} }

View File

@ -1,6 +1,5 @@
package ru.dbotthepony.mc.otm.block.matter package ru.dbotthepony.mc.otm.block.matter
import com.google.common.collect.ImmutableMap
import net.minecraft.world.level.block.EntityBlock import net.minecraft.world.level.block.EntityBlock
import net.minecraft.core.BlockPos import net.minecraft.core.BlockPos
import net.minecraft.core.Direction 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.phys.shapes.CollisionContext
import net.minecraft.world.item.context.BlockPlaceContext import net.minecraft.world.item.context.BlockPlaceContext
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock 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.get
import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.BlockRotation
import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
class MatterPanelBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { class MatterPanelBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock {
init {
tooltips.colored(color)
addSimpleDescription()
}
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity {
return MatterPanelBlockEntity(blockPos, blockState) return MatterPanelBlockEntity(blockPos, blockState)
} }

View File

@ -19,6 +19,13 @@ import ru.dbotthepony.mc.otm.core.get
import ru.dbotthepony.mc.otm.shapes.BlockShapes import ru.dbotthepony.mc.otm.shapes.BlockShapes
class MatterReconstructorBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { 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 { override fun newBlockEntity(pPos: BlockPos, pState: BlockState): BlockEntity {
return MatterReconstructorBlockEntity(pPos, pState) return MatterReconstructorBlockEntity(pPos, pState)
} }
@ -30,10 +37,6 @@ class MatterReconstructorBlock(val color: DyeColor?) : RotatableMatteryBlock(DEF
return BlockEntityTicker { _, _, _, pBlockEntity -> if (pBlockEntity is MatterReconstructorBlockEntity) pBlockEntity.tick() } return BlockEntityTicker { _, _, _, pBlockEntity -> if (pBlockEntity is MatterReconstructorBlockEntity) pBlockEntity.tick() }
} }
init {
addSimpleDescription()
}
private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.MATTER_RECONSTRUCTOR.rotateFromNorth(it[rotationProperty]).computeShape() } private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.MATTER_RECONSTRUCTOR.rotateFromNorth(it[rotationProperty]).computeShape() }
@Suppress("override_deprecation") @Suppress("override_deprecation")

View File

@ -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.CollisionContext
import net.minecraft.world.phys.shapes.VoxelShape import net.minecraft.world.phys.shapes.VoxelShape
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock 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.matter.MatterRecyclerBlockEntity
import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.entity.WorkerState
import ru.dbotthepony.mc.otm.block.getShapeForEachState 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 import ru.dbotthepony.mc.otm.shapes.BlockShapes
class MatterRecyclerBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { 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 { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
return MatterRecyclerBlockEntity(p_153215_, p_153216_) return MatterRecyclerBlockEntity(p_153215_, p_153216_)
} }

View File

@ -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.CollisionContext
import net.minecraft.world.phys.shapes.VoxelShape import net.minecraft.world.phys.shapes.VoxelShape
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock 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.matter.MatterReplicatorBlockEntity
import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.entity.WorkerState
import ru.dbotthepony.mc.otm.block.getShapeForEachState 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 import ru.dbotthepony.mc.otm.shapes.BlockShapes
class MatterReplicatorBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { 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 { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity {
return MatterReplicatorBlockEntity(blockPos, blockState) return MatterReplicatorBlockEntity(blockPos, blockState)
} }

View File

@ -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.CollisionContext
import net.minecraft.world.phys.shapes.VoxelShape import net.minecraft.world.phys.shapes.VoxelShape
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock 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.matter.MatterScannerBlockEntity
import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.entity.WorkerState
import ru.dbotthepony.mc.otm.block.getShapeForEachState 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 import ru.dbotthepony.mc.otm.shapes.BlockShapes
class MatterScannerBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { 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 { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity {
return MatterScannerBlockEntity(blockPos, blockState) return MatterScannerBlockEntity(blockPos, blockState)
} }

View File

@ -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.CollisionContext
import net.minecraft.world.phys.shapes.VoxelShape import net.minecraft.world.phys.shapes.VoxelShape
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock 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.entity.matter.PatternStorageBlockEntity
import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.block.getShapeForEachState
import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.get
import ru.dbotthepony.mc.otm.shapes.BlockShapes import ru.dbotthepony.mc.otm.shapes.BlockShapes
class PatternStorageBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { class PatternStorageBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock {
init {
addSimpleDescription()
}
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity {
return PatternStorageBlockEntity(blockPos, blockState) return PatternStorageBlockEntity(blockPos, blockState)
} }
@ -38,25 +43,6 @@ class PatternStorageBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), E
return state 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() } private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.PATTERN_STORAGE.rotateFromNorth(it[rotationProperty]).computeShape() }
@Suppress("override_deprecation") @Suppress("override_deprecation")

View File

@ -23,6 +23,10 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities
import ru.dbotthepony.mc.otm.shapes.BlockShapes import ru.dbotthepony.mc.otm.shapes.BlockShapes
class DriveRackBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { class DriveRackBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock {
init {
tooltips.blockEntityEnergy()
}
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity {
return DriveRackBlockEntity(blockPos, blockState) return DriveRackBlockEntity(blockPos, blockState)
} }
@ -38,17 +42,6 @@ class DriveRackBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), Entity
return BlockEntityTicker { _, _, _, tile -> if (tile is DriveRackBlockEntity) tile.tick() } return BlockEntityTicker { _, _, _, tile -> if (tile is DriveRackBlockEntity) tile.tick() }
} }
override fun appendHoverText(
itemStack: ItemStack,
blockAccessor: BlockGetter?,
components: MutableList<Component>,
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() } private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.DRIVE_RACK.rotateFromNorth(it[rotationProperty]).computeShape() }
@Suppress("override_deprecation") @Suppress("override_deprecation")

View File

@ -29,6 +29,11 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities
import ru.dbotthepony.mc.otm.shapes.BlockShapes import ru.dbotthepony.mc.otm.shapes.BlockShapes
class DriveViewerBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { class DriveViewerBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock {
init {
tooltips.colored(color)
tooltips.blockEntityEnergy()
}
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity {
return DriveViewerBlockEntity(blockPos, blockState) return DriveViewerBlockEntity(blockPos, blockState)
} }
@ -50,17 +55,6 @@ class DriveViewerBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MAC
builder.add(DRIVE_PRESENT) builder.add(DRIVE_PRESENT)
} }
override fun appendHoverText(
itemStack: ItemStack,
blockAccessor: BlockGetter?,
components: MutableList<Component>,
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 { override fun getStateForPlacement(context: BlockPlaceContext): BlockState {
return super.getStateForPlacement(context)!!.setValue(DRIVE_PRESENT, false) return super.getStateForPlacement(context)!!.setValue(DRIVE_PRESENT, false)
} }

View File

@ -24,6 +24,11 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities
import ru.dbotthepony.mc.otm.shapes.BlockShapes import ru.dbotthepony.mc.otm.shapes.BlockShapes
class ItemMonitorBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { class ItemMonitorBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock {
init {
tooltips.colored(color)
tooltips.blockEntityEnergy()
}
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity {
return ItemMonitorBlockEntity(blockPos, blockState) 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() } return BlockEntityTicker { _, _, _, tile -> if (tile is ItemMonitorBlockEntity) tile.tick() }
} }
override fun appendHoverText(
itemStack: ItemStack,
blockAccessor: BlockGetter?,
components: MutableList<Component>,
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() } private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.ITEM_MONITOR.rotateFromNorth(it[rotationProperty]).computeShape() }
@Suppress("override_deprecation") @Suppress("override_deprecation")

View File

@ -32,6 +32,10 @@ import ru.dbotthepony.mc.otm.shapes.BlockShapes
import ru.dbotthepony.mc.otm.core.math.unaryMinus import ru.dbotthepony.mc.otm.core.math.unaryMinus
class StorageBusBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { class StorageBusBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock {
init {
tooltips.blockEntityEnergy()
}
override fun rotationFreedom(): BlockRotationFreedom { override fun rotationFreedom(): BlockRotationFreedom {
return BlockRotationFreedom.DIRECTIONAL 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)) return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.DIRECTIONAL.property, BlockRotation.of(-context.clickedFace))
} }
override fun appendHoverText(
itemStack: ItemStack,
blockAccessor: BlockGetter?,
components: MutableList<Component>,
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<Block, BlockState>) { override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
super.createBlockStateDefinition(builder) super.createBlockStateDefinition(builder)

View File

@ -32,6 +32,10 @@ import ru.dbotthepony.mc.otm.shapes.BlockShapes
import ru.dbotthepony.mc.otm.core.math.unaryMinus import ru.dbotthepony.mc.otm.core.math.unaryMinus
class StorageImporterBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { class StorageImporterBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock {
init {
tooltips.blockEntityEnergy()
}
override fun rotationFreedom(): BlockRotationFreedom { override fun rotationFreedom(): BlockRotationFreedom {
return BlockRotationFreedom.DIRECTIONAL 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)) return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.DIRECTIONAL.property, BlockRotation.of(-context.clickedFace))
} }
override fun appendHoverText(
itemStack: ItemStack,
blockAccessor: BlockGetter?,
components: MutableList<Component>,
tooltipType: TooltipFlag
) {
super.appendHoverText(itemStack, blockAccessor, components, tooltipType)
WorkerEnergyStorage.appendHoverText(itemStack, blockAccessor, components, tooltipType)
MatteryPoweredBlockEntity.appendHoverText(itemStack, blockAccessor, components, tooltipType)
}
private val shapes = getShapeForEachStateMattery { private val shapes = getShapeForEachStateMattery {
Shapes.joinUnoptimized(CableBlock.getShapeFor(it, 0.185), BlockShapes.STORAGE_IMPORTER.rotateFromNorth(it[rotationProperty]).computeShape(), BooleanOp.OR) 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 { class StorageExporterBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock {
init {
tooltips.blockEntityEnergy()
}
override fun rotationFreedom(): BlockRotationFreedom { override fun rotationFreedom(): BlockRotationFreedom {
return BlockRotationFreedom.DIRECTIONAL return BlockRotationFreedom.DIRECTIONAL
} }
@ -136,17 +133,6 @@ class StorageExporterBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES),
) )
} }
override fun appendHoverText(
itemStack: ItemStack,
blockAccessor: BlockGetter?,
components: MutableList<Component>,
tooltipType: TooltipFlag
) {
super.appendHoverText(itemStack, blockAccessor, components, tooltipType)
WorkerEnergyStorage.appendHoverText(itemStack, blockAccessor, components, tooltipType)
MatteryPoweredBlockEntity.appendHoverText(itemStack, blockAccessor, components, tooltipType)
}
override fun <T : BlockEntity?> getTicker( override fun <T : BlockEntity?> getTicker(
p_153212_: Level, p_153212_: Level,
p_153213_: BlockState, p_153213_: BlockState,

View File

@ -24,6 +24,11 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities
import ru.dbotthepony.mc.otm.shapes.BlockShapes import ru.dbotthepony.mc.otm.shapes.BlockShapes
class StoragePowerSupplierBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { 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 { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
return StoragePowerSupplierBlockEntity(p_153215_, p_153216_) 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() } return BlockEntityTicker { _, _, _, tile -> if (tile is StoragePowerSupplierBlockEntity) tile.tick() }
} }
override fun appendHoverText(
itemStack: ItemStack,
blockAccessor: BlockGetter?,
components: MutableList<Component>,
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() } private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.STORAGE_POWER_SUPPLIER.rotateFromNorth(it[rotationProperty]).computeShape() }
@Suppress("override_deprecation") @Suppress("override_deprecation")

View File

@ -15,6 +15,7 @@ import net.minecraft.world.phys.shapes.CollisionContext
import net.minecraft.world.phys.shapes.Shapes import net.minecraft.world.phys.shapes.Shapes
import net.minecraft.world.phys.shapes.VoxelShape import net.minecraft.world.phys.shapes.VoxelShape
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock 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.WorkerState
import ru.dbotthepony.mc.otm.block.entity.tech.AbstractPoweredFurnaceBlockEntity 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.PoweredBlastFurnaceBlockEntity
@ -30,6 +31,13 @@ sealed class AbstractPoweredFurnaceBlock<T : AbstractPoweredFurnaceBlockEntity<*
val factory: (BlockPos, BlockState) -> T, val factory: (BlockPos, BlockState) -> T,
shape: BlockShape? shape: BlockShape?
) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { ) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock {
init {
tooltips.painted(color)
addSimpleDescription()
tooltips.doubleProcessing()
tooltips.blockEntityEnergy()
}
override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): T { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): T {
return factory(p_153215_, p_153216_) return factory(p_153215_, p_153216_)
} }

View File

@ -2,13 +2,11 @@ package ru.dbotthepony.mc.otm.block.tech
import net.minecraft.ChatFormatting import net.minecraft.ChatFormatting
import net.minecraft.core.BlockPos import net.minecraft.core.BlockPos
import net.minecraft.network.chat.Component
import net.minecraft.util.StringRepresentable import net.minecraft.util.StringRepresentable
import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.player.Player import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.DyeColor import net.minecraft.world.item.DyeColor
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.TooltipFlag
import net.minecraft.world.item.context.BlockPlaceContext import net.minecraft.world.item.context.BlockPlaceContext
import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.Level 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.CollisionContext
import net.minecraft.world.phys.shapes.VoxelShape import net.minecraft.world.phys.shapes.VoxelShape
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock 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.AndroidChargerBlockEntity
import ru.dbotthepony.mc.otm.block.entity.tech.AndroidChargerMiddleBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.AndroidChargerMiddleBlockEntity
import ru.dbotthepony.mc.otm.block.entity.tech.AndroidChargerTopBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.AndroidChargerTopBlockEntity
import ru.dbotthepony.mc.otm.block.getShapeForEachState 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.TranslatableComponent
import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.get
import ru.dbotthepony.mc.otm.core.gracefulBlockBreak import ru.dbotthepony.mc.otm.core.gracefulBlockBreak
@ -39,6 +36,12 @@ import ru.dbotthepony.mc.otm.oncePre
import ru.dbotthepony.mc.otm.shapes.BlockShapes 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 { 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 { enum class Type : StringRepresentable {
BASE, BASE,
MIDDLE, MIDDLE,
@ -140,14 +143,6 @@ class AndroidChargerBlock(val color: DyeColor?) : RotatableMatteryBlock(Properti
} }
} }
override fun appendHoverText(itemStack: ItemStack, blockAccessor: BlockGetter?, components: MutableList<Component>, 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)) { private val shapes = getShapeForEachState(listOf(rotationProperty, PART)) {
val shape = when (it[PART]!!) { val shape = when (it[PART]!!) {
Type.BASE -> BlockShapes.ANDROID_CHARGER_BASE Type.BASE -> BlockShapes.ANDROID_CHARGER_BASE

View File

@ -1,13 +1,10 @@
package ru.dbotthepony.mc.otm.block.tech package ru.dbotthepony.mc.otm.block.tech
import net.minecraft.core.BlockPos import net.minecraft.core.BlockPos
import net.minecraft.network.chat.Component
import net.minecraft.world.InteractionHand import net.minecraft.world.InteractionHand
import net.minecraft.world.InteractionResult import net.minecraft.world.InteractionResult
import net.minecraft.world.entity.player.Player import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.DyeColor 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.BlockGetter
import net.minecraft.world.level.Level import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block 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.CollisionContext
import net.minecraft.world.phys.shapes.VoxelShape import net.minecraft.world.phys.shapes.VoxelShape
import ru.dbotthepony.mc.otm.block.MatteryBlock 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.tech.AndroidStationBlockEntity
import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity
import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.entity.WorkerState
import ru.dbotthepony.mc.otm.capability.MatteryCapability 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.core.orNull
import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlockEntities
import ru.dbotthepony.mc.otm.shapes.BlockShapes import ru.dbotthepony.mc.otm.shapes.BlockShapes
class AndroidStationBlock(val color: DyeColor?) : MatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { class AndroidStationBlock(val color: DyeColor?) : MatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock {
init {
tooltips.painted(color)
addSimpleDescription()
tooltips.blockEntityEnergy()
}
override fun use( override fun use(
blockState: BlockState, blockState: BlockState,
level: Level, level: Level,
@ -52,17 +54,6 @@ class AndroidStationBlock(val color: DyeColor?) : MatteryBlock(DEFAULT_MACHINE_P
builder.add(WorkerState.SEMI_WORKER_STATE) builder.add(WorkerState.SEMI_WORKER_STATE)
} }
override fun appendHoverText(
itemStack: ItemStack,
blockAccessor: BlockGetter?,
components: MutableList<Component>,
tooltipType: TooltipFlag
) {
super.appendHoverText(itemStack, blockAccessor, components, tooltipType)
WorkerEnergyStorage.appendHoverText(itemStack, blockAccessor, components, tooltipType)
MatteryPoweredBlockEntity.appendHoverText(itemStack, blockAccessor, components, tooltipType)
}
override fun getShape( override fun getShape(
p_151964_: BlockState, p_151964_: BlockState,
p_151965_: BlockGetter, p_151965_: BlockGetter,

View File

@ -1,32 +1,31 @@
package ru.dbotthepony.mc.otm.block.tech 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.core.BlockPos
import net.minecraft.world.item.DyeColor 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.BlockGetter
import net.minecraft.world.level.Level 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.CollisionContext
import net.minecraft.world.phys.shapes.VoxelShape import net.minecraft.world.phys.shapes.VoxelShape
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock 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.block.getShapeForEachState
import ru.dbotthepony.mc.otm.core.get 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.registry.MBlockEntities
import ru.dbotthepony.mc.otm.shapes.BlockShapes import ru.dbotthepony.mc.otm.shapes.BlockShapes
class BatteryBankBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { class BatteryBankBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock {
init {
tooltips.painted(color)
addSimpleDescription()
}
override fun <T : BlockEntity> getTicker( override fun <T : BlockEntity> getTicker(
level: Level, level: Level,
p_153213_: BlockState, p_153213_: BlockState,

View File

@ -1,10 +1,7 @@
package ru.dbotthepony.mc.otm.block.tech package ru.dbotthepony.mc.otm.block.tech
import net.minecraft.core.BlockPos import net.minecraft.core.BlockPos
import net.minecraft.network.chat.Component
import net.minecraft.world.item.DyeColor 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.BlockGetter
import net.minecraft.world.level.Level import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block 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.CollisionContext
import net.minecraft.world.phys.shapes.VoxelShape import net.minecraft.world.phys.shapes.VoxelShape
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock 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.tech.ChemicalGeneratorBlockEntity
import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.entity.WorkerState
import ru.dbotthepony.mc.otm.block.getShapeForEachState 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.core.get
import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlockEntities
import ru.dbotthepony.mc.otm.shapes.BlockShapes import ru.dbotthepony.mc.otm.shapes.BlockShapes
class ChemicalGeneratorBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { 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 { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
return ChemicalGeneratorBlockEntity(p_153215_, p_153216_) return ChemicalGeneratorBlockEntity(p_153215_, p_153216_)
} }
@ -46,16 +49,6 @@ class ChemicalGeneratorBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAU
builder.add(WorkerState.SEMI_WORKER_STATE) builder.add(WorkerState.SEMI_WORKER_STATE)
} }
override fun appendHoverText(
itemStack: ItemStack,
blockAccessor: BlockGetter?,
tooltips: MutableList<Component>,
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() } private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.CHEMICAL_GENERATOR.rotateFromNorth(it[rotationProperty]).computeShape() }
@Suppress("override_deprecation") @Suppress("override_deprecation")

View File

@ -17,7 +17,6 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.block.getShapeForEachState
import ru.dbotthepony.mc.otm.block.entity.tech.CobblerBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.CobblerBlockEntity
import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.get
import ru.dbotthepony.mc.otm.core.needsNoPowerDescription
import ru.dbotthepony.mc.otm.shapes.BlockShapes 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 { 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 { init {
needsNoPowerDescription() tooltips.needsNoPower()
tooltips.painted(color)
} }
private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.COBBLESTONE_GENERATOR.rotateFromNorth(it[rotationProperty]).computeShape() } private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.COBBLESTONE_GENERATOR.rotateFromNorth(it[rotationProperty]).computeShape() }

View File

@ -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.CollisionContext
import net.minecraft.world.phys.shapes.VoxelShape import net.minecraft.world.phys.shapes.VoxelShape
import ru.dbotthepony.mc.otm.block.MatteryBlock 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.block.entity.tech.EnergyCounterBlockEntity
import ru.dbotthepony.mc.otm.core.asSupplier import ru.dbotthepony.mc.otm.core.asSupplier
import ru.dbotthepony.mc.otm.core.collect.SupplierMap import ru.dbotthepony.mc.otm.core.collect.SupplierMap
@ -28,6 +29,14 @@ import java.util.concurrent.Callable
import java.util.function.Supplier import java.util.function.Supplier
class EnergyCounterBlock(val color: DyeColor?) : MatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { 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 { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity {
return EnergyCounterBlockEntity(blockPos, blockState) return EnergyCounterBlockEntity(blockPos, blockState)
} }
@ -124,7 +133,7 @@ class EnergyCounterBlock(val color: DyeColor?) : MatteryBlock(DEFAULT_MACHINE_PR
} }
companion object { companion object {
@JvmField val INPUT_DIRECTION: EnumProperty<Direction> = EnumProperty.create("input", Direction::class.java) val INPUT_DIRECTION: EnumProperty<Direction> = EnumProperty.create("input", Direction::class.java)
@JvmField val IF_DIRECTION: EnumProperty<Direction> = EnumProperty.create("if", Direction::class.java) val IF_DIRECTION: EnumProperty<Direction> = EnumProperty.create("if", Direction::class.java)
} }
} }

View File

@ -22,6 +22,11 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities
import ru.dbotthepony.mc.otm.shapes.BlockShapes import ru.dbotthepony.mc.otm.shapes.BlockShapes
class EnergyServoBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { 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 { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
return EnergyServoBlockEntity(p_153215_, p_153216_) return EnergyServoBlockEntity(p_153215_, p_153216_)
} }
@ -38,10 +43,6 @@ class EnergyServoBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MAC
return null return null
} }
init {
addSimpleDescription()
}
private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.ENERGY_SERVO.rotateFromNorth(it[rotationProperty]).computeShape() } private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.ENERGY_SERVO.rotateFromNorth(it[rotationProperty]).computeShape() }
@Suppress("override_deprecation") @Suppress("override_deprecation")

View File

@ -1,6 +1,8 @@
package ru.dbotthepony.mc.otm.block.tech package ru.dbotthepony.mc.otm.block.tech
import net.minecraft.ChatFormatting
import net.minecraft.core.BlockPos import net.minecraft.core.BlockPos
import net.minecraft.nbt.LongTag
import net.minecraft.world.InteractionHand import net.minecraft.world.InteractionHand
import net.minecraft.world.InteractionResult import net.minecraft.world.InteractionResult
import net.minecraft.world.entity.player.Player 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.addSimpleDescription
import ru.dbotthepony.mc.otm.block.entity.tech.EssenceStorageBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.EssenceStorageBlockEntity
import ru.dbotthepony.mc.otm.block.getShapeForEachState 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.get
import ru.dbotthepony.mc.otm.core.util.getLevelFromXp
import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MItems
import ru.dbotthepony.mc.otm.shapes.BlockShapes 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 { 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<LongTag>("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 { override fun newBlockEntity(pPos: BlockPos, pState: BlockState): BlockEntity {
return EssenceStorageBlockEntity(pPos, pState) return EssenceStorageBlockEntity(pPos, pState)
} }
@ -47,10 +67,6 @@ class EssenceStorageBlock(val color: DyeColor?) : RotatableMatteryBlock(Properti
return super.use(blockState, level, blockPos, ply, hand, blockHitResult) return super.use(blockState, level, blockPos, ply, hand, blockHitResult)
} }
init {
addSimpleDescription()
}
private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.ESSENCE_STORAGE.rotateFromNorth(it[rotationProperty]).computeShape() } private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.ESSENCE_STORAGE.rotateFromNorth(it[rotationProperty]).computeShape() }
@Suppress("override_deprecation") @Suppress("override_deprecation")

View File

@ -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.BlockRotationFreedom
import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.math.plus
import ru.dbotthepony.mc.otm.core.math.times 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.core.runInBackground
import ru.dbotthepony.mc.otm.oncePre import ru.dbotthepony.mc.otm.oncePre
import ru.dbotthepony.mc.otm.registry.MBlockEntities 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) 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 { 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 { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
return GravitationStabilizerBlockEntity(p_153215_, p_153216_) return GravitationStabilizerBlockEntity(p_153215_, p_153216_)
} }
@ -145,13 +151,6 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock {
return shapes[p_60555_[BlockRotationFreedom.DIRECTIONAL].ordinal] 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 { companion object {
private val shapes = SupplierList.ofFuture( private val shapes = SupplierList.ofFuture(
runInBackground { BlockShapes.GRAVITATION_STABILIZER.rotateAroundX(PI / 2).computeShape() }, runInBackground { BlockShapes.GRAVITATION_STABILIZER.rotateAroundX(PI / 2).computeShape() },

View File

@ -32,12 +32,16 @@ import ru.dbotthepony.mc.otm.block.getShapeForEachState
import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.get
import ru.dbotthepony.mc.otm.core.math.minus import ru.dbotthepony.mc.otm.core.math.minus
import ru.dbotthepony.mc.otm.core.math.plus 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.once
import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MBlocks
import ru.dbotthepony.mc.otm.shapes.BlockShapes 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()) { 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") @Suppress("OVERRIDE_DEPRECATION")
override fun randomTick( override fun randomTick(
blockState: BlockState, blockState: BlockState,
@ -136,9 +140,4 @@ class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of().mapColor(Map
} }
} }
} }
init {
addSimpleDescription()
needsNoPowerDescription()
}
} }

View File

@ -1,10 +1,7 @@
package ru.dbotthepony.mc.otm.block.tech package ru.dbotthepony.mc.otm.block.tech
import net.minecraft.core.BlockPos import net.minecraft.core.BlockPos
import net.minecraft.network.chat.Component
import net.minecraft.world.item.DyeColor 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.BlockGetter
import net.minecraft.world.level.Level import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block 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.CollisionContext
import net.minecraft.world.phys.shapes.VoxelShape import net.minecraft.world.phys.shapes.VoxelShape
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock 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.WorkerState
import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity
import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.block.getShapeForEachState
import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.get
import ru.dbotthepony.mc.otm.shapes.BlockShapes 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 { 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 { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
return PlatePressBlockEntity(p_153215_, p_153216_, isTwin) 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) builder.add(WorkerState.WORKER_STATE)
} }
override fun appendHoverText(
itemStack: ItemStack,
blockAccessor: BlockGetter?,
components: MutableList<Component>,
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() } private val shapes = getShapeForEachState(rotationProperty) { (if (isTwin) BlockShapes.TWIN_PLATE_PRESS_IDLE else BlockShapes.PLATE_PRESS_IDLE).rotateFromNorth(it[rotationProperty]).computeShape() }
@Suppress("override_deprecation") @Suppress("override_deprecation")

View File

@ -289,13 +289,13 @@ fun moveEnergy(source: IEnergyStorage, destination: IEnergyStorage, amount: Deci
return Decimal.ZERO return Decimal.ZERO
} }
internal fun IFluidHandler.fluidLevel(tooltips: MutableList<Component>) { internal fun IFluidHandler.fluidLevel(tooltips: (Component) -> Unit) {
val fluid = getFluidInTank(0) val fluid = getFluidInTank(0)
if (fluid.isEmpty) { 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 { } 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))
} }
} }

View File

@ -93,72 +93,72 @@ interface IMatteryUpgrade {
private val positiveBound = Decimal("0.01") private val positiveBound = Decimal("0.01")
private val negativeBound = Decimal("-0.01") private val negativeBound = Decimal("-0.01")
fun IMatteryUpgrade.addUpgradeTooltipLines(tooltips: MutableCollection<Component>) { fun IMatteryUpgrade.addUpgradeTooltipLines(tooltips: (Component) -> Unit) {
if (upgradeTypes.isNotEmpty() && ShiftPressedCond.asBoolean) { 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) { 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 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 "" val speedBonusLimit = if (actualSpeedBonus == MachinesConfig.Upgrades.MIN_SPEED || actualSpeedBonus == MachinesConfig.Upgrades.MAX_SPEED) "_limit" else ""
if (speedBonus >= 0.01) { 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) { } 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) { 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) { 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) { 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) { 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) { 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 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 "" val consumedLimit = if (actualEnergyConsumed == MachinesConfig.Upgrades.MIN_ENERGY || actualEnergyConsumed == MachinesConfig.Upgrades.MAX_ENERGY) "_limit" else ""
if (energyConsumed >= positiveBound) { 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) { } 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) { 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) { 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) { 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) { } 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<Component> { fun IMatteryUpgrade.getUpgradeTooltipLines(): MutableList<Component> {
return ArrayList<Component>().also { addUpgradeTooltipLines(it) } return ArrayList<Component>().also { addUpgradeTooltipLines(it::add) }
} }
interface ITieredUpgradeSet { interface ITieredUpgradeSet {

View File

@ -4,21 +4,12 @@
package ru.dbotthepony.mc.otm.capability.energy package ru.dbotthepony.mc.otm.capability.energy
import net.minecraft.nbt.CompoundTag 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.INBTSerializable
import net.minecraftforge.common.util.LazyOptional 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.EnergyBalanceValues
import ru.dbotthepony.mc.otm.config.VerboseEnergyBalanceValues 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.Decimal
import ru.dbotthepony.mc.otm.core.math.defineDecimal
import ru.dbotthepony.mc.otm.core.nbt.mapPresent import ru.dbotthepony.mc.otm.core.nbt.mapPresent
import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.nbt.set
@ -158,19 +149,6 @@ open class WorkerEnergyStorage(
listener: () -> Unit, listener: () -> Unit,
values: VerboseEnergyBalanceValues values: VerboseEnergyBalanceValues
) : this(listener, values::energyCapacity, values::maxEnergyReceive, values::maxEnergyExtract) ) : this(listener, values::energyCapacity, values::maxEnergyReceive, values::maxEnergyExtract)
companion object {
fun appendHoverText(itemStack: ItemStack, tooltips: MutableList<Component>) {
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<Component>, flag: TooltipFlag) {
return appendHoverText(itemStack, tooltips)
}
}
} }
open class GeneratorEnergyStorage( open class GeneratorEnergyStorage(
@ -188,19 +166,6 @@ open class GeneratorEnergyStorage(
listener: () -> Unit, listener: () -> Unit,
values: VerboseEnergyBalanceValues values: VerboseEnergyBalanceValues
) : this(listener, values::energyCapacity, values::maxEnergyReceive, values::maxEnergyExtract) ) : this(listener, values::energyCapacity, values::maxEnergyReceive, values::maxEnergyExtract)
companion object {
fun appendHoverText(itemStack: ItemStack, tooltips: MutableList<Component>) {
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<Component>, flag: TooltipFlag) {
return appendHoverText(itemStack, tooltips)
}
}
} }
open class CapacitorEnergyStorage( open class CapacitorEnergyStorage(
@ -218,17 +183,4 @@ open class CapacitorEnergyStorage(
listener: () -> Unit, listener: () -> Unit,
values: VerboseEnergyBalanceValues values: VerboseEnergyBalanceValues
) : this(listener, values::energyCapacity, values::maxEnergyReceive, values::maxEnergyExtract) ) : this(listener, values::energyCapacity, values::maxEnergyReceive, values::maxEnergyExtract)
companion object {
fun appendHoverText(itemStack: ItemStack, tooltips: MutableList<Component>) {
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<Component>, flag: TooltipFlag) {
return appendHoverText(itemStack, tooltips)
}
}
} }

View File

@ -14,8 +14,8 @@ sealed interface IEnergyStorageImpl {
val maxOutput: Decimal? val maxOutput: Decimal?
} }
internal fun batteryLevel(it: IEnergyStorage, tooltips: MutableList<Component>) { internal fun batteryLevel(it: IEnergyStorage, tooltips: (Component) -> Unit) {
tooltips.add( tooltips(
TranslatableComponent( TranslatableComponent(
"otm.item.power.storage", "otm.item.power.storage",
it.energyStored.formatPower(formatAsReadable = ShiftPressedCond), it.energyStored.formatPower(formatAsReadable = ShiftPressedCond),
@ -23,16 +23,16 @@ internal fun batteryLevel(it: IEnergyStorage, tooltips: MutableList<Component>)
).withStyle(ChatFormatting.GRAY)) ).withStyle(ChatFormatting.GRAY))
} }
internal fun batteryLevel(it: IMatteryEnergyStorage, tooltips: MutableList<Component>, displayMaxLevel: Boolean = true) { internal fun batteryLevel(it: IMatteryEnergyStorage, tooltips: (Component) -> Unit, displayMaxLevel: Boolean = true) {
if (displayMaxLevel) if (displayMaxLevel)
tooltips.add( tooltips(
TranslatableComponent( TranslatableComponent(
"otm.item.power.storage", "otm.item.power.storage",
it.batteryLevel.formatPower(formatAsReadable = ShiftPressedCond), it.batteryLevel.formatPower(formatAsReadable = ShiftPressedCond),
it.maxBatteryLevel.formatPower(formatAsReadable = ShiftPressedCond) it.maxBatteryLevel.formatPower(formatAsReadable = ShiftPressedCond)
).withStyle(ChatFormatting.GRAY)) ).withStyle(ChatFormatting.GRAY))
else else
tooltips.add( tooltips(
TranslatableComponent( TranslatableComponent(
"otm.item.power.storage0", "otm.item.power.storage0",
it.batteryLevel.formatPower(formatAsReadable = ShiftPressedCond) it.batteryLevel.formatPower(formatAsReadable = ShiftPressedCond)
@ -41,68 +41,20 @@ internal fun batteryLevel(it: IMatteryEnergyStorage, tooltips: MutableList<Compo
if (it is IEnergyStorageImpl) { if (it is IEnergyStorageImpl) {
when (it.energyFlow) { when (it.energyFlow) {
FlowDirection.INPUT -> { FlowDirection.INPUT -> {
if (it.maxInput != null) { tooltips(TranslatableComponent("otm.item.power.throughput_mono", (it.maxInput ?: Decimal.POSITIVE_INFINITY).formatPower(formatAsReadable = ShiftPressedCond)).withStyle(ChatFormatting.GRAY))
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))
}
} }
FlowDirection.OUTPUT -> { FlowDirection.OUTPUT -> {
if (it.maxOutput != null) { tooltips(TranslatableComponent("otm.item.power.throughput_mono", (it.maxOutput ?: Decimal.POSITIVE_INFINITY).formatPower(formatAsReadable = ShiftPressedCond)).withStyle(ChatFormatting.GRAY))
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))
}
} }
FlowDirection.BI_DIRECTIONAL -> { FlowDirection.BI_DIRECTIONAL -> {
val maxInput = it.maxInput tooltips(
val maxOutput = it.maxOutput TranslatableComponent(
"otm.item.power.throughput",
if (maxInput != null && maxOutput != null) { (it.maxInput ?: Decimal.POSITIVE_INFINITY).formatPower(formatAsReadable = ShiftPressedCond),
tooltips.add( (it.maxOutput ?: Decimal.POSITIVE_INFINITY).formatPower(formatAsReadable = ShiftPressedCond)
TranslatableComponent( ).withStyle(ChatFormatting.GRAY))
"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))
}
} }
FlowDirection.NONE -> {} FlowDirection.NONE -> {}

View File

@ -12,6 +12,7 @@ import net.minecraftforge.common.util.LazyOptional
import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.FlowDirection
import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.MatteryCapability
import ru.dbotthepony.mc.otm.capability.energy 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.math.Decimal
import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.map
import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.nbt.set
@ -73,20 +74,6 @@ abstract class ItemEnergyStorageImpl(val itemStack: ItemStack) : IMatteryEnergyS
companion object { companion object {
const val ENERGY_KEY = "energy" const val ENERGY_KEY = "energy"
fun appendHoverText(itemStack: ItemStack, level: Level?, tooltips: MutableList<Component>, flag: TooltipFlag) {
appendHoverText(itemStack, tooltips)
}
fun appendHoverText(itemStack: ItemStack, tooltips: MutableList<Component>) {
val energy = itemStack.energy ?: return
if (energy is IMatteryEnergyStorage) {
batteryLevel(energy, tooltips)
} else {
batteryLevel(energy, tooltips)
}
}
} }
} }

View File

@ -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.math.Decimal
import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.nbt.set
open class MatterStorageImpl @JvmOverloads constructor( open class MatterStorageImpl(
protected val listener: Runnable?, protected val listener: Runnable?,
override val matterFlow: FlowDirection, override val matterFlow: FlowDirection,
protected val maxStoredMatterSupplier: () -> Decimal, protected val maxStoredMatterSupplier: () -> Decimal,
@ -93,7 +93,7 @@ open class MatterStorageImpl @JvmOverloads constructor(
override fun serializeNBT(): CompoundTag { override fun serializeNBT(): CompoundTag {
return CompoundTag().also { return CompoundTag().also {
it["stored"] = storedMatter.serializeNBT() it[MATTER_STORED_KEY] = storedMatter.serializeNBT()
//it["max_storage"] = maxStoredMatter.serializeNBT() //it["max_storage"] = maxStoredMatter.serializeNBT()
//if (maxReceive != null) it["max_receive"] = maxReceive.serializeNBT() //if (maxReceive != null) it["max_receive"] = maxReceive.serializeNBT()
//if (maxExtract != null) it["max_extract"] = maxExtract.serializeNBT() //if (maxExtract != null) it["max_extract"] = maxExtract.serializeNBT()
@ -102,9 +102,13 @@ open class MatterStorageImpl @JvmOverloads constructor(
override fun deserializeNBT(tag: CompoundTag?) { override fun deserializeNBT(tag: CompoundTag?) {
if (tag == null) return if (tag == null) return
storedMatter = Decimal.deserializeNBT(tag["stored"]) storedMatter = Decimal.deserializeNBT(tag[MATTER_STORED_KEY])
//maxStoredMatter = ImpreciseFraction.deserializeNBT(tag["max_storage"]) //maxStoredMatter = ImpreciseFraction.deserializeNBT(tag["max_storage"])
//maxReceive = if (tag.contains("max_receive")) ImpreciseFraction.deserializeNBT(tag["max_receive"]) else null //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 //maxExtract = if (tag.contains("max_extract")) ImpreciseFraction.deserializeNBT(tag["max_extract"]) else null
} }
companion object {
const val MATTER_STORED_KEY = "stored"
}
} }

View File

@ -3,13 +3,11 @@ package ru.dbotthepony.mc.otm.client.render
import com.mojang.blaze3d.platform.GlStateManager import com.mojang.blaze3d.platform.GlStateManager
import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.* import com.mojang.blaze3d.vertex.*
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.renderer.GameRenderer import net.minecraft.client.renderer.GameRenderer
import net.minecraft.client.renderer.RenderStateShard import net.minecraft.client.renderer.RenderStateShard
import net.minecraft.client.renderer.RenderStateShard.LineStateShard import net.minecraft.client.renderer.RenderStateShard.LineStateShard
import net.minecraft.client.renderer.RenderType import net.minecraft.client.renderer.RenderType
import net.minecraft.client.renderer.ShaderInstance import net.minecraft.client.renderer.ShaderInstance
import net.minecraft.client.renderer.texture.TextureAtlasSprite
import net.minecraft.resources.ResourceLocation import net.minecraft.resources.ResourceLocation
import net.minecraft.server.packs.resources.ResourceProvider import net.minecraft.server.packs.resources.ResourceProvider
import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.LogManager
@ -294,9 +292,15 @@ fun drawLine(
tess.end() 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 { 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 { 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 // crossing at least one line
if (y in this.y .. this.y + height) { if (y in this.yStart .. this.yStart + height) {
if (x < this.x && x + width > this.x + this.width) { if (x < this.xStart && x + width > this.xEnd) {
return true return true
} }
} else if (x in this.x .. this.x + width) { } else if (x in this.xStart .. this.xStart + width) {
if (y < this.y && y + height > this.y + this.height) { if (y < this.yStart && y + height > this.yEnd) {
return true return true
} }
} }
// final test: check if scissor rect is completely inside provided rect // 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 { 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 val scale = minecraft.window.guiScale
return cross((x * scale).roundToInt(), (y * scale).roundToInt(), (width * scale).roundToInt(), (height * scale).roundToInt()) 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<ScissorRect>() private val scissorStack = ArrayDeque<ScissorRect>()
@Suppress("NAME_SHADOWING")
@JvmOverloads @JvmOverloads
fun pushScissorRect(x: Int, y: Int, width: Int, height: Int, lock: Boolean = false) { fun pushScissorRect(x: Int, y: Int, width: Int, height: Int, lock: Boolean = false) {
var x = x var xStart = x
var y = y var yStart = y
var width = width var xEnd = x + width
var height = height var yEnd = y + height
val peek = scissorStack.lastOrNull() val peek = scissorStack.lastOrNull()
@ -349,34 +356,31 @@ fun pushScissorRect(x: Int, y: Int, width: Int, height: Int, lock: Boolean = fal
return return
} }
x = x.coerceAtLeast(peek.x) xStart = xStart.coerceAtLeast(peek.xStart)
y = y.coerceAtLeast(peek.y) yStart = yStart.coerceAtLeast(peek.yStart)
width = width.coerceAtMost(peek.width) xEnd = xEnd.coerceAtMost(peek.xEnd)
height = height.coerceAtMost(peek.height) 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) scissorStack.add(peek)
return return
} }
} }
scissorStack.add(ScissorRect(x, y, width, height, lock)) val new = ScissorRect(xStart, yStart, xEnd, yEnd, lock)
y = minecraft.window.height - y - height scissorStack.add(new)
RenderSystem.enableScissor(x, y, width, height) new.apply()
} }
fun popScissorRect() { fun popScissorRect() {
scissorStack.removeLast() scissorStack.removeLast()
val peek = scissorStack.lastOrNull() val peek = scissorStack.lastOrNull()
if (peek == null) { if (peek == null) {
RenderSystem.disableScissor() 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() val currentScissorRect get() = scissorStack.lastOrNull()

View File

@ -233,6 +233,12 @@ open class EditablePanel<out S : Screen>(
parent?.boundsInvalidated = true 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] * Width of this panel as considered by docking code, updated inside [performLayout]
* *
@ -1147,7 +1153,7 @@ open class EditablePanel<out S : Screen>(
if (child.dockResize.changeHeight) if (child.dockResize.changeHeight)
child.height = child.dockedHeight child.height = child.dockedHeight
else if (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 -> { Dock.RIGHT -> {
@ -1161,7 +1167,7 @@ open class EditablePanel<out S : Screen>(
if (child.dockResize.changeHeight) if (child.dockResize.changeHeight)
child.height = child.dockedHeight child.height = child.dockedHeight
else if (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 -> { Dock.TOP -> {
@ -1175,7 +1181,7 @@ open class EditablePanel<out S : Screen>(
if (child.dockResize.changeWidth) if (child.dockResize.changeWidth)
child.width = child.dockedWidth child.width = child.dockedWidth
else if (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 -> { Dock.BOTTOM -> {
@ -1189,7 +1195,7 @@ open class EditablePanel<out S : Screen>(
if (child.dockResize.changeWidth) if (child.dockResize.changeWidth)
child.width = child.dockedWidth child.width = child.dockedWidth
else if (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()
} }
} }
} }

View File

@ -502,7 +502,7 @@ class DeviceControls<out S : MatteryScreen<*>>(
} }
val i = it.size val i = it.size
upgrades.currentStats.addUpgradeTooltipLines(it) upgrades.currentStats.addUpgradeTooltipLines(it::add)
if (it.size != i) { if (it.size != i) {
it.add(i, TranslatableComponent("otm.gui.upgrades.current").withStyle(ChatFormatting.GRAY)) it.add(i, TranslatableComponent("otm.gui.upgrades.current").withStyle(ChatFormatting.GRAY))

View File

@ -19,8 +19,17 @@ open class BackgroundPanel<out S : Screen>(
dockPadding = DockProperty(3f, 3f, 3f, 3f) dockPadding = DockProperty(3f, 3f, 3f, 3f)
} }
var drawBackground = true
override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { 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 { companion object {

View File

@ -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<M : AbstractProcessingMachineMenu>(menu: M, inventory: Inventory, title: Component) : MatteryScreen<M>(menu, inventory, title) {
override fun makeMainFrame(): FramePanel<MatteryScreen<*>> {
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<ProgressGaugePanel<*>>()
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
}
}

View File

@ -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<PlatePressMenu>(menu, inventory, title) {
override fun makeMainFrame(): FramePanel<MatteryScreen<*>> {
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
}
}

View File

@ -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<PoweredFurnaceMenu>(menu, inventory, title) {
override fun makeMainFrame(): FramePanel<MatteryScreen<*>> {
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
}
}

View File

@ -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<TwinPlatePressMenu>(menu, inventory, title) {
override fun makeMainFrame(): FramePanel<MatteryScreen<*>> {
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
}
}

View File

@ -7,7 +7,6 @@ import mezz.jei.api.constants.VanillaTypes
import mezz.jei.api.forge.ForgeTypes import mezz.jei.api.forge.ForgeTypes
import mezz.jei.api.gui.handlers.IGuiContainerHandler import mezz.jei.api.gui.handlers.IGuiContainerHandler
import mezz.jei.api.helpers.IJeiHelpers import mezz.jei.api.helpers.IJeiHelpers
import mezz.jei.api.ingredients.ITypedIngredient
import mezz.jei.api.registration.IGuiHandlerRegistration import mezz.jei.api.registration.IGuiHandlerRegistration
import mezz.jei.api.registration.IRecipeCatalystRegistration import mezz.jei.api.registration.IRecipeCatalystRegistration
import mezz.jei.api.registration.IRecipeCategoryRegistration 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.client.renderer.Rect2i
import net.minecraft.resources.ResourceLocation import net.minecraft.resources.ResourceLocation
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import net.minecraftforge.fluids.FluidStack
import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen 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.matter.MatterEntanglerMenu
import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu
import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu 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.recipe.PainterRecipe
import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MItems
import ru.dbotthepony.mc.otm.registry.MRecipes 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) } MItems.POWERED_SMOKER.values.forEach { registration.addRecipeCatalyst(ItemStack(it), MicrowaveRecipeCategory.recipeType) }
registration.addRecipeCatalyst(ItemStack(MItems.ExopackUpgrades.CRAFTING_UPGRADE), RecipeTypes.CRAFTING) registration.addRecipeCatalyst(ItemStack(MItems.ExopackUpgrades.CRAFTING_UPGRADE), RecipeTypes.CRAFTING)
registration.addRecipeCatalyst(ItemStack(MItems.ITEM_MONITOR[null]!!), 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) } MItems.TWIN_PLATE_PRESS.values.forEach { registration.addRecipeCatalyst(ItemStack(it), PlatePressRecipeCategory.recipeType) }
registration.addRecipeCatalyst(ItemStack(MItems.PAINTER), PainterRecipeCategory.recipeType) registration.addRecipeCatalyst(ItemStack(MItems.PAINTER), PainterRecipeCategory.recipeType)
registration.addRecipeCatalyst(ItemStack(MItems.MATTER_ENTANGLER), MatterEntanglerRecipeCategory.recipeType) registration.addRecipeCatalyst(ItemStack(MItems.MATTER_ENTANGLER), MatterEntanglerRecipeCategory.recipeType)
@ -114,8 +110,7 @@ class JEIPlugin : IModPlugin {
registration.addRecipeTransferHandler(ExopackInventoryTransferHandler(helper), RecipeTypes.CRAFTING) registration.addRecipeTransferHandler(ExopackInventoryTransferHandler(helper), RecipeTypes.CRAFTING)
registration.addRecipeTransferHandler(simpleTransferInfo(MatterEntanglerRecipeCategory.recipeType, MatterEntanglerMenu::inputs)) registration.addRecipeTransferHandler(simpleTransferInfo(MatterEntanglerRecipeCategory.recipeType, MatterEntanglerMenu::inputs))
registration.addRecipeTransferHandler(simpleTransferInfo0(PainterRecipeCategory.recipeType, PainterMenu::inputSlot)) registration.addRecipeTransferHandler(simpleTransferInfo0(PainterRecipeCategory.recipeType, PainterMenu::inputSlot))
registration.addRecipeTransferHandler(simpleTransferInfo0(PlatePressRecipeCategory.recipeType, PlatePressMenu::inputSlot)) registration.addRecipeTransferHandler(simpleTransferInfo(PlatePressRecipeCategory.recipeType, PlatePressMenu::inputSlots))
registration.addRecipeTransferHandler(simpleTransferInfo(PlatePressRecipeCategory.recipeType, TwinPlatePressMenu::inputSlots))
registration.addRecipeTransferHandler(simpleTransferInfo(MicrowaveRecipeCategory.recipeType, PoweredFurnaceMenu::inputSlots)) registration.addRecipeTransferHandler(simpleTransferInfo(MicrowaveRecipeCategory.recipeType, PoweredFurnaceMenu::inputSlots))
} }

View File

@ -42,7 +42,7 @@ object PlatePressRecipeCategory : IRecipeCategory<PlatePressRecipe>, IDrawable {
} }
override fun getTitle(): Component { 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) { override fun draw(graphics: GuiGraphics, xOffset: Int, yOffset: Int) {
@ -96,7 +96,7 @@ object PlatePressRecipeCategory : IRecipeCategory<PlatePressRecipe>, IDrawable {
} }
private val iconField by lazy { 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 { override fun getIcon(): IDrawable {

View File

@ -4,6 +4,10 @@ import net.minecraftforge.fml.config.ModConfig
object ClientConfig : AbstractConfig("client", ModConfig.Type.CLIENT) { 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 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") .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) .defineInRange("JUMP_BOOST_LOOK_ANGLE", 30.0, -180.0, 180.0)

View File

@ -14,7 +14,7 @@ object ItemsConfig : AbstractConfig("items") {
val BASIC = batteryValues(MNames.BATTERY_BASIC, Decimal(400_000), Decimal(600)) 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 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 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_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)) val QUANTUM_CAPACITOR = conciseValues(MNames.QUANTUM_CAPACITOR, Decimal(1_000_000), Decimal(200_000))
@ -36,7 +36,7 @@ object ItemsConfig : AbstractConfig("items") {
object Capacitors { object Capacitors {
val BASIC by builder.defineDecimal(MNames.MATTER_CAPACITOR_BASIC, Decimal(2_500), minimum = Decimal.ONE_TENTH) 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 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 { init {

View File

@ -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<out Component>) {
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<Component>) {
lines.forEach { c ->
addDescriptionFunctionsInternal({ ObjectIterators.singleton(c.copy()) })
}
}
fun addDescriptionFunctionsInternal(lines: Stream<out (ItemStack) -> Iterator<Component>>)
fun addDescriptionFunctionsInternal(vararg lines: (ItemStack) -> Iterator<Component>)
fun addDescriptionFunctionsInternal(lines: Collection<(ItemStack) -> Iterator<Component>>)
fun assembleDescription(itemStack: ItemStack, into: MutableCollection<Component>)
class Impl : ITooltippable {
private val descriptionLines = ArrayList<(ItemStack) -> Iterator<Component>>()
override fun addDescriptionFunctionsInternal(lines: Stream<out (ItemStack) -> Iterator<Component>>) {
lines.forEach { descriptionLines.add(it) }
}
override fun addDescriptionFunctionsInternal(vararg lines: (ItemStack) -> Iterator<Component>) {
lines.forEach { descriptionLines.add(it) }
}
override fun addDescriptionFunctionsInternal(lines: Collection<(ItemStack) -> Iterator<Component>>) {
lines.forEach { descriptionLines.add(it) }
}
override fun assembleDescription(itemStack: ItemStack, into: MutableCollection<Component>) {
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 : ITooltippable> T.addDescriptionLines(lines: Stream<out Component>): T {
addDescriptionLinesInternal(lines)
return this
}
fun <T : ITooltippable> T.addDescriptionLines(vararg lines: Component): T {
addDescriptionLinesInternal(lines.stream())
return this
}
fun <T : ITooltippable> T.addDescriptionLines(lines: Collection<Component>): T {
addDescriptionLinesInternal(lines)
return this
}
fun <T : ITooltippable> T.addDescriptionFunctions(lines: Stream<out (ItemStack) -> Iterator<Component>>): T {
addDescriptionFunctionsInternal(lines)
return this
}
fun <T : ITooltippable> T.addDescriptionFunctions(vararg lines: (ItemStack) -> Iterator<Component>): T {
addDescriptionFunctionsInternal(lines.stream())
return this
}
fun <T : ITooltippable> T.addDescriptionFunctions(line: (ItemStack) -> Iterator<Component>): T {
addDescriptionFunctionsInternal(line)
return this
}
fun <T : ITooltippable> T.addDescriptionFunctions(lines: Collection<(ItemStack) -> Iterator<Component>>): T {
addDescriptionFunctionsInternal(lines)
return this
}
fun <T : ITooltippable> T.needsNoPowerDescription(formatting: ChatFormatting = ChatFormatting.GRAY): T {
return addDescriptionLines(TranslatableComponent("otm.needs_no_power").withStyle(formatting))
}

View File

@ -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<Component>) {
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 <reified T : Tag> 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<CompoundTag>(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<CompoundTag>(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)
}
}
}
}

View File

@ -380,6 +380,14 @@ fun <T> emptyIterator(): MutableIterator<T> {
return ObjectIterators.emptyIterator() return ObjectIterators.emptyIterator()
} }
fun <T> iteratorOf(value: T): MutableIterator<T> {
return ObjectIterators.singleton(value)
}
fun <T> iteratorOf(vararg value: T): MutableIterator<T> {
return ObjectIterators.wrap(value)
}
fun <T> Iterator<T>.toStream(): Stream<T> { fun <T> Iterator<T>.toStream(): Stream<T> {
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(this, 0), false) return StreamSupport.stream(Spliterators.spliteratorUnknownSize(this, 0), false)
} }

View File

@ -29,7 +29,7 @@ import ru.dbotthepony.mc.otm.registry.MatteryDamageSource
import ru.dbotthepony.mc.otm.runIfClient import ru.dbotthepony.mc.otm.runIfClient
import kotlin.math.roundToInt import kotlin.math.roundToInt
open class BatteryItem : Item { open class BatteryItem : MatteryItem {
val _capacity: () -> Decimal val _capacity: () -> Decimal
val _receive: () -> Decimal val _receive: () -> Decimal
val _extract: () -> Decimal val _extract: () -> Decimal
@ -103,14 +103,8 @@ open class BatteryItem : Item {
return p_150901_.matteryEnergy?.getBarColor() ?: super.getBarColor(p_150901_) return p_150901_.matteryEnergy?.getBarColor() ?: super.getBarColor(p_150901_)
} }
override fun appendHoverText( init {
stack: ItemStack, tooltips.itemEnergy()
p_41422_: Level?,
p_41423_: MutableList<Component>,
p_41424_: TooltipFlag
) {
super.appendHoverText(stack, p_41422_, p_41423_, p_41424_)
ItemEnergyStorageImpl.appendHoverText(stack, p_41423_)
} }
override fun initCapabilities(stack: ItemStack, nbt: CompoundTag?): ICapabilityProvider { override fun initCapabilities(stack: ItemStack, nbt: CompoundTag?): ICapabilityProvider {
@ -119,19 +113,14 @@ open class BatteryItem : Item {
} }
class CrudeBatteryItem : BatteryItem(ItemsConfig.Batteries.CRUDE) { class CrudeBatteryItem : BatteryItem(ItemsConfig.Batteries.CRUDE) {
override fun appendHoverText( init {
stack: ItemStack, tooltips.addNormal { itemStack, acceptor ->
p_41422_: Level?, val isAndroid = runIfClient(false) { minecraft.player?.matteryPlayer?.isAndroid ?: false }
p_41423_: MutableList<Component>,
p_41424_: TooltipFlag
) {
super.appendHoverText(stack, p_41422_, p_41423_, p_41424_)
val isAndroid = runIfClient(false) { minecraft.player?.matteryPlayer?.isAndroid ?: false } if (isAndroid) {
acceptor(TranslatableComponent("otm.gui.crude_battery.replace_in_world").withStyle(ChatFormatting.GRAY))
if (isAndroid) { acceptor(TranslatableComponent("otm.gui.crude_battery.replace_in_world_warning").withStyle(ChatFormatting.DARK_RED))
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))
} }
} }

View File

@ -46,7 +46,7 @@ import ru.dbotthepony.mc.otm.core.isNotEmpty
import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.core.orNull
import java.util.function.IntSupplier 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 // TODO: Так как использование предмета заблокировано за player.abilities.canBuild
// капсулу нельзя использовать в режиме приключения // капсулу нельзя использовать в режиме приключения
// почему же можно использовать вёдра на котлах? // почему же можно использовать вёдра на котлах?
@ -72,12 +72,8 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6
return super.getName(pStack) return super.getName(pStack)
} }
override fun appendHoverText(pStack: ItemStack, pLevel: Level?, pTooltipComponents: MutableList<Component>, pIsAdvanced: TooltipFlag) { init {
super.appendHoverText(pStack, pLevel, pTooltipComponents, pIsAdvanced) tooltips.itemFluid()
pStack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK {
it.fluidLevel(pTooltipComponents)
}
} }
override fun initCapabilities(stack: ItemStack, nbt: CompoundTag?): ICapabilityProvider { override fun initCapabilities(stack: ItemStack, nbt: CompoundTag?): ICapabilityProvider {

View File

@ -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.fluid.BlockMatteryFluidHandler
import ru.dbotthepony.mc.otm.capability.fluidLevel import ru.dbotthepony.mc.otm.capability.fluidLevel
import ru.dbotthepony.mc.otm.client.render.blockentity.FluidTankRenderer 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.TranslatableComponent
import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.ifPresentK
import java.util.function.Consumer import java.util.function.Consumer
import java.util.function.IntSupplier import java.util.function.IntSupplier
class FluidTankItem(block: FluidTankBlock, properties: Properties, val capacity: IntSupplier) : BlockItem(block, properties) { 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 { override fun initCapabilities(stack: ItemStack, nbt: CompoundTag?): ICapabilityProvider {
return BlockMatteryFluidHandler.Item(stack, capacity, FluidTankBlockEntity.FLUID_KEY) 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<Component>, pFlag: TooltipFlag) { override fun appendHoverText(pStack: ItemStack, pLevel: Level?, pTooltip: MutableList<Component>, pFlag: TooltipFlag) {
super.appendHoverText(pStack, pLevel, pTooltip, pFlag) super.appendHoverText(pStack, pLevel, pTooltip, pFlag)
tooltips.assemble(pStack, pTooltip::add)
pStack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK {
it.fluidLevel(pTooltip)
}
} }
override fun initializeClient(consumer: Consumer<IClientItemExtensions>) { override fun initializeClient(consumer: Consumer<IClientItemExtensions>) {

View File

@ -7,22 +7,19 @@ import net.minecraft.world.item.Item
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.TooltipFlag import net.minecraft.world.item.TooltipFlag
import net.minecraft.world.level.Level import net.minecraft.world.level.Level
import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.core.TooltipList
import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.core.ITooltippable
import ru.dbotthepony.mc.otm.core.TranslatableComponent 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<Component>, tooltipType: TooltipFlag) { override fun appendHoverText(itemStack: ItemStack, level: Level?, components: MutableList<Component>, tooltipType: TooltipFlag) {
super.appendHoverText(itemStack, level, components, tooltipType) super.appendHoverText(itemStack, level, components, tooltipType)
assembleDescription(itemStack, components) tooltips.assemble(itemStack, components)
} }
} }
fun <T : MatteryItem> T.addSimpleDescription(suffix: String = "", formatting: ChatFormatting = ChatFormatting.GRAY): T { fun <T : MatteryItem> 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
} }

View File

@ -18,8 +18,9 @@ import net.minecraft.world.level.gameevent.GameEvent
import ru.dbotthepony.mc.otm.entity.MinecartCargoCrate import ru.dbotthepony.mc.otm.entity.MinecartCargoCrate
import ru.dbotthepony.mc.otm.registry.MEntityTypes 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 { init {
tooltips.painted(color)
DispenserBlock.registerBehavior(this, Companion) DispenserBlock.registerBehavior(this, Companion)
} }

View File

@ -18,21 +18,14 @@ enum class PillType {
BECOME_ANDROID, BECOME_HUMANE, OBLIVION BECOME_ANDROID, BECOME_HUMANE, OBLIVION
} }
class HealPillItem : Item(Properties().stacksTo(64).rarity(Rarity.UNCOMMON)) { class HealPillItem : MatteryItem(Properties().stacksTo(64).rarity(Rarity.UNCOMMON)) {
override fun getUseDuration(p_41454_: ItemStack): Int { override fun getUseDuration(itemStack: ItemStack): Int {
return 24 return 24
} }
override fun appendHoverText( init {
p_41421_: ItemStack, tooltips.add(TranslatableComponent("otm.pill.heal").withStyle(ChatFormatting.GRAY))
p_41422_: Level?, tooltips.add(TranslatableComponent("otm.pill.heal_android").withStyle(ChatFormatting.GRAY))
p_41423_: MutableList<Component>,
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))
} }
override fun use(level: Level, ply: Player, hand: InteractionHand): InteractionResultHolder<ItemStack> { override fun use(level: Level, ply: Player, hand: InteractionHand): InteractionResultHolder<ItemStack> {
@ -62,33 +55,24 @@ class HealPillItem : Item(Properties().stacksTo(64).rarity(Rarity.UNCOMMON)) {
override fun getUseAnimation(p_41452_: ItemStack): UseAnim = UseAnim.EAT override fun getUseAnimation(p_41452_: ItemStack): UseAnim = UseAnim.EAT
} }
class PillItem(val pillType: PillType) : class PillItem(val pillType: PillType) : MatteryItem(Properties().stacksTo(64).rarity(Rarity.UNCOMMON)) {
Item(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 { override fun getUseDuration(p_41454_: ItemStack): Int {
return 32 return 32
} }
override fun appendHoverText(
p_41421_: ItemStack,
p_41422_: Level?,
p_41423_: MutableList<Component>,
p_41424_: TooltipFlag
) {
super.appendHoverText(p_41421_, p_41422_, p_41423_, p_41424_)
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<ItemStack> { override fun use(level: Level, ply: Player, hand: InteractionHand): InteractionResultHolder<ItemStack> {
val resolver = ply.getCapability(MatteryCapability.MATTERY_PLAYER).resolve() val resolver = ply.getCapability(MatteryCapability.MATTERY_PLAYER).resolve()

View File

@ -29,7 +29,7 @@ import ru.dbotthepony.mc.otm.data.DecimalProvider
import ru.dbotthepony.mc.otm.registry.MItemFunctionTypes import ru.dbotthepony.mc.otm.registry.MItemFunctionTypes
import java.util.Optional import java.util.Optional
class ProceduralBatteryItem : Item(Properties().stacksTo(1)) { class ProceduralBatteryItem : MatteryItem(Properties().stacksTo(1)) {
class Cap(stack: ItemStack) : ItemEnergyStorageImpl(stack) { class Cap(stack: ItemStack) : ItemEnergyStorageImpl(stack) {
override var maxInput: Decimal override var maxInput: Decimal
get() = itemStack.tag?.mapPresent("maxInput", Decimal.Companion::deserializeNBT) ?: Decimal.ZERO 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_) return p_150901_.matteryEnergy?.getBarColor() ?: super.getBarColor(p_150901_)
} }
override fun appendHoverText(p_41421_: ItemStack, p_41422_: Level?, p_41423_: MutableList<Component>, p_41424_: TooltipFlag) { init {
super.appendHoverText(p_41421_, p_41422_, p_41423_, p_41424_) 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) {
if (energy is Cap) { acceptor(TranslatableComponent("$descriptionId.desc").withStyle(ChatFormatting.GRAY))
if (energy.maxInput.isZero && energy.maxOutput.isZero && energy.maxBatteryLevel.isZero) { } else {
p_41423_.add(TranslatableComponent("$descriptionId.desc").withStyle(ChatFormatting.GRAY)) batteryLevel(energy, acceptor)
} else { }
batteryLevel(energy, p_41423_)
} }
} }
} }

View File

@ -30,7 +30,7 @@ class SimpleUpgrade(
override val matterStorage: Decimal = Decimal.ZERO, override val matterStorage: Decimal = Decimal.ZERO,
override val matterStorageFlat: Decimal = Decimal.ZERO, override val matterStorageFlat: Decimal = Decimal.ZERO,
override val failureMultiplier: Double = 1.0, override val failureMultiplier: Double = 1.0,
) : Item(properties), IMatteryUpgrade, ICapabilityProvider { ) : MatteryItem(properties), IMatteryUpgrade, ICapabilityProvider {
private val resolver = LazyOptional.of { this } private val resolver = LazyOptional.of { this }
override fun <T : Any?> getCapability(cap: Capability<T>, side: Direction?): LazyOptional<T> { override fun <T : Any?> getCapability(cap: Capability<T>, side: Direction?): LazyOptional<T> {
@ -41,9 +41,10 @@ class SimpleUpgrade(
return LazyOptional.empty() return LazyOptional.empty()
} }
override fun appendHoverText(p_41421_: ItemStack, p_41422_: Level?, p_41423_: MutableList<Component>, p_41424_: TooltipFlag) { init {
super.appendHoverText(p_41421_, p_41422_, p_41423_, p_41424_) tooltips.addNormal { _, acceptor ->
addUpgradeTooltipLines(p_41423_) addUpgradeTooltipLines(acceptor)
}
} }
override fun initCapabilities(stack: ItemStack, nbt: CompoundTag?): ICapabilityProvider { override fun initCapabilities(stack: ItemStack, nbt: CompoundTag?): ICapabilityProvider {

View File

@ -23,22 +23,16 @@ open class SingleUseBatteryItem(
private val _capacity: () -> Decimal, private val _capacity: () -> Decimal,
private val _throughput: () -> Decimal? = { null }, private val _throughput: () -> Decimal? = { null },
properties: Properties = Properties().stacksTo(1) properties: Properties = Properties().stacksTo(1)
) : Item(properties) { ) : MatteryItem(properties) {
constructor(values: EnergyBalanceValues, properties: Properties = Properties().stacksTo(1)) : this(values::energyCapacity, values::energyThroughput, 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) constructor(storage: Decimal, throughput: Decimal? = null, properties: Properties = Properties().stacksTo(1)) : this({ storage }, { throughput }, properties)
val capacity get() = _capacity.invoke() val capacity get() = _capacity.invoke()
val throughput get() = _throughput.invoke() val throughput get() = _throughput.invoke()
override fun appendHoverText( init {
itemStack: ItemStack, tooltips.add(TranslatableComponent("otm.battery.single_use").withStyle(ChatFormatting.GRAY))
p_41422_: Level?, tooltips.itemEnergy()
list: MutableList<Component>,
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)
} }
override fun initCapabilities(stack: ItemStack, nbt: CompoundTag?): ICapabilityProvider { 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)) { class ZPMItem : SingleUseBatteryItem(ItemsConfig.Batteries.ZPM, Properties().stacksTo(1).rarity(Rarity.EPIC)) {
override fun appendHoverText( init {
itemStack: ItemStack, tooltips.add(TranslatableComponent("$descriptionId.description").withStyle(ChatFormatting.DARK_GRAY))
p_41422_: Level?,
list: MutableList<Component>,
p_41424_: TooltipFlag
) {
super.appendHoverText(itemStack, p_41422_, list, p_41424_)
list.add(TranslatableComponent("$descriptionId.description").withStyle(ChatFormatting.DARK_GRAY))
} }
} }

View File

@ -1,15 +1,10 @@
package ru.dbotthepony.mc.otm.item.matter package ru.dbotthepony.mc.otm.item.matter
import net.minecraft.ChatFormatting import net.minecraft.ChatFormatting
import net.minecraft.MethodsReturnNonnullByDefault
import net.minecraft.core.Direction import net.minecraft.core.Direction
import net.minecraft.nbt.CompoundTag 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.ItemStack
import net.minecraft.world.item.Rarity 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.Capability
import net.minecraftforge.common.capabilities.ICapabilityProvider import net.minecraftforge.common.capabilities.ICapabilityProvider
import net.minecraftforge.common.util.LazyOptional 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.ifPresentK
import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.map
import ru.dbotthepony.mc.otm.core.tagNotNull import ru.dbotthepony.mc.otm.core.tagNotNull
import javax.annotation.ParametersAreNonnullByDefault import ru.dbotthepony.mc.otm.item.MatteryItem
@ParametersAreNonnullByDefault class MatterCapacitorItem : MatteryItem {
@MethodsReturnNonnullByDefault
class MatterCapacitorItem : Item {
private inner class Matter(private val stack: ItemStack) : ICapabilityProvider, IMatterStorage { private inner class Matter(private val stack: ItemStack) : ICapabilityProvider, IMatterStorage {
private val resolver = LazyOptional.of<IMatterStorage> { this } private val resolver = LazyOptional.of<IMatterStorage> { this }
@ -37,7 +30,7 @@ class MatterCapacitorItem : Item {
override var storedMatter: Decimal override var storedMatter: Decimal
get() { get() {
if (isCreative) return Decimal.LONG_MAX_VALUE if (isCreative) return Decimal.POSITIVE_INFINITY
return stack.tag?.map("matter", Decimal.Companion::deserializeNBT) ?: Decimal.ZERO return stack.tag?.map("matter", Decimal.Companion::deserializeNBT) ?: Decimal.ZERO
} }
set(value) { set(value) {
@ -49,7 +42,7 @@ class MatterCapacitorItem : Item {
} }
override val missingMatter: Decimal get() { 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 { override fun receiveMatter(howMuch: Decimal, simulate: Boolean): Decimal {
@ -96,7 +89,7 @@ class MatterCapacitorItem : Item {
constructor() : super(Properties().stacksTo(1).rarity(Rarity.EPIC)) { constructor() : super(Properties().stacksTo(1).rarity(Rarity.EPIC)) {
isCreative = true isCreative = true
_capacity = { Decimal.LONG_MAX_VALUE } _capacity = { Decimal.POSITIVE_INFINITY }
} }
override fun isBarVisible(p_150899_: ItemStack): Boolean { override fun isBarVisible(p_150899_: ItemStack): Boolean {
@ -120,20 +113,12 @@ class MatterCapacitorItem : Item {
return p_150901_.matter?.getBarColor() ?: super.getBarColor(p_150901_) return p_150901_.matter?.getBarColor() ?: super.getBarColor(p_150901_)
} }
override fun appendHoverText( init {
stack: ItemStack, tooltips.addNormal { itemStack, acceptor ->
p_41422_: Level?, itemStack.getCapability(MatteryCapability.MATTER).ifPresentK {
p_41423_: MutableList<Component>, acceptor(
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(
TranslatableComponent( TranslatableComponent(
"otm.item.matter.normal", "otm.item.matter.storage",
it.storedMatter.formatMatter(formatAsReadable = ShiftPressedCond), it.storedMatter.formatMatter(formatAsReadable = ShiftPressedCond),
capacity.formatMatter(formatAsReadable = ShiftPressedCond) capacity.formatMatter(formatAsReadable = ShiftPressedCond)
).withStyle(ChatFormatting.GRAY) ).withStyle(ChatFormatting.GRAY)
@ -147,10 +132,7 @@ class MatterCapacitorItem : Item {
} }
companion object { companion object {
private val maxInput = Decimal.LONG_MAX_VALUE private val maxInput = Decimal.POSITIVE_INFINITY
private val maxOutput = Decimal.LONG_MAX_VALUE private val maxOutput = Decimal.POSITIVE_INFINITY
private val INFINITE_STORAGE: Component =
TranslatableComponent("otm.item.matter.infinite").withStyle(ChatFormatting.GRAY)
} }
} }

View File

@ -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.nbt.uuids
import ru.dbotthepony.mc.otm.core.tagNotNull import ru.dbotthepony.mc.otm.core.tagNotNull
import ru.dbotthepony.mc.otm.core.util.formatPower 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.MNetworkContext
import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.MatteryPacket
import ru.dbotthepony.mc.otm.network.WeaponNetworkChannel import ru.dbotthepony.mc.otm.network.WeaponNetworkChannel
@ -136,7 +137,7 @@ open class WeaponDataTable(val tag: CompoundTag) {
} }
} }
abstract class AbstractWeaponItem<D : WeaponDataTable>(val tables: KClass<D>, properties: Properties = Properties().stacksTo(1).rarity(Rarity.RARE)) : Item(properties) { abstract class AbstractWeaponItem<D : WeaponDataTable>(val tables: KClass<D>, properties: Properties = Properties().stacksTo(1).rarity(Rarity.RARE)) : MatteryItem(properties) {
fun makeDataTable(tag: CompoundTag) = tables.primaryConstructor!!.call(tag) fun makeDataTable(tag: CompoundTag) = tables.primaryConstructor!!.call(tag)
/** /**

View File

@ -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.math.nextVariance
import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.core.orNull
import ru.dbotthepony.mc.otm.core.util.WriteOnce 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.MDamageTypes
import ru.dbotthepony.mc.otm.registry.MatteryDamageSource 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<Attribute, AttributeModifier> val chargedAttributes: Multimap<Attribute, AttributeModifier>
val dischargedAttributes: Multimap<Attribute, AttributeModifier> val dischargedAttributes: Multimap<Attribute, AttributeModifier>
@ -135,20 +137,13 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani
return p_150901_.matteryEnergy?.getBarColor() ?: super.getBarColor(p_150901_) return p_150901_.matteryEnergy?.getBarColor() ?: super.getBarColor(p_150901_)
} }
override fun appendHoverText( init {
itemStack: ItemStack, tooltips.itemEnergy()
p_41422_: Level?,
p_41423_: MutableList<Component>,
p_41424_: TooltipFlag
) {
super.appendHoverText(itemStack, p_41422_, p_41423_, p_41424_)
ItemEnergyStorageImpl.appendHoverText(itemStack, p_41423_) addSimpleDescription()
addSimpleDescription("2")
p_41423_.add(DESCRIPTION) addSimpleDescription("3")
p_41423_.add(DESCRIPTION2) addSimpleDescription("4")
p_41423_.add(DESCRIPTION3)
p_41423_.add(DESCRIPTION4)
} }
override fun mineBlock( override fun mineBlock(
@ -249,10 +244,5 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani
return null 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)
} }
} }

View File

@ -174,15 +174,8 @@ open class PlasmaWeaponDataTable(tag: CompoundTag) : WeaponDataTable(tag) {
} }
abstract class PlasmaWeaponItem<D : PlasmaWeaponDataTable>(tables: KClass<D>, private val energyCapacity: Decimal) : AbstractWeaponItem<D>(tables) { abstract class PlasmaWeaponItem<D : PlasmaWeaponDataTable>(tables: KClass<D>, private val energyCapacity: Decimal) : AbstractWeaponItem<D>(tables) {
override fun appendHoverText( init {
itemStack: ItemStack, tooltips.itemEnergy()
p_41422_: Level?,
p_41423_: MutableList<Component>,
p_41424_: TooltipFlag
) {
super.appendHoverText(itemStack, p_41422_, p_41423_, p_41424_)
ItemEnergyStorageImpl.appendHoverText(itemStack, p_41423_)
} }
fun energyData(itemStack: ItemStack) = itemStack.matteryEnergy as PlasmaWeaponEnergy fun energyData(itemStack: ItemStack) = itemStack.matteryEnergy as PlasmaWeaponEnergy

View File

@ -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<ProcessingTuple>
abstract val itemConfig: ItemConfigPlayerInput?
abstract val energyConfig: EnergyConfigPlayerInput?
abstract val profiledEnergy: ProfiledLevelGaugeWidget<*>
abstract val balanceInputs: BooleanInputWithFeedback?
abstract val upgrades: UpgradeSlots?
open val recipeTypes: Supplier<List<RecipeType<*>>>?
get() = null
init {
addInventorySlots()
}
}

View File

@ -7,7 +7,6 @@ import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.enchantment.Enchantments import net.minecraft.world.item.enchantment.Enchantments
import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting
import ru.dbotthepony.mc.otm.block.entity.tech.EssenceStorageBlockEntity 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.core.util.getTotalXpRequiredForLevel
import ru.dbotthepony.mc.otm.item.EssenceCapsuleItem import ru.dbotthepony.mc.otm.item.EssenceCapsuleItem
import ru.dbotthepony.mc.otm.item.EssenceServoItem 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.MItems
import ru.dbotthepony.mc.otm.registry.MMenus import ru.dbotthepony.mc.otm.registry.MMenus
class EssenceStorageMenu @JvmOverloads constructor( class EssenceStorageMenu(
containerID: Int, containerID: Int,
inventory: Inventory, inventory: Inventory,
tile: EssenceStorageBlockEntity? = null tile: EssenceStorageBlockEntity? = null
@ -88,18 +87,10 @@ class EssenceStorageMenu @JvmOverloads constructor(
} }
init { 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 { storeLevels.filter {
it.experienceProgress > 0f || it.experienceLevel > 0 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 } dispenseLevels.filter { (tile?.experienceStored ?: experienceStored) > 0L }
if (tile != null) { if (tile != null) {

View File

@ -1,36 +1,64 @@
package ru.dbotthepony.mc.otm.menu.tech package ru.dbotthepony.mc.otm.menu.tech
import mezz.jei.api.recipe.RecipeType
import net.minecraft.server.level.ServerPlayer import net.minecraft.server.level.ServerPlayer
import net.minecraft.world.SimpleContainer import net.minecraft.world.SimpleContainer
import net.minecraft.world.entity.player.Inventory 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.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.OutputSlot
import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu
import ru.dbotthepony.mc.otm.menu.MatterySlot 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.EnergyConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput 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.ProfiledLevelGaugeWidget
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
import ru.dbotthepony.mc.otm.registry.MMenus import ru.dbotthepony.mc.otm.registry.MMenus
import java.util.function.Supplier
class PlatePressMenu( class PlatePressMenu(
type: MenuType<*>,
containerID: Int, containerID: Int,
inventory: Inventory, inventory: Inventory,
tile: PlatePressBlockEntity? = null tile: PlatePressBlockEntity? = null,
) : MatteryPoweredMenu(MMenus.PLATE_PRESS, containerID, inventory, tile) { isTwin: Boolean
val inputSlot = MatterySlot(tile?.inputContainer ?: SimpleContainer(1), 0) ) : AbstractProcessingMachineMenu(type, containerID, inventory, tile) {
val outputSlot = OutputSlot(tile?.outputContainer ?: SimpleContainer(1), 0) { tile?.experience?.popExperience(player as ServerPlayer) } 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) override val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig, allowPush = true)
val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig, allowPush = true) override val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPull = true)
val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPull = true) override val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget)
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<ProcessingTuple> = immutableList(if (isTwin) 2 else 1) {
ProcessingTuple(inputSlots[it], outputSlots[it], gauges[it])
}
override val recipeTypes: Supplier<List<RecipeType<*>>>
get() = Supplier { listOf(PlatePressRecipeCategory.recipeType) }
init { init {
addStorageSlot(inputSlot) if (tile != null) balanceInputs?.with(tile::balanceInputs)
addStorageSlot(outputSlot) addStorageSlot(inputSlots)
addInventorySlots() 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)
}
} }
} }

View File

@ -1,5 +1,7 @@
package ru.dbotthepony.mc.otm.menu.tech 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.server.level.ServerPlayer
import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.inventory.MenuType 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.PoweredBlastFurnaceBlockEntity
import ru.dbotthepony.mc.otm.block.entity.tech.PoweredFurnaceBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.PoweredFurnaceBlockEntity
import ru.dbotthepony.mc.otm.block.entity.tech.PoweredSmokerBlockEntity 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.core.immutableList
import ru.dbotthepony.mc.otm.menu.OutputSlot import ru.dbotthepony.mc.otm.menu.OutputSlot
import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu 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.ProfiledLevelGaugeWidget
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
import ru.dbotthepony.mc.otm.registry.MMenus import ru.dbotthepony.mc.otm.registry.MMenus
import java.util.function.Supplier
class PoweredFurnaceMenu( class PoweredFurnaceMenu(
type: MenuType<PoweredFurnaceMenu>, type: MenuType<PoweredFurnaceMenu>,
containerID: Int, containerID: Int,
inventory: Inventory, inventory: Inventory,
tile: AbstractPoweredFurnaceBlockEntity<*, *>? = null tile: AbstractPoweredFurnaceBlockEntity<*, *>? = null
) : MatteryPoweredMenu(type, containerID, inventory, tile) { ) : AbstractProcessingMachineMenu(type, containerID, inventory, tile) {
val inputSlots = makeSlots(tile?.inputs, 2, ::MatterySlot) 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 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 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<ProcessingTuple> = immutableList(2) {
ProcessingTuple(inputSlots[it], outputSlots[it], progressGauge[it])
}
override val recipeTypes: Supplier<List<RecipeType<*>>>?
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 { init {
if (tile != null) balanceInputs.with(tile::balanceInputs) if (tile != null) balanceInputs.with(tile::balanceInputs)
addStorageSlot(inputSlots) addStorageSlot(inputSlots)
addStorageSlot(outputSlots) addStorageSlot(outputSlots)
addInventorySlots()
} }
companion object { companion object {

View File

@ -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()
}
}

View File

@ -81,7 +81,7 @@ class PlatePressRecipe(
override fun getType(): RecipeType<PlatePressRecipe> = MRecipes.PLATE_PRESS override fun getType(): RecipeType<PlatePressRecipe> = MRecipes.PLATE_PRESS
override fun getToastSymbol(): ItemStack { override fun getToastSymbol(): ItemStack {
return ItemStack(MItems.PLATE_PRESS[null]!!) return ItemStack(MItems.TWIN_PLATE_PRESS[null]!!)
} }
fun toFinished() = SERIALIZER.toFinished(this) fun toFinished() = SERIALIZER.toFinished(this)

View File

@ -25,6 +25,7 @@ import ru.dbotthepony.mc.otm.core.tagNotNull
import ru.dbotthepony.mc.otm.data.Codec2RecipeSerializer import ru.dbotthepony.mc.otm.data.Codec2RecipeSerializer
import ru.dbotthepony.mc.otm.data.RecipePair import ru.dbotthepony.mc.otm.data.RecipePair
import ru.dbotthepony.mc.otm.data.codec import ru.dbotthepony.mc.otm.data.codec
import ru.dbotthepony.mc.otm.data.SingletonCodec
import java.util.stream.Stream import java.util.stream.Stream
class UpgradeRecipe( class UpgradeRecipe(
@ -89,14 +90,19 @@ class UpgradeRecipe(
Codec.STRING.fieldOf("path").forGetter(Direct::path) Codec.STRING.fieldOf("path").forGetter(Direct::path)
).apply(it, ::Direct) ).apply(it, ::Direct)
} }
}, INDIRECT { },
INDIRECT {
override val codec: Codec<Indirect> = RecordCodecBuilder.create { override val codec: Codec<Indirect> = RecordCodecBuilder.create {
it.group( it.group(
Codec.STRING.fieldOf("source").forGetter(Indirect::pathSource), Codec.STRING.fieldOf("source").forGetter(Indirect::pathSource),
Codec.STRING.fieldOf("destination").forGetter(Indirect::pathDestination), Codec.STRING.fieldOf("destination").forGetter(Indirect::pathDestination),
).apply(it, ::Indirect) ).apply(it, ::Indirect)
} }
}; },
ALL {
override val codec: Codec<All> by lazy { SingletonCodec(All) }
},
;
override fun getSerializedName(): String { override fun getSerializedName(): String {
return name.lowercase() 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<Op> = copyPaths.collect(ImmutableList.toImmutableList()) val copyPaths: ImmutableList<Op> = copyPaths.collect(ImmutableList.toImmutableList())
override fun assemble(pInv: CraftingContainer, registryAccess: RegistryAccess): ItemStack { override fun assemble(pInv: CraftingContainer, registryAccess: RegistryAccess): ItemStack {

View File

@ -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<Block> = BlockTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "cargo_crates"))
val INDUSTRIAL_GLASS: TagKey<Block> = BlockTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "industrial_glass"))
val CRAFTING_TABLES: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "crafting_tables"))
val WORKBENCHES: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "workbenches"))
val WORKBENCH: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "workbench"))
val REQUIRES_TRITANIUM_TOOL: TagKey<Block> = BlockTags.create(ResourceLocation("minecraft", "requires_tritanium_tool"))
val HARDENED_GLASS_PANES: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes"))
val HARDENED_GLASS_PANES_BLACK: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/black"))
val HARDENED_GLASS_PANES_BLUE: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/blue"))
val HARDENED_GLASS_PANES_BROWN: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/brown"))
val HARDENED_GLASS_PANES_COLORLESS: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/colorless"))
val HARDENED_GLASS_PANES_CYAN: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/cyan"))
val HARDENED_GLASS_PANES_GRAY: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/gray"))
val HARDENED_GLASS_PANES_GREEN: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/green"))
val HARDENED_GLASS_PANES_LIGHT_BLUE: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/light_blue"))
val HARDENED_GLASS_PANES_LIGHT_GRAY: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/light_gray"))
val HARDENED_GLASS_PANES_LIME: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/lime"))
val HARDENED_GLASS_PANES_MAGENTA: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/magenta"))
val HARDENED_GLASS_PANES_ORANGE: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/orange"))
val HARDENED_GLASS_PANES_PINK: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/pink"))
val HARDENED_GLASS_PANES_PURPLE: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/purple"))
val HARDENED_GLASS_PANES_RED: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/red"))
val HARDENED_GLASS_PANES_WHITE: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/white"))
val HARDENED_GLASS_PANES_YELLOW: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/yellow"))
val HARDENED_GLASS: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass"))
val HARDENED_GLASS_BLACK: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/black"))
val HARDENED_GLASS_BLUE: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/blue"))
val HARDENED_GLASS_BROWN: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/brown"))
val HARDENED_GLASS_COLORLESS: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/colorless"))
val HARDENED_GLASS_CYAN: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/cyan"))
val HARDENED_GLASS_GRAY: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/gray"))
val HARDENED_GLASS_GREEN: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/green"))
val HARDENED_GLASS_LIGHT_BLUE: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/light_blue"))
val HARDENED_GLASS_LIGHT_GRAY: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/light_gray"))
val HARDENED_GLASS_LIME: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/lime"))
val HARDENED_GLASS_MAGENTA: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/magenta"))
val HARDENED_GLASS_ORANGE: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/orange"))
val HARDENED_GLASS_PINK: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/pink"))
val HARDENED_GLASS_PURPLE: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/purple"))
val HARDENED_GLASS_RED: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/red"))
val HARDENED_GLASS_WHITE: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/white"))
val HARDENED_GLASS_YELLOW: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/yellow"))
val MACHINES: TagKey<Block> = BlockTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "machines"))
}

View File

@ -1,11 +1,9 @@
package ru.dbotthepony.mc.otm.registry package ru.dbotthepony.mc.otm.registry
import net.minecraft.resources.ResourceLocation import net.minecraft.resources.ResourceLocation
import net.minecraft.tags.BlockTags
import net.minecraft.tags.ItemTags import net.minecraft.tags.ItemTags
import net.minecraft.tags.TagKey import net.minecraft.tags.TagKey
import net.minecraft.world.item.Item import net.minecraft.world.item.Item
import net.minecraft.world.level.block.Block
import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.OverdriveThatMatters
@Suppress("unused") @Suppress("unused")
@ -38,6 +36,7 @@ object MItemTags {
val GOLD_WIRES: TagKey<Item> = ItemTags.create(ResourceLocation("forge", "wires/gold")) val GOLD_WIRES: TagKey<Item> = ItemTags.create(ResourceLocation("forge", "wires/gold"))
val PISTONS: TagKey<Item> = ItemTags.create(ResourceLocation("forge", "pistons")) val PISTONS: TagKey<Item> = ItemTags.create(ResourceLocation("forge", "pistons"))
val FURNACES: TagKey<Item> = ItemTags.create(ResourceLocation("forge", "furnaces"))
val TOOLS_HAMMERS: TagKey<Item> = ItemTags.create(ResourceLocation("forge", "tools/hammers")) val TOOLS_HAMMERS: TagKey<Item> = ItemTags.create(ResourceLocation("forge", "tools/hammers"))
@ -82,54 +81,3 @@ object MItemTags {
val MACHINES: TagKey<Item> = ItemTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "machines")) val MACHINES: TagKey<Item> = ItemTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "machines"))
} }
@Suppress("unused")
object MBlockTags {
val CARGO_CRATES: TagKey<Block> = BlockTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "cargo_crates"))
val INDUSTRIAL_GLASS: TagKey<Block> = BlockTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "industrial_glass"))
val CRAFTING_TABLES: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "crafting_tables"))
val WORKBENCHES: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "workbenches"))
val WORKBENCH: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "workbench"))
val REQUIRES_TRITANIUM_TOOL: TagKey<Block> = BlockTags.create(ResourceLocation("minecraft", "requires_tritanium_tool"))
val HARDENED_GLASS_PANES: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes"))
val HARDENED_GLASS_PANES_BLACK: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/black"))
val HARDENED_GLASS_PANES_BLUE: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/blue"))
val HARDENED_GLASS_PANES_BROWN: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/brown"))
val HARDENED_GLASS_PANES_COLORLESS: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/colorless"))
val HARDENED_GLASS_PANES_CYAN: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/cyan"))
val HARDENED_GLASS_PANES_GRAY: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/gray"))
val HARDENED_GLASS_PANES_GREEN: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/green"))
val HARDENED_GLASS_PANES_LIGHT_BLUE: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/light_blue"))
val HARDENED_GLASS_PANES_LIGHT_GRAY: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/light_gray"))
val HARDENED_GLASS_PANES_LIME: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/lime"))
val HARDENED_GLASS_PANES_MAGENTA: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/magenta"))
val HARDENED_GLASS_PANES_ORANGE: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/orange"))
val HARDENED_GLASS_PANES_PINK: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/pink"))
val HARDENED_GLASS_PANES_PURPLE: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/purple"))
val HARDENED_GLASS_PANES_RED: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/red"))
val HARDENED_GLASS_PANES_WHITE: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/white"))
val HARDENED_GLASS_PANES_YELLOW: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/yellow"))
val HARDENED_GLASS: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass"))
val HARDENED_GLASS_BLACK: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/black"))
val HARDENED_GLASS_BLUE: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/blue"))
val HARDENED_GLASS_BROWN: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/brown"))
val HARDENED_GLASS_COLORLESS: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/colorless"))
val HARDENED_GLASS_CYAN: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/cyan"))
val HARDENED_GLASS_GRAY: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/gray"))
val HARDENED_GLASS_GREEN: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/green"))
val HARDENED_GLASS_LIGHT_BLUE: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/light_blue"))
val HARDENED_GLASS_LIGHT_GRAY: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/light_gray"))
val HARDENED_GLASS_LIME: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/lime"))
val HARDENED_GLASS_MAGENTA: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/magenta"))
val HARDENED_GLASS_ORANGE: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/orange"))
val HARDENED_GLASS_PINK: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/pink"))
val HARDENED_GLASS_PURPLE: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/purple"))
val HARDENED_GLASS_RED: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/red"))
val HARDENED_GLASS_WHITE: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/white"))
val HARDENED_GLASS_YELLOW: TagKey<Block> = BlockTags.create(ResourceLocation("forge", "hardened_glass/yellow"))
val MACHINES: TagKey<Block> = BlockTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "machines"))
}

View File

@ -115,7 +115,6 @@ object MItems {
init { init {
val machines = ArrayList<Supplier<BlockItem>>() val machines = ArrayList<Supplier<BlockItem>>()
machines.addAll(PLATE_PRESS.asSupplierArray())
machines.addAll(TWIN_PLATE_PRESS.asSupplierArray()) machines.addAll(TWIN_PLATE_PRESS.asSupplierArray())
machines.addAll(POWERED_FURNACE.asSupplierArray()) machines.addAll(POWERED_FURNACE.asSupplierArray())
machines.addAll(POWERED_BLAST_FURNACE.asSupplierArray()) machines.addAll(POWERED_BLAST_FURNACE.asSupplierArray())

View File

@ -5,9 +5,7 @@ import net.minecraft.world.flag.FeatureFlags
import net.minecraft.world.inventory.MenuType import net.minecraft.world.inventory.MenuType
import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.eventbus.api.IEventBus
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent
import net.minecraftforge.registries.DeferredRegister
import net.minecraftforge.registries.ForgeRegistries 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.block.entity.tech.AndroidChargerBlockEntity
import ru.dbotthepony.mc.otm.client.screen.decorative.CargoCrateScreen import ru.dbotthepony.mc.otm.client.screen.decorative.CargoCrateScreen
import ru.dbotthepony.mc.otm.client.screen.decorative.FluidTankScreen 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.EnergyServoScreen
import ru.dbotthepony.mc.otm.client.screen.tech.EssenceStorageScreen 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.decorative.PainterScreen
import ru.dbotthepony.mc.otm.client.screen.tech.PlatePressScreen import ru.dbotthepony.mc.otm.client.screen.tech.AbstractProcessingMachineScreen
import ru.dbotthepony.mc.otm.client.screen.tech.PoweredFurnaceScreen
import ru.dbotthepony.mc.otm.client.screen.tech.TwinPlatePressScreen
import ru.dbotthepony.mc.otm.menu.decorative.CargoCrateMenu import ru.dbotthepony.mc.otm.menu.decorative.CargoCrateMenu
import ru.dbotthepony.mc.otm.menu.decorative.FluidTankMenu import ru.dbotthepony.mc.otm.menu.decorative.FluidTankMenu
import ru.dbotthepony.mc.otm.menu.decorative.HoloSignMenu 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.decorative.PainterMenu
import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu
import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu
import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu
object MMenus { object MMenus {
private val registry = MDeferredRegister(ForgeRegistries.MENU_TYPES) 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 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 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 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_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_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 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 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 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) } 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(ITEM_MONITOR, ::ItemMonitorScreen)
MenuScreens.register(ENERGY_COUNTER, ::EnergyCounterScreen) MenuScreens.register(ENERGY_COUNTER, ::EnergyCounterScreen)
MenuScreens.register(CHEMICAL_GENERATOR, ::ChemicalGeneratorScreen) MenuScreens.register(CHEMICAL_GENERATOR, ::ChemicalGeneratorScreen)
MenuScreens.register(PLATE_PRESS, ::PlatePressScreen) MenuScreens.register(PLATE_PRESS, ::AbstractProcessingMachineScreen)
MenuScreens.register(TWIN_PLATE_PRESS, ::TwinPlatePressScreen) MenuScreens.register(TWIN_PLATE_PRESS, ::AbstractProcessingMachineScreen)
MenuScreens.register(MATTER_RECYCLER, ::MatterRecyclerScreen) MenuScreens.register(MATTER_RECYCLER, ::MatterRecyclerScreen)
MenuScreens.register(STORAGE_BUS, ::StorageBusScreen) MenuScreens.register(STORAGE_BUS, ::StorageBusScreen)
MenuScreens.register(STORAGE_IMPORTER_EXPORTER, ::StorageImporterExporterScreen) MenuScreens.register(STORAGE_IMPORTER_EXPORTER, ::StorageImporterExporterScreen)
@ -149,9 +144,9 @@ object MMenus {
MenuScreens.register(ESSENCE_STORAGE, ::EssenceStorageScreen) MenuScreens.register(ESSENCE_STORAGE, ::EssenceStorageScreen)
MenuScreens.register(ITEM_REPAIER, ::MatterReconstructorScreen) MenuScreens.register(ITEM_REPAIER, ::MatterReconstructorScreen)
MenuScreens.register(FLUID_TANK, ::FluidTankScreen) MenuScreens.register(FLUID_TANK, ::FluidTankScreen)
MenuScreens.register(POWERED_FURNACE, ::PoweredFurnaceScreen) MenuScreens.register(POWERED_FURNACE, ::AbstractProcessingMachineScreen)
MenuScreens.register(POWERED_BLAST_FURNACE, ::PoweredFurnaceScreen) MenuScreens.register(POWERED_BLAST_FURNACE, ::AbstractProcessingMachineScreen)
MenuScreens.register(POWERED_SMOKER, ::PoweredFurnaceScreen) MenuScreens.register(POWERED_SMOKER, ::AbstractProcessingMachineScreen)
MenuScreens.register(PAINTER, ::PainterScreen) MenuScreens.register(PAINTER, ::PainterScreen)
MenuScreens.register(MATTER_ENTANGLER, ::MatterEntanglerScreen) MenuScreens.register(MATTER_ENTANGLER, ::MatterEntanglerScreen)
} }

View File

@ -15,7 +15,7 @@ import net.minecraft.world.entity.ai.village.poi.PoiTypes
import net.minecraft.world.item.DyeColor import net.minecraft.world.item.DyeColor
import net.minecraft.world.item.DyeableArmorItem import net.minecraft.world.item.DyeableArmorItem
import net.minecraft.world.item.Item 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.BlockGetter
import net.minecraft.world.level.block.* import net.minecraft.world.level.block.*
import net.minecraft.world.level.block.state.BlockBehaviour 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.FMLClientSetupEvent
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent
import net.minecraftforge.fml.loading.FMLEnvironment 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.NewRegistryEvent
import net.minecraftforge.registries.RegisterEvent import net.minecraftforge.registries.RegisterEvent
import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.OverdriveThatMatters
@ -406,7 +406,10 @@ object MRegistry : IBlockItemRegistryAcceptor {
} }
private fun registerItemDecorators(event: RegisterItemDecorationsEvent) { private fun registerItemDecorators(event: RegisterItemDecorationsEvent) {
event.register(Items.SHIELD, MatteryGUI::renderShieldCooldownOverlay) ForgeRegistries.ITEMS.forEach {
event.register(MItems.TRITANIUM_SHIELD, MatteryGUI::renderShieldCooldownOverlay) if (it is ShieldItem) {
event.register(it, MatteryGUI::renderShieldCooldownOverlay)
}
}
} }
} }

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -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
}
}

Some files were not shown because too many files have changed in this diff Show More