From 8e71631108b23c349d2768ecbf99bee1e2e9a015 Mon Sep 17 00:00:00 2001 From: bombcar Date: Fri, 4 Feb 2022 16:59:25 -0600 Subject: [PATCH] other minor fixes --- .../client/gui/GuiAdvancedMemoryCard.kt | 19 ++++++++++--------- .../betterp2p/client/gui/InfoWrapper.kt | 3 ++- .../betterp2p/item/ItemAdvancedMemoryCard.kt | 5 +++-- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/projecturanus/betterp2p/client/gui/GuiAdvancedMemoryCard.kt b/src/main/java/com/projecturanus/betterp2p/client/gui/GuiAdvancedMemoryCard.kt index 563b349..fb7bdd3 100644 --- a/src/main/java/com/projecturanus/betterp2p/client/gui/GuiAdvancedMemoryCard.kt +++ b/src/main/java/com/projecturanus/betterp2p/client/gui/GuiAdvancedMemoryCard.kt @@ -14,6 +14,7 @@ import net.minecraft.client.gui.GuiScreen import net.minecraft.client.resources.I18n import net.minecraft.util.ResourceLocation import org.lwjgl.input.Mouse +import java.util.* class GuiAdvancedMemoryCard(msg: S2CListP2P) : GuiScreen(), TextureBound { private val outputColor = 0x4566ccff @@ -81,7 +82,7 @@ class GuiAdvancedMemoryCard(msg: S2CListP2P) : GuiScreen(), TextureBound { } } - fun sortInfo() { + private fun sortInfo() { sortedInfo = infos.sortedBy { if (it.index == selectedIndex) { -2 // Put the selected p2p in the front @@ -95,7 +96,7 @@ class GuiAdvancedMemoryCard(msg: S2CListP2P) : GuiScreen(), TextureBound { } } - fun checkInfo() { + private fun checkInfo() { infos.forEach { it.error = false } infos.groupBy { it.frequency }.filter { it.value.none { x -> !x.output } }.forEach { it.value.forEach { info -> info.error = true @@ -112,11 +113,11 @@ class GuiAdvancedMemoryCard(msg: S2CListP2P) : GuiScreen(), TextureBound { refreshOverlay() } - fun syncMemoryInfo() { + private fun syncMemoryInfo() { ModNetwork.channel.sendToServer(C2SUpdateInfo(MemoryInfo(selectedIndex, selectedInfo?.frequency ?: 0, mode))) } - fun drawInformation() { + private fun drawInformation() { val x = 8 var y = 170 for (line in descriptionLines) { @@ -142,7 +143,7 @@ class GuiAdvancedMemoryCard(msg: S2CListP2P) : GuiScreen(), TextureBound { if (modeButton.func_146115_a()) { descriptionLines.clear() - descriptionLines += I18n.format("gui.advanced_memory_card.desc.mode", I18n.format("gui.advanced_memory_card.mode.${mode.next().name.toLowerCase()}")) + descriptionLines += I18n.format("gui.advanced_memory_card.desc.mode", I18n.format("gui.advanced_memory_card.mode.${mode.next().name.lowercase(Locale.getDefault())}")) } else { descriptionLines.clear() } @@ -161,19 +162,19 @@ class GuiAdvancedMemoryCard(msg: S2CListP2P) : GuiScreen(), TextureBound { } private fun getModeString(): String { - return I18n.format("gui.advanced_memory_card.mode.${mode.name.toLowerCase()}") + return I18n.format("gui.advanced_memory_card.mode.${mode.name.lowercase(Locale.getDefault())}") } - fun findInput(frequency: Long) = + private fun findInput(frequency: Long) = infos.find { it.frequency == frequency && !it.output } - fun selectInfo(index: Int) { + private fun selectInfo(index: Int) { selectedIndex = index syncMemoryInfo() refreshOverlay() } - fun refreshOverlay() { + private fun refreshOverlay() { ClientCache.selectedPosition = arrayListOf(selectedInfo?.posX, selectedInfo?.posY, selectedInfo?.posZ) ClientCache.selectedFacing = selectedInfo?.facing ClientCache.positions.clear() diff --git a/src/main/java/com/projecturanus/betterp2p/client/gui/InfoWrapper.kt b/src/main/java/com/projecturanus/betterp2p/client/gui/InfoWrapper.kt index 0a54fad..5b45d4e 100644 --- a/src/main/java/com/projecturanus/betterp2p/client/gui/InfoWrapper.kt +++ b/src/main/java/com/projecturanus/betterp2p/client/gui/InfoWrapper.kt @@ -4,6 +4,7 @@ import com.projecturanus.betterp2p.network.P2PInfo import net.minecraft.client.gui.GuiButton import net.minecraft.client.resources.I18n import net.minecraft.util.EnumFacing +import java.util.* class InfoWrapper(info: P2PInfo) { // Basic information @@ -45,7 +46,7 @@ fun Long.toHexString(): String { hex += Integer.toHexString((tmp % 16).toInt()) tmp /= 16 } - return hex.toUpperCase().reversed() + return hex.uppercase(Locale.getDefault()).reversed() } fun String.format4(): String { diff --git a/src/main/java/com/projecturanus/betterp2p/item/ItemAdvancedMemoryCard.kt b/src/main/java/com/projecturanus/betterp2p/item/ItemAdvancedMemoryCard.kt index 78dc718..96186e8 100644 --- a/src/main/java/com/projecturanus/betterp2p/item/ItemAdvancedMemoryCard.kt +++ b/src/main/java/com/projecturanus/betterp2p/item/ItemAdvancedMemoryCard.kt @@ -24,6 +24,7 @@ import net.minecraft.nbt.NBTTagCompound import net.minecraft.util.StatCollector import net.minecraft.world.World import net.minecraftforge.common.util.ForgeDirection +import java.util.* object ItemAdvancedMemoryCard : Item() { init { @@ -47,7 +48,7 @@ object ItemAdvancedMemoryCard : Item() { @SideOnly(Side.CLIENT) override fun addInformation(stack: ItemStack, player: EntityPlayer, tooltip: MutableList, boolean: Boolean) { val info = getInfo(stack) - tooltip += StatCollector.translateToLocal("gui.advanced_memory_card.mode.${info.mode.name.toLowerCase()}") + tooltip += StatCollector.translateToLocal("gui.advanced_memory_card.mode.${info.mode.name.lowercase(Locale.getDefault())}") } @SideOnly(Side.CLIENT) @@ -97,7 +98,7 @@ object ItemAdvancedMemoryCard : Item() { itemIcon = ri.registerIcon("$MODID:advanced_memory_card") } - fun getInfo(stack: ItemStack): MemoryInfo { + private fun getInfo(stack: ItemStack): MemoryInfo { if (stack.item != this) throw ClassCastException("Cannot cast ${stack.item.javaClass.name} to ${javaClass.name}") if (stack.tagCompound == null) stack.tagCompound = NBTTagCompound()