Skip to content
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
162 changes: 86 additions & 76 deletions api/UniversalCraft.api

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions root.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ version = versionFromBuildIdAndBranch()
preprocess {
strictExtraMappings.set(true)

val fabric12111 = createNode("1.21.11-fabric", 12111, "srg")
val fabric12109 = createNode("1.21.9-fabric", 12109, "srg")
val neoForge12107 = createNode("1.21.7-neoforge", 12107, "srg")
val forge12107 = createNode("1.21.7-forge", 12107, "srg")
Expand Down Expand Up @@ -57,6 +58,7 @@ preprocess {
val forge11202 = createNode("1.12.2-forge", 11202, "srg")
val forge10809 = createNode("1.8.9-forge", 10809, "srg")

fabric12111.link(fabric12109)
fabric12109.link(fabric12107)
neoForge12107.link(fabric12107)
forge12107.link(fabric12107)
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ listOf(
"1.21.7-forge",
"1.21.7-neoforge",
"1.21.9-fabric",
"1.21.11-fabric",
).forEach { version ->
include(":$version")
project(":$version").apply {
Expand Down
53 changes: 48 additions & 5 deletions src/main/java/gg/essential/universal/UGraphics.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
import static org.lwjgl.opengl.GL13.GL_ACTIVE_TEXTURE;
import static org.lwjgl.opengl.GL13.GL_TEXTURE0;

//#if MC>=12111
//$$ import com.mojang.blaze3d.textures.FilterMode;
//#endif

//#if MC>=12109
//$$ import net.minecraft.client.font.TextDrawable;
//$$ import net.minecraft.text.StyleSpriteSource;
Expand Down Expand Up @@ -519,9 +523,12 @@ public static void bindTexture(ResourceLocation resourceLocation) {
}
//#endif

@Deprecated // see UGraphics.Globals
public static void bindTexture(int index, int glTextureId) {
//#if STANDALONE
//$$ configureTextureUnit(index, () -> glBindTexture(GL_TEXTURE_2D, glTextureId));
//#elseif MC>=12111
//$$ throw new UnsupportedOperationException("No longer supported on 1.21.11+, use `UBufferBuilder`/`URenderPipeline` instead.");
//#elseif MC>=12106
//$$ RenderSystem.setShaderTexture(index, RenderSystem.getDevice().createTextureView(new UnownedGlTexture(glTextureId)));
//#elseif MC>=12105
Expand All @@ -534,6 +541,7 @@ public static void bindTexture(int index, int glTextureId) {
}

//#if !STANDALONE
@Deprecated // see UGraphics.Globals
public static void bindTexture(int index, ResourceLocation resourceLocation) {
bindTexture(index, getOrLoadTextureId(resourceLocation));
}
Expand Down Expand Up @@ -687,8 +695,13 @@ public static void drawString(UMatrixStack stack, String text, float x, float y,
//$$ try (URenderPass renderPass = new URenderPass()) {
//$$ renderPass.draw(UBuiltBuffer.wrap(builtBuffer), URenderPipeline.wrap(pipeline), builder -> {
//$$ RenderPass mcRenderPass = ((URenderPass.DrawCallBuilderImpl) builder).getMc();
//$$ mcRenderPass.bindSampler("Sampler0", texture);
//$$ mcRenderPass.bindSampler("Sampler2", lightTexture);
//#if MC>=12111
//$$ mcRenderPass.bindTexture("Sampler0", texture, RenderSystem.getSamplerCache().get(FilterMode.NEAREST));
//$$ mcRenderPass.bindTexture("Sampler2", lightTexture, RenderSystem.getSamplerCache().get(FilterMode.LINEAR));
//#else
//$$ mcRenderPass.bindSampler("Sampler0", texture);
//$$ mcRenderPass.bindSampler("Sampler2", lightTexture);
//#endif
//$$ return kotlin.Unit.INSTANCE;
//$$ });
//$$ }
Expand All @@ -705,7 +718,11 @@ public static void drawString(UMatrixStack stack, String text, float x, float y,
//$$ }
//$$ drawable.render(matrix, bufferBuilder, LIGHT, false);
//$$ }
//#if MC>=12111
//$$ @Override public void drawGlyph(TextDrawable.DrawnGlyphRect glyph) { draw(glyph); }
//#else
//$$ @Override public void drawGlyph(TextDrawable drawable) { draw(drawable); }
//#endif
//$$ @Override public void drawRectangle(TextDrawable drawable) { draw(drawable); }
//#else
//$$ private void setupBuffer(BakedGlyph bakedGlyph) {
Expand Down Expand Up @@ -1028,6 +1045,10 @@ public static void disableScissor() {

public enum DrawMode {
LINES(GL11.GL_LINES),
/**
* @deprecated No longer properly supported as of 1.21.11, use {@link #LINES} instead
*/
@Deprecated
LINE_STRIP(GL11.GL_LINE_STRIP),
TRIANGLES(GL11.GL_TRIANGLES),
TRIANGLE_STRIP(GL11.GL_TRIANGLE_STRIP),
Expand Down Expand Up @@ -1059,7 +1080,11 @@ public enum DrawMode {
//$$ private static VertexFormat.DrawMode glToMcDrawMode(int glMode) {
//$$ switch (glMode) {
//$$ case GL11.GL_LINES: return VertexFormat.DrawMode.LINES;
//$$ case GL11.GL_LINE_STRIP: return VertexFormat.DrawMode.LINE_STRIP;
//#if MC>=12111
//$$ case GL11.GL_LINE_STRIP: return VertexFormat.DrawMode.DEBUG_LINE_STRIP;
//#else
//$$ case GL11.GL_LINE_STRIP: return VertexFormat.DrawMode.LINE_STRIP;
//#endif
//$$ case GL11.GL_TRIANGLES: return VertexFormat.DrawMode.TRIANGLES;
//$$ case GL11.GL_TRIANGLE_STRIP: return VertexFormat.DrawMode.TRIANGLE_STRIP;
//$$ case GL11.GL_TRIANGLE_FAN: return VertexFormat.DrawMode.TRIANGLE_FAN;
Expand All @@ -1071,7 +1096,11 @@ public enum DrawMode {
//$$ private static DrawMode fromMc(VertexFormat.DrawMode mcMode) {
//$$ switch (mcMode) {
//$$ case LINES: return DrawMode.LINES;
//$$ case LINE_STRIP: return DrawMode.LINE_STRIP;
//#if MC>=12111
//$$ case DEBUG_LINE_STRIP: return DrawMode.LINE_STRIP;
//#else
//$$ case LINE_STRIP: return DrawMode.LINE_STRIP;
//#endif
//$$ case TRIANGLES: return DrawMode.TRIANGLES;
//$$ case TRIANGLE_STRIP: return DrawMode.TRIANGLE_STRIP;
//$$ case TRIANGLE_FAN: return DrawMode.TRIANGLE_FAN;
Expand Down Expand Up @@ -1543,7 +1572,7 @@ public UGraphics light(int u, int v) {
return this;
}

//#if MC>=12105 && !STANDALONE
//#if MC>=12105 && MC<12111
//$$ private static class UnownedGlTexture extends GlTexture {
//$$ public UnownedGlTexture(int glId) {
//#if MC>=12106
Expand Down Expand Up @@ -1606,6 +1635,8 @@ public static void scale(double x, double y, double z) {
* {@code RenderSystem.setShaderTexture}, but just like the vanilla {@code RenderPipeline},
* {@code URenderPipeline} also requires textures to be set explicitly, despite {@code UGraphics.bindTexture} not
* yet being deprecated (because it's still used for {@code RenderLayer}).
* <br>
* Update: As of 1.21.11, {@code UGraphics.bindTexture} is now deprecated too.
* <p>
* If you need to still use the old global state on versions prior to 1.21.5, you may use the methods declared in
* this class. They are functionally identical to the ones in UGraphics but are not deprecated with the
Expand Down Expand Up @@ -1691,5 +1722,17 @@ public UGraphics beginWithDefaultShader(DrawMode mode, VertexFormat format) {
}
//#endif
//#endif

//#if MC<12111 || STANDALONE
public static void bindTexture(int index, int glTextureId) {
UGraphics.bindTexture(index, glTextureId);
}

//#if !STANDALONE
public static void bindTexture(int index, ResourceLocation resourceLocation) {
UGraphics.bindTexture(index, resourceLocation);
}
//#endif
//#endif
}
}
14 changes: 13 additions & 1 deletion src/main/kotlin/gg/essential/universal/render/URenderPass.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import gg.essential.universal.vertex.UBuiltBufferInternal

//#if STANDALONE
//#else
//#if MC>=12111
//$$ import net.minecraft.client.render.RenderLayers
//#endif

//#if MC>=12106
//$$ import com.mojang.blaze3d.buffers.GpuBuffer
//$$ import org.lwjgl.system.MemoryStack
Expand Down Expand Up @@ -64,8 +68,12 @@ internal class URenderPass : AutoCloseable {
//#else
//$$ RenderSystem.getModelOffset(),
//#endif
//#if MC>=12111
//$$ org.joml.Matrix4f(),
//#else
//$$ RenderSystem.getTextureMatrix(),
//$$ RenderSystem.getShaderLineWidth(),
//#endif
//$$ )
//#endif
//$$ val builtBuffer = builtBuffer.mc
Expand Down Expand Up @@ -158,11 +166,15 @@ internal class URenderPass : AutoCloseable {
//#else
//$$ val texture = object : GlTexture("", TextureFormat.RGBA8, 0, 0, 0, textureGlId) {
//#endif
//#if MC<12111
//$$ init {
//$$ needsReinit = false
//$$ }
//#endif
//$$ }
//#if MC>=12106
//#if MC>=12111
//$$ mc.bindTexture(name, RenderSystem.getDevice().createTextureView(texture), RenderLayers.BLOCK_SAMPLER.get())
//#elseif MC>=12106
//$$ mc.bindSampler(name, RenderSystem.getDevice().createTextureView(texture))
//#else
//$$ mc.bindSampler(name, texture)
Expand Down
17 changes: 12 additions & 5 deletions src/main/kotlin/gg/essential/universal/render/URenderPipeline.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import net.minecraft.util.ResourceLocation
//$$ import net.minecraft.client.gl.UniformType
//$$ import net.minecraft.client.render.BuiltBuffer
//$$ import org.apache.commons.codec.digest.DigestUtils
//$$ import java.util.function.BiFunction
//#else
import gg.essential.universal.shader.UShader
import gg.essential.universal.vertex.UBuiltBufferInternal
Expand Down Expand Up @@ -66,14 +65,22 @@ import net.minecraft.client.renderer.vertex.VertexFormatElement

//#endif

//#if MC>=12105 && !STANDALONE
//#if MC>=12111
//$$ typealias ShaderSourceGetter = net.minecraft.client.gl.ShaderSourceGetter
//#else
//$$ typealias ShaderSourceGetter = java.util.function.BiFunction<Identifier, ShaderType, String?>
//#endif
//#endif

class URenderPipeline private constructor(
private val id: ResourceLocation,
internal val format: VertexFormat,
//#if STANDALONE
//$$ private val drawMode: DrawMode,
//#endif
//#if MC>=12105 && !STANDALONE
//$$ private var shaderSourceGetter: BiFunction<Identifier, ShaderType, String?>?,
//$$ private var shaderSourceGetter: ShaderSourceGetter?,
//$$ internal val mcRenderPipeline: RenderPipeline,
//#else
private val shader: ShaderSupplier?,
Expand Down Expand Up @@ -230,7 +237,7 @@ class URenderPipeline private constructor(
//$$ return
//$$ }
//#endif
null -> UGraphics.bindTexture(index, glId)
null -> UGraphics.Globals.bindTexture(index, glId)
}
}
//#endif
Expand Down Expand Up @@ -365,7 +372,7 @@ class URenderPipeline private constructor(
) : Builder, BuilderProps by BuilderPropsImpl() {
override fun build(): URenderPipeline {
//#if MC>=12105 && !STANDALONE
//$$ var shaderSourceGetter: BiFunction<Identifier, ShaderType, String?>? = null
//$$ var shaderSourceGetter: ShaderSourceGetter? = null
//$$ var mcRenderPipeline = RenderPipeline.builder().apply {
//$$ withLocation(id)
//$$ withVertexFormat(format, drawMode.mcMode)
Expand All @@ -379,7 +386,7 @@ class URenderPipeline private constructor(
//$$ val vertId = Identifier.of("universalcraft", "shader/generated/" + DigestUtils.sha1Hex(transformedVertSource).lowercase())
//$$ val fragId = Identifier.of("universalcraft", "shader/generated/" + DigestUtils.sha1Hex(transformedFragSource).lowercase())
//$$
//$$ shaderSourceGetter = BiFunction { id: Identifier, type: ShaderType ->
//$$ shaderSourceGetter = ShaderSourceGetter { id: Identifier, type: ShaderType ->
//$$ when (id) {
//$$ vertId -> transformedVertSource
//$$ fragId -> transformedFragSource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import gg.essential.universal.UGraphics
//$$ import org.lwjgl.opengl.GL20C
//$$ import java.nio.Buffer
//#else
//#if MC>=12111
//$$ import com.mojang.blaze3d.textures.AddressMode
//#endif

//#if MC>=12106
//$$ import com.mojang.blaze3d.textures.GpuTextureView
//#endif
Expand Down Expand Up @@ -126,6 +130,9 @@ class ReleasedDynamicTexture private constructor(
//#else
//$$ val texture = device.createTexture(null as String?, TextureFormat.RGBA8, width, height, 1)
//#endif
//#if MC>=12111
//$$ sampler = RenderSystem.getSamplerCache().get(AddressMode.REPEAT, AddressMode.REPEAT, FilterMode.LINEAR, FilterMode.NEAREST, true);
//#else
//$$ texture.setTextureFilter(FilterMode.NEAREST, true)
//$$ UGraphics.configureTexture((texture as GlTexture).glId) {
//#if MC>=12106
Expand All @@ -134,6 +141,7 @@ class ReleasedDynamicTexture private constructor(
//$$ texture.checkDirty()
//#endif
//$$ }
//#endif
//$$ device.createCommandEncoder().writeToTexture(texture, textureData!!)
//$$ textureData = null
//$$ uploaded = true
Expand Down Expand Up @@ -200,12 +208,15 @@ class ReleasedDynamicTexture private constructor(
//$$ return super.getGlTextureView()
//$$ }
//$$
//#if MC<12111
//$$ override fun setUseMipmaps(mipmaps: Boolean) {
//$$ uploadTexture()
//$$ super.setUseMipmaps(mipmaps)
//$$ }
//#endif
//#endif
//$$
//#if MC<12111
//$$ override fun setClamp(clamp: Boolean) {
//$$ uploadTexture()
//$$ super.setClamp(clamp)
Expand All @@ -215,6 +226,7 @@ class ReleasedDynamicTexture private constructor(
//$$ uploadTexture()
//$$ super.setFilter(bilinear, mipmap)
//$$ }
//#endif
//$$
//$$ override fun getGlTexture(): GpuTexture {
//$$ uploadTexture()
Expand Down
4 changes: 4 additions & 0 deletions versions/1.21.11-fabric/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
essential.defaults.loom.minecraft=com.mojang:minecraft:1.21.11-pre5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pending release

Copy link
Contributor

@Traben-0 Traben-0 Dec 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now that i look further it seems we've just left these as is in the RC stages historically so this can be a nit i guess ¯\(ツ)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, can't bump it to to release prior to merge if we want to have Essential ready by release.

They'll usually be cleaned once essential-gradle-toolkit adds a default for that version and we bump our egt dependency.

essential.defaults.loom.mappings=net.fabricmc:yarn:1.21.11-pre5+build.1:v2
# Required because our Loom doesn't yet support the unpick version included in the above yarn version
essential.loom.disableUnpick=true
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ internal class TemporaryTextureAllocator(
height,
1,
1
).apply { setTextureFilter(FilterMode.NEAREST, false) }
).apply {
//#if MC<12111
setTextureFilter(FilterMode.NEAREST, false)
//#endif
}
var depthTexture = gpuDevice.createTexture(
{ "Pre-rendered depth texture" },
GpuTexture.USAGE_RENDER_ATTACHMENT,
Expand Down
Loading