Make defaultDisplayName be property

This commit is contained in:
DBotThePony 2022-03-20 21:25:09 +07:00
parent 7cce062ae5
commit 2c4bd9ccd8
Signed by: DBot
GPG Key ID: DCC23B5715498507
19 changed files with 58 additions and 66 deletions

View File

@ -23,9 +23,8 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
return AndroidStationMenu(containerID, inventory, this) return AndroidStationMenu(containerID, inventory, this)
} }
override fun getDefaultDisplayName(): Component { override val defaultDisplayName: Component
return MACHINE_NAME get() = MACHINE_NAME
}
override val energy = WorkerEnergyStorage(this, STORAGE, MAX_IO) override val energy = WorkerEnergyStorage(this, STORAGE, MAX_IO)

View File

@ -26,7 +26,6 @@ import ru.dbotthepony.mc.otm.container.MatteryContainer
import ru.dbotthepony.mc.otm.core.ImpreciseFraction import ru.dbotthepony.mc.otm.core.ImpreciseFraction
import ru.dbotthepony.mc.otm.ifPresentK import ru.dbotthepony.mc.otm.ifPresentK
import ru.dbotthepony.mc.otm.menu.BatteryBankMenu import ru.dbotthepony.mc.otm.menu.BatteryBankMenu
import ru.dbotthepony.mc.otm.orNull
import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlockEntities
import ru.dbotthepony.mc.otm.set import ru.dbotthepony.mc.otm.set
import ru.dbotthepony.mc.otm.unaryMinus import ru.dbotthepony.mc.otm.unaryMinus
@ -213,9 +212,8 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte
super.load(nbt) super.load(nbt)
} }
override fun getDefaultDisplayName(): Component { override val defaultDisplayName: Component
return MACHINE_NAME get() = MACHINE_NAME
}
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
return BatteryBankMenu(containerID, inventory, this) return BatteryBankMenu(containerID, inventory, this)

View File

@ -67,16 +67,15 @@ class CargoCrateBlockEntity(
nbt.ifHas("slots", CompoundTag::class.java, container::deserializeNBT) nbt.ifHas("slots", CompoundTag::class.java, container::deserializeNBT)
} }
override fun getDefaultDisplayName(): Component { override val defaultDisplayName: Component
return NAME get() = MACHINE_NAME
}
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
return CargoCrateMenu(containerID, inventory, this) return CargoCrateMenu(containerID, inventory, this)
} }
companion object { companion object {
private val NAME = TranslatableComponent("block.overdrive_that_matters.cargo_crate") private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.cargo_crate")
const val CAPACITY = 9 * 6 const val CAPACITY = 9 * 6
} }
} }

View File

@ -31,9 +31,8 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities
import java.lang.ref.WeakReference import java.lang.ref.WeakReference
class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryBlockEntity(MBlockEntities.CHEMICAL_GENERATOR, pos, state) { class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryBlockEntity(MBlockEntities.CHEMICAL_GENERATOR, pos, state) {
override fun getDefaultDisplayName(): Component { override val defaultDisplayName: Component
return NAME get() = MACHINE_NAME
}
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
return ChemicalGeneratorMenu(containerID, inventory, this) return ChemicalGeneratorMenu(containerID, inventory, this)
@ -238,7 +237,7 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryBl
private const val THROUGHPUT_INT = 160 private const val THROUGHPUT_INT = 160
private val GENERATION_SPEED = ImpreciseFraction(40) private val GENERATION_SPEED = ImpreciseFraction(40)
private val MAX_ENERGY = ImpreciseFraction(24_000) private val MAX_ENERGY = ImpreciseFraction(24_000)
private val NAME = TranslatableComponent("block.overdrive_that_matters.chemical_generator") private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.chemical_generator")
const val SLOT_INPUT = 0 const val SLOT_INPUT = 0
const val SLOT_BATTERY = 1 const val SLOT_BATTERY = 1

View File

@ -71,9 +71,8 @@ class DriveRackBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
batteryChargeLoop() batteryChargeLoop()
} }
override fun getDefaultDisplayName(): Component { override val defaultDisplayName: Component
return NAME get() = MACHINE_NAME
}
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu? { override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu? {
return DriveRackMenu(containerID, inventory, this) return DriveRackMenu(containerID, inventory, this)
@ -96,7 +95,7 @@ class DriveRackBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
} }
companion object { companion object {
private val NAME = TranslatableComponent("block.overdrive_that_matters.drive_rack") private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.drive_rack")
private val STORAGE = ImpreciseFraction(80_000) private val STORAGE = ImpreciseFraction(80_000)
} }
} }

View File

@ -68,9 +68,8 @@ class DriveViewerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte
} }
} }
override fun getDefaultDisplayName(): Component { override val defaultDisplayName: Component
return NAME get() = MACHINE_NAME
}
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu? { override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu? {
return DriveViewerMenu(containerID, inventory, this) return DriveViewerMenu(containerID, inventory, this)
@ -92,6 +91,6 @@ class DriveViewerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte
} }
companion object { companion object {
private val NAME = TranslatableComponent("block.overdrive_that_matters.drive_viewer") private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.drive_viewer")
} }
} }

View File

@ -163,9 +163,8 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat
} }
} }
override fun getDefaultDisplayName(): Component { override val defaultDisplayName: Component
return NAME get() = MACHINE_NAME
}
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
return EnergyCounterMenu(containerID, inventory, this) return EnergyCounterMenu(containerID, inventory, this)
@ -471,6 +470,6 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat
} }
companion object { companion object {
private val NAME = TranslatableComponent("block.overdrive_that_matters.energy_counter") private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.energy_counter")
} }
} }

View File

@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.block.entity
import net.minecraft.core.BlockPos import net.minecraft.core.BlockPos
import net.minecraft.core.SectionPos import net.minecraft.core.SectionPos
import net.minecraft.network.chat.Component
import net.minecraft.network.chat.TranslatableComponent import net.minecraft.network.chat.TranslatableComponent
import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.entity.player.Player import net.minecraft.world.entity.player.Player
@ -20,7 +21,10 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities
class GravitationStabilizerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryBlockEntity( class GravitationStabilizerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryBlockEntity(
MBlockEntities.GRAVITATION_STABILIZER, p_155229_, p_155230_) { MBlockEntities.GRAVITATION_STABILIZER, p_155229_, p_155230_) {
override fun getDefaultDisplayName() = NAME
override val defaultDisplayName: Component
get() = MACHINE_NAME
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player) = null override fun createMenu(containerID: Int, inventory: Inventory, ply: Player) = null
private var blackHole: BlackHoleBlockEntity? = null private var blackHole: BlackHoleBlockEntity? = null
@ -78,6 +82,6 @@ class GravitationStabilizerBlockEntity(p_155229_: BlockPos, p_155230_: BlockStat
companion object { companion object {
private val minBBox = BlockPos(1, 1, 1) private val minBBox = BlockPos(1, 1, 1)
const val RANGE = 64 const val RANGE = 64
private val NAME = TranslatableComponent("block.overdrive_that_matters.gravitation_stabilizer") private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.gravitation_stabilizer")
} }
} }

View File

@ -30,9 +30,8 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
batteryChargeLoop() batteryChargeLoop()
} }
override fun getDefaultDisplayName(): Component { override val defaultDisplayName: Component
return NAME get() = MACHINE_NAME
}
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
return ItemMonitorMenu(containerID, inventory, this) return ItemMonitorMenu(containerID, inventory, this)
@ -62,6 +61,6 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
} }
companion object { companion object {
private val NAME = TranslatableComponent("block.overdrive_that_matters.item_monitor") private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.item_monitor")
} }
} }

View File

@ -162,9 +162,8 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
return super.getCapability(cap, side) return super.getCapability(cap, side)
} }
override fun getDefaultDisplayName(): Component { override val defaultDisplayName: Component
return MACHINE_NAME get() = MACHINE_NAME
}
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
return MatterBottlerMenu(containerID, inventory, this) return MatterBottlerMenu(containerID, inventory, this)

View File

@ -71,7 +71,7 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState)
} }
override fun receiveMatterInner(howMuch: ImpreciseFraction, simulate: Boolean): ImpreciseFraction { override fun receiveMatterInner(howMuch: ImpreciseFraction, simulate: Boolean): ImpreciseFraction {
var howMuch = howMuch @Suppress("NAME_SHADOWING") var howMuch = howMuch
var summ = ImpreciseFraction.ZERO var summ = ImpreciseFraction.ZERO
for (stack in container) { for (stack in container) {
@ -96,7 +96,7 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState)
} }
override fun extractMatterInner(howMuch: ImpreciseFraction, simulate: Boolean): ImpreciseFraction { override fun extractMatterInner(howMuch: ImpreciseFraction, simulate: Boolean): ImpreciseFraction {
var howMuch = howMuch @Suppress("NAME_SHADOWING") var howMuch = howMuch
var summ = ImpreciseFraction.ZERO var summ = ImpreciseFraction.ZERO
for (stack in container) { for (stack in container) {
@ -148,9 +148,8 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState)
private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.matter_capacitor_bank") private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.matter_capacitor_bank")
} }
override fun getDefaultDisplayName(): Component { override val defaultDisplayName: Component
return MACHINE_NAME get() = MACHINE_NAME
}
override fun saveAdditional(nbt: CompoundTag) { override fun saveAdditional(nbt: CompoundTag) {
super.saveAdditional(nbt) super.saveAdditional(nbt)

View File

@ -123,9 +123,8 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState)
{ slot: Int, _: Int, _: ItemStack -> slot != INPUT_SLOT }) { slot: Int, _: Int, _: ItemStack -> slot != INPUT_SLOT })
} }
override fun getDefaultDisplayName(): Component { override val defaultDisplayName: Component
return MACHINE_NAME get() = MACHINE_NAME
}
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
return MatterDecomposerMenu(containerID, inventory, this) return MatterDecomposerMenu(containerID, inventory, this)

View File

@ -49,9 +49,8 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
listeners.remove(menu) listeners.remove(menu)
} }
override fun getDefaultDisplayName(): Component { override val defaultDisplayName: Component
return NAME get() = MACHINE_NAME
}
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
return MatterPanelMenu(containerID, inventory, this) return MatterPanelMenu(containerID, inventory, this)
@ -219,6 +218,6 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
} }
companion object { companion object {
private val NAME = TranslatableComponent("block.overdrive_that_matters.matter_panel") private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.matter_panel")
} }
} }

View File

@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.block.entity
import net.minecraft.core.BlockPos import net.minecraft.core.BlockPos
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.network.chat.TranslatableComponent import net.minecraft.network.chat.TranslatableComponent
import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerLevel
import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Inventory
@ -119,7 +120,8 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState)
return super.getCapability(cap, side) return super.getCapability(cap, side)
} }
override fun getDefaultDisplayName() = NAME override val defaultDisplayName: Component
get() = MACHINE_NAME
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
return MatterRecyclerMenu(containerID, inventory, this) return MatterRecyclerMenu(containerID, inventory, this)
@ -174,7 +176,7 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState)
} }
companion object { companion object {
private val NAME = TranslatableComponent("block.overdrive_that_matters.matter_recycler") private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.matter_recycler")
private val STORAGE = ImpreciseFraction(40) private val STORAGE = ImpreciseFraction(40)
private val POWER_CONSUMPTION = ImpreciseFraction(80) private val POWER_CONSUMPTION = ImpreciseFraction(80)
private val MAX_POWER = ImpreciseFraction(80_000) private val MAX_POWER = ImpreciseFraction(80_000)

View File

@ -57,9 +57,8 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
val container = MatteryContainer(this::setChangedLight, 5) val container = MatteryContainer(this::setChangedLight, 5)
private val itemHandler = container.handler(MatteryContainerFilterOnlyOut) private val itemHandler = container.handler(MatteryContainerFilterOnlyOut)
override fun getDefaultDisplayName(): Component { override val defaultDisplayName: Component
return NAME get() = MACHINE_NAME
}
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
return MatterReplicatorMenu(containerID, inventory, this) return MatterReplicatorMenu(containerID, inventory, this)
@ -226,7 +225,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
} }
companion object { companion object {
private val NAME = TranslatableComponent("block.overdrive_that_matters.matter_replicator") private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.matter_replicator")
private val BASE_CONSUMPTION = ImpreciseFraction(400) private val BASE_CONSUMPTION = ImpreciseFraction(400)
private val DRAIN_MULT = ImpreciseFraction(200) private val DRAIN_MULT = ImpreciseFraction(200)
private val STORAGE = ImpreciseFraction(200_000) private val STORAGE = ImpreciseFraction(200_000)

View File

@ -92,9 +92,8 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
matterNode.destroy(::MatterNetworkGraph) matterNode.destroy(::MatterNetworkGraph)
} }
override fun getDefaultDisplayName(): Component { override val defaultDisplayName: Component
return NAME get() = MACHINE_NAME
}
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
return MatterScannerMenu(containerID, inventory, this) return MatterScannerMenu(containerID, inventory, this)
@ -187,7 +186,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
} }
companion object { companion object {
private val NAME = TranslatableComponent("block.overdrive_that_matters.matter_scanner") private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.matter_scanner")
private val BASE_CONSUMPTION = ImpreciseFraction("40") private val BASE_CONSUMPTION = ImpreciseFraction("40")
private val STORAGE = ImpreciseFraction(80_000) private val STORAGE = ImpreciseFraction(80_000)
private val MAX_IO = ImpreciseFraction(400) private val MAX_IO = ImpreciseFraction(400)

View File

@ -65,7 +65,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc
} }
} }
protected abstract fun getDefaultDisplayName(): Component protected abstract val defaultDisplayName: Component
abstract override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu? abstract override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu?
protected fun tickOnce(func: Runnable) { protected fun tickOnce(func: Runnable) {
@ -122,7 +122,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc
} }
override fun getDisplayName(): Component { override fun getDisplayName(): Component {
return customDisplayName ?: getDefaultDisplayName() return customDisplayName ?: defaultDisplayName
} }
protected open fun redstoneStatusUpdated(new_blocked: Boolean, old_blocked: Boolean) {} protected open fun redstoneStatusUpdated(new_blocked: Boolean, old_blocked: Boolean) {}

View File

@ -142,9 +142,8 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
return super.getCapability(cap, side) return super.getCapability(cap, side)
} }
override fun getDefaultDisplayName(): Component { override val defaultDisplayName: Component
return NAME get() = MACHINE_NAME
}
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
return PatternStorageMenu(containerID, inventory, this) return PatternStorageMenu(containerID, inventory, this)
@ -206,6 +205,6 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
} }
companion object { companion object {
private val NAME = TranslatableComponent("block.overdrive_that_matters.pattern_storage") private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.pattern_storage")
} }
} }

View File

@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.block.entity
import net.minecraft.core.BlockPos import net.minecraft.core.BlockPos
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.network.chat.TranslatableComponent import net.minecraft.network.chat.TranslatableComponent
import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.entity.player.Player import net.minecraft.world.entity.player.Player
@ -65,7 +66,8 @@ class PlatePressBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matter
container.deserializeNBT(nbt["container"]) container.deserializeNBT(nbt["container"])
} }
override fun getDefaultDisplayName() = NAME override val defaultDisplayName: Component
get() = MACHINE_NAME
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
return PlatePressMenu(containerID, inventory, this) return PlatePressMenu(containerID, inventory, this)
@ -101,7 +103,7 @@ class PlatePressBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matter
companion object { companion object {
private val BASELINE_CONSUMPTION = ImpreciseFraction(15) private val BASELINE_CONSUMPTION = ImpreciseFraction(15)
private val NAME = TranslatableComponent("block.overdrive_that_matters.plate_press") private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.plate_press")
const val SLOT_INPUT = 0 const val SLOT_INPUT = 0
const val SLOT_OUTPUT = 1 const val SLOT_OUTPUT = 1
} }