From 44c0422387ce0fa28c3d9cc858d8b5e5c5c5059f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 29 Jan 2023 22:25:28 +0700 Subject: [PATCH] Allow to specify field name prefix in SynchronizedRedstoneControl --- .../ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt index 2fbd9561a..bc4adde43 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt @@ -65,9 +65,11 @@ class RedstoneControl(private val valueChanges: (new: Boolean, old: Boolean) -> class SynchronizedRedstoneControl( synchronizer: FieldSynchronizer, + fieldNamePrefix: String?, private val valueChanges: (new: Boolean, old: Boolean) -> Unit, - fieldNamePrefix: String? = null ) : AbstractRedstoneControl() { + constructor(synchronizer: FieldSynchronizer, valueChanges: (new: Boolean, old: Boolean) -> Unit) : this(synchronizer, null, valueChanges) + override var redstoneSetting: RedstoneSetting by synchronizer.enum(RedstoneSetting.LOW, setter = { value, access, setByRemote -> if (setByRemote) { access.write(value) @@ -80,7 +82,7 @@ class SynchronizedRedstoneControl( valueChanges.invoke(state, old) } } - }) + }, name = if (fieldNamePrefix != null) "${fieldNamePrefix}_redstoneSetting" else null) override var redstoneSignal: Int by synchronizer.int(0, setter = { value, access, setByRemote -> if (setByRemote) { @@ -94,5 +96,5 @@ class SynchronizedRedstoneControl( valueChanges.invoke(state, old) } } - }) + }, name = if (fieldNamePrefix != null) "${fieldNamePrefix}_redstoneSignal" else null) }