Skip to content

Commit 7c326eb

Browse files
committed
feat: Update 1.21.11
Cursor changes when PackEntryWidget hovered Identifier and Util typealias Own handleClickEvent in NoYACLScreen Forge 1.20.1 in previous commit
1 parent d58080f commit 7c326eb

12 files changed

Lines changed: 97 additions & 29 deletions

File tree

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ modstitch {
7272
"1.21.5" -> 71
7373
"1.21.8" -> 81
7474
"1.21.10" -> 88
75+
"1.21.11" -> 94.1
7576
else -> throw IllegalArgumentException("Please store the resource pack version for $mcVersion in build.gradle.kts! https://minecraft.wiki/w/Pack_format")
7677
}.toString()
7778
)

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ stonecutter {
3131
mc("1.21.5", loaders = listOf("fabric", "neoforge"))
3232
mc("1.21.8", loaders = listOf("fabric", "neoforge"))
3333
mc("1.21.10", loaders = listOf("fabric", "neoforge"))
34+
mc("1.21.11", loaders = listOf("fabric", "neoforge"))
3435
}
3536
}
3637
rootProject.name = "DynamicPack"

src/main/java/com/calculatorsteam/dynamicpack/mixins/ResourcePackEntryMixin.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import net.minecraft.client.gui.GuiGraphics;
77
import net.minecraft.client.gui.screens.packs.TransferableSelectionList;
88
import net.minecraft.client.gui.screens.packs.PackSelectionModel;
9-
import net.minecraft.resources.ResourceLocation;
109
import org.spongepowered.asm.mixin.Final;
1110
import org.spongepowered.asm.mixin.Mixin;
1211
import org.spongepowered.asm.mixin.Shadow;
@@ -59,11 +58,14 @@ private void render(GuiGraphics context, /*? if <1.21.9 {*//*int index, int y, i
5958
boolean selectable = showHoverOverlay();
6059
dynamicpack$selected = -1;
6160
if (dynamicpack$foldTicks == maxFoldTicks) {
62-
/*? if >=1.21 {*/
63-
VersionFunctions.blitSprite(context, ResourceLocation.withDefaultNamespace("transferable_list/unselect"),
61+
/*? if >=1.21.11 {*/
62+
VersionFunctions.blitSprite(context, net.minecraft.resources.Identifier.withDefaultNamespace("transferable_list/unselect"),
6463
x + entryWidth - 16 - deltaX, y + entryWidth / 20 - 16, 16, 32);
65-
/*?} else {*/
66-
/*context.blit(new ResourceLocation("textures/gui/resource_packs.png"),
64+
/*?} else if >=1.21 {*/
65+
/*VersionFunctions.blitSprite(context, net.minecraft.resources.ResourceLocation.withDefaultNamespace("transferable_list/unselect"),
66+
x + entryWidth - 16 - deltaX, y + entryWidth / 20 - 16, 16, 32);
67+
*//*?} else {*/
68+
/*context.blit(new net.minecraft.resources.ResourceLocation("textures/gui/resource_packs.png"),
6769
x + entryWidth - 16 - deltaX, y + entryWidth / 20 - 16, 32.0F, 0.0F, 16, 32, 256, 256);
6870
*//*?}*/
6971
} else {
@@ -82,7 +84,11 @@ private void render(GuiGraphics context, /*? if <1.21.9 {*//*int index, int y, i
8284
boolean widgetHovered = mouseX <= entryX + width && mouseX >= entryX &&
8385
mouseY <= entryY + height && mouseY >= entryY;
8486
widget.render(pack, context, entryX, entryY, widgetHovered, tickDelta);
85-
if (widgetHovered) dynamicpack$selected = 0; // фиксированный индекс
87+
if (widgetHovered) {
88+
dynamicpack$selected = 0; // фиксированный индекс
89+
//? if > 1.21.9
90+
context.requestCursor(parent.isActive() ? com.mojang.blaze3d.platform.cursor.CursorTypes.POINTING_HAND : com.mojang.blaze3d.platform.cursor.CursorTypes.NOT_ALLOWED);
91+
}
8692
prevMargin = widget.getXMargin(pack);
8793
}
8894
}

src/main/kotlin/com/calculatorsteam/dynamicpack/Constants.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ object Constants {
1515

1616
const val VERSION_BUILD: Long = 51
1717
const val VERSION_NAME_MOD: String = "1.2.1"
18-
/*? if >=1.21.9 {*/
19-
const val VERSION_NAME_BRANCH: String = "mc1.21.10"
20-
/*?} else if >=1.21.6 {*/
18+
/*? if >=1.21.11 {*/
19+
const val VERSION_NAME_BRANCH: String = "mc1.21.11"
20+
/*?} else if >=1.21.9 {*/
21+
/*const val VERSION_NAME_BRANCH: String = "mc1.21.10"
22+
*//*?} else if >=1.21.6 {*/
2123
/*const val VERSION_NAME_BRANCH: String = "mc1.21.8"
2224
*//*?} else if >=1.21.5 {*/
2325
/*const val VERSION_NAME_BRANCH: String = "mc1.21.5"

src/main/kotlin/com/calculatorsteam/dynamicpack/client/config/NoYACLScreen.kt

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.calculatorsteam.dynamicpack.client.config;
22

3+
import com.calculatorsteam.dynamicpack.platform.Util
34
import com.calculatorsteam.dynamicpack.platform.VersionFunctions
45
import net.minecraft.ChatFormatting
5-
import net.minecraft.Util
66
import net.minecraft.client.gui.GuiGraphics
77
import net.minecraft.client.gui.components.Button
88
import net.minecraft.client.gui.screens.Screen
@@ -12,7 +12,6 @@ import net.minecraft.network.chat.Component
1212
import net.minecraft.network.chat.Style
1313
import net.minecraft.util.FormattedCharSequence
1414
import net.minecraft.util.Mth
15-
import java.net.URI
1615

1716
/**
1817
* Screen displayed if YACL (YetAnotherConfigLib) is not found.
@@ -93,25 +92,49 @@ open class NoYACLScreen(private val parent: Screen) : Screen(Component.translata
9392
}
9493
/*?} else {*/
9594
/*if (click.action == ClickEvent.Action.OPEN_URL) {
96-
Util.getPlatform().openUri(URI(click.value))
95+
Util.getPlatform().openUri(java.net.URI(click.value))
9796
}
9897
*//*?}*/
9998
} else {
100-
return handleComponentClicked(style)
99+
/*? if >=1.21.11 {*/
100+
return this.handleClickEvent(style.getClickEvent());
101+
/*?} else {*/
102+
/*return handleComponentClicked(style)
103+
*//*?}*/
101104
}
102105

103106
return false
104107
}
105108

106109
protected fun getStyle(mouseX: Int, mouseY: Int): Style? {
110+
/*? if >=1.21.11 {*/
107111
val y = mouseY - 90
112+
val line = y / this.font.lineHeight
113+
114+
if (y < 0 || y > y + this.wrappedText.size * this.font.lineHeight) return null;
115+
if (line < 0 || line >= this.wrappedText.size) return null;
116+
117+
val clickableStyleFinder = net.minecraft.client.gui.ActiveTextCollector.ClickableStyleFinder(this.font, mouseX, mouseY)
118+
return clickableStyleFinder.result()
119+
/*?} else {*/
120+
/*val y = mouseY - 90
108121
val line = y / font.lineHeight
109122
110123
if (y < 0 || line !in wrappedText.indices) return null
111124
val text = wrappedText[line]
112125
113126
val x = mouseX - (width / 2 - font.width(text) / 2)
114127
return font.splitter.componentStyleAtWidth(text, x)
128+
*//*?}*/
129+
}
115130

131+
/*? if >=1.21.11 {*/
132+
protected fun handleClickEvent(clickEvent: ClickEvent?): Boolean {
133+
if (clickEvent == null) {
134+
return false;
135+
}
136+
defaultHandleGameClickEvent(clickEvent, this.minecraft, this);
137+
return true;
116138
}
139+
/*?}*/
117140
}

src/main/kotlin/com/calculatorsteam/dynamicpack/client/gui/ContentsScreen.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ class ContentsScreen(
3434
protected val enums = linkedSetOf<BaseEnum>()
3535

3636
init {
37-
this.minecraft = Minecraft.getInstance()
3837
this.pack.addDestroyListener(onPackReSync)
3938
this.preferences = (pack.getRemote() as DynamicRepoRemote).preferences
4039

src/main/kotlin/com/calculatorsteam/dynamicpack/client/gui/DynamicPackScreen.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ class DynamicPackScreen(
3434
private lateinit var syncButtonAll: Button
3535

3636
init {
37-
this.minecraft = Minecraft.getInstance()
3837
setPack(pack)
3938
}
4039

src/main/kotlin/com/calculatorsteam/dynamicpack/client/gui/widget/DynamicPackResourcePackEntryWidget.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package com.calculatorsteam.dynamicpack.client.gui.widget
33
import com.calculatorsteam.dynamicpack.DynamicPackMod
44
import com.calculatorsteam.dynamicpack.client.gui.DynamicPackScreen
55
import com.calculatorsteam.dynamicpack.pack.DynamicResourcePack
6+
import com.calculatorsteam.dynamicpack.platform.Identifier
67
import com.calculatorsteam.dynamicpack.platform.VersionFunctions
78
import net.minecraft.client.Minecraft
89
import net.minecraft.client.gui.GuiGraphics
910
import net.minecraft.client.gui.screens.packs.PackSelectionModel
10-
import net.minecraft.resources.ResourceLocation
1111
import kotlin.math.cos
1212
import kotlin.math.sin
1313

@@ -42,9 +42,9 @@ class DynamicPackResourcePackEntryWidget : ResourcePackEntryWidget {
4242
DynamicPackMod.getDynamicPackByMinecraftName(entry.id)
4343

4444
companion object {
45-
private val BUTTON_TEXTURE = ResourceLocation.tryBuild("dynamicpack", "select_button.png")
46-
private val BUTTON_WARNING_TEXTURE = ResourceLocation.tryBuild("dynamicpack", "select_button_warning.png")
47-
private val BUTTON_SYNCING_TEXTURE = ResourceLocation.tryBuild("dynamicpack", "select_button_syncing.png")
45+
private val BUTTON_TEXTURE = Identifier.tryBuild("dynamicpack", "select_button.png")
46+
private val BUTTON_WARNING_TEXTURE = Identifier.tryBuild("dynamicpack", "select_button_warning.png")
47+
private val BUTTON_SYNCING_TEXTURE = Identifier.tryBuild("dynamicpack", "select_button_syncing.png")
4848

4949
fun drawTexture(context: GuiGraphics, pack: DynamicResourcePack, x: Int, y: Int, hovered: Boolean) {
5050
val latestException = pack.getLatestException()

src/main/kotlin/com/calculatorsteam/dynamicpack/platform/VersionFunctions.kt

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,23 @@ import net.minecraft.locale.Language
1616
import net.minecraft.network.chat.Component
1717
import net.minecraft.network.chat.FormattedText
1818
import net.minecraft.network.chat.Style
19-
import net.minecraft.resources.ResourceLocation
2019
import net.minecraft.util.FormattedCharSequence
2120
import java.net.URI
2221

22+
typealias Identifier =
23+
//? if >=1.21.11 {
24+
net.minecraft.resources.Identifier
25+
//?} else {
26+
/*net.minecraft.resources.ResourceLocation
27+
*///?}
28+
29+
typealias Util =
30+
//? if >=1.21.11 {
31+
net.minecraft.util.Util
32+
//?} else {
33+
/*net.minecraft.Util
34+
*///?}
35+
2336
object VersionFunctions {
2437
private val client: Minecraft = Minecraft.getInstance()
2538

@@ -78,18 +91,22 @@ object VersionFunctions {
7891

7992
fun drawTexture(
8093
context: GuiGraphics,
81-
texture: ResourceLocation?,
94+
texture: Identifier?,
8295
x: Int, y: Int,
8396
u: Float, v: Float,
8497
width: Int, height: Int,
8598
textureWidth: Int, textureHeight: Int
8699
) {
87-
/*? if >=1.21.6 {*/
100+
/*? if >=1.21.11 {*/
88101
if (texture != null) {
102+
context.blit(net.minecraft.client.renderer.RenderPipelines.GUI_TEXTURED, texture, x, y, u, v, width, height, textureWidth, textureHeight)
103+
}
104+
/*?} else if >=1.21.6 {*/
105+
/*if (texture != null) {
89106
RenderSystem.setShaderTexture(0, Minecraft.getInstance().textureManager.getTexture(texture).textureView);
90107
context.blit(net.minecraft.client.renderer.RenderPipelines.GUI_TEXTURED, texture, x, y, u, v, width, height, textureWidth, textureHeight)
91108
}
92-
/*?} else if >=1.21.5 {*/
109+
*//*?} else if >=1.21.5 {*/
93110
/*if (texture != null) {
94111
RenderSystem.setShaderTexture(0, Minecraft.getInstance().getTextureManager().getTexture(texture).getTexture());
95112
context.blit(net.minecraft.client.renderer.RenderType::guiTextured, texture, x, y, u, v, width, height, textureWidth, textureHeight)
@@ -124,7 +141,7 @@ object VersionFunctions {
124141
}
125142

126143
@JvmStatic
127-
fun blitSprite(context: Any, sprite: ResourceLocation , x: Int, y: Int, width: Int, height: Int) {
144+
fun blitSprite(context: Any, sprite: Identifier , x: Int, y: Int, width: Int, height: Int) {
128145
/*? if >=1.21.6 {*/
129146
(context as GuiGraphics).blitSprite(net.minecraft.client.renderer.RenderPipelines.GUI_TEXTURED, sprite, x, y, width, height)
130147
/*?} else if >=1.21.2 {*/
@@ -158,10 +175,6 @@ object VersionFunctions {
158175
*//*?}*/
159176
}
160177

161-
fun versionString(): String {
162-
return "1.21.8"
163-
}
164-
165178
fun getToastManager():
166179
/*? if >=1.21.2 {*/
167180
net.minecraft.client.gui.components.toasts.ToastManager {

stonecutter.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ plugins {
88
id("dev.isxander.modstitch.base") version modstitchVersion apply false
99
id("dev.isxander.modstitch.publishing") version modstitchVersion apply false
1010
}
11-
stonecutter active "1.21.10-fabric"
11+
stonecutter active "1.21.11-fabric"
1212

1313
allprojects {
1414
repositories {

0 commit comments

Comments
 (0)