From 0432fa0ed998eae4b436c4cd7ffde544a584b76b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 16 Sep 2022 21:30:27 +0700 Subject: [PATCH] Energy Servo Fixes #22 --- .../mc/otm/datagen/lang/English.kt | 2 + .../mc/otm/datagen/loot/LootTablesData.kt | 2 + .../datagen/recipes/CraftingTableRecipes.kt | 6 + .../dbotthepony/mc/otm/datagen/tags/Tags.kt | 1 + .../mc/otm/block/EnergyServoBlock.kt | 31 ++++ .../block/entity/EnergyServoBlockEntity.kt | 155 ++++++++++++++++++ .../mc/otm/client/screen/EnergyServoScreen.kt | 65 ++++++++ .../mc/otm/client/screen/panels/FramePanel.kt | 7 + .../dbotthepony/mc/otm/core/CompoundTagExt.kt | 2 +- .../mc/otm/menu/EnergyServoMenu.kt | 44 +++++ .../mc/otm/registry/MBlockEntities.kt | 1 + .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 1 + .../ru/dbotthepony/mc/otm/registry/MItems.kt | 27 ++- .../ru/dbotthepony/mc/otm/registry/MMenus.kt | 2 + .../ru/dbotthepony/mc/otm/registry/MNames.kt | 35 ++-- 15 files changed, 357 insertions(+), 24 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/EnergyServoBlock.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/EnergyServoScreen.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyServoMenu.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 62063b46d..03eaf840c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -302,6 +302,8 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.PLATE_PRESS, "Plate Press") add(MBlocks.MATTER_RECYCLER, "Matter Recycler") + add(MBlocks.ENERGY_SERVO, "Energy Servo") + add(MBlocks.ENERGY_SERVO, "desc", "Charges, Discharges or Exchanges energy of items") add(MBlocks.CARBON_FIBRE_BLOCK, "Carbon fibre Block") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index a6da5ddb7..a491de9f3 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -39,6 +39,8 @@ fun addLootTables(lootTables: LootTables) { lootTables.dropsSelf(MBlocks.PHANTOM_ATTRACTOR) + lootTables.tile(MBlocks.ENERGY_SERVO) + lootTables.tile(MBlocks.ENERGY_COUNTER, EnergyCounterBlockEntity.IO_LIMIT_KEY, EnergyCounterBlockEntity.PASSED_ENERGY_KEY, EnergyCounterBlockEntity.POWER_HISTORY_KEY, EnergyCounterBlockEntity.POWER_HISTORY_POINTER_KEY) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index b2c0ba781..709a4c156 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -147,6 +147,12 @@ fun addCraftingTableRecipes(consumer: Consumer) { .unlockedBy(Tags.Items.ENDER_PEARLS) .build(consumer) + MatteryRecipe(MItems.ENERGY_SERVO) + .row(MItemTags.PLATE_TRITANIUM, MItems.MACHINE_FRAME, MItemTags.PLATE_TRITANIUM) + .row(MItemTags.PLATE_TRITANIUM, MItems.ENERGY_BUS, MItemTags.PLATE_TRITANIUM) + .unlockedBy(Tags.Items.ENDER_PEARLS) + .build(consumer) + // броня MatteryRecipe(MItems.TRITANIUM_HELMET) .row(MItemTags.PLATE_TRITANIUM, MItemTags.PLATE_TRITANIUM, MItemTags.PLATE_TRITANIUM) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index 6b040f1e2..a56822b7c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -54,6 +54,7 @@ fun addTags(tagsProvider: TagsProvider) { MBlocks.STORAGE_POWER_SUPPLIER, MBlocks.PHANTOM_ATTRACTOR, + MBlocks.ENERGY_SERVO, ), Tiers.IRON) tagsProvider.requiresPickaxe(MBlocks.TRITANIUM_ORE, Tiers.IRON) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/EnergyServoBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/EnergyServoBlock.kt new file mode 100644 index 000000000..5e66f9092 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/EnergyServoBlock.kt @@ -0,0 +1,31 @@ +package ru.dbotthepony.mc.otm.block + +import net.minecraft.core.BlockPos +import net.minecraft.world.level.Level +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.level.material.Material +import net.minecraft.world.level.material.MaterialColor +import ru.dbotthepony.mc.otm.block.entity.EnergyServoBlockEntity +import ru.dbotthepony.mc.otm.registry.MBlockEntities + +class EnergyServoBlock : RotatableMatteryBlock(Properties.of(Material.METAL, MaterialColor.COLOR_BLUE).explosionResistance(12f).destroyTime(2f)), EntityBlock { + override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { + return EnergyServoBlockEntity(p_153215_, p_153216_) + } + + override fun getTicker( + p_153212_: Level, + p_153213_: BlockState, + p_153214_: BlockEntityType + ): BlockEntityTicker? { + if (p_153214_ == MBlockEntities.ENERGY_SERVO && !p_153212_.isClientSide) { + return BlockEntityTicker { _, _, _, it -> if (it is EnergyServoBlockEntity) it.tick() } + } + + return null + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt new file mode 100644 index 000000000..358cf545f --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt @@ -0,0 +1,155 @@ +package ru.dbotthepony.mc.otm.block.entity + +import net.minecraft.core.BlockPos +import net.minecraft.core.Direction +import net.minecraft.nbt.CompoundTag +import net.minecraft.network.chat.Component +import net.minecraft.world.Container +import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.entity.player.Player +import net.minecraft.world.inventory.AbstractContainerMenu +import net.minecraft.world.item.ItemStack +import net.minecraft.world.level.block.state.BlockState +import net.minecraftforge.common.capabilities.Capability +import net.minecraftforge.common.capabilities.ForgeCapabilities +import net.minecraftforge.common.util.LazyOptional +import ru.dbotthepony.mc.otm.block.IDroppableContainer +import ru.dbotthepony.mc.otm.capability.IMatteryEnergyStorage +import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.energy +import ru.dbotthepony.mc.otm.capability.energyStoredMattery +import ru.dbotthepony.mc.otm.capability.extractEnergy +import ru.dbotthepony.mc.otm.capability.maxEnergyStoredMattery +import ru.dbotthepony.mc.otm.capability.receiveEnergy +import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.container.MatteryContainerFilter +import ru.dbotthepony.mc.otm.core.ImpreciseFraction +import ru.dbotthepony.mc.otm.core.map +import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.menu.EnergyServoMenu +import ru.dbotthepony.mc.otm.registry.MBlockEntities +import ru.dbotthepony.mc.otm.registry.MBlocks + +class EnergyServoBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryBlockEntity(MBlockEntities.ENERGY_SERVO, blockPos, blockState), IDroppableContainer { + override val defaultDisplayName: Component + get() = MBlocks.ENERGY_SERVO.name + + val container = MatteryContainer(this::setChangedLight, 2) + + override val droppableContainer: Container + get() = container + + val itemHandler = container.handler(object : MatteryContainerFilter { + override fun canInsert(slot: Int, stack: ItemStack): Boolean { + return when (slot) { + SLOT_DISCHARGE -> stack.isEmpty || stack.energy?.let { it.extractEnergy(Int.MAX_VALUE, true) > 0 } ?: false + SLOT_CHARGE -> stack.isEmpty || stack.energy?.let { it.receiveEnergy(Int.MAX_VALUE, true) > 0 } ?: false + else -> false + } + } + + override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { + return when (slot) { + SLOT_DISCHARGE -> stack.isEmpty || stack.energy?.let { it.extractEnergy(Int.MAX_VALUE, true) <= 0 } ?: false + SLOT_CHARGE -> stack.isEmpty || stack.energy?.let { it.receiveEnergy(Int.MAX_VALUE, true) <= 0 } ?: false + else -> false + } + } + }) + + val energy = object : IMatteryEnergyStorage { + override fun extractEnergyOuter(howMuch: ImpreciseFraction, simulate: Boolean): ImpreciseFraction { + return extractEnergyInner(howMuch, simulate) + } + + override fun extractEnergyInner(howMuch: ImpreciseFraction, simulate: Boolean): ImpreciseFraction { + return container[SLOT_DISCHARGE].energy?.extractEnergy(howMuch, simulate) ?: ImpreciseFraction.ZERO + } + + override fun receiveEnergyOuter(howMuch: ImpreciseFraction, simulate: Boolean): ImpreciseFraction { + return receiveEnergyInner(howMuch, simulate) + } + + override fun receiveEnergyInner(howMuch: ImpreciseFraction, simulate: Boolean): ImpreciseFraction { + return container[SLOT_CHARGE].energy?.receiveEnergy(howMuch, simulate) ?: ImpreciseFraction.ZERO + } + + override val batteryLevel: ImpreciseFraction + get() = container[SLOT_CHARGE].energy?.energyStoredMattery ?: container[SLOT_DISCHARGE].energy?.energyStoredMattery ?: ImpreciseFraction.ZERO + + override val maxBatteryLevel: ImpreciseFraction + get() = container[SLOT_CHARGE].energy?.maxEnergyStoredMattery ?: container[SLOT_DISCHARGE].energy?.maxEnergyStoredMattery ?: ImpreciseFraction.ZERO + } + + private var resolverEnergy = LazyOptional.of { energy } + private var valid = true + + override fun invalidateCaps() { + super.invalidateCaps() + valid = false + resolverEnergy.invalidate() + itemHandler.invalidate() + } + + override fun reviveCaps() { + super.reviveCaps() + valid = true + resolverEnergy = LazyOptional.of { energy } + itemHandler.revive() + } + + override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { + return EnergyServoMenu(containerID, inventory, this) + } + + override fun getCapability(cap: Capability, side: Direction?): LazyOptional { + if (valid) { + when (cap) { + MatteryCapability.ENERGY, ForgeCapabilities.ENERGY -> return resolverEnergy.cast() + ForgeCapabilities.ITEM_HANDLER -> return itemHandler.get().cast() + } + } + + return super.getCapability(cap, side) + } + + override fun saveAdditional(nbt: CompoundTag) { + super.saveAdditional(nbt) + + nbt[INVENTORY_KEY] = container.serializeNBT() + } + + override fun load(nbt: CompoundTag) { + super.load(nbt) + nbt.map(INVENTORY_KEY, container::deserializeNBT) + } + + fun tick() { + val charge = container[SLOT_CHARGE] + val discharge = container[SLOT_DISCHARGE] + + if (!charge.isEmpty && !discharge.isEmpty) { + val chargeEnergy = charge.energy ?: return + val dischargeEnergy = discharge.energy ?: return + + val extracted = dischargeEnergy.extractEnergy(ImpreciseFraction.LONG_MAX_VALUE, true) + + if (extracted.isPositive) { + val received = chargeEnergy.receiveEnergy(extracted, true) + + if (received.isPositive) { + val extracted2 = dischargeEnergy.extractEnergy(received, false) + + if (extracted2 == received) { + chargeEnergy.receiveEnergy(dischargeEnergy.extractEnergy(received, false), false) + } + } + } + } + } + + companion object { + const val SLOT_DISCHARGE = 0 + const val SLOT_CHARGE = 1 + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/EnergyServoScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/EnergyServoScreen.kt new file mode 100644 index 000000000..9823da844 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/EnergyServoScreen.kt @@ -0,0 +1,65 @@ +package ru.dbotthepony.mc.otm.client.screen + +import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.network.chat.Component +import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.panels.AbstractSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.BatterySlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.Dock +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.widget.HorizontalPowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalPowerGaugePanel +import ru.dbotthepony.mc.otm.menu.EnergyServoMenu + +class EnergyServoScreen(menu: EnergyServoMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { + override fun makeMainFrame(): FramePanel>? { + val frame = FramePanel.padded(this, + width = AbstractSlotPanel.SIZE * 2f + HorizontalPowerGaugePanel.GAUGE_BACKGROUND_TALL.width + 8f + ProgressGaugePanel.GAUGE_BACKGROUND.width * 2f, + AbstractSlotPanel.SIZE, title) + + BatterySlotPanel(this, frame, menu.dischargeSlot).also { + it.dock = Dock.LEFT + it.dockRight = 2f + } + + object : EditablePanel(this@EnergyServoScreen, frame) { + init { + dock = Dock.LEFT + dockRight = 2f + dockTop = 2f + width = ProgressGaugePanel.GAUGE_BACKGROUND.width + } + + override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + ProgressGaugePanel.GAUGE_BACKGROUND.render(stack) + } + } + + TallHorizontalPowerGaugePanel(this, frame, menu.powerGauge).also { + it.dock = Dock.LEFT + it.dockRight = 2f + } + + object : EditablePanel(this@EnergyServoScreen, frame) { + init { + dock = Dock.LEFT + dockRight = 2f + dockTop = 2f + width = ProgressGaugePanel.GAUGE_BACKGROUND.width + } + + override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + ProgressGaugePanel.GAUGE_BACKGROUND.render(stack) + } + } + + BatterySlotPanel(this, frame, menu.chargeSlot).also { + it.dock = Dock.LEFT + it.dockRight + } + + return frame + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index 7388a352b..48e9e733d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -206,6 +206,13 @@ open class FramePanel( title: Component ) = FramePanel(screen, parent, 0f, 0f, width + PADDING * 2, height + PADDING_TOP + PADDING, title) + fun padded( + screen: S, + width: Float, + height: Float, + title: Component + ) = FramePanel(screen, null, 0f, 0f, width + PADDING * 2, height + PADDING_TOP + PADDING, title) + const val PADDING = 8f const val PADDING_TOP = 14f diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/CompoundTagExt.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/CompoundTagExt.kt index 2571fc42e..0991db9a8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/CompoundTagExt.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/CompoundTagExt.kt @@ -41,7 +41,7 @@ fun CompoundTag.contains(vararg keys: String): Boolean { return true } -inline fun CompoundTag.map(key: String, consumer: (T) -> R): R? { +inline fun CompoundTag.map(key: String, consumer: (T) -> R): R? { val tag = get(key) if (tag is T) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyServoMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyServoMenu.kt new file mode 100644 index 000000000..eb8e679a8 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyServoMenu.kt @@ -0,0 +1,44 @@ +package ru.dbotthepony.mc.otm.menu + +import com.google.common.collect.ImmutableList +import net.minecraft.world.SimpleContainer +import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.inventory.Slot +import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.block.entity.EnergyServoBlockEntity +import ru.dbotthepony.mc.otm.capability.energy +import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget +import ru.dbotthepony.mc.otm.registry.MMenus + +class EnergyServoMenu @JvmOverloads constructor( + p_38852_: Int, + inventory: Inventory, + tile: EnergyServoBlockEntity? = null +) : MatteryMenu(MMenus.ENERGY_SERVO, p_38852_, inventory, tile) { + val dischargeSlot: MatterySlot + val chargeSlot: MatterySlot + + val powerGauge = LevelGaugeWidget(this, tile?.energy) + + init { + val container = tile?.container ?: SimpleContainer(2) + + dischargeSlot = object : MatterySlot(container, EnergyServoBlockEntity.SLOT_DISCHARGE) { + override fun mayPlace(p_40231_: ItemStack): Boolean { + return super.mayPlace(p_40231_) && (p_40231_.energy?.let { it.extractEnergy(Int.MAX_VALUE, true) > 0 } ?: false) + } + } + + chargeSlot = object : MatterySlot(container, EnergyServoBlockEntity.SLOT_CHARGE) { + override fun mayPlace(p_40231_: ItemStack): Boolean { + return super.mayPlace(p_40231_) && (p_40231_.energy?.let { it.receiveEnergy(Int.MAX_VALUE, true) > 0 } ?: false) + } + } + + addSlot(dischargeSlot) + addSlot(chargeSlot) + addInventorySlots() + } + + override val storageSlots: Collection = ImmutableList.of(dischargeSlot, chargeSlot) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt index 8856b9184..5514cfdd4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt @@ -44,6 +44,7 @@ object MBlockEntities { val PLATE_PRESS: BlockEntityType<*> by registry.register(MNames.PLATE_PRESS) { BlockEntityType.Builder.of(::PlatePressBlockEntity, MBlocks.PLATE_PRESS).build(null) } val GRAVITATION_STABILIZER: BlockEntityType<*> by registry.register(MNames.GRAVITATION_STABILIZER) { BlockEntityType.Builder.of(::GravitationStabilizerBlockEntity, MBlocks.GRAVITATION_STABILIZER).build(null) } val MATTER_RECYCLER: BlockEntityType<*> by registry.register(MNames.MATTER_RECYCLER) { BlockEntityType.Builder.of(::MatterRecyclerBlockEntity, MBlocks.MATTER_RECYCLER).build(null) } + val ENERGY_SERVO: BlockEntityType<*> by registry.register(MNames.ENERGY_SERVO) { BlockEntityType.Builder.of(::EnergyServoBlockEntity, MBlocks.ENERGY_SERVO).build(null) } val STORAGE_BUS: BlockEntityType<*> by registry.register(MNames.STORAGE_BUS) { BlockEntityType.Builder.of(::StorageBusBlockEntity, MBlocks.STORAGE_BUS).build(null) } val STORAGE_IMPORTER: BlockEntityType<*> by registry.register(MNames.STORAGE_IMPORTER) { BlockEntityType.Builder.of(::StorageImporterBlockEntity, MBlocks.STORAGE_IMPORTER).build(null) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt index 3a35f9f5a..aff5452e4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -38,6 +38,7 @@ object MBlocks { val CHEMICAL_GENERATOR: Block by registry.register(MNames.CHEMICAL_GENERATOR) { ChemicalGeneratorBlock() } val PLATE_PRESS: Block by registry.register(MNames.PLATE_PRESS) { PlatePressBlock() } val MATTER_RECYCLER: Block by registry.register(MNames.MATTER_RECYCLER) { MatterRecyclerBlock() } + val ENERGY_SERVO: Block by registry.register(MNames.ENERGY_SERVO) { EnergyServoBlock() } val STORAGE_BUS: Block by registry.register(MNames.STORAGE_BUS) { StorageBusBlock() } val STORAGE_IMPORTER: Block by registry.register(MNames.STORAGE_IMPORTER) { StorageImporterBlock() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt index 828f4766e..7140ca39b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -68,10 +68,10 @@ object MItems { ) { super.appendHoverText(p_40572_, p_40573_, p_40574_, p_40575_) - p_40574_.add(TranslatableComponent("block.${OverdriveThatMatters.MOD_ID}.${MNames.GRAVITATION_STABILIZER}.desc").withStyle(ChatFormatting.GRAY)) - p_40574_.add(TranslatableComponent("block.${OverdriveThatMatters.MOD_ID}.${MNames.GRAVITATION_STABILIZER}.desc2").withStyle(ChatFormatting.DARK_GRAY)) - p_40574_.add(TranslatableComponent("block.${OverdriveThatMatters.MOD_ID}.${MNames.GRAVITATION_STABILIZER}.desc3").withStyle(ChatFormatting.DARK_GRAY)) - p_40574_.add(TranslatableComponent("block.${OverdriveThatMatters.MOD_ID}.${MNames.GRAVITATION_STABILIZER}.desc4").withStyle(ChatFormatting.DARK_GRAY)) + p_40574_.add(TranslatableComponent("${MBlocks.GRAVITATION_STABILIZER.descriptionId}.desc").withStyle(ChatFormatting.GRAY)) + p_40574_.add(TranslatableComponent("${MBlocks.GRAVITATION_STABILIZER.descriptionId}.desc2").withStyle(ChatFormatting.DARK_GRAY)) + p_40574_.add(TranslatableComponent("${MBlocks.GRAVITATION_STABILIZER.descriptionId}.desc3").withStyle(ChatFormatting.DARK_GRAY)) + p_40574_.add(TranslatableComponent("${MBlocks.GRAVITATION_STABILIZER.descriptionId}.desc4").withStyle(ChatFormatting.DARK_GRAY)) } } } @@ -86,8 +86,23 @@ object MItems { ) { super.appendHoverText(p_40572_, p_40573_, p_40574_, p_40575_) - p_40574_.add(TranslatableComponent("block.${OverdriveThatMatters.MOD_ID}.${MNames.PHANTOM_ATTRACTOR}.desc").withStyle(ChatFormatting.GRAY)) - p_40574_.add(TranslatableComponent("block.${OverdriveThatMatters.MOD_ID}.${MNames.PHANTOM_ATTRACTOR}.desc2").withStyle(ChatFormatting.DARK_GRAY)) + p_40574_.add(TranslatableComponent("${MBlocks.PHANTOM_ATTRACTOR.descriptionId}.desc").withStyle(ChatFormatting.GRAY)) + p_40574_.add(TranslatableComponent("${MBlocks.PHANTOM_ATTRACTOR.descriptionId}.desc2").withStyle(ChatFormatting.DARK_GRAY)) + } + } + } + + val ENERGY_SERVO: Item by registry.register(MNames.ENERGY_SERVO) { + object : BlockItem(MBlocks.ENERGY_SERVO, DEFAULT_PROPERTIES){ + override fun appendHoverText( + p_40572_: ItemStack, + p_40573_: Level?, + p_40574_: MutableList, + p_40575_: TooltipFlag + ) { + super.appendHoverText(p_40572_, p_40573_, p_40574_, p_40575_) + + p_40574_.add(TranslatableComponent("${MBlocks.ENERGY_SERVO.descriptionId}.desc").withStyle(ChatFormatting.GRAY)) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt index b038b5aa9..e1f7f81f2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt @@ -31,6 +31,7 @@ object MMenus { val CHEMICAL_GENERATOR: MenuType<*> by registry.register(MNames.CHEMICAL_GENERATOR) { MenuType(::ChemicalGeneratorMenu) } val PLATE_PRESS: MenuType<*> by registry.register(MNames.PLATE_PRESS) { MenuType(::PlatePressMenu) } val MATTER_RECYCLER: MenuType<*> by registry.register(MNames.MATTER_RECYCLER) { MenuType(::MatterRecyclerMenu) } + val ENERGY_SERVO: MenuType<*> by registry.register(MNames.ENERGY_SERVO) { MenuType(::EnergyServoMenu) } val STORAGE_BUS: MenuType<*> by registry.register(MNames.STORAGE_BUS) { MenuType(::StorageBusMenu) } val STORAGE_EXPORTER: MenuType<*> by registry.register(MNames.STORAGE_EXPORTER) { MenuType(::StorageExporterMenu) } @@ -66,6 +67,7 @@ object MMenus { MenuScreens.register(STORAGE_EXPORTER as MenuType, ::StorageExporterScreen) MenuScreens.register(STORAGE_IMPORTER as MenuType, ::StorageImporterScreen) MenuScreens.register(STORAGE_POWER_SUPPLIER as MenuType, ::StoragePowerSupplierScreen) + MenuScreens.register(ENERGY_SERVO as MenuType, ::EnergyServoScreen) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index daaf63f8a..5b4b22f4b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -11,23 +11,24 @@ object MNames { const val METAL_BEAM = "metal_beam" // blocks - const val ANDROID_STATION = "android_station" // без рецепта - const val BATTERY_BANK = "battery_bank" // нужен рецепт - const val MATTER_DECOMPOSER = "matter_decomposer" // есть рецепт - const val MATTER_CAPACITOR_BANK = "matter_capacitor_bank" // есть рецепт - const val MATTER_CABLE = "matter_cable" // есть рецепт - const val PATTERN_STORAGE = "pattern_storage" // есть рецепт - const val MATTER_SCANNER = "matter_scanner" // есть рецепт - const val MATTER_PANEL = "matter_panel" // есть рецепт - const val MATTER_REPLICATOR = "matter_replicator" // есть рецепт - const val MATTER_BOTTLER = "matter_bottler" // есть рецепт - const val DRIVE_VIEWER = "drive_viewer" // есть рецепт - const val DRIVE_RACK = "drive_rack" // нужен рецепт (после улучшений) - const val ITEM_MONITOR = "item_monitor" // нужен рецепт (после улучшений) - const val ENERGY_COUNTER = "energy_counter" // есть рецепт - const val CHEMICAL_GENERATOR = "chemical_generator" // есть рецепт - const val PLATE_PRESS = "plate_press" // есть рецепт - const val MATTER_RECYCLER = "matter_recycler" // нужен рецепт + const val ANDROID_STATION = "android_station" + const val BATTERY_BANK = "battery_bank" + const val MATTER_DECOMPOSER = "matter_decomposer" + const val MATTER_CAPACITOR_BANK = "matter_capacitor_bank" + const val MATTER_CABLE = "matter_cable" + const val PATTERN_STORAGE = "pattern_storage" + const val MATTER_SCANNER = "matter_scanner" + const val MATTER_PANEL = "matter_panel" + const val MATTER_REPLICATOR = "matter_replicator" + const val MATTER_BOTTLER = "matter_bottler" + const val DRIVE_VIEWER = "drive_viewer" + const val DRIVE_RACK = "drive_rack" + const val ITEM_MONITOR = "item_monitor" + const val ENERGY_COUNTER = "energy_counter" + const val CHEMICAL_GENERATOR = "chemical_generator" + const val PLATE_PRESS = "plate_press" + const val MATTER_RECYCLER = "matter_recycler" + const val ENERGY_SERVO = "energy_servo" const val STORAGE_CABLE = "storage_cable" // нужен рецепт const val STORAGE_POWER_SUPPLIER = "storage_power_supplier" // нужен рецепт