Skip to content

Commit 3799e8d

Browse files
committed
1.21.6 fabric port
1 parent 3b3b87d commit 3799e8d

File tree

11 files changed

+73
-57
lines changed

11 files changed

+73
-57
lines changed

build.gradle.kts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,17 @@ val shadeModImplementation: Configuration by configurations.creating {
6969
}
7070

7171
// Version definitions
72-
val mcVersion = VersionDefinition(
72+
val mcVersion = VersionDefinition( // Used for pre releases and release candidates
73+
default = mcPlatform.versionString
74+
)
75+
val compatibleMcVersion = VersionDefinition(
7376
"1.20.1" to VersionRange("1.20", "1.20.1", name = "1.20.1"),
7477
"1.21.1" to VersionRange("1.21", "1.21.1", name = "1.21.1"),
7578
"1.21.4" to VersionRange("1.21.2", "1.21.4", name = "1.21.3/4"),
7679
// NeoForge changed stuff going from .3 to .4
7780
"1.21.4-neoforge" to VersionRange("1.21.4", "1.21.4", name = "1.21.4"),
78-
"1.21.5" to VersionRange("1.21.5", "1.21.5", name = "1.21.5", openEnd = true),
81+
"1.21.5" to VersionRange("1.21.5", "1.21.5", name = "1.21.5"),
82+
"1.21.6" to VersionRange("1.21.6", "1.21.6", name = "1.21.6", openEnd = true)
7983
)
8084
val javaVersion = VersionDefinition(
8185
"1.20.1" to "17",
@@ -91,12 +95,14 @@ val fabricApiVersion = VersionDefinition(
9195
"1.21.1" to "0.114.0+1.21.1",
9296
"1.21.4" to "0.118.0+1.21.4",
9397
"1.21.5" to "0.119.4+1.21.5",
98+
"1.21.6" to "0.126.1+1.21.6",
9499
)
95100
val modMenuVersion = VersionDefinition(
96101
"1.20.1" to "7.2.2",
97102
"1.21.1" to "11.0.3",
98103
"1.21.4" to "13.0.2",
99104
"1.21.5" to "14.0.0-rc.2",
105+
"1.21.6" to "15.0.0-beta.3",
100106
)
101107
val neoForgeVersion = VersionDefinition(
102108
"1.21.1" to "21.1.95",
@@ -121,12 +127,12 @@ val kotlinForForgeVersion = VersionDefinition(
121127
"1.21.5" to "5.7.0",
122128
)
123129
val universalVersion = VersionDefinition(
124-
"1.21.1" to "1.21-${mcPlatform.loaderString}:401",
125-
default = "${mcPlatform.name}:401"
130+
"1.21.1" to "1.21-${mcPlatform.loaderString}:414+fix-uscreen-panorama-background-break-drawing",
131+
default = "${mcPlatform.name}:414+fix-uscreen-panorama-background-break-drawing"
126132
)
127133

128134
dependencies {
129-
minecraft("com.mojang:minecraft:${mcPlatform.versionString}")
135+
minecraft("com.mojang:minecraft:${mcVersion.get(mcPlatform)}")
130136

131137
@Suppress("UnstableApiUsage")
132138
mappings(loom.layered {
@@ -137,7 +143,7 @@ dependencies {
137143
})
138144

139145
if (mcPlatform.isFabric) {
140-
modImplementation("net.fabricmc:fabric-loader:0.16.10")
146+
modImplementation("net.fabricmc:fabric-loader:0.16.13")
141147

142148
modImplementation("net.fabricmc:fabric-language-kotlin:${libs.versions.fabric.language.kotlin.get()}")
143149
modImplementation("net.fabricmc.fabric-api:fabric-api:${fabricApiVersion.get(mcPlatform)}")
@@ -157,7 +163,7 @@ dependencies {
157163
isTransitive = false
158164
}
159165
// Always shade elementa since we use a custom version, relocate to avoid conflicts
160-
shadeModImplementation("gg.essential:elementa:DIAMOND-11") {
166+
shadeModImplementation("gg.essential:elementa:DIAMOND-12") {
161167
isTransitive = false
162168
}
163169
// Since elementa is relocated, and MineMark doesn't guarantee backwards compatibility, we need to shade this
@@ -184,13 +190,13 @@ if (mcPlatform.isForge) configurations.configureEach {
184190

185191
base.archivesName.set(
186192
"$mod_name (${
187-
mcVersion.get(mcPlatform).getName().replace("/", "-")
193+
compatibleMcVersion.get(mcPlatform).getName().replace("/", "-")
188194
}-${mcPlatform.loaderString})-$mod_version"
189195
)
190196

191197
publishMods {
192198
file.set(tasks.remapJar.get().archiveFile)
193-
displayName.set("[${mcVersion.get(mcPlatform).getName()}-${mcPlatform.loaderString}] $mod_name $mod_version")
199+
displayName.set("[${compatibleMcVersion.get(mcPlatform).getName()}-${mcPlatform.loaderString}] $mod_name $mod_version")
194200
version.set(mod_version)
195201
changelog.set(rootProject.file("changelog.md").readText())
196202
type.set(STABLE)
@@ -204,8 +210,8 @@ publishMods {
204210
accessToken.set(System.getenv("CURSEFORGE_TOKEN"))
205211

206212
minecraftVersionRange {
207-
start = mcVersion.get(mcPlatform).startVersion
208-
end = mcVersion.get(mcPlatform).endVersion
213+
start = compatibleMcVersion.get(mcPlatform).startVersion
214+
end = compatibleMcVersion.get(mcPlatform).endVersion
209215
}
210216

211217
if (mcPlatform.isFabric) {
@@ -220,8 +226,8 @@ publishMods {
220226
accessToken.set(System.getenv("MODRINTH_TOKEN"))
221227

222228
minecraftVersionRange {
223-
start = mcVersion.get(mcPlatform).startVersion
224-
end = mcVersion.get(mcPlatform).endVersion
229+
start = compatibleMcVersion.get(mcPlatform).startVersion
230+
end = compatibleMcVersion.get(mcPlatform).endVersion
225231
}
226232

227233
if (mcPlatform.isFabric) {
@@ -265,7 +271,7 @@ tasks {
265271
"name" to mod_name,
266272
"version" to mod_version,
267273
"aw" to accesWidener,
268-
"mcVersion" to mcVersion.get(mcPlatform).getLoaderRange(mcPlatform),
274+
"mcVersion" to compatibleMcVersion.get(mcPlatform).getLoaderRange(mcPlatform),
269275
"minNeoForgeVersion" to minimumNeoForgeVersion.get(mcPlatform)
270276
)
271277

buildSrc/src/main/java/dev/dediamondpro/buildsource/VersionRange.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ class VersionRange(
2121
val startVersion: String,
2222
val endVersion: String,
2323
private val name: String = "$startVersion-$endVersion",
24-
private val openEnd: Boolean = false
24+
private val openEnd: Boolean = false,
25+
private val allowAll: Boolean = false, // Mostly used for pre releases and release candidates
2526
) {
2627
fun getName(): String {
2728
return name;
@@ -32,10 +33,12 @@ class VersionRange(
3233
}
3334

3435
fun getFabricRange(): String {
36+
if (allowAll) return "*"
3537
return ">=$startVersion" + if (!openEnd) " <=$endVersion" else ""
3638
}
3739

3840
fun getForgeRange(): String {
41+
if (allowAll) return "[1,)"
3942
return "[$startVersion," + if (!openEnd) "$endVersion]" else ")"
4043
}
4144
}

settings.gradle.kts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pluginManagement {
2727
}
2828

2929
plugins {
30-
id("dev.kikugie.stonecutter") version "0.5.2"
30+
id("dev.kikugie.stonecutter") version "0.6.1"
3131
}
3232

3333
val platforms = listOf(
@@ -42,6 +42,7 @@ val platforms = listOf(
4242
"1.21.5-forge",
4343
"1.21.5-neoforge",
4444
"1.21.5-fabric",
45+
"1.21.6-fabric",
4546
)
4647

4748
stonecutter {
@@ -51,7 +52,7 @@ stonecutter {
5152
for (version in platforms) {
5253
vers(version, version.split('-')[0])
5354
}
54-
vcsVersion = "1.21.5-fabric"
55+
vcsVersion = "1.21.6-fabric"
5556
}
5657
}
5758

src/main/java/dev/dediamondpro/resourcify/mixins/TabManagerMixin.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,14 @@
33
import dev.dediamondpro.resourcify.gui.world.DownloadWorldTab;
44
import net.minecraft.client.gui.components.tabs.Tab;
55
import net.minecraft.client.gui.components.tabs.TabManager;
6-
import net.minecraft.client.gui.navigation.ScreenRectangle;
7-
import org.jetbrains.annotations.Nullable;
86
import org.spongepowered.asm.mixin.Mixin;
9-
import org.spongepowered.asm.mixin.Shadow;
107
import org.spongepowered.asm.mixin.injection.At;
118
import org.spongepowered.asm.mixin.injection.Inject;
129
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1310

1411
@Mixin(TabManager.class)
1512
public class TabManagerMixin {
1613

17-
@Shadow @Nullable private ScreenRectangle tabArea;
18-
1914
@Inject(method = "setCurrentTab", at = @At("HEAD"), cancellable = true)
2015
public void onResourcifyWorldTab(Tab tab, boolean playClickSound, CallbackInfo ci) {
2116
// The tab opens a GUI, so we don't want it to be selected because then the GUI would open again after its closed

src/main/kotlin/dev/dediamondpro/resourcify/Constants.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717

1818
package dev.dediamondpro.resourcify
1919

20+
import org.slf4j.Logger
2021
import org.slf4j.LoggerFactory
2122

2223
object Constants {
2324
const val NAME = /*$ mod_name*/ "Resourcify"
2425
const val ID = /*$ mod_id*/ "resourcify"
25-
const val VERSION = /*$ mod_version*/ "1.7.1"
26-
val LOGGER = LoggerFactory.getLogger("Resourcify")
26+
const val VERSION = /*$ mod_version*/ "1.7.2"
27+
val LOGGER: Logger = LoggerFactory.getLogger("Resourcify")
2728
}

src/main/kotlin/dev/dediamondpro/resourcify/elements/McImage.kt

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,31 @@
1717

1818
package dev.dediamondpro.resourcify.elements
1919

20-
import com.mojang.blaze3d.systems.RenderSystem
20+
import dev.dediamondpro.resourcify.util.EmptyImage
21+
import dev.dediamondpro.resourcify.util.supply
2122
import gg.essential.elementa.UIComponent
23+
import gg.essential.elementa.components.UIImage
2224
import gg.essential.elementa.components.image.ImageProvider
23-
import gg.essential.universal.UGraphics
2425
import gg.essential.universal.UMatrixStack
25-
import net.minecraft.client.Minecraft
26-
import net.minecraft.client.renderer.RenderType
26+
import gg.essential.universal.UMinecraft
2727
import net.minecraft.resources.ResourceLocation
2828
import java.awt.Color
29+
import javax.imageio.ImageIO
30+
31+
class McImage(texture: ResourceLocation) : UIComponent(), ImageProvider {
32+
var backingImage: UIImage? = null
33+
34+
init {
35+
val resource = UMinecraft.getMinecraft().resourceManager.getResource(texture)?.orElse(null)
36+
if (resource != null) {
37+
backingImage = UIImage(supply {
38+
resource.open().use {
39+
return@use ImageIO.read(it)
40+
}
41+
}, EmptyImage, EmptyImage)
42+
}
43+
}
2944

30-
class McImage(private val texture: ResourceLocation) : UIComponent(), ImageProvider {
3145
override fun drawImage(
3246
matrixStack: UMatrixStack,
3347
x: Double,
@@ -36,29 +50,7 @@ class McImage(private val texture: ResourceLocation) : UIComponent(), ImageProvi
3650
height: Double,
3751
color: Color
3852
) {
39-
//? if >=1.21.5 {
40-
val bufferSource = Minecraft.getInstance().gameRenderer.renderBuffers.bufferSource()
41-
val renderType = RenderType.guiTextured(texture)
42-
val vertexConsumer = bufferSource.getBuffer(renderType)
43-
val pose = matrixStack.toMC().last().pose()
44-
val colorInt = color.rgb
45-
46-
vertexConsumer.addVertex(pose, x.toFloat(), (y + height).toFloat(), 0F).setUv(0F, 1F).setColor(colorInt)
47-
vertexConsumer.addVertex(pose, (x + width).toFloat(), (y + height).toFloat(), 0F).setUv(1F, 1F).setColor(colorInt)
48-
vertexConsumer.addVertex(pose, (x + width).toFloat(), y.toFloat(), 0F).setUv(1F, 0F).setColor(colorInt)
49-
vertexConsumer.addVertex(pose, x.toFloat(), y.toFloat(), 0F).setUv(0F, 0F).setColor(colorInt)
50-
bufferSource.endLastBatch()
51-
//?} else {
52-
/*RenderSystem.setShaderTexture(0, texture)
53-
val renderer = UGraphics.getFromTessellator()
54-
55-
renderer.beginWithDefaultShader(UGraphics.DrawMode.QUADS, UGraphics.CommonVertexFormats.POSITION_TEXTURE_COLOR)
56-
renderer.pos(matrixStack, x, y + height, 0.0).tex(0.0, 1.0).color(color).endVertex()
57-
renderer.pos(matrixStack, x + width, y + height, 0.0).tex(1.0, 1.0).color(color).endVertex()
58-
renderer.pos(matrixStack, x + width, y, 0.0).tex(1.0, 0.0).color(color).endVertex()
59-
renderer.pos(matrixStack, x, y, 0.0).tex(0.0, 0.0).color(color).endVertex()
60-
renderer.drawDirect()
61-
*///?}
53+
backingImage?.drawImage(matrixStack, x, y, width, height, color)
6254
}
6355

6456
override fun draw(matrixStack: UMatrixStack) {

src/main/kotlin/dev/dediamondpro/resourcify/gui/PaginatedScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import kotlin.math.floor
2929

3030

3131
abstract class PaginatedScreen(private val adaptScale: Boolean = true, private val minimumWidth: Float = 500f) : WindowScreen(
32-
version = ElementaVersion.V8,
32+
version = ElementaVersion.V10,
3333
drawDefaultBackground = true
3434
) {
3535
private var defaultScale = -1

src/main/kotlin/dev/dediamondpro/resourcify/gui/injections/ImageButton.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ import net.minecraft.client.renderer.RenderType
2525
import net.minecraft.network.chat.Component
2626
import net.minecraft.resources.ResourceLocation
2727

28+
//? if >= 1.21.6
29+
import net.minecraft.client.renderer.RenderPipelines
30+
2831
class ImageButton(
2932
screen: Screen, private val xFunc: (Int) -> Int, private val yFunc: (Int) -> Int,
3033
private val image: ResourceLocation,
@@ -42,7 +45,13 @@ class ImageButton(
4245

4346
override fun renderWidget(context: GuiGraphics, mouseX: Int, mouseY: Int, delta: Float) {
4447
super.renderWidget(context, mouseX, mouseY, delta)
45-
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
46-
context.blit(/*? >=1.21.2 {*/ RenderType::guiTextured, /*?}*/ image, x + 2, y + 2, 0f, 0f, width - 4, height - 4, 16, 16)
48+
//? if <= 1.21.5
49+
/*RenderSystem.setShaderColor(1f, 1f, 1f, 1f)*/
50+
//? if >= 1.21.6 {
51+
context.blit(RenderPipelines.GUI_TEXTURED, image, x + 2, y + 2, 0f, 0f, width - 4, height - 4, 16, 16)
52+
//?} else if >= 1.21.2 {
53+
/*context.blit(RenderType::guiTextured, image, x + 2, y + 2, 0f, 0f, width - 4, height - 4, 16, 16)
54+
*///?} else
55+
/*context.blit(image, x + 2, y + 2, 0f, 0f, width - 4, height - 4, 16, 16)*/
4756
}
4857
}

src/main/kotlin/dev/dediamondpro/resourcify/gui/world/DownloadWorldTab.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ class DownloadWorldTab : Tab {
1515
return Component.translatable("resourcify.world.download")
1616
}
1717

18+
//? if >= 1.21.6 {
19+
override fun getTabExtraNarration(): Component? {
20+
return Component.empty()
21+
}
22+
//?}
23+
1824
override fun visitChildren(consumer: Consumer<AbstractWidget>) {
1925
}
2026

src/main/kotlin/dev/dediamondpro/resourcify/platform/Platform.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ import java.io.File
2828

2929
object Platform {
3030
fun getMcVersion(): String {
31-
return SharedConstants.getCurrentVersion().name
31+
//? if >= 1.21.6 {
32+
return SharedConstants.getCurrentVersion().name()
33+
//?} else
34+
/*return SharedConstants.getCurrentVersion().name*/
3235
}
3336

3437
fun getLoader(): String {

0 commit comments

Comments
 (0)