From a8dcafb6322ce2406e5a3fa3ef8a6d3b5a8ad3b0 Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Sat, 20 Jul 2024 11:24:23 +0200 Subject: [PATCH 1/3] Build: Update preprocessor --- root.gradle.kts | 2 ++ settings.gradle.kts | 2 +- src/main/kotlin/gg/essential/universal/UMatrixStack.kt | 3 --- src/main/kotlin/gg/essential/universal/UPacket.kt | 5 ----- versions/1.12.2-1.8.9.txt | 1 - versions/1.16.2-1.12.2.txt | 2 +- versions/1.17.1-1.16.2.txt | 1 + 7 files changed, 5 insertions(+), 11 deletions(-) diff --git a/root.gradle.kts b/root.gradle.kts index 97efeb9..756ac0b 100644 --- a/root.gradle.kts +++ b/root.gradle.kts @@ -9,6 +9,8 @@ plugins { version = versionFromBuildIdAndBranch() preprocess { + strictExtraMappings.set(true) + val fabric12100 = createNode("1.21-fabric", 12100, "srg") val fabric12006 = createNode("1.20.6-fabric", 12006, "srg") val forge12004 = createNode("1.20.4-forge", 12004, "srg") diff --git a/settings.gradle.kts b/settings.gradle.kts index eb9df96..b65bfdf 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -8,7 +8,7 @@ pluginManagement { maven("https://repo.essential.gg/repository/maven-public") } plugins { - val egtVersion = "0.5.0" + val egtVersion = "0.6.2" id("gg.essential.multi-version.root") version egtVersion id("gg.essential.multi-version.api-validation") version egtVersion } diff --git a/src/main/kotlin/gg/essential/universal/UMatrixStack.kt b/src/main/kotlin/gg/essential/universal/UMatrixStack.kt index 83d280f..a2f78ec 100644 --- a/src/main/kotlin/gg/essential/universal/UMatrixStack.kt +++ b/src/main/kotlin/gg/essential/universal/UMatrixStack.kt @@ -187,9 +187,6 @@ class UMatrixStack private constructor( //#if MC>=11700 //#if MC>=12005 //$$ RenderSystem.getModelViewStack().mul(stack.last.model) - //#elseif MC>=11800 - //$$ // FIXME preprocessor bug: should remap the intermediary name to yarn no problem - //$$ RenderSystem.getModelViewStack().multiplyPositionMatrix(stack.last.model) //#else //$$ RenderSystem.getModelViewStack().method_34425(stack.last.model) //#endif diff --git a/src/main/kotlin/gg/essential/universal/UPacket.kt b/src/main/kotlin/gg/essential/universal/UPacket.kt index d7fe596..ff1b83d 100644 --- a/src/main/kotlin/gg/essential/universal/UPacket.kt +++ b/src/main/kotlin/gg/essential/universal/UPacket.kt @@ -10,12 +10,7 @@ import net.minecraft.network.play.server.S02PacketChat //#if MC>=11901 //#else //#if MC>=11900 -//$$ // FIXME preprocessor bug: remaps alias references in code to remapped type, so we can't keep the alias -//#if FABRIC //$$ import net.minecraft.network.message.MessageType as MCMessageType -//#else -//$$ import net.minecraft.network.chat.ChatType -//#endif //$$ import net.minecraft.util.registry.Registry //$$ import net.minecraft.util.registry.RegistryKey //$$ diff --git a/versions/1.12.2-1.8.9.txt b/versions/1.12.2-1.8.9.txt index 0552052..cb8234a 100644 --- a/versions/1.12.2-1.8.9.txt +++ b/versions/1.12.2-1.8.9.txt @@ -1,5 +1,4 @@ net.minecraft.client.renderer.BufferBuilder net.minecraft.client.renderer.WorldRenderer -net.minecraft.util.text.ITextComponent net.minecraft.util.ChatComponentText net.minecraft.util.text.TextFormatting net.minecraft.util.EnumChatFormatting net.minecraft.util.text.TextComponentString net.minecraft.util.ChatComponentText net.minecraft.util.text.ITextComponent net.minecraft.util.IChatComponent diff --git a/versions/1.16.2-1.12.2.txt b/versions/1.16.2-1.12.2.txt index 5971266..43127b4 100644 --- a/versions/1.16.2-1.12.2.txt +++ b/versions/1.16.2-1.12.2.txt @@ -7,7 +7,7 @@ net.minecraft.resources.IResourceManager net.minecraft.client.resources.IResourc net.minecraft.client.renderer.texture.TextureUtil prepareImage() allocateTexture() net.minecraft.util.math.vector.Matrix3f org.lwjgl.util.vector.Matrix3f net.minecraft.util.math.vector.Matrix4f org.lwjgl.util.vector.Matrix4f -net.minecraft.util.math.vector.Matrix4f write() org.lwjgl.util.vector.Matrix4f store() +net.minecraft.util.math.vector.Matrix4f write(Ljava/nio/FloatBuffer;)V store(Ljava/nio/FloatBuffer;)Lorg/lwjgl/util/vector/Matrix; net.minecraft.util.math.vector.Quaternion org.lwjgl.util.vector.Quaternion net.minecraft.util.math.vector.Vector3f org.lwjgl.util.vector.Vector3f net.minecraft.util.math.vector.Vector4f org.lwjgl.util.vector.Vector4f diff --git a/versions/1.17.1-1.16.2.txt b/versions/1.17.1-1.16.2.txt index 0d9c3e4..05387a9 100644 --- a/versions/1.17.1-1.16.2.txt +++ b/versions/1.17.1-1.16.2.txt @@ -1,5 +1,6 @@ com.mojang.blaze3d.platform.TextureUtil net.minecraft.client.texture.TextureUtil com.mojang.blaze3d.platform.TextureUtil prepareImage() net.minecraft.client.texture.TextureUtil allocate() +com.mojang.blaze3d.platform.GlStateManager com.mojang.blaze3d.platform.GlStateManager com.mojang.blaze3d.platform.GlStateManager glCreateProgram() createProgram() com.mojang.blaze3d.platform.GlStateManager _glUseProgram() useProgram() com.mojang.blaze3d.platform.GlStateManager glCreateShader() createShader() From d0267766eded0d3beb33401571cc1cf06e6af781 Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Sat, 20 Jul 2024 11:26:56 +0200 Subject: [PATCH 2/3] Build: Cleanup unnecessary mappings Automaticaly generated via cleanupUnnecessaryMappings task. --- root.gradle.kts | 2 +- versions/1.12.2-1.8.9.txt | 10 ---------- versions/1.16.2-1.12.2.txt | 20 -------------------- 3 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 versions/1.12.2-1.8.9.txt diff --git a/root.gradle.kts b/root.gradle.kts index 756ac0b..8898226 100644 --- a/root.gradle.kts +++ b/root.gradle.kts @@ -60,5 +60,5 @@ preprocess { fabric11701.link(fabric11602, file("versions/1.17.1-1.16.2.txt")) fabric11602.link(forge11602) forge11602.link(forge11202, file("versions/1.16.2-1.12.2.txt")) - forge11202.link(forge10809, file("versions/1.12.2-1.8.9.txt")) + forge11202.link(forge10809) } diff --git a/versions/1.12.2-1.8.9.txt b/versions/1.12.2-1.8.9.txt deleted file mode 100644 index cb8234a..0000000 --- a/versions/1.12.2-1.8.9.txt +++ /dev/null @@ -1,10 +0,0 @@ -net.minecraft.client.renderer.BufferBuilder net.minecraft.client.renderer.WorldRenderer -net.minecraft.util.text.TextFormatting net.minecraft.util.EnumChatFormatting -net.minecraft.util.text.TextComponentString net.minecraft.util.ChatComponentText -net.minecraft.util.text.ITextComponent net.minecraft.util.IChatComponent -net.minecraft.util.text.Style net.minecraft.util.ChatStyle -net.minecraft.util.text.event.ClickEvent net.minecraft.event.ClickEvent -net.minecraft.util.text.event.HoverEvent net.minecraft.event.HoverEvent -net.minecraft.util.text.event.ClickEvent$Action net.minecraft.event.ClickEvent$Action -net.minecraft.util.text.event.HoverEvent$Action net.minecraft.event.HoverEvent$Action -net.minecraft.network.play.server.SPacketChat net.minecraft.network.play.server.S02PacketChat diff --git a/versions/1.16.2-1.12.2.txt b/versions/1.16.2-1.12.2.txt index 43127b4..f6dcd38 100644 --- a/versions/1.16.2-1.12.2.txt +++ b/versions/1.16.2-1.12.2.txt @@ -1,8 +1,3 @@ -net.minecraft.client.audio.SimpleSound net.minecraft.client.audio.PositionedSoundRecord -net.minecraft.client.audio.SimpleSound master() func_194007_a() -net.minecraft.util.SoundEvents BLOCK_NOTE_BLOCK_PLING net.minecraft.init.SoundEvents BLOCK_NOTE_PLING -net.minecraft.util.SoundEvents net.minecraft.init.SoundEvents -net.minecraft.client.renderer.texture.Texture net.minecraft.client.renderer.texture.AbstractTexture net.minecraft.resources.IResourceManager net.minecraft.client.resources.IResourceManager net.minecraft.client.renderer.texture.TextureUtil prepareImage() allocateTexture() net.minecraft.util.math.vector.Matrix3f org.lwjgl.util.vector.Matrix3f @@ -10,25 +5,10 @@ net.minecraft.util.math.vector.Matrix4f org.lwjgl.util.vector.Matrix4f net.minecraft.util.math.vector.Matrix4f write(Ljava/nio/FloatBuffer;)V store(Ljava/nio/FloatBuffer;)Lorg/lwjgl/util/vector/Matrix; net.minecraft.util.math.vector.Quaternion org.lwjgl.util.vector.Quaternion net.minecraft.util.math.vector.Vector3f org.lwjgl.util.vector.Vector3f -net.minecraft.util.math.vector.Vector4f org.lwjgl.util.vector.Vector4f net.minecraft.client.gui.screen.Screen net.minecraft.client.gui.GuiScreen net.minecraft.client.gui.widget.Widget net.minecraft.client.gui.GuiButton -net.minecraft.client.renderer.entity.RenderPlayer net.minecraft.client.renderer.entity.PlayerRenderer -net.minecraft.entity.player.PlayerEntity net.minecraft.entity.player.EntityPlayer com.mojang.blaze3d.systems.RenderSystem net.minecraft.client.renderer.GlStateManager com.mojang.blaze3d.systems.RenderSystem activeTexture() net.minecraft.client.renderer.GlStateManager setActiveTexture() com.mojang.blaze3d.systems.RenderSystem enableTexture() net.minecraft.client.renderer.GlStateManager enableTexture2D() com.mojang.blaze3d.systems.RenderSystem disableTexture() net.minecraft.client.renderer.GlStateManager disableTexture2D() -net.minecraft.client.renderer.vertex.VertexFormat hasUV() hasUvOffset() -net.minecraft.client.renderer.vertex.VertexFormatElement$Usage net.minecraft.client.renderer.vertex.VertexFormatElement$EnumUsage net.minecraft.client.renderer.vertex.DefaultVertexFormats POSITION_TEX_LIGHTMAP_COLOR POSITION_TEX_LMAP_COLOR -net.minecraft.client.renderer.entity.PlayerRenderer net.minecraft.client.renderer.entity.RenderPlayer -net.minecraft.client.world.ClientWorld net.minecraft.client.multiplayer.WorldClient -net.minecraft.client.entity.player.ClientPlayerEntity net.minecraft.client.entity.EntityPlayerSP -net.minecraft.client.network.play.ClientPlayNetHandler net.minecraft.client.network.NetHandlerPlayClient -net.minecraft.potion.EffectInstance net.minecraft.potion.PotionEffect -net.minecraft.util.text.StringTextComponent net.minecraft.util.text.TextComponentString -net.minecraft.client.GameSettings net.minecraft.client.settings.GameSettings -net.minecraft.client.gui.NewChatGui net.minecraft.client.gui.GuiNewChat -net.minecraft.client.gui.screen.MainMenuScreen net.minecraft.client.gui.GuiMainMenu -net.minecraft.network.play.server.SChatPacket net.minecraft.network.play.server.SPacketChat From 68411553c0e548f9efc33b9030fb6f90c556ff8b Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Sat, 20 Jul 2024 13:19:55 +0200 Subject: [PATCH 3/3] Build: Replace some preprocessor statements with mappings Now that preprocessor supports manual method mappings with specific descriptors, we can remap all of these via mappings instead of having to use preprocessor statements. The blendEquation one should have been using GlStateManager on 1.12.2 anyway. --- .../gg/essential/universal/UGraphics.java | 67 ++----------------- versions/1.16.2-1.12.2.txt | 13 ++++ 2 files changed, 19 insertions(+), 61 deletions(-) diff --git a/src/main/java/gg/essential/universal/UGraphics.java b/src/main/java/gg/essential/universal/UGraphics.java index 14caf26..b79c6b4 100644 --- a/src/main/java/gg/essential/universal/UGraphics.java +++ b/src/main/java/gg/essential/universal/UGraphics.java @@ -13,6 +13,7 @@ import gg.essential.universal.vertex.UVertexConsumer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.texture.SimpleTexture; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; @@ -70,19 +71,15 @@ //#if MC>=11502 //$$ import com.mojang.blaze3d.platform.GlStateManager; -//$$ import net.minecraft.client.renderer.BufferBuilder; //$$ import net.minecraft.client.renderer.texture.NativeImage; //$$ import java.io.ByteArrayInputStream; //$$ import java.io.ByteArrayOutputStream; -//#else -import static org.lwjgl.opengl.GL14.glBlendEquation; //#endif //#if MC>=11400 //$$ import net.minecraft.client.renderer.texture.Texture; //#else import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.texture.ITextureObject; //#endif @@ -232,8 +229,6 @@ public static void enableBlend() { public static void disableTexture2D() { //#if MC>=11904 //$$ // no-op - //#elseif MC>=11502 - //$$ RenderSystem.disableTexture(); //#else GlStateManager.disableTexture2D(); //#endif @@ -242,12 +237,8 @@ public static void disableTexture2D() { public static void disableAlpha() { //#if MC<11700 - //#if MC>=11502 - //$$ RenderSystem.disableAlphaTest(); - //#else GlStateManager.disableAlpha(); //#endif - //#endif } public static void shadeModel(int mode) { @@ -257,19 +248,15 @@ public static void shadeModel(int mode) { } public static void blendEquation(int equation) { - //#if MC>=11500 - //$$ RenderSystem.blendEquation(equation); + //#if MC>=10900 + //$$ GlStateManager.glBlendEquation(equation); //#else - glBlendEquation(equation); + org.lwjgl.opengl.GL14.glBlendEquation(equation); //#endif } public static void tryBlendFuncSeparate(int srcFactor, int dstFactor, int srcFactorAlpha, int dstFactorAlpha) { - //#if MC>=11502 - //$$ RenderSystem.blendFuncSeparate(srcFactor, dstFactor, srcFactorAlpha, dstFactorAlpha); - //#else GlStateManager.tryBlendFuncSeparate(srcFactor, dstFactor, srcFactorAlpha, dstFactorAlpha); - //#endif } /** @@ -284,8 +271,6 @@ public static void tryBlendFuncSeparate(int srcFactor, int dstFactor, int srcFac public static void enableTexture2D() { //#if MC>=11904 //$$ // no-op - //#elseif MC>=11502 - //$$ RenderSystem.enableTexture(); //#else GlStateManager.enableTexture2D(); //#endif @@ -301,12 +286,8 @@ public static void deleteTexture(int glTextureId) { public static void enableAlpha() { //#if MC<11700 - //#if MC>=11502 - //$$ RenderSystem.enableAlphaTest(); - //#else GlStateManager.enableAlpha(); //#endif - //#endif } public static void configureTexture(int glTextureId, Runnable block) { @@ -651,31 +632,19 @@ public static String glGetProgramInfoLog(int program, int maxLen) { } public static void color4f(float red, float green, float blue, float alpha) { - //#if MC<11502 GlStateManager.color(red, green, blue, alpha); - //#else - //$$ RenderSystem.color4f(red, green, blue, alpha); - //#endif } public static void directColor3f(float red, float green, float blue) { //#if MC>=11700 //$$ color4f(red, green, blue, 1f); //#else - //#if MC<11502 GlStateManager.color(red, green, blue); - //#else - //$$ RenderSystem.color3f(red, green, blue); - //#endif //#endif } public static void enableDepth() { - //#if MC<11502 GlStateManager.enableDepth(); - //#else - //$$ RenderSystem.enableDepthTest(); - //#endif } public static void depthFunc(int mode) { @@ -687,11 +656,7 @@ public static void depthMask(boolean flag) { } public static void disableDepth() { - //#if MC<11502 GlStateManager.disableDepth(); - //#else - //$$ RenderSystem.disableDepthTest(); - //#endif } //#if MC>=11700 @@ -1125,43 +1090,23 @@ public static void popMatrix() { } public static void translate(float x, float y, float z) { - //#if MC>=11502 - //$$ RenderSystem.translatef(x, y, z); - //#else - translate(x, y, (double) z); - //#endif + GlStateManager.translate(x, y, z); } public static void translate(double x, double y, double z) { - //#if MC>=11502 - //$$ RenderSystem.translated(x, y, z); - //#else GlStateManager.translate(x, y, z); - //#endif } public static void rotate(float angle, float x, float y, float z) { - //#if MC>=11502 - //$$ RenderSystem.rotatef(angle, x, y, z); - //#else GlStateManager.rotate(angle, x, y, z); - //#endif } public static void scale(float x, float y, float z) { - //#if MC>=11502 - //$$ RenderSystem.scalef(x, y, z); - //#else - scale(x, y, (double) z); - //#endif + GlStateManager.scale(x, y, z); } public static void scale(double x, double y, double z) { - //#if MC>=11502 - //$$ RenderSystem.scaled(x, y, z); - //#else GlStateManager.scale(x, y, z); - //#endif } } //#endif diff --git a/versions/1.16.2-1.12.2.txt b/versions/1.16.2-1.12.2.txt index f6dcd38..343f5e7 100644 --- a/versions/1.16.2-1.12.2.txt +++ b/versions/1.16.2-1.12.2.txt @@ -8,6 +8,19 @@ net.minecraft.util.math.vector.Vector3f org.lwjgl.util.vector.Vector3f net.minecraft.client.gui.screen.Screen net.minecraft.client.gui.GuiScreen net.minecraft.client.gui.widget.Widget net.minecraft.client.gui.GuiButton com.mojang.blaze3d.systems.RenderSystem net.minecraft.client.renderer.GlStateManager +com.mojang.blaze3d.systems.RenderSystem translated() translate(DDD)V +com.mojang.blaze3d.systems.RenderSystem translatef() translate(FFF)V +com.mojang.blaze3d.systems.RenderSystem rotatef() rotate(FFFF)V +com.mojang.blaze3d.systems.RenderSystem scalef() scale(FFF)V +com.mojang.blaze3d.systems.RenderSystem scaled() scale(DDD)V +com.mojang.blaze3d.systems.RenderSystem color3f() color(FFF)V +com.mojang.blaze3d.systems.RenderSystem color4f() color(FFFF)V +com.mojang.blaze3d.systems.RenderSystem enableDepthTest() enableDepth() +com.mojang.blaze3d.systems.RenderSystem disableDepthTest() disableDepth() +com.mojang.blaze3d.systems.RenderSystem enableAlphaTest() enableAlpha() +com.mojang.blaze3d.systems.RenderSystem disableAlphaTest() disableAlpha() +com.mojang.blaze3d.systems.RenderSystem blendEquation() glBlendEquation() +com.mojang.blaze3d.systems.RenderSystem blendFuncSeparate() tryBlendFuncSeparate() com.mojang.blaze3d.systems.RenderSystem activeTexture() net.minecraft.client.renderer.GlStateManager setActiveTexture() com.mojang.blaze3d.systems.RenderSystem enableTexture() net.minecraft.client.renderer.GlStateManager enableTexture2D() com.mojang.blaze3d.systems.RenderSystem disableTexture() net.minecraft.client.renderer.GlStateManager disableTexture2D()