|
44 | 44 | import static org.lwjgl.opengl.GL13.GL_ACTIVE_TEXTURE;
|
45 | 45 | import static org.lwjgl.opengl.GL13.GL_TEXTURE0;
|
46 | 46 |
|
| 47 | +//#if MC>=12102 |
| 48 | +//$$ import net.minecraft.client.gl.ShaderProgramKey; |
| 49 | +//$$ import net.minecraft.client.gl.ShaderProgramKeys; |
| 50 | +//$$ import java.util.HashMap; |
| 51 | +//#endif |
| 52 | + |
47 | 53 | //#if MC>=12100
|
48 | 54 | //$$ import net.minecraft.client.render.BufferRenderer;
|
49 | 55 | //$$ import net.minecraft.client.render.BuiltBuffer;
|
@@ -837,7 +843,11 @@ public static void disableDepth() {
|
837 | 843 |
|
838 | 844 | //#if MC>=11700 && !STANDALONE
|
839 | 845 | //$$ public static void setShader(Supplier<Shader> shader) {
|
840 |
| - //$$ RenderSystem.setShader(shader); |
| 846 | + //#if MC>=12102 |
| 847 | + //$$ RenderSystem.setShader(shader.get()); |
| 848 | + //#else |
| 849 | + //$$ RenderSystem.setShader(shader); |
| 850 | + //#endif |
841 | 851 | //$$ }
|
842 | 852 | //#endif
|
843 | 853 |
|
@@ -971,7 +981,20 @@ public UGraphics beginWithActiveShader(DrawMode mode, VertexFormat format) {
|
971 | 981 | }
|
972 | 982 | //#endif
|
973 | 983 |
|
974 |
| - //#if MC>=11700 && !STANDALONE |
| 984 | + //#if STANDALONE |
| 985 | + //#elseif MC>=12102 |
| 986 | + //$$ private static final Map<VertexFormat, ShaderProgramKey> DEFAULT_SHADERS = new HashMap<>(); |
| 987 | + //$$ static { |
| 988 | + //$$ DEFAULT_SHADERS.put(VertexFormats.LINES, ShaderProgramKeys.RENDERTYPE_LINES); |
| 989 | + //$$ DEFAULT_SHADERS.put(VertexFormats.POSITION_TEXTURE_COLOR_LIGHT, ShaderProgramKeys.PARTICLE); |
| 990 | + //$$ DEFAULT_SHADERS.put(VertexFormats.POSITION, ShaderProgramKeys.POSITION); |
| 991 | + //$$ DEFAULT_SHADERS.put(VertexFormats.POSITION_COLOR, ShaderProgramKeys.POSITION_COLOR); |
| 992 | + //$$ DEFAULT_SHADERS.put(VertexFormats.POSITION_COLOR_LIGHT, ShaderProgramKeys.POSITION_COLOR_LIGHTMAP); |
| 993 | + //$$ DEFAULT_SHADERS.put(VertexFormats.POSITION_TEXTURE, ShaderProgramKeys.POSITION_TEX); |
| 994 | + //$$ DEFAULT_SHADERS.put(VertexFormats.POSITION_TEXTURE_COLOR, ShaderProgramKeys.POSITION_TEX_COLOR); |
| 995 | + //$$ DEFAULT_SHADERS.put(VertexFormats.POSITION_COLOR_TEXTURE_LIGHT, ShaderProgramKeys.POSITION_COLOR_TEX_LIGHTMAP); |
| 996 | + //$$ } |
| 997 | + //#elseif MC>=11700 |
975 | 998 | //$$ // Note: Needs to be an Identity hash map because VertexFormat's equals method is broken (compares via its
|
976 | 999 | //$$ // component Map but order very much matters for VertexFormat) as of 1.17
|
977 | 1000 | //$$ private static final Map<VertexFormat, Supplier<Shader>> DEFAULT_SHADERS = new IdentityHashMap<>();
|
@@ -1011,11 +1034,16 @@ public UGraphics beginWithDefaultShader(DrawMode mode, CommonVertexFormats forma
|
1011 | 1034 | //#if !STANDALONE
|
1012 | 1035 | public UGraphics beginWithDefaultShader(DrawMode mode, VertexFormat format) {
|
1013 | 1036 | //#if MC>=11700
|
1014 |
| - //$$ Supplier<Shader> supplier = DEFAULT_SHADERS.get(format); |
1015 |
| - //$$ if (supplier == null) { |
| 1037 | + //#if MC>=12102 |
| 1038 | + //$$ ShaderProgramKey shader = DEFAULT_SHADERS.get(format); |
| 1039 | + //#else |
| 1040 | + //$$ Supplier<Shader> shader = DEFAULT_SHADERS.get(format); |
| 1041 | + //#endif |
| 1042 | + //$$ if (shader == null) { |
1016 | 1043 | //$$ throw new IllegalArgumentException("No default shader for " + format + ". Bind your own and use beginWithActiveShader instead.");
|
1017 | 1044 | //$$ }
|
1018 |
| - //$$ setShader(supplier); |
| 1045 | + //$$ |
| 1046 | + //$$ RenderSystem.setShader(shader); |
1019 | 1047 | //#endif
|
1020 | 1048 | return beginWithActiveShader(mode, format);
|
1021 | 1049 | }
|
@@ -1079,8 +1107,12 @@ public void drawSorted(int cameraX, int cameraY, int cameraZ) {
|
1079 | 1107 | //#else
|
1080 | 1108 | //#if MC>=12100
|
1081 | 1109 | //$$ BuiltBuffer builtBuffer = instance.end();
|
| 1110 | + //#if MC>=12102 |
| 1111 | + //$$ builtBuffer.sortQuads(SORTED_QUADS_ALLOCATOR, RenderSystem.getProjectionType().getVertexSorter()); |
| 1112 | + //#else |
1082 | 1113 | //$$ builtBuffer.sortQuads(SORTED_QUADS_ALLOCATOR, RenderSystem.getVertexSorting());
|
1083 | 1114 | //#endif
|
| 1115 | + //#endif |
1084 | 1116 | //#if MC>=11600
|
1085 | 1117 | //$$ if (renderLayer != null) {
|
1086 | 1118 | //#if MC>=12100
|
|
0 commit comments