Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc: Cleanup warnings #77

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/gg/essential/universal/UGraphics.java
Original file line number Diff line number Diff line change
Expand Up @@ -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]");

Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/gg/essential/universal/UImage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/gg/essential/universal/UKeyboard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/gg/essential/universal/UMatrixStack.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/gg/essential/universal/UMinecraft.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/gg/essential/universal/shader/UShader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 4 additions & 1 deletion src/main/kotlin/gg/essential/universal/wrappers/UPlayer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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<Any>(hoverAction as HoverEvent.Action<Any>, hoverValue!!)
//$$ @Suppress("UNCHECKED_CAST")
//$$ val event = HoverEvent(hoverAction as HoverEvent.Action<Any>, 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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ internal object DummyPack : ResourcePack {
throw UnsupportedOperationException()
}

override fun open(type: ResourceType?, id: Identifier?): InputSupplier<InputStream>? {
override fun open(type: ResourceType, id: Identifier): InputSupplier<InputStream>? {
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<String> {
override fun getNamespaces(type: ResourceType): MutableSet<String> {
throw UnsupportedOperationException()
}

override fun <T : Any?> parseMetadata(metaReader: ResourceMetadataReader<T>?): T? {
override fun <T : Any?> parseMetadata(metaReader: ResourceMetadataReader<T>): T? {
throw UnsupportedOperationException()
}

Expand Down
Loading