Rename fraction() to decimal() in FieldSynchronizer

This commit is contained in:
DBotThePony 2023-06-22 22:55:30 +07:00
parent 2298dd17c7
commit 4e62b47f84
Signed by: DBot
GPG Key ID: DCC23B5715498507
6 changed files with 11 additions and 13 deletions

View File

@ -41,7 +41,7 @@ import kotlin.math.roundToInt
import kotlin.math.sqrt
class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryBlockEntity(MBlockEntities.BLACK_HOLE, p_155229_, p_155230_) {
var mass by synchronizer.fraction(BASELINE_MASS, setter = setter@{ mass, field, setByRemote ->
var mass by synchronizer.decimal(BASELINE_MASS, setter = setter@{ mass, field, setByRemote ->
if (setByRemote) {
field.write(mass)
return@setter

View File

@ -28,7 +28,7 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities
import java.util.*
class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.ENERGY_COUNTER, p_155229_, p_155230_) {
var passed by synchronizer.fraction()
var passed by synchronizer.decimal()
override val blockRotation: BlockRotation get() {
return BlockRotation.of(blockState[EnergyCounterBlock.INPUT_DIRECTION])
@ -37,7 +37,7 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat
private val history = Array(10 * 20) { Decimal.ZERO }
internal var historyTick = 0
var lastTick by synchronizer.fraction()
var lastTick by synchronizer.decimal()
internal set
var ioLimit: Decimal? = null

View File

@ -27,8 +27,8 @@ class AndroidPowerSource(
override val energyFlow: FlowDirection
get() = FlowDirection.INPUT
private var battery by synchronizer.fraction(initialCharge)
private var maxBattery by synchronizer.fraction(maxCharge)
private var battery by synchronizer.decimal(initialCharge)
private var maxBattery by synchronizer.decimal(maxCharge)
var item by synchronizer.item(setter = setter@{ value, access, setByRemote ->
access.write(value)

View File

@ -1,7 +1,6 @@
package ru.dbotthepony.mc.otm.menu.storage
import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.inventory.Slot
import ru.dbotthepony.mc.otm.block.entity.storage.StoragePowerSupplierBlockEntity
import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu
import ru.dbotthepony.mc.otm.registry.MMenus
@ -11,7 +10,7 @@ class StoragePowerSupplierMenu @JvmOverloads constructor(
inventory: Inventory,
tile: StoragePowerSupplierBlockEntity? = null
) : MatteryPoweredMenu(MMenus.STORAGE_POWER_SUPPLIER, p_38852_, inventory, tile) {
var totalTransferred by mSynchronizer.fraction()
var totalTransferred by mSynchronizer.decimal()
var activeNodes by mSynchronizer.int()
init {

View File

@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.menu.tech
import net.minecraft.core.Direction
import kotlin.jvm.JvmOverloads
import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.inventory.Slot
import net.minecraft.world.level.block.Block
import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting
import ru.dbotthepony.mc.otm.block.tech.EnergyCounterBlock
@ -19,10 +18,10 @@ class EnergyCounterMenu @JvmOverloads constructor(
inventory: Inventory,
tile: EnergyCounterBlockEntity? = null
) : MatteryMenu(MMenus.ENERGY_COUNTER, p_38852_, inventory, tile) {
var passed by mSynchronizer.fraction()
var average by mSynchronizer.fraction()
var last20Ticks by mSynchronizer.fraction()
var lastTick by mSynchronizer.fraction()
var passed by mSynchronizer.decimal()
var average by mSynchronizer.decimal()
var last20Ticks by mSynchronizer.decimal()
var lastTick by mSynchronizer.decimal()
var maxIO by mSynchronizer.bigDecimal()
val switchDirection = oneWayInput {

View File

@ -241,7 +241,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa
}
@JvmOverloads
fun fraction(
fun decimal(
value: Decimal = Decimal.ZERO,
getter: FieldGetter<Decimal>? = null,
setter: FieldSetter<Decimal>? = null,