diff --git a/src/main/java/gg/essential/universal/UGraphics.java b/src/main/java/gg/essential/universal/UGraphics.java index 6897513..6a6f882 100644 --- a/src/main/java/gg/essential/universal/UGraphics.java +++ b/src/main/java/gg/essential/universal/UGraphics.java @@ -85,6 +85,7 @@ import net.minecraft.client.renderer.texture.ITextureObject; //#endif +@SuppressWarnings("deprecation") // lots of MC methods are deprecated on some versions but only replaced on the next one public class UGraphics { private static final Pattern formattingCodePattern = Pattern.compile("(?i)\u00a7[0-9A-FK-OR]"); diff --git a/src/main/kotlin/gg/essential/universal/UImage.kt b/src/main/kotlin/gg/essential/universal/UImage.kt index 986ef11..a2aa939 100644 --- a/src/main/kotlin/gg/essential/universal/UImage.kt +++ b/src/main/kotlin/gg/essential/universal/UImage.kt @@ -67,6 +67,7 @@ class UImage(val nativeImage: BufferedImage) { //#if MC>=11600 //$$ return UImage(NativeImage(width, height, clear)) //#else + @Suppress("UNUSED_EXPRESSION") clear // not yet using native memory, so it'll be cleared by the jvm return UImage(BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB)) //#endif } diff --git a/src/main/kotlin/gg/essential/universal/UKeyboard.kt b/src/main/kotlin/gg/essential/universal/UKeyboard.kt index 38a9d1f..9c17d82 100644 --- a/src/main/kotlin/gg/essential/universal/UKeyboard.kt +++ b/src/main/kotlin/gg/essential/universal/UKeyboard.kt @@ -250,6 +250,7 @@ object UKeyboard { fun allowRepeatEvents(enabled: Boolean) { //#if MC>=11903 //$$ // Minecraft removed this function in 1.19.3, repeat events are now always enabled. + //$$ @Suppress("UNUSED_EXPRESSION") enabled //#elseif MC>=11502 //$$ UMinecraft.getMinecraft().keyboardListener.enableRepeatEvents(enabled) //#else @@ -348,10 +349,12 @@ object UKeyboard { //$$ if (it.length == 1) it.uppercase() else it //$$ } //#else + @Suppress("UNUSED_EXPRESSION") scanCode return Keyboard.getKeyName(keyCode) //#endif } + @Suppress("DEPRECATION") @Deprecated("Does not work for mouse or scanCode-type bindings", replaceWith = ReplaceWith("getKeyName(keyCode, -1)")) @JvmStatic fun getKeyName(keyCode: Int): String? = getKeyName(keyCode, -1) diff --git a/src/main/kotlin/gg/essential/universal/UMatrixStack.kt b/src/main/kotlin/gg/essential/universal/UMatrixStack.kt index a2f78ec..29a9e74 100644 --- a/src/main/kotlin/gg/essential/universal/UMatrixStack.kt +++ b/src/main/kotlin/gg/essential/universal/UMatrixStack.kt @@ -165,6 +165,7 @@ class UMatrixStack private constructor( //$$ model.mul(quaternion) //$$ normal.mul(quaternion) //#else + @Suppress("UNUSED_EXPRESSION") quaternion TODO("lwjgl quaternion multiply") // there seems to be no existing methods to do this //#endif } diff --git a/src/main/kotlin/gg/essential/universal/UMinecraft.kt b/src/main/kotlin/gg/essential/universal/UMinecraft.kt index 1db791e..176a412 100644 --- a/src/main/kotlin/gg/essential/universal/UMinecraft.kt +++ b/src/main/kotlin/gg/essential/universal/UMinecraft.kt @@ -76,6 +76,9 @@ object UMinecraft { } @JvmStatic + //#if FORGE + @Suppress("UNNECESSARY_SAFE_CALL") // Forge adds inappropriate NonNullByDefault + //#endif fun getChatGUI(): GuiNewChat? = getMinecraft().ingameGUI?.chatGUI @JvmStatic diff --git a/src/main/kotlin/gg/essential/universal/shader/UShader.kt b/src/main/kotlin/gg/essential/universal/shader/UShader.kt index 2ee6921..537a1c9 100644 --- a/src/main/kotlin/gg/essential/universal/shader/UShader.kt +++ b/src/main/kotlin/gg/essential/universal/shader/UShader.kt @@ -45,6 +45,7 @@ interface UShader { //#if MC>=11700 //$$ return MCShader.fromLegacyShader(vertSource, fragSource, blendState, vertexFormat) //#else + @Suppress("UNUSED_EXPRESSION") vertexFormat // only relevant to MCShader return GlShader(vertSource, fragSource, blendState) //#endif } diff --git a/src/main/kotlin/gg/essential/universal/wrappers/UPlayer.kt b/src/main/kotlin/gg/essential/universal/wrappers/UPlayer.kt index 89c3c25..0eb1da3 100644 --- a/src/main/kotlin/gg/essential/universal/wrappers/UPlayer.kt +++ b/src/main/kotlin/gg/essential/universal/wrappers/UPlayer.kt @@ -19,6 +19,9 @@ object UPlayer { //#if MC>=11900 //$$ getPlayer()!!.sendMessage(message) //#elseif MC>=11602 + //#if FORGE + //$$ @Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") // Forge adds inappropriate NonNullByDefault + //#endif //$$ getPlayer()!!.sendMessage(message, null) //#elseif MC>=11202 //$$ getPlayer()!!.sendMessage(message) @@ -30,7 +33,7 @@ object UPlayer { @JvmStatic fun getUUID(): UUID { //#if MC>=12002 - //$$ return UMinecraft.getMinecraft().session.uuidOrNull!! + //$$ return UMinecraft.getMinecraft().session.uuidOrNull // misnamed, should not actually ever be null //#else return UMinecraft.getMinecraft().session.profile.id //#endif diff --git a/src/main/kotlin/gg/essential/universal/wrappers/message/UTextComponent.kt b/src/main/kotlin/gg/essential/universal/wrappers/message/UTextComponent.kt index b22e347..d57d101 100644 --- a/src/main/kotlin/gg/essential/universal/wrappers/message/UTextComponent.kt +++ b/src/main/kotlin/gg/essential/universal/wrappers/message/UTextComponent.kt @@ -45,7 +45,7 @@ class UTextComponent : IChatComponent { lateinit var component: IChatComponent //#endif private set - var text: String + var text: String = "" set(value) { field = value reInstance() @@ -156,10 +156,12 @@ class UTextComponent : IChatComponent { } private fun reInstanceClick() { + val clickAction = clickAction + val clickValue = clickValue if (clickAction == null || clickValue == null) return - val event = ClickEvent(clickAction, clickValue!!.formatIf(formatted)) + val event = ClickEvent(clickAction, clickValue.formatIf(formatted)) //#if MC>=11600 //$$ component.style = component.style.setClickEvent(event) @@ -171,17 +173,20 @@ class UTextComponent : IChatComponent { } private fun reInstanceHover() { + val hoverAction = hoverAction + val hoverValue = hoverValue if (hoverAction == null || hoverValue == null) return //#if MC>=11602 - //$$ val event = HoverEvent(hoverAction as HoverEvent.Action, hoverValue!!) + //$$ @Suppress("UNCHECKED_CAST") + //$$ val event = HoverEvent(hoverAction as HoverEvent.Action, hoverValue) //$$ setHoverEventHelper(event) //#else val value: IChatComponent = when (hoverValue) { - is String -> ChatComponentText(hoverValue as String) - is UTextComponent -> (hoverValue as UTextComponent).component - is IChatComponent -> hoverValue as IChatComponent + is String -> ChatComponentText(hoverValue) + is UTextComponent -> hoverValue.component + is IChatComponent -> hoverValue else -> ChatComponentText(hoverValue.toString()) } setHoverEventHelper(HoverEvent( diff --git a/versions/1.17.1-fabric/src/main/kotlin/gg/essential/universal/shader/MCShader.kt b/versions/1.17.1-fabric/src/main/kotlin/gg/essential/universal/shader/MCShader.kt index d7f4b8e..4a7c3b5 100644 --- a/versions/1.17.1-fabric/src/main/kotlin/gg/essential/universal/shader/MCShader.kt +++ b/versions/1.17.1-fabric/src/main/kotlin/gg/essential/universal/shader/MCShader.kt @@ -137,6 +137,9 @@ internal class MCShader( val name = DigestUtils.sha1Hex(json).lowercase() + //#if FORGE + //$$ @Suppress("DEPRECATION") // Forge wants us to use its overload, but we don't care + //#endif return MCShader(Shader(factory, name, shaderVertexFormat), blendState) } } diff --git a/versions/1.19.3-fabric/src/main/kotlin/gg/essential/universal/DummyPack.kt b/versions/1.19.3-fabric/src/main/kotlin/gg/essential/universal/DummyPack.kt index 7e346f0..8df3611 100644 --- a/versions/1.19.3-fabric/src/main/kotlin/gg/essential/universal/DummyPack.kt +++ b/versions/1.19.3-fabric/src/main/kotlin/gg/essential/universal/DummyPack.kt @@ -24,19 +24,19 @@ internal object DummyPack : ResourcePack { throw UnsupportedOperationException() } - override fun open(type: ResourceType?, id: Identifier?): InputSupplier? { + override fun open(type: ResourceType, id: Identifier): InputSupplier? { throw UnsupportedOperationException() } - override fun findResources(type: ResourceType?, namespace: String?, prefix: String?, consumer: ResourcePack.ResultConsumer?) { + override fun findResources(type: ResourceType, namespace: String, prefix: String, consumer: ResourcePack.ResultConsumer) { throw UnsupportedOperationException() } - override fun getNamespaces(type: ResourceType?): MutableSet { + override fun getNamespaces(type: ResourceType): MutableSet { throw UnsupportedOperationException() } - override fun parseMetadata(metaReader: ResourceMetadataReader?): T? { + override fun parseMetadata(metaReader: ResourceMetadataReader): T? { throw UnsupportedOperationException() }