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 b7797fb52..f217db8fe 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 @@ -982,6 +982,9 @@ private fun androidFeatures(provider: MatteryLanguageProvider) { private fun gui(provider: MatteryLanguageProvider) { with(provider.english) { + gui("exopack.accept_wireless_charge", "Accept wireless charging") + gui("exopack.dont_accept_wireless_charge", "Do not accept wireless charging") + gui("multiblock.formed", "Multiblock is formed: %s") gui("flywheel.current_loss_t", "Current energy loss per tick:") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 0efb16145..a5e49ff4c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -975,6 +975,9 @@ private fun androidFeatures(provider: MatteryLanguageProvider) { private fun gui(provider: MatteryLanguageProvider) { with(provider.russian) { + gui("exopack.accept_wireless_charge", "Принимать заряд от беспроводных зарядников") + gui("exopack.dont_accept_wireless_charge", "Не принимать заряд от беспроводных зарядников") + gui("multiblock.formed", "Мультиблок сформирован: %s") gui("flywheel.current_loss_t", "Текущая потеря энергии в тик:") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt index 3c687d365..8d2df30aa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt @@ -56,7 +56,7 @@ class AndroidChargerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Ma if (!available.isPositive) return } - if (ply.hasExopack) { + if (ply.hasExopack && ply.acceptExopackChargeFromWirelessCharger) { val received = ply.exopackEnergy.receiveEnergyChecked(available, false) available -= received energyConfig.energy.extractEnergy(received, false) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayer.kt index d3c8ae76f..717b6d975 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayer.kt @@ -565,6 +565,7 @@ class MatteryPlayer(val ply: Player) { val exopackEnergy = ProfiledEnergyStorage(BatteryBackedEnergyStorage(ply, syncher, Decimal.ZERO, ExopackConfig.ENERGY_CAPACITY, false, onChange = { for (v in smelters) v.notify(MachineJobEventLoop.IdleReason.POWER) })) val exopackChargeSlots = MatteryContainer(4) + var acceptExopackChargeFromWirelessCharger = true init { savetables.int(::ticksIExist) @@ -578,6 +579,7 @@ class MatteryPlayer(val ply: Player) { savetables.bool(::isExopackVisible, "displayExoSuit") savetables.bool(::isExopackCraftingUpgraded, "isExoSuitCraftingUpgraded") savetables.bool(::isExopackEnderAccessInstalled, "isExopackEnderAccessUpgraded") + savetables.bool(::acceptExopackChargeFromWirelessCharger) savetables.int(::nextDischargeHurt) savetables.int(::nextHealTick) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt index 2d52e5824..5949f6962 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt @@ -43,6 +43,8 @@ object Widgets18 { val CURIOS_INVENTORY = miscGrid.next() val STATISTICS_TAB = miscGrid.next() val SETTINGS_TAB = miscGrid.next() + val WIRELESS_CHARGING_ENABLED = miscGrid.next() + val WIRELESS_CHARGING_DISABLED = miscGrid.next() private val slotBgGrid = WidgetLocation.SLOT_BACKGROUNDS.grid(4, 4) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt index 2eeccb3e4..dac9e5539 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt @@ -24,6 +24,7 @@ import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.render.translation import ru.dbotthepony.mc.otm.client.screen.panels.* +import ru.dbotthepony.mc.otm.client.screen.panels.button.BooleanButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.DeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel @@ -172,13 +173,25 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } protected fun makeChargePanels(frame: EditablePanel<*>) { - val chargeWidth = HorizontalPowerGaugePanel.GAUGE_BACKGROUND_TALL.width + AbstractSlotPanel.SIZE + 6f + ProgressGaugePanel.GAUGE_BACKGROUND.width * 2f + val chargeWidth = HorizontalPowerGaugePanel.GAUGE_BACKGROUND_TALL.width + AbstractSlotPanel.SIZE * 2 + 8f + ProgressGaugePanel.GAUGE_BACKGROUND.width * 2f val chargeStrip = BackgroundPanel.paddedCenter(this, frame, frame.width - chargeWidth - 6f, frame.height + 2f, chargeWidth, AbstractSlotPanel.SIZE) val chargeStrip2 = BackgroundPanel.paddedCenter(this, frame, frame.width + 2f, frame.height - AbstractSlotPanel.SIZE * 3f + 2f, AbstractSlotPanel.SIZE, AbstractSlotPanel.SIZE * 4f) chargeStrip.customDock { chargeStrip.setPos(frame.width - chargeWidth - 6f, frame.height + 2f) } chargeStrip2.customDock { chargeStrip2.setPos(frame.width + 2f, frame.height - AbstractSlotPanel.SIZE * 3f + 2f) } + BooleanButtonPanel.square18( + this, chargeStrip, + prop = menu.acceptExopackChargeFromWirelessCharger, + iconActive = Widgets18.WIRELESS_CHARGING_ENABLED, + iconInactive = Widgets18.WIRELESS_CHARGING_DISABLED, + tooltipActive = TranslatableComponent("otm.gui.exopack.accept_wireless_charge"), + tooltipInactive = TranslatableComponent("otm.gui.exopack.dont_accept_wireless_charge"), + ).also { + it.dock = Dock.LEFT + it.dockRight = 2f + } + BatterySlotPanel(this, chargeStrip, menu.exopackChargeSlots[0]).also { it.dock = Dock.LEFT } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt index 6d27c6177..0d8e58e48 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt @@ -7,7 +7,14 @@ import net.minecraft.server.level.ServerPlayer import net.minecraft.world.Container import net.minecraft.world.entity.ExperienceOrb import net.minecraft.world.entity.player.Player -import net.minecraft.world.inventory.* +import net.minecraft.world.inventory.AbstractContainerMenu +import net.minecraft.world.inventory.ContainerSynchronizer +import net.minecraft.world.inventory.CraftingContainer +import net.minecraft.world.inventory.CraftingMenu +import net.minecraft.world.inventory.ResultContainer +import net.minecraft.world.inventory.ResultSlot +import net.minecraft.world.inventory.Slot +import net.minecraft.world.inventory.TransientCraftingContainer import net.minecraft.world.item.ItemStack import net.neoforged.neoforge.network.PacketDistributor import ru.dbotthepony.mc.otm.capability.MatteryPlayer diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 674e64ea6..4a65058ae 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -44,6 +44,7 @@ import ru.dbotthepony.mc.otm.container.sortWithIndices import ru.dbotthepony.mc.otm.core.ResourceLocation import ru.dbotthepony.mc.otm.core.collect.ConditionalSet import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.network.MatteryStreamCodec import ru.dbotthepony.mc.otm.network.MenuDataPacket @@ -207,7 +208,8 @@ abstract class MatteryMenu( var sortInventoryInput: SortInput? = null private set - val playerSortSettings = IItemStackSortingSettings.inputs(this, player.matteryPlayer?.sortingSettings) + val playerSortSettings = IItemStackSortingSettings.inputs(this, player.matteryPlayer.sortingSettings) + val acceptExopackChargeFromWirelessCharger = BooleanInputWithFeedback(this, true, player.matteryPlayer::acceptExopackChargeFromWirelessCharger) var offhandSlot: InventorySlot? = null protected set diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/widget_18.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/widget_18.png index 4ecb97677..984eb0090 100644 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/widget_18.png and b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/widget_18.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/widget_18.xcf b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/widget_18.xcf index ceec2f67e..f9b632cf4 100644 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/widget_18.xcf and b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/widget_18.xcf differ