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

update: Minecraft 1.20.6 #24

Merged
merged 7 commits into from
May 14, 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
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup Java JDK
uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
distribution: temurin

- name: Gradle Wrapper Validation
Expand Down
7 changes: 1 addition & 6 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,7 @@ tasks {
}
}

repositories {
maven("https://maven.noxcrew.com/public")
}

dependencies {
compileOnly("org.jetbrains:annotations:24.0.1")
modCompileOnly(libs.noxesium) { isTransitive = false }
compileOnlyApi("org.jetbrains:annotations:24.0.1")
testImplementation(kotlin("test"))
}
27 changes: 12 additions & 15 deletions api/src/main/java/com/noxcrew/sheeplib/mixin/GuiMixin.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
package com.noxcrew.sheeplib.mixin;

import com.mojang.blaze3d.platform.Window;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.noxcrew.sheeplib.DialogContainer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.world.scores.Scoreboard;
import net.minecraft.client.gui.LayeredDraw;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

/**
* Renders the [DialogContainerScreen].
* Adds the {@link DialogContainer} as a render layer.
*/
@Mixin(Gui.class)
public class GuiMixin {
@SuppressWarnings("InvalidInjectorMethodSignature")
@Inject(
method = "render",
@ModifyExpressionValue(
method="<init>",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/components/ChatComponent;render(Lnet/minecraft/client/gui/GuiGraphics;III)V"
),
locals = LocalCapture.CAPTURE_FAILHARD)
public void render(GuiGraphics guiGraphics, float f, CallbackInfo ci, Window window, Scoreboard scoreboard, int o, int q) {
DialogContainer.INSTANCE.render(guiGraphics, o, q, 0);
target = "Lnet/minecraft/client/gui/LayeredDraw;add(Lnet/minecraft/client/gui/LayeredDraw$Layer;)Lnet/minecraft/client/gui/LayeredDraw;",
ordinal = 11
)
)
public LayeredDraw addRenderLayer(LayeredDraw original) {
return original.add(DialogContainer.INSTANCE);
}

}

This file was deleted.

This file was deleted.

This file was deleted.

35 changes: 12 additions & 23 deletions api/src/main/kotlin/com/noxcrew/sheeplib/DialogContainer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import kotlinx.atomicfu.update
import net.minecraft.ChatFormatting
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.LayeredDraw
import net.minecraft.client.gui.components.Renderable
import net.minecraft.client.gui.components.events.ContainerEventHandler
import net.minecraft.client.gui.components.events.GuiEventListener
Expand All @@ -19,7 +20,7 @@ import kotlin.reflect.jvm.jvmName
/**
* The container for all open dialogs.
*/
public object DialogContainer : Renderable, ContainerEventHandler, NarratableEntry {
public object DialogContainer : LayeredDraw.Layer, ContainerEventHandler, NarratableEntry {

private val minecraft = Minecraft.getInstance()
private val logger = LoggerFactory.getLogger("SheepLib")
Expand All @@ -33,27 +34,21 @@ public object DialogContainer : Renderable, ContainerEventHandler, NarratableEnt
/** Whether the container is currently being dragged. */
private var isDragging: Boolean = false

/** The step to offset each dialog by in the Z-axis. */
private const val Z_STEP_PER_DIALOG = 5f
override fun render(guiGraphics: GuiGraphics, f: Float) {
val cursorIsActive = minecraft?.screen is ChatScreen

/**
* The amount to offset the initial Z co-ordinate by, for all dialogs.
* This is needed to sit on top of the vanilla chat window.
*/
private const val Z_INITIAL_OFFSET = 100f
val childX = if (cursorIsActive) minecraft.mouseHandler.xpos() / minecraft.window.guiScale else -1
val childY = if (cursorIsActive) minecraft.mouseHandler.ypos() / minecraft.window.guiScale else -1

/** Renders widgets. */
override fun render(guiGraphics: GuiGraphics, i: Int, j: Int, f: Float) {
val cursorIsActive = minecraft?.screen is ChatScreen
val children = children.value

val childX = if (cursorIsActive) i else -1
val childY = if (cursorIsActive) j else -1
// Share the Z space evenly between dialogs..
val zOffsetPerDialog = LayeredDraw.Z_SEPARATION / children.size

guiGraphics.pose().pushPose()
guiGraphics.pose().translate(0f, 0f, Z_INITIAL_OFFSET)
children.value.forEach {
guiGraphics.pose().translate(0f, 0f, Z_STEP_PER_DIALOG)
(it as Renderable).render(guiGraphics, childX, childY, f)
children.forEach {
(it as Renderable).render(guiGraphics, childX.toInt(), childY.toInt(), f)
guiGraphics.pose().translate(0f, 0f, zOffsetPerDialog)
}
guiGraphics.pose().popPose()
}
Expand Down Expand Up @@ -150,10 +145,4 @@ public object DialogContainer : Renderable, ContainerEventHandler, NarratableEnt
/** Unused. */
override fun narrationPriority(): NarratableEntry.NarrationPriority = NarratableEntry.NarrationPriority.NONE

/**
* The total amount of space in the Z axis that the dialogs have used,
* assuming each dialog spans across no more than [Z_STEP_PER_DIALOG].
*/
@JvmStatic
internal fun zIndexUse() = Z_INITIAL_OFFSET + ((children.value.size + 1) * Z_STEP_PER_DIALOG)
}
45 changes: 0 additions & 45 deletions api/src/main/kotlin/com/noxcrew/sheeplib/SheepLibMixinPlugin.kt

This file was deleted.

8 changes: 2 additions & 6 deletions api/src/main/resources/sheeplib.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
"client": [
"ChatScreenMixin",
"GuiMixin",
"NoxesiumCompatGuiMixin",
"PlayerTabOverlayMixin",
"StringWidgetMixin",
"SubtitleOverlayMixin"
],
"plugin": "com.noxcrew.sheeplib.SheepLibMixinPlugin"
"StringWidgetMixin"
]
}
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import org.gradle.accessors.dm.LibrariesForLibs

val VERSION = "1.3.2"
val VERSION = "1.3.3-SNAPSHOT"

allprojects {
group = "com.noxcrew.sheeplib"
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/sheeplib.fabric.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal val Project.libs get() = project.extensions.getByName("libs") as Librar

kotlin {
explicitApi()
jvmToolchain(17)
jvmToolchain(21)
}

tasks {
Expand Down
15 changes: 6 additions & 9 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
[versions]
minecraft = "1.20.4"
fabric-loader = "0.15.0"
fabric-api = "0.91.1+1.20.4" # for the test mod only
fabric-loom = "1.4-SNAPSHOT"
minecraft = "1.20.6"
fabric-loader = "0.15.10"
fabric-api = "0.98.0+1.20.6" # for the test mod only
fabric-loom = "1.6-SNAPSHOT"

kotlin = "1.9.0"
fabric-kotlin = "1.10.0+kotlin.1.9.0"
kotlin = "1.9.23"
fabric-kotlin = "1.10.19+kotlin.1.9.23"
coroutines = "1.7.3"
noxesium = "1.2.0"

jb-annotations = "24.0.1"

Expand All @@ -23,8 +22,6 @@ kotlin-gradle = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin",
kotlin-jvm = { group = "org.jetbrains.kotlin", name = "jvm", version.ref = "kotlin" }
kotlin-coroutines = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core-jvm", version.ref = "coroutines" }

noxesium = { group = "com.noxcrew.noxesium", name = "fabric", version.ref = "noxesium" }

guava = { group = "com.google.guava", name = "guava" } # version from minecraftLibraries

jb-annotations = { group = "org.jetbrains", name = "annotations", version.ref = "jb-annotations" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Loading