Holo screen locale, api docs

This commit is contained in:
DBotThePony 2023-01-29 21:01:12 +07:00
parent 46f0b1bf59
commit ac2deefcae
Signed by: DBot
GPG Key ID: DCC23B5715498507
6 changed files with 23 additions and 11 deletions

View File

@ -116,6 +116,9 @@ private fun sounds(provider: MatteryLanguageProvider) {
private fun misc(provider: MatteryLanguageProvider) { private fun misc(provider: MatteryLanguageProvider) {
with(provider.english) { 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("ticks", "Ticks")
gui("power_cost_per_use", "Power cost per use: %s") gui("power_cost_per_use", "Power cost per use: %s")

View File

@ -125,6 +125,9 @@ private fun sounds(provider: MatteryLanguageProvider) {
private fun misc(provider: MatteryLanguageProvider) { private fun misc(provider: MatteryLanguageProvider) {
with(provider.russian) { with(provider.russian) {
gui("lock_holo_screen", "Заблокировать содержимое")
gui("lock_holo_screen.tip", "Блокировка и разблокировка содержимого возможна только в режиме творчества.\nКогда заблокировано, границы ввода текста отключены.")
gui("ticks", "Тиков") gui("ticks", "Тиков")
gui("power_cost_per_use", "Энергии на операцию: %s") gui("power_cost_per_use", "Энергии на операцию: %s")

View File

@ -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")) val lock = CheckBoxLabelInputPanel(this, frame, menu.locked, TranslatableComponent("otm.gui.lock_holo_screen"))
lock.dock = Dock.BOTTOM lock.dock = Dock.BOTTOM
lock.dockMargin = DockProperty(2f, 2f, 2f, 2f) lock.dockMargin = DockProperty(2f, 2f, 2f, 2f)
lock.tooltip = TranslatableComponent("otm.gui.lock_holo_screen.tip")
return frame return frame
} }

View File

@ -18,6 +18,7 @@ import net.minecraft.world.level.block.entity.BlockEntity
import net.minecraftforge.network.NetworkEvent import net.minecraftforge.network.NetworkEvent
import net.minecraftforge.network.PacketDistributor import net.minecraftforge.network.PacketDistributor
import ru.dbotthepony.mc.otm.capability.matteryPlayer 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.cos.cosmeticArmorSlots
import ru.dbotthepony.mc.otm.compat.curios.isCurioSlot import ru.dbotthepony.mc.otm.compat.curios.isCurioSlot
import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.container.ItemFilter
@ -50,7 +51,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor(
val tile: BlockEntity? = null val tile: BlockEntity? = null
) : AbstractContainerMenu(menuType, containerId) { ) : AbstractContainerMenu(menuType, containerId) {
/** /**
* Server->Client field synchronizer * Server->Client synchronizer
*/ */
val mSynchronizer = FieldSynchronizer() val mSynchronizer = FieldSynchronizer()
val ply: Player get() = inventory.player 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<V>(val codec: IStreamCodec<V>, allowSpectators: Boolean = false, val handler: (V) -> Unit) : Predicate<Player?> { inner class PlayerInput<V>(val codec: IStreamCodec<V>, allowSpectators: Boolean = false, val handler: (V) -> Unit) : Predicate<Player?> {
val id = playerInputs.size val id = playerInputs.size
@ -117,15 +118,11 @@ abstract class MatteryMenu @JvmOverloads protected constructor(
} }
fun input(value: V) { fun input(value: V) {
if (test(minecraft.player as Player?)) {
val stream = FastByteArrayOutputStream() val stream = FastByteArrayOutputStream()
codec.write(DataOutputStream(stream), value) codec.write(DataOutputStream(stream), value)
MenuNetworkChannel.sendToServer(PlayerInputPacket(containerId, id, stream.array.copyOfRange(0, stream.length))) 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)
}
} }
internal fun invoke(value: Any?) { internal fun invoke(value: Any?) {

View File

@ -17,6 +17,7 @@ class HoloSignMenu @JvmOverloads constructor(
val locked = BooleanInputWithFeedback(this) val locked = BooleanInputWithFeedback(this)
init { init {
text.filter { it.isCreative || !locked.value }
locked.filter { it.isCreative } locked.filter { it.isCreative }
if (tile != null) { if (tile != null) {

View File

@ -9,9 +9,16 @@ import java.util.function.Predicate
import java.util.function.Supplier import java.util.function.Supplier
import kotlin.reflect.KMutableProperty0 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<V> : GetterSetter<V>, Predicate<Player?> interface IPlayerInputWithFeedback<V> : GetterSetter<V>, Predicate<Player?>
/** /**
* Represents Server to Client synchronization and Client to Server input
*
* Getting and setting values should ONLY be done clientside * Getting and setting values should ONLY be done clientside
*/ */
abstract class AbstractPlayerInputWithFeedback<V> : IPlayerInputWithFeedback<V> { abstract class AbstractPlayerInputWithFeedback<V> : IPlayerInputWithFeedback<V> {
@ -23,7 +30,7 @@ abstract class AbstractPlayerInputWithFeedback<V> : IPlayerInputWithFeedback<V>
} }
override fun accept(t: V) { override fun accept(t: V) {
input.checkedInput(t, minecraft.player as Player?) input.input(t)
} }
override fun test(player: Player?) = input.test(player) override fun test(player: Player?) = input.test(player)