Skip to content

Commit 2d38021

Browse files
authored
Build: Port to 1.21.9 Fabric
GitHub: #115
1 parent 4c4ca75 commit 2d38021

File tree

9 files changed

+215
-81
lines changed

9 files changed

+215
-81
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ done
7474
<img alt="standalone" src="https://img.shields.io/badge/dynamic/xml?color=A97BFF&label=%20&query=/metadata/versioning/versions/version[not(contains(text(),'%2B'))][last()]&url=https://repo.essential.gg/repository/maven-releases/gg/essential/universalcraft-standalone/maven-metadata.xml">
7575
</td>
7676
</tr>
77+
<tr><td>1.21.9</td><td>fabric</td><td><img alt="1.21.9-fabric" src="https://img.shields.io/badge/dynamic/xml?color=A97BFF&label=%20&query=/metadata/versioning/versions/version[not(contains(text(),'%2B'))][last()]&url=https://repo.essential.gg/repository/maven-releases/gg/essential/universalcraft-1.21.9-fabric/maven-metadata.xml"></td></tr>
7778
<tr><td>1.21.7</td><td>neoforge</td><td><img alt="1.21.7-neoforge" src="https://img.shields.io/badge/dynamic/xml?color=A97BFF&label=%20&query=/metadata/versioning/versions/version[not(contains(text(),'%2B'))][last()]&url=https://repo.essential.gg/repository/maven-releases/gg/essential/universalcraft-1.21.7-neoforge/maven-metadata.xml"></td></tr>
7879
<tr><td>1.21.7</td><td>forge</td><td><img alt="1.21.7-forge" src="https://img.shields.io/badge/dynamic/xml?color=A97BFF&label=%20&query=/metadata/versioning/versions/version[not(contains(text(),'%2B'))][last()]&url=https://repo.essential.gg/repository/maven-releases/gg/essential/universalcraft-1.21.7-forge/maven-metadata.xml"></td></tr>
7980
<tr><td>1.21.7</td><td>fabric</td><td><img alt="1.21.7-fabric" src="https://img.shields.io/badge/dynamic/xml?color=A97BFF&label=%20&query=/metadata/versioning/versions/version[not(contains(text(),'%2B'))][last()]&url=https://repo.essential.gg/repository/maven-releases/gg/essential/universalcraft-1.21.7-fabric/maven-metadata.xml"></td></tr>

api/UniversalCraft.api

Lines changed: 92 additions & 74 deletions
Large diffs are not rendered by default.

root.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import gg.essential.gradle.util.*
22

33
plugins {
44
kotlin("jvm") version "1.9.23" apply false
5-
id("gg.essential.loom") version "1.7.28" apply false
5+
id("gg.essential.loom") version "1.7.35" apply false
66
id("gg.essential.multi-version.root")
77
id("gg.essential.multi-version.api-validation")
88
}
@@ -12,6 +12,7 @@ version = versionFromBuildIdAndBranch()
1212
preprocess {
1313
strictExtraMappings.set(true)
1414

15+
val fabric12109 = createNode("1.21.9-fabric", 12109, "srg")
1516
val neoForge12107 = createNode("1.21.7-neoforge", 12107, "srg")
1617
val forge12107 = createNode("1.21.7-forge", 12107, "srg")
1718
val fabric12107 = createNode("1.21.7-fabric", 12107, "srg")
@@ -56,6 +57,7 @@ preprocess {
5657
val forge11202 = createNode("1.12.2-forge", 11202, "srg")
5758
val forge10809 = createNode("1.8.9-forge", 10809, "srg")
5859

60+
fabric12109.link(fabric12107)
5961
neoForge12107.link(fabric12107)
6062
forge12107.link(fabric12107)
6163
fabric12107.link(fabric12106)

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ listOf(
6464
"1.21.7-fabric",
6565
"1.21.7-forge",
6666
"1.21.7-neoforge",
67+
"1.21.9-fabric",
6768
).forEach { version ->
6869
include(":$version")
6970
project(":$version").apply {

src/main/java/gg/essential/universal/UGraphics.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@
4646
import static org.lwjgl.opengl.GL13.GL_ACTIVE_TEXTURE;
4747
import static org.lwjgl.opengl.GL13.GL_TEXTURE0;
4848

49+
//#if MC>=12109
50+
//$$ import net.minecraft.client.font.TextDrawable;
51+
//$$ import net.minecraft.text.StyleSpriteSource;
52+
//#endif
53+
4954
//#if MC>=12106
5055
//$$ import com.mojang.blaze3d.systems.RenderPass;
5156
//$$ import com.mojang.blaze3d.textures.GpuTextureView;
@@ -164,7 +169,9 @@ public class UGraphics {
164169
//$$ private DefaultShader shader;
165170
//#else
166171

167-
//#if MC>=12100
172+
//#if MC>=12109
173+
//$$ public static Style EMPTY_WITH_FONT_ID = Style.EMPTY.withFont(new StyleSpriteSource.Font(Identifier.of("minecraft", "alt")));
174+
//#elseif MC>=12100
168175
//$$ public static Style EMPTY_WITH_FONT_ID = Style.EMPTY.withFont(Identifier.of("minecraft", "alt"));
169176
//#elseif MC>=11602
170177
//$$ public static Style EMPTY_WITH_FONT_ID = Style.EMPTY.setFontId(new ResourceLocation("minecraft", "alt"));
@@ -492,6 +499,8 @@ public static void setActiveTexture(int glId) {
492499
public static void bindTexture(int glTextureId) {
493500
//#if STANDALONE
494501
//$$ glBindTexture(GL_TEXTURE_2D, glTextureId);
502+
//#elseif MC>=12109
503+
//$$ bindTexture(getActiveTexture() - GL_TEXTURE0, glTextureId);
495504
//#elseif MC>=11700
496505
//$$ bindTexture(GlStateManager._getActiveTexture() - GL_TEXTURE0, glTextureId);
497506
//#else
@@ -686,6 +695,19 @@ public static void drawString(UMatrixStack stack, String text, float x, float y,
686695
//$$ }
687696
//$$ }
688697
//$$
698+
//#if MC>=12109
699+
//$$ private void draw(TextDrawable drawable) {
700+
//$$ if (pipeline != drawable.getPipeline() || texture != drawable.textureView()) {
701+
//$$ flush();
702+
//$$ pipeline = drawable.getPipeline();
703+
//$$ texture = drawable.textureView();
704+
//$$ bufferBuilder = Tessellator.getInstance().begin(pipeline.getVertexFormatMode(), pipeline.getVertexFormat());
705+
//$$ }
706+
//$$ drawable.render(matrix, bufferBuilder, LIGHT, false);
707+
//$$ }
708+
//$$ @Override public void drawGlyph(TextDrawable drawable) { draw(drawable); }
709+
//$$ @Override public void drawRectangle(TextDrawable drawable) { draw(drawable); }
710+
//#else
689711
//$$ private void setupBuffer(BakedGlyph bakedGlyph) {
690712
//$$ if (pipeline == bakedGlyph.getPipeline() && texture == bakedGlyph.getTexture()) {
691713
//$$ return;
@@ -709,6 +731,7 @@ public static void drawString(UMatrixStack stack, String text, float x, float y,
709731
//$$ if (bakedGlyph.getTexture() == null) return;
710732
//$$ bakedGlyph.drawRectangle(rectangle, matrix, bufferBuilder, LIGHT, false);
711733
//$$ }
734+
//#endif
712735
//$$ }
713736
//#endif
714737

src/main/kotlin/gg/essential/universal/UMinecraft.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ object UMinecraft {
5252
val isRunningOnMac: Boolean =
5353
//#if STANDALONE
5454
//$$ UDesktop.isMac
55+
//#elseif MC>=12109
56+
//$$ net.minecraft.client.input.SystemKeycodes.IS_MAC_OS
5557
//#else
5658
Minecraft.isRunningOnMac
5759
//#endif

src/main/kotlin/gg/essential/universal/UScreen.kt

Lines changed: 84 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ package gg.essential.universal
22

33
import net.minecraft.client.gui.GuiScreen
44

5+
//#if MC>=12109
6+
//$$ import net.minecraft.client.gui.Click
7+
//$$ import net.minecraft.client.input.CharInput
8+
//$$ import net.minecraft.client.input.KeyInput
9+
//$$ import net.minecraft.client.input.MouseInput
10+
//#endif
11+
512
//#if MC>=12106
613
//$$ import com.mojang.blaze3d.systems.RenderSystem
714
//#endif
@@ -127,6 +134,57 @@ abstract class UScreen(
127134
//#endif
128135
//$$ }
129136
//$$
137+
//#if MC>=12109
138+
//$$ final override fun keyPressed(input: KeyInput): Boolean {
139+
//$$ onKeyPressed(input.key, 0.toChar(), input.modifiers.toModifiers())
140+
//$$ return false
141+
//$$ }
142+
//$$
143+
//$$ final override fun keyReleased(input: KeyInput): Boolean {
144+
//$$ onKeyReleased(input.key, 0.toChar(), input.modifiers.toModifiers())
145+
//$$ return false
146+
//$$ }
147+
//$$
148+
//$$ final override fun charTyped(input: CharInput): Boolean {
149+
//$$ val codepoint = input.codepoint
150+
//$$ if (Character.isBmpCodePoint(codepoint)) {
151+
//$$ onKeyPressed(0, input.codepoint.toChar(), input.modifiers.toModifiers())
152+
//$$ } else if (Character.isValidCodePoint(codepoint)) {
153+
//$$ onKeyPressed(0, Character.highSurrogate(input.codepoint), input.modifiers.toModifiers())
154+
//$$ onKeyPressed(0, Character.lowSurrogate(input.codepoint), input.modifiers.toModifiers())
155+
//$$ }
156+
//$$ return false
157+
//$$ }
158+
//$$
159+
//$$ private var lastMouseInput: MouseInput? = null
160+
//$$ private var lastDoubled: Boolean? = null
161+
//$$
162+
//$$ final override fun mouseClicked(click: Click, doubled: Boolean): Boolean {
163+
//$$ lastMouseInput = click.buttonInfo
164+
//$$ lastDoubled = doubled
165+
//$$ if (click.button() == 1) lastClick = UMinecraft.getTime()
166+
//$$ onMouseClicked(click.x, click.y, click.button())
167+
//$$ lastMouseInput = null
168+
//$$ lastDoubled = null
169+
//$$ return false
170+
//$$ }
171+
//$$
172+
//$$ final override fun mouseReleased(click: Click): Boolean {
173+
//$$ lastMouseInput = click.buttonInfo
174+
//$$ onMouseReleased(click.x, click.y, click.button())
175+
//$$ lastMouseInput = null
176+
//$$ return false
177+
//$$ }
178+
//$$
179+
//$$ override fun mouseDragged(click: Click, offsetX: Double, offsetY: Double): Boolean {
180+
//$$ lastMouseInput = click.buttonInfo
181+
//$$ lastDraggedDx = offsetX
182+
//$$ lastDraggedDy = offsetY
183+
//$$ onMouseDragged(click.x, click.y, click.button(), UMinecraft.getTime() - lastClick)
184+
//$$ lastMouseInput = null
185+
//$$ return false
186+
//$$ }
187+
//#else
130188
//$$ final override fun keyPressed(keyCode: Int, scanCode: Int, modifierCode: Int): Boolean {
131189
//$$ onKeyPressed(keyCode, 0.toChar(), modifierCode.toModifiers())
132190
//$$ return false
@@ -160,6 +218,7 @@ abstract class UScreen(
160218
//$$ onMouseDragged(x, y, mouseButton, UMinecraft.getTime() - lastClick)
161219
//$$ return false
162220
//$$ }
221+
//#endif
163222
//$$
164223
//#if MC>=12002
165224
//$$ override fun mouseScrolled(mouseX: Double, mouseY: Double, horizontalAmount: Double, delta: Double): Boolean {
@@ -341,10 +400,18 @@ abstract class UScreen(
341400
open fun onKeyPressed(keyCode: Int, typedChar: Char, modifiers: UKeyboard.Modifiers?) {
342401
//#if MC>=11502
343402
//$$ if (keyCode != 0) {
344-
//$$ super.keyPressed(keyCode, 0, modifiers.toInt())
403+
//#if MC>=12109
404+
//$$ super.keyPressed(KeyInput(keyCode, 0, modifiers.toInt()))
405+
//#else
406+
//$$ super.keyPressed(keyCode, 0, modifiers.toInt())
407+
//#endif
345408
//$$ }
346409
//$$ if (typedChar != 0.toChar()) {
347-
//$$ super.charTyped(typedChar, modifiers.toInt())
410+
//#if MC>=12109
411+
//$$ super.charTyped(CharInput(typedChar.code, modifiers.toInt()))
412+
//#else
413+
//$$ super.charTyped(typedChar, modifiers.toInt())
414+
//#endif
348415
//$$ }
349416
//#else
350417
try {
@@ -358,7 +425,11 @@ abstract class UScreen(
358425
open fun onKeyReleased(keyCode: Int, typedChar: Char, modifiers: UKeyboard.Modifiers?) {
359426
//#if MC>=11502
360427
//$$ if (keyCode != 0) {
361-
//$$ super.keyReleased(keyCode, 0, modifiers.toInt())
428+
//#if MC>=12109
429+
//$$ super.keyReleased(KeyInput(keyCode, 0, modifiers.toInt()))
430+
//#else
431+
//$$ super.keyReleased(keyCode, 0, modifiers.toInt())
432+
//#endif
362433
//$$ }
363434
//#endif
364435
}
@@ -367,7 +438,11 @@ abstract class UScreen(
367438
//#if MC>=11502
368439
//$$ if (mouseButton == 1)
369440
//$$ lastClick = UMinecraft.getTime()
441+
//#if MC>=12109
442+
//$$ super.mouseClicked(Click(mouseX, mouseY, MouseInput(mouseButton, lastMouseInput?.modifiers ?: 0)), lastDoubled ?: false)
443+
//#else
370444
//$$ super.mouseClicked(mouseX, mouseY, mouseButton)
445+
//#endif
371446
//#else
372447
try {
373448
super.mouseClicked(mouseX.toInt(), mouseY.toInt(), mouseButton)
@@ -378,15 +453,19 @@ abstract class UScreen(
378453
}
379454

380455
open fun onMouseReleased(mouseX: Double, mouseY: Double, state: Int) {
381-
//#if MC>=11502
456+
//#if MC>=12109
457+
//$$ super.mouseReleased(Click(mouseX, mouseY, MouseInput(state, lastMouseInput?.modifiers ?: 0)))
458+
//#elseif MC>=11502
382459
//$$ super.mouseReleased(mouseX, mouseY, state)
383460
//#else
384461
super.mouseReleased(mouseX.toInt(), mouseY.toInt(), state)
385462
//#endif
386463
}
387464

388465
open fun onMouseDragged(x: Double, y: Double, clickedButton: Int, timeSinceLastClick: Long) {
389-
//#if MC>=11502
466+
//#if MC>=12109
467+
//$$ super.mouseDragged(Click(x, y, MouseInput(clickedButton, lastMouseInput?.modifiers ?: 0)), lastDraggedDx, lastDraggedDy)
468+
//#elseif MC>=11502
390469
//$$ super.mouseDragged(x, y, clickedButton, lastDraggedDx, lastDraggedDy)
391470
//#else
392471
super.mouseClickMove(x.toInt(), y.toInt(), clickedButton, timeSinceLastClick)

src/main/kotlin/gg/essential/universal/render/URenderPass.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ internal class URenderPass : AutoCloseable {
5959
//$$ val dynamicUniforms = RenderSystem.getDynamicUniforms().write(
6060
//$$ RenderSystem.getModelViewMatrix(),
6161
//$$ org.joml.Vector4f(1f, 1f, 1f, 1f),
62+
//#if MC>=12109
63+
//$$ org.joml.Vector3f(),
64+
//#else
6265
//$$ RenderSystem.getModelOffset(),
66+
//#endif
6367
//$$ RenderSystem.getTextureMatrix(),
6468
//$$ RenderSystem.getShaderLineWidth(),
6569
//$$ )
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
essential.defaults.loom.minecraft=com.mojang:minecraft:1.21.9-rc1
2+
essential.defaults.loom.mappings=net.fabricmc:yarn:1.21.9-rc1+build.2:v2
3+
# Required because our Loom doesn't yet support the unpick version included in the above yarn version
4+
essential.loom.disableUnpick=true

0 commit comments

Comments
 (0)