get internationalized
This commit is contained in:
@@ -153,28 +153,29 @@ class CaseBlockEntity(blockPos: BlockPos, blockState: BlockState): NodeBlockEnti
|
|||||||
val archs = getMachineArchitectures()
|
val archs = getMachineArchitectures()
|
||||||
// Beep patterns taken from https://github.com/MightyPirates/OpenComputers/blob/571482db88080d56329e8f8cf0db2a90825bf1d7/src/main/scala/li/cil/oc/server/machine/Machine.scala
|
// Beep patterns taken from https://github.com/MightyPirates/OpenComputers/blob/571482db88080d56329e8f8cf0db2a90825bf1d7/src/main/scala/li/cil/oc/server/machine/Machine.scala
|
||||||
if(archs.isEmpty()) {
|
if(archs.isEmpty()) {
|
||||||
crash("no cpu")
|
crash("@neocomputers.errors.ENOCPU")
|
||||||
beepAsync("-..")
|
beepAsync("-..")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if(getMachineComponentsUsed() > getMachineComponentsTotal()) {
|
if(getMachineComponentsUsed() > getMachineComponentsTotal()) {
|
||||||
crash("too many components")
|
crash("@neocomputers.errors.E2BIG")
|
||||||
beepAsync("-..")
|
beepAsync("-..")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if(node.energy < 100) {
|
// less than 20% energy is bad
|
||||||
crash("not enough energy")
|
if(node.energy < node.energyCapacity/5) {
|
||||||
|
crash("@neocomputers.errors.ENOENJ")
|
||||||
// we add a beep for the special case where we do have a little bit of energy :P
|
// we add a beep for the special case where we do have a little bit of energy :P
|
||||||
if(node.energy > 0) beepAsync("..")
|
if(node.energy > 0) beepAsync("..")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if(getMachineMemoryTotal() == 0L) {
|
if(getMachineMemoryTotal() == 0L) {
|
||||||
crash("no memory provided")
|
crash("@neocomputers.errors.ENOMEM")
|
||||||
beepAsync("-.")
|
beepAsync("-.")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if(arch !in archs) {
|
if(arch !in archs) {
|
||||||
// Just pick one!
|
// Just pick one! TODO: consult EEPROM first
|
||||||
arch = archs.first()
|
arch = archs.first()
|
||||||
}
|
}
|
||||||
beepAsync(".")
|
beepAsync(".")
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package org.neoflock.neocomputers.entity
|
|||||||
import net.minecraft.core.BlockPos
|
import net.minecraft.core.BlockPos
|
||||||
import net.minecraft.core.Direction
|
import net.minecraft.core.Direction
|
||||||
import net.minecraft.world.level.Level
|
import net.minecraft.world.level.Level
|
||||||
|
import net.minecraft.world.phys.Vec3
|
||||||
import org.neoflock.neocomputers.item.ComponentItem
|
import org.neoflock.neocomputers.item.ComponentItem
|
||||||
import org.neoflock.neocomputers.network.Networking
|
import org.neoflock.neocomputers.network.Networking
|
||||||
import java.time.Duration
|
import java.time.Duration
|
||||||
@@ -18,6 +19,7 @@ data class MachineCrashEvent(override val machine: MachineEntity, val error: Str
|
|||||||
interface MachineEntity {
|
interface MachineEntity {
|
||||||
// Block position of machine, for wireless tech
|
// Block position of machine, for wireless tech
|
||||||
fun getMachineBlockPosition(): BlockPos
|
fun getMachineBlockPosition(): BlockPos
|
||||||
|
fun getMachinePrecisePosition(): Vec3 = getMachineBlockPosition().center
|
||||||
fun getMachineLevel(): Level
|
fun getMachineLevel(): Level
|
||||||
|
|
||||||
// Pattern can have dots (.), dashes (-) and spaces ( ).
|
// Pattern can have dots (.), dashes (-) and spaces ( ).
|
||||||
|
|||||||
@@ -57,18 +57,20 @@ class CaseScreen : GenericContainerScreen<CaseMenu> {
|
|||||||
arch = buf.readUtf()
|
arch = buf.readUtf()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getErrorComponent(err: String): Component = if(err.startsWith("@")) Component.translatable(err.substring(1)) else Component.literal(err)
|
||||||
|
|
||||||
fun computeButtonTooltip(): List<Component> {
|
fun computeButtonTooltip(): List<Component> {
|
||||||
val msgs = mutableListOf(Component.literal("Computer " + if(isOn) "ON" else "OFF").withStyle(if(isOn) ChatFormatting.GREEN else ChatFormatting.RED))
|
val msgs = mutableListOf(Component.translatable(if(isOn) "neocomputers.computer.on" else "neocomputers.computer.off").withStyle(if(isOn) ChatFormatting.GREEN else ChatFormatting.RED))
|
||||||
if(lastError != null) {
|
if(lastError != null) {
|
||||||
msgs.addLast(Component.literal("Error: ").withStyle(ChatFormatting.RED).append(Component.literal(lastError!!)))
|
msgs.addLast(Component.translatable("neocomputers.computer.errorNoMsg").withStyle(ChatFormatting.RED).append(getErrorComponent(lastError!!)))
|
||||||
}
|
}
|
||||||
if(arch.isNotEmpty()) {
|
if(arch.isNotEmpty()) {
|
||||||
msgs.addLast(Component.literal("Architecture: $arch"))
|
msgs.addLast(Component.translatable("neocomputers.arch", arch))
|
||||||
}
|
}
|
||||||
if(hasShiftDown()) {
|
if(hasShiftDown()) {
|
||||||
msgs.addLast(Component.literal("Energy: $energy / $maxEnergy J").withStyle(if(energy < 100) ChatFormatting.RED else ChatFormatting.WHITE))
|
msgs.addLast(Component.translatable("neocomputers.computer.energy", energy, maxEnergy).withStyle(if(energy < maxEnergy/5) ChatFormatting.RED else ChatFormatting.WHITE))
|
||||||
msgs.addLast(Component.literal("Memory: ${Formatting.formatMemory(memory)} / ${Formatting.formatMemory(maxMemory)}"))
|
msgs.addLast(Component.translatable("neocomputers.computer.memory", Formatting.formatMemory(memory), Formatting.formatMemory(maxMemory)))
|
||||||
msgs.addLast(Component.literal("Components: $components / $maxComponents").withStyle(if(components <= maxComponents) ChatFormatting.WHITE else ChatFormatting.RED))
|
msgs.addLast(Component.translatable("neocomputers.computer.components", components, maxEnergy).withStyle(if(components <= maxComponents) ChatFormatting.WHITE else ChatFormatting.RED))
|
||||||
}
|
}
|
||||||
return msgs
|
return msgs
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ object DataComponents {
|
|||||||
DataComponentType.builder<String>().persistent(Codec.STRING).build())
|
DataComponentType.builder<String>().persistent(Codec.STRING).build())
|
||||||
val READONLY = Registry.register(BuiltInRegistries.DATA_COMPONENT_TYPE, ResourceLocation.fromNamespaceAndPath(NeoComputers.MODID, "readonly"),
|
val READONLY = Registry.register(BuiltInRegistries.DATA_COMPONENT_TYPE, ResourceLocation.fromNamespaceAndPath(NeoComputers.MODID, "readonly"),
|
||||||
DataComponentType.builder<Boolean>().persistent(Codec.BOOL).build())
|
DataComponentType.builder<Boolean>().persistent(Codec.BOOL).build())
|
||||||
|
val ARCH = Registry.register(BuiltInRegistries.DATA_COMPONENT_TYPE, ResourceLocation.fromNamespaceAndPath(NeoComputers.MODID, "architecture"),
|
||||||
|
DataComponentType.builder<String>().persistent(Codec.STRING).build())
|
||||||
|
|
||||||
val EEPROM_CODE = Registry.register(BuiltInRegistries.DATA_COMPONENT_TYPE, ResourceLocation.fromNamespaceAndPath(NeoComputers.MODID, "eeprom_code"),
|
val EEPROM_CODE = Registry.register(BuiltInRegistries.DATA_COMPONENT_TYPE, ResourceLocation.fromNamespaceAndPath(NeoComputers.MODID, "eeprom_code"),
|
||||||
DataComponentType.builder<ByteBuffer>().persistent(Codec.BYTE_BUFFER).build())
|
DataComponentType.builder<ByteBuffer>().persistent(Codec.BYTE_BUFFER).build())
|
||||||
val EEPROM_DATA = Registry.register(BuiltInRegistries.DATA_COMPONENT_TYPE, ResourceLocation.fromNamespaceAndPath(NeoComputers.MODID, "eeprom_data"),
|
val EEPROM_DATA = Registry.register(BuiltInRegistries.DATA_COMPONENT_TYPE, ResourceLocation.fromNamespaceAndPath(NeoComputers.MODID, "eeprom_data"),
|
||||||
|
|||||||
@@ -43,10 +43,14 @@ open class EEPROMItem(val tier: Int, val codeCapacity: Int, val dataCapacity: In
|
|||||||
if(tooltipFlag.isAdvanced) {
|
if(tooltipFlag.isAdvanced) {
|
||||||
val codeSize = itemStack.get(DataComponents.EEPROM_CODESIZE) ?: 0
|
val codeSize = itemStack.get(DataComponents.EEPROM_CODESIZE) ?: 0
|
||||||
val dataSize = itemStack.get(DataComponents.EEPROM_DATASIZE) ?: 0
|
val dataSize = itemStack.get(DataComponents.EEPROM_DATASIZE) ?: 0
|
||||||
|
val arch = itemStack.get(DataComponents.ARCH)
|
||||||
val addr = itemStack.get(DataComponents.ADDRESS)
|
val addr = itemStack.get(DataComponents.ADDRESS)
|
||||||
val readonly = itemStack.get(DataComponents.READONLY) ?: false
|
val readonly = itemStack.get(DataComponents.READONLY) ?: false
|
||||||
val addrComp = if(addr == null) Component.translatable("neocomputers.noaddr") else Component.literal(addr)
|
val addrComp = if(addr == null) Component.translatable("neocomputers.noaddr") else Component.literal(addr)
|
||||||
list.addLast(addrComp)
|
list.addLast(addrComp)
|
||||||
|
if(arch != null) {
|
||||||
|
list.addLast(Component.translatable("neocomputers.arch", arch))
|
||||||
|
}
|
||||||
list.addLast(Component.translatable("neocomputers.eeprom.codeused", Formatting.formatMemory(codeSize.toLong()),
|
list.addLast(Component.translatable("neocomputers.eeprom.codeused", Formatting.formatMemory(codeSize.toLong()),
|
||||||
Formatting.formatMemory(codeCapacity.toLong())))
|
Formatting.formatMemory(codeCapacity.toLong())))
|
||||||
list.addLast(Component.translatable("neocomputers.eeprom.dataused", Formatting.formatMemory(dataSize.toLong()),
|
list.addLast(Component.translatable("neocomputers.eeprom.dataused", Formatting.formatMemory(dataSize.toLong()),
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ object Tabs {
|
|||||||
val codeBuf = ByteBuffer.allocate(code.size)
|
val codeBuf = ByteBuffer.allocate(code.size)
|
||||||
codeBuf.put(code)
|
codeBuf.put(code)
|
||||||
luaBios.set(DataComponents.LABEL, "Lua BIOS")
|
luaBios.set(DataComponents.LABEL, "Lua BIOS")
|
||||||
|
luaBios.set(DataComponents.ARCH, "Lua 5.2")
|
||||||
luaBios.set(DataComponents.EEPROM_CODE, codeBuf)
|
luaBios.set(DataComponents.EEPROM_CODE, codeBuf)
|
||||||
luaBios.set(DataComponents.EEPROM_CODESIZE, code.size)
|
luaBios.set(DataComponents.EEPROM_CODESIZE, code.size)
|
||||||
output.accept(luaBios)
|
output.accept(luaBios)
|
||||||
|
|||||||
@@ -38,6 +38,10 @@
|
|||||||
"item.neocomputers.hdd0": "Hard Disk Drive (Tier 1)",
|
"item.neocomputers.hdd0": "Hard Disk Drive (Tier 1)",
|
||||||
"item.neocomputers.hdd1": "Hard Disk Drive (Tier 2)",
|
"item.neocomputers.hdd1": "Hard Disk Drive (Tier 2)",
|
||||||
"item.neocomputers.hdd2": "Hard Disk Drive (Tier 3)",
|
"item.neocomputers.hdd2": "Hard Disk Drive (Tier 3)",
|
||||||
|
"neocomputers.errors.ENOCPU": "no CPU",
|
||||||
|
"neocomputers.errors.E2BIG": "too many components",
|
||||||
|
"neocomputers.errors.ENOENJ": "dangerously low energy",
|
||||||
|
"neocomputers.errors.ENOMEM": "missing memory",
|
||||||
"neocomputers.wlan.range": "Range: %1$s blocks",
|
"neocomputers.wlan.range": "Range: %1$s blocks",
|
||||||
"neocomputers.data.limit": "Memory: %1$s",
|
"neocomputers.data.limit": "Memory: %1$s",
|
||||||
"neocomputers.gpu.vram": "Video Memory: %1$spx",
|
"neocomputers.gpu.vram": "Video Memory: %1$spx",
|
||||||
@@ -45,7 +49,14 @@
|
|||||||
"neocomputers.readonly": "Read-Only",
|
"neocomputers.readonly": "Read-Only",
|
||||||
"neocomputers.readwrite": "Read-Write",
|
"neocomputers.readwrite": "Read-Write",
|
||||||
"neocomputers.noaddr": "No address assigned",
|
"neocomputers.noaddr": "No address assigned",
|
||||||
|
"neocomputers.computer.on": "ON",
|
||||||
|
"neocomputers.computer.off": "OFF",
|
||||||
|
"neocomputers.computer.errorNoMsg": "Error: ",
|
||||||
|
"neocomputers.computer.energy": "Energy: %1$s / %2$s J",
|
||||||
|
"neocomputers.computer.memory": "Memory: %1$s / %2$s",
|
||||||
|
"neocomputers.computer.components": "Components: %1$s / %2$s",
|
||||||
"neocomputers.memory.capacity": "Capacity: %1$s",
|
"neocomputers.memory.capacity": "Capacity: %1$s",
|
||||||
|
"neocomputers.arch": "Architecture: %1$s",
|
||||||
"neocomputers.eeprom.codeused": "Code Storage: %1$s / %2$s",
|
"neocomputers.eeprom.codeused": "Code Storage: %1$s / %2$s",
|
||||||
"neocomputers.eeprom.dataused": "Data Storage: %1$s / %2$s",
|
"neocomputers.eeprom.dataused": "Data Storage: %1$s / %2$s",
|
||||||
"neocomputers.tunnel.channel": "Linked Channel: %1$s",
|
"neocomputers.tunnel.channel": "Linked Channel: %1$s",
|
||||||
|
|||||||
Reference in New Issue
Block a user