Skip to content

Commit

Permalink
Backport to Minecraft 1.19.3
Browse files Browse the repository at this point in the history
  • Loading branch information
opekope2 committed Sep 25, 2024
1 parent 3501766 commit d9e7026
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import net.fabricmc.fabric.api.event.player.UseBlockCallback
import net.fabricmc.fabric.api.event.player.UseEntityCallback
import net.fabricmc.fabric.api.event.player.UseItemCallback
import net.minecraft.client.MinecraftClient
import net.minecraft.client.gui.DrawContext
import net.minecraft.client.gui.screen.Screen
import net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen
import net.minecraft.client.gui.screen.ingame.BookEditScreen
import net.minecraft.client.gui.screen.ingame.BookScreen
import net.minecraft.client.gui.screen.ingame.HangingSignEditScreen
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.entity.Entity
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.item.ItemStack
Expand Down Expand Up @@ -99,11 +99,11 @@ internal object InteractionHandler : ClientModInitializer, UseBlockCallback, Use
ScreenEvents.afterRender(screen).register(this)
}

override fun beforeRender(screen: Screen?, drawContext: DrawContext?, mouseX: Int, mouseY: Int, tickDelta: Float) {
override fun beforeRender(screen: Screen?, matrices: MatrixStack?, mouseX: Int, mouseY: Int, tickDelta: Float) {
TextureReplacer.isReplacingTextures = true
}

override fun afterRender(screen: Screen?, drawContext: DrawContext?, mouseX: Int, mouseY: Int, tickDelta: Float) {
override fun afterRender(screen: Screen?, matrices: MatrixStack?, mouseX: Int, mouseY: Int, tickDelta: Float) {
TextureReplacer.isReplacingTextures = false
}

Expand Down
19 changes: 12 additions & 7 deletions OptiGUI/src/main/kotlin/opekope2/optigui/toast/InspectorToast.kt
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
package opekope2.optigui.toast

import net.minecraft.client.gui.DrawContext
import com.mojang.blaze3d.systems.RenderSystem
import net.minecraft.client.render.GameRenderer
import net.minecraft.client.toast.Toast
import net.minecraft.client.toast.ToastManager
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.text.Text

/**
* A toast displaying the inspector message.
*/
class InspectorToast : Toast {
override fun draw(context: DrawContext, manager: ToastManager, startTime: Long): Toast.Visibility {
val textRenderer = manager.client.textRenderer
context.drawTexture(Toast.TEXTURE, 0, 0, 0, 0, width, height)
override fun draw(matrices: MatrixStack?, manager: ToastManager, startTime: Long): Toast.Visibility {
RenderSystem.setShader(GameRenderer::getPositionTexProgram)
RenderSystem.setShaderTexture(0, Toast.TEXTURE)
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)

context.drawText(textRenderer, TITLE, 7, 7, 0xFF00FFFF.toInt(), false)
context.drawText(textRenderer, DESCRIPTION, 7, 18, 0xFFFFFFFF.toInt(), false)
return if (startTime >= 4000 * manager.notificationDisplayTimeMultiplier) Toast.Visibility.HIDE
manager.drawTexture(matrices, 0, 0, 0, 0, width, height)
manager.client.textRenderer.draw(matrices, TITLE, 7f, 7f, 0xFF00FFFF.toInt())
manager.client.textRenderer.draw(matrices, DESCRIPTION, 7f, 18f, 0xFFFFFFFF.toInt())

return if (startTime >= 4000) Toast.Visibility.HIDE
else Toast.Visibility.SHOW
}

Expand Down
2 changes: 1 addition & 1 deletion OptiGUI/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"fabric-networking-api-v1": "*",
"fabric-resource-loader-v0": "*",
"fabric-language-kotlin": ">=$fabric_language_kotlin",
"minecraft": ">=$minecraft <1.20.2",
"minecraft": ">=$minecraft <1.20",
"java": ">=$java"
},
"recommends": {
Expand Down
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[versions]
java = "17" # Don't forget to update *.mixins.json
kotlin = "1.8.21"
optigui = "2.3.0-beta.5+1.20"
minecraft = "1.20"
yarn = "1.20+build.1"
optigui = "2.3.0-beta.5+1.19.3"
minecraft = "1.19.3"
yarn = "1.19.3+build.5"
fabric-loom = "1.5-SNAPSHOT"
fabric-loader = "0.15.7"
fabric-api = "0.83.0+1.20"
fabric-api = "0.76.1+1.19.3"
fabric-language-kotlin = "1.9.4+kotlin.1.8.21"
commons-text = "1.11.0"
ini4j = "0.5.4"
Expand Down

0 comments on commit d9e7026

Please sign in to comment.