"Accept wireless charging" button in exopack
This commit is contained in:
parent
f4ade757c3
commit
9107f63d9d
@ -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:")
|
||||
|
@ -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", "Текущая потеря энергии в тик:")
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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<T : MatteryMenu>(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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
Loading…
Reference in New Issue
Block a user