diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 6729cade1..6dc802e52 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -116,6 +116,9 @@ private fun sounds(provider: MatteryLanguageProvider) { private fun misc(provider: MatteryLanguageProvider) { with(provider.english) { + gui("lock_holo_screen", "Lock contents") + gui("lock_holo_screen.tip", "Locking and unlocking contents is only possible in creative.\nWhen locked, text boundaries are removed.") + gui("ticks", "Ticks") gui("power_cost_per_use", "Power cost per use: %s") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 8658d3e89..46b3441a3 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -125,6 +125,9 @@ private fun sounds(provider: MatteryLanguageProvider) { private fun misc(provider: MatteryLanguageProvider) { with(provider.russian) { + gui("lock_holo_screen", "Заблокировать содержимое") + gui("lock_holo_screen.tip", "Блокировка и разблокировка содержимого возможна только в режиме творчества.\nКогда заблокировано, границы ввода текста отключены.") + gui("ticks", "Тиков") gui("power_cost_per_use", "Энергии на операцию: %s") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt index f13c8649d..676642d71 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt @@ -22,6 +22,7 @@ class HoloSignScreen(menu: HoloSignMenu, inventory: Inventory, title: Component) val lock = CheckBoxLabelInputPanel(this, frame, menu.locked, TranslatableComponent("otm.gui.lock_holo_screen")) lock.dock = Dock.BOTTOM lock.dockMargin = DockProperty(2f, 2f, 2f, 2f) + lock.tooltip = TranslatableComponent("otm.gui.lock_holo_screen.tip") return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 87912e150..a04aaf714 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -18,6 +18,7 @@ import net.minecraft.world.level.block.entity.BlockEntity import net.minecraftforge.network.NetworkEvent import net.minecraftforge.network.PacketDistributor import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.compat.cos.cosmeticArmorSlots import ru.dbotthepony.mc.otm.compat.curios.isCurioSlot import ru.dbotthepony.mc.otm.container.ItemFilter @@ -50,7 +51,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( val tile: BlockEntity? = null ) : AbstractContainerMenu(menuType, containerId) { /** - * Server->Client field synchronizer + * Server->Client synchronizer */ val mSynchronizer = FieldSynchronizer() val ply: Player get() = inventory.player @@ -90,7 +91,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( } /** - * Client->Server handler + * Client->Server input */ inner class PlayerInput(val codec: IStreamCodec, allowSpectators: Boolean = false, val handler: (V) -> Unit) : Predicate { val id = playerInputs.size @@ -117,14 +118,10 @@ abstract class MatteryMenu @JvmOverloads protected constructor( } fun input(value: V) { - val stream = FastByteArrayOutputStream() - codec.write(DataOutputStream(stream), value) - MenuNetworkChannel.sendToServer(PlayerInputPacket(containerId, id, stream.array.copyOfRange(0, stream.length))) - } - - fun checkedInput(value: V, player: Player?) { - if (allowSpectators || player?.isSpectator == false) { - return input(value) + if (test(minecraft.player as Player?)) { + val stream = FastByteArrayOutputStream() + codec.write(DataOutputStream(stream), value) + MenuNetworkChannel.sendToServer(PlayerInputPacket(containerId, id, stream.array.copyOfRange(0, stream.length))) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt index 1a2c9203b..402406f00 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt @@ -17,6 +17,7 @@ class HoloSignMenu @JvmOverloads constructor( val locked = BooleanInputWithFeedback(this) init { + text.filter { it.isCreative || !locked.value } locked.filter { it.isCreative } if (tile != null) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt index 22695363c..077e9a9ff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt @@ -9,9 +9,16 @@ import java.util.function.Predicate import java.util.function.Supplier import kotlin.reflect.KMutableProperty0 +/** + * Represents Server to Client synchronization and Client to Server input + * + * Getting and setting values should ONLY be done clientside + */ interface IPlayerInputWithFeedback : GetterSetter, Predicate /** + * Represents Server to Client synchronization and Client to Server input + * * Getting and setting values should ONLY be done clientside */ abstract class AbstractPlayerInputWithFeedback : IPlayerInputWithFeedback { @@ -23,7 +30,7 @@ abstract class AbstractPlayerInputWithFeedback : IPlayerInputWithFeedback } override fun accept(t: V) { - input.checkedInput(t, minecraft.player as Player?) + input.input(t) } override fun test(player: Player?) = input.test(player)