Make defaultDisplayName be property
This commit is contained in:
parent
7cce062ae5
commit
2c4bd9ccd8
@ -23,9 +23,8 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
return AndroidStationMenu(containerID, inventory, this)
|
||||
}
|
||||
|
||||
override fun getDefaultDisplayName(): Component {
|
||||
return MACHINE_NAME
|
||||
}
|
||||
override val defaultDisplayName: Component
|
||||
get() = MACHINE_NAME
|
||||
|
||||
override val energy = WorkerEnergyStorage(this, STORAGE, MAX_IO)
|
||||
|
||||
|
@ -26,7 +26,6 @@ import ru.dbotthepony.mc.otm.container.MatteryContainer
|
||||
import ru.dbotthepony.mc.otm.core.ImpreciseFraction
|
||||
import ru.dbotthepony.mc.otm.ifPresentK
|
||||
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.set
|
||||
import ru.dbotthepony.mc.otm.unaryMinus
|
||||
@ -213,9 +212,8 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte
|
||||
super.load(nbt)
|
||||
}
|
||||
|
||||
override fun getDefaultDisplayName(): Component {
|
||||
return MACHINE_NAME
|
||||
}
|
||||
override val defaultDisplayName: Component
|
||||
get() = MACHINE_NAME
|
||||
|
||||
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
|
||||
return BatteryBankMenu(containerID, inventory, this)
|
||||
|
@ -67,16 +67,15 @@ class CargoCrateBlockEntity(
|
||||
nbt.ifHas("slots", CompoundTag::class.java, container::deserializeNBT)
|
||||
}
|
||||
|
||||
override fun getDefaultDisplayName(): Component {
|
||||
return NAME
|
||||
}
|
||||
override val defaultDisplayName: Component
|
||||
get() = MACHINE_NAME
|
||||
|
||||
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
|
||||
return CargoCrateMenu(containerID, inventory, this)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
@ -31,9 +31,8 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryBlockEntity(MBlockEntities.CHEMICAL_GENERATOR, pos, state) {
|
||||
override fun getDefaultDisplayName(): Component {
|
||||
return NAME
|
||||
}
|
||||
override val defaultDisplayName: Component
|
||||
get() = MACHINE_NAME
|
||||
|
||||
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
|
||||
return ChemicalGeneratorMenu(containerID, inventory, this)
|
||||
@ -238,7 +237,7 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryBl
|
||||
private const val THROUGHPUT_INT = 160
|
||||
private val GENERATION_SPEED = ImpreciseFraction(40)
|
||||
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_BATTERY = 1
|
||||
|
@ -71,9 +71,8 @@ class DriveRackBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
batteryChargeLoop()
|
||||
}
|
||||
|
||||
override fun getDefaultDisplayName(): Component {
|
||||
return NAME
|
||||
}
|
||||
override val defaultDisplayName: Component
|
||||
get() = MACHINE_NAME
|
||||
|
||||
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu? {
|
||||
return DriveRackMenu(containerID, inventory, this)
|
||||
@ -96,7 +95,7 @@ class DriveRackBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
@ -68,9 +68,8 @@ class DriveViewerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte
|
||||
}
|
||||
}
|
||||
|
||||
override fun getDefaultDisplayName(): Component {
|
||||
return NAME
|
||||
}
|
||||
override val defaultDisplayName: Component
|
||||
get() = MACHINE_NAME
|
||||
|
||||
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu? {
|
||||
return DriveViewerMenu(containerID, inventory, this)
|
||||
@ -92,6 +91,6 @@ class DriveViewerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val NAME = TranslatableComponent("block.overdrive_that_matters.drive_viewer")
|
||||
private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.drive_viewer")
|
||||
}
|
||||
}
|
@ -163,9 +163,8 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat
|
||||
}
|
||||
}
|
||||
|
||||
override fun getDefaultDisplayName(): Component {
|
||||
return NAME
|
||||
}
|
||||
override val defaultDisplayName: Component
|
||||
get() = MACHINE_NAME
|
||||
|
||||
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
|
||||
return EnergyCounterMenu(containerID, inventory, this)
|
||||
@ -471,6 +470,6 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val NAME = TranslatableComponent("block.overdrive_that_matters.energy_counter")
|
||||
private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.energy_counter")
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.block.entity
|
||||
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.SectionPos
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.network.chat.TranslatableComponent
|
||||
import net.minecraft.world.entity.player.Inventory
|
||||
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(
|
||||
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
|
||||
|
||||
private var blackHole: BlackHoleBlockEntity? = null
|
||||
@ -78,6 +82,6 @@ class GravitationStabilizerBlockEntity(p_155229_: BlockPos, p_155230_: BlockStat
|
||||
companion object {
|
||||
private val minBBox = BlockPos(1, 1, 1)
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
@ -30,9 +30,8 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
batteryChargeLoop()
|
||||
}
|
||||
|
||||
override fun getDefaultDisplayName(): Component {
|
||||
return NAME
|
||||
}
|
||||
override val defaultDisplayName: Component
|
||||
get() = MACHINE_NAME
|
||||
|
||||
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
|
||||
return ItemMonitorMenu(containerID, inventory, this)
|
||||
@ -62,6 +61,6 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val NAME = TranslatableComponent("block.overdrive_that_matters.item_monitor")
|
||||
private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.item_monitor")
|
||||
}
|
||||
}
|
@ -162,9 +162,8 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
return super.getCapability(cap, side)
|
||||
}
|
||||
|
||||
override fun getDefaultDisplayName(): Component {
|
||||
return MACHINE_NAME
|
||||
}
|
||||
override val defaultDisplayName: Component
|
||||
get() = MACHINE_NAME
|
||||
|
||||
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
|
||||
return MatterBottlerMenu(containerID, inventory, this)
|
||||
|
@ -71,7 +71,7 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState)
|
||||
}
|
||||
|
||||
override fun receiveMatterInner(howMuch: ImpreciseFraction, simulate: Boolean): ImpreciseFraction {
|
||||
var howMuch = howMuch
|
||||
@Suppress("NAME_SHADOWING") var howMuch = howMuch
|
||||
var summ = ImpreciseFraction.ZERO
|
||||
|
||||
for (stack in container) {
|
||||
@ -96,7 +96,7 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState)
|
||||
}
|
||||
|
||||
override fun extractMatterInner(howMuch: ImpreciseFraction, simulate: Boolean): ImpreciseFraction {
|
||||
var howMuch = howMuch
|
||||
@Suppress("NAME_SHADOWING") var howMuch = howMuch
|
||||
var summ = ImpreciseFraction.ZERO
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
override fun getDefaultDisplayName(): Component {
|
||||
return MACHINE_NAME
|
||||
}
|
||||
override val defaultDisplayName: Component
|
||||
get() = MACHINE_NAME
|
||||
|
||||
override fun saveAdditional(nbt: CompoundTag) {
|
||||
super.saveAdditional(nbt)
|
||||
|
@ -123,9 +123,8 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState)
|
||||
{ slot: Int, _: Int, _: ItemStack -> slot != INPUT_SLOT })
|
||||
}
|
||||
|
||||
override fun getDefaultDisplayName(): Component {
|
||||
return MACHINE_NAME
|
||||
}
|
||||
override val defaultDisplayName: Component
|
||||
get() = MACHINE_NAME
|
||||
|
||||
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
|
||||
return MatterDecomposerMenu(containerID, inventory, this)
|
||||
|
@ -49,9 +49,8 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
listeners.remove(menu)
|
||||
}
|
||||
|
||||
override fun getDefaultDisplayName(): Component {
|
||||
return NAME
|
||||
}
|
||||
override val defaultDisplayName: Component
|
||||
get() = MACHINE_NAME
|
||||
|
||||
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
|
||||
return MatterPanelMenu(containerID, inventory, this)
|
||||
@ -219,6 +218,6 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val NAME = TranslatableComponent("block.overdrive_that_matters.matter_panel")
|
||||
private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.matter_panel")
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ 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.network.chat.TranslatableComponent
|
||||
import net.minecraft.server.level.ServerLevel
|
||||
import net.minecraft.world.entity.player.Inventory
|
||||
@ -119,7 +120,8 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState)
|
||||
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 {
|
||||
return MatterRecyclerMenu(containerID, inventory, this)
|
||||
@ -174,7 +176,7 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState)
|
||||
}
|
||||
|
||||
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 POWER_CONSUMPTION = ImpreciseFraction(80)
|
||||
private val MAX_POWER = ImpreciseFraction(80_000)
|
||||
|
@ -57,9 +57,8 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
val container = MatteryContainer(this::setChangedLight, 5)
|
||||
private val itemHandler = container.handler(MatteryContainerFilterOnlyOut)
|
||||
|
||||
override fun getDefaultDisplayName(): Component {
|
||||
return NAME
|
||||
}
|
||||
override val defaultDisplayName: Component
|
||||
get() = MACHINE_NAME
|
||||
|
||||
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
|
||||
return MatterReplicatorMenu(containerID, inventory, this)
|
||||
@ -226,7 +225,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
}
|
||||
|
||||
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 DRAIN_MULT = ImpreciseFraction(200)
|
||||
private val STORAGE = ImpreciseFraction(200_000)
|
||||
|
@ -92,9 +92,8 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
matterNode.destroy(::MatterNetworkGraph)
|
||||
}
|
||||
|
||||
override fun getDefaultDisplayName(): Component {
|
||||
return NAME
|
||||
}
|
||||
override val defaultDisplayName: Component
|
||||
get() = MACHINE_NAME
|
||||
|
||||
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
|
||||
return MatterScannerMenu(containerID, inventory, this)
|
||||
@ -187,7 +186,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
}
|
||||
|
||||
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 STORAGE = ImpreciseFraction(80_000)
|
||||
private val MAX_IO = ImpreciseFraction(400)
|
||||
|
@ -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?
|
||||
|
||||
protected fun tickOnce(func: Runnable) {
|
||||
@ -122,7 +122,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc
|
||||
}
|
||||
|
||||
override fun getDisplayName(): Component {
|
||||
return customDisplayName ?: getDefaultDisplayName()
|
||||
return customDisplayName ?: defaultDisplayName
|
||||
}
|
||||
|
||||
protected open fun redstoneStatusUpdated(new_blocked: Boolean, old_blocked: Boolean) {}
|
||||
|
@ -142,9 +142,8 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
return super.getCapability(cap, side)
|
||||
}
|
||||
|
||||
override fun getDefaultDisplayName(): Component {
|
||||
return NAME
|
||||
}
|
||||
override val defaultDisplayName: Component
|
||||
get() = MACHINE_NAME
|
||||
|
||||
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
|
||||
return PatternStorageMenu(containerID, inventory, this)
|
||||
@ -206,6 +205,6 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val NAME = TranslatableComponent("block.overdrive_that_matters.pattern_storage")
|
||||
private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.pattern_storage")
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ 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.network.chat.TranslatableComponent
|
||||
import net.minecraft.world.entity.player.Inventory
|
||||
import net.minecraft.world.entity.player.Player
|
||||
@ -65,7 +66,8 @@ class PlatePressBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matter
|
||||
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 {
|
||||
return PlatePressMenu(containerID, inventory, this)
|
||||
@ -101,7 +103,7 @@ class PlatePressBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matter
|
||||
|
||||
companion object {
|
||||
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_OUTPUT = 1
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user