Compare commits

..
12 Commits
43 changed files with 827 additions and 78 deletions

No files matched your search

+1 -1
View File
@@ -1,4 +1,4 @@
# Description or your *PR* and other info
# Description of your *PR* and other info
<!-- Please include a summary of the change -->
<!-- Any details that you think are important to review this PR? -->
<!-- Are there any Issues / PRs related to this one? -->
+1
View File
@@ -12,6 +12,7 @@ build/
/config/
/crash-reports/
/logs/
tmp/
options.txt
/saves/
usernamecache.json
+1 -1
View File
@@ -144,7 +144,7 @@ dependencies {
compileOnly(rfg.deobf("curse.maven:campfirebackport-387444:4611675"))
compileOnly(rfg.deobf("curse.maven:xaeros-minimap-263420:5060684"))
compileOnly(rfg.deobf("curse.maven:security-craft-64760:2818228"))
compileOnly(rfg.deobf("curse.maven:et-futurum-requiem-441392:5873837"))
compileOnly("ganymedes01.etfuturum:Et-Futurum-Requiem:2.6.49-GTNH:dev")
compileOnly(rfg.deobf("curse.maven:biomes-o-plenty-220318:2499612"))
devOnlyNonPublishable("com.github.GTNewHorizons:CosmeticArmorReworked:1.0.3-GTNH:dev")
@@ -89,6 +89,7 @@ import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.LongBuffer;
import java.nio.ShortBuffer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
@@ -5174,6 +5175,12 @@ public class GLStateManager {
RENDER_BACKEND.deleteBuffers(buffers);
}
public static void glDeleteBuffers(int[] buffers) {
for (int buffer : buffers) {
glDeleteBuffers(buffer);
}
}
private static void invalidateDeletedBuffer(int buffer) {
if (buffer == 0) return;
if (boundVBO == buffer) boundVBO = 0;
@@ -5185,6 +5192,7 @@ public class GLStateManager {
for (VAOManager.VAOData data : VAOManager.vaoMap.values()) {
if (data.ebo == buffer) data.ebo = 0;
}
}
public static void glBindBuffer(int target, int buffer) {
@@ -5237,34 +5245,279 @@ public class GLStateManager {
return RENDER_BACKEND.genBuffers();
}
public static void glGenBuffers(IntBuffer buffers) {
for (int i = buffers.position(); i < buffers.limit(); i++) buffers.put(i, RENDER_BACKEND.genBuffers());
}
public static void glGenBuffers(int[] buffers) {
for (int i = 0; i < buffers.length; i++) buffers[i] = RENDER_BACKEND.genBuffers();
}
public static int glCreateBuffers() {
return RENDER_BACKEND.createBuffers();
}
public static void glCreateBuffers(IntBuffer buffers) {
for (int i = buffers.position(); i < buffers.limit(); i++) buffers.put(i, RENDER_BACKEND.createBuffers());
}
public static void glCreateBuffers(int[] buffers) {
for (int i = 0; i < buffers.length; i++) buffers[i] = RENDER_BACKEND.createBuffers();
}
public static void glBufferData(int target, long size, int usage) { RENDER_BACKEND.bufferData(target, size, usage); }
public static void glBufferData(int target, ByteBuffer data, int usage) { RENDER_BACKEND.bufferData(target, data, usage); }
public static void glBufferData(int target, ShortBuffer data, int usage) { RENDER_BACKEND.bufferData(target, data, usage); }
public static void glBufferData(int target, IntBuffer data, int usage) { RENDER_BACKEND.bufferData(target, data, usage); }
public static void glBufferData(int target, FloatBuffer data, int usage) { RENDER_BACKEND.bufferData(target, data, usage); }
public static void glBufferData(int target, DoubleBuffer data, int usage) { RENDER_BACKEND.bufferData(target, data, usage); }
public static void glBufferData(int target, LongBuffer data, int usage) { glBufferData(target, MemoryUtilities.memByteBuffer(data), usage); }
public static void glBufferData(int target, int[] data, int usage) { RENDER_BACKEND.bufferData(target, data, usage); }
public static void glBufferData(int target, float[] data, int usage) { RENDER_BACKEND.bufferData(target, data, usage); }
public static void glBufferData(int target, java.nio.ByteBuffer data, int usage) { RENDER_BACKEND.bufferData(target, data, usage); }
public static void glBufferData(int target, java.nio.ShortBuffer data, int usage) { RENDER_BACKEND.bufferData(target, data, usage); }
public static void glBufferData(int target, java.nio.IntBuffer data, int usage) { RENDER_BACKEND.bufferData(target, data, usage); }
public static void glBufferData(int target, java.nio.FloatBuffer data, int usage) { RENDER_BACKEND.bufferData(target, data, usage); }
public static void glBufferData(int target, java.nio.DoubleBuffer data, int usage) { RENDER_BACKEND.bufferData(target, data, usage); }
public static void glBufferSubData(int target, long offset, java.nio.ByteBuffer data) { RENDER_BACKEND.bufferSubData(target, offset, data); }
public static void glBufferSubData(int target, long offset, java.nio.ShortBuffer data) { RENDER_BACKEND.bufferSubData(target, offset, data); }
public static void glBufferSubData(int target, long offset, java.nio.IntBuffer data) { RENDER_BACKEND.bufferSubData(target, offset, data); }
public static void glBufferSubData(int target, long offset, java.nio.FloatBuffer data) { RENDER_BACKEND.bufferSubData(target, offset, data); }
public static void glBufferSubData(int target, long offset, java.nio.DoubleBuffer data) { RENDER_BACKEND.bufferSubData(target, offset, data); }
public static void glBufferData(int target, short[] data, int usage) {
final ByteBuffer copy = copyOf(data);
glBufferData(target, copy, usage);
MemoryUtilities.memFree(copy);
}
public static void glBufferData(int target, long[] data, int usage) {
final ByteBuffer copy = copyOf(data);
glBufferData(target, copy, usage);
MemoryUtilities.memFree(copy);
}
public static void glBufferData(int target, double[] data, int usage) {
final ByteBuffer copy = copyOf(data);
glBufferData(target, copy, usage);
MemoryUtilities.memFree(copy);
}
public static void nglBufferData(int target, long size, long data, int usage) {
if (data == 0L) {
glBufferData(target, size, usage);
return;
}
glBufferData(target, MemoryUtilities.memByteBuffer(data, checkedSize(size)), usage);
}
public static void glBufferSubData(int target, long offset, ByteBuffer data) { RENDER_BACKEND.bufferSubData(target, offset, data); }
public static void glBufferSubData(int target, long offset, ShortBuffer data) { RENDER_BACKEND.bufferSubData(target, offset, data); }
public static void glBufferSubData(int target, long offset, IntBuffer data) { RENDER_BACKEND.bufferSubData(target, offset, data); }
public static void glBufferSubData(int target, long offset, FloatBuffer data) { RENDER_BACKEND.bufferSubData(target, offset, data); }
public static void glBufferSubData(int target, long offset, DoubleBuffer data) { RENDER_BACKEND.bufferSubData(target, offset, data); }
public static void glBufferSubData(int target, long offset, LongBuffer data) { glBufferSubData(target, offset, MemoryUtilities.memByteBuffer(data)); }
public static void glBufferSubData(int target, long offset, short[] data) {
final ByteBuffer copy = copyOf(data);
glBufferSubData(target, offset, copy);
MemoryUtilities.memFree(copy);
}
public static void glBufferSubData(int target, long offset, int[] data) {
final ByteBuffer copy = copyOf(data);
glBufferSubData(target, offset, copy);
MemoryUtilities.memFree(copy);
}
public static void glBufferSubData(int target, long offset, long[] data) {
final ByteBuffer copy = copyOf(data);
glBufferSubData(target, offset, copy);
MemoryUtilities.memFree(copy);
}
public static void glBufferSubData(int target, long offset, float[] data) {
final ByteBuffer copy = copyOf(data);
glBufferSubData(target, offset, copy);
MemoryUtilities.memFree(copy);
}
public static void glBufferSubData(int target, long offset, double[] data) {
final ByteBuffer copy = copyOf(data);
glBufferSubData(target, offset, copy);
MemoryUtilities.memFree(copy);
}
public static void nglBufferSubData(int target, long offset, long size, long data) { glBufferSubData(target, offset, MemoryUtilities.memByteBuffer(data, checkedSize(size))); }
public static ByteBuffer glMapBuffer(int target, int access) { return RENDER_BACKEND.mapBuffer(target, access); }
public static ByteBuffer glMapBuffer(int target, int access, ByteBuffer old_buffer) { return glMapBuffer(target, access); }
public static ByteBuffer glMapBuffer(int target, int access, long length, ByteBuffer old_buffer) { return RENDER_BACKEND.mapBuffer(target, access, length, old_buffer); }
public static ByteBuffer glMapBufferRange(int target, long offset, long length, int access) { return RENDER_BACKEND.mapBufferRange(target, offset, length, access); }
public static ByteBuffer glMapBufferRange(int target, long offset, long length, int access, ByteBuffer old_buffer) { return glMapBufferRange(target, offset, length, access); }
public static void glFlushMappedBufferRange(int target, long offset, long length) { RENDER_BACKEND.flushMappedBufferRange(target, offset, length); }
public static boolean glUnmapBuffer(int target) { return RENDER_BACKEND.unmapBuffer(target); }
public static void glGetBufferSubData(int target, long offset, java.nio.ByteBuffer data) { RENDER_BACKEND.getBufferSubData(target, offset, data); }
public static void glGetBufferSubData(int target, long offset, java.nio.ShortBuffer data) { RENDER_BACKEND.getBufferSubData(target, offset, data); }
public static void glGetBufferSubData(int target, long offset, java.nio.IntBuffer data) { RENDER_BACKEND.getBufferSubData(target, offset, data); }
public static void glGetBufferSubData(int target, long offset, java.nio.FloatBuffer data) { RENDER_BACKEND.getBufferSubData(target, offset, data); }
public static void glGetBufferSubData(int target, long offset, java.nio.DoubleBuffer data) { RENDER_BACKEND.getBufferSubData(target, offset, data); }
public static void glGetBufferSubData(int target, long offset, ByteBuffer data) { RENDER_BACKEND.getBufferSubData(target, offset, data); }
public static void glGetBufferSubData(int target, long offset, ShortBuffer data) { RENDER_BACKEND.getBufferSubData(target, offset, data); }
public static void glGetBufferSubData(int target, long offset, IntBuffer data) { RENDER_BACKEND.getBufferSubData(target, offset, data); }
public static void glGetBufferSubData(int target, long offset, FloatBuffer data) { RENDER_BACKEND.getBufferSubData(target, offset, data); }
public static void glGetBufferSubData(int target, long offset, DoubleBuffer data) { RENDER_BACKEND.getBufferSubData(target, offset, data); }
public static void glGetBufferSubData(int target, long offset, LongBuffer data) { glGetBufferSubData(target, offset, MemoryUtilities.memByteBuffer(data)); }
public static void glGetBufferSubData(int target, long offset, short[] data) {
final ByteBuffer copy = MemoryUtilities.memAlloc(data.length << 1);
glGetBufferSubData(target, offset, copy);
copy.asShortBuffer().get(data);
MemoryUtilities.memFree(copy);
}
public static void glGetBufferSubData(int target, long offset, int[] data) {
final ByteBuffer copy = MemoryUtilities.memAlloc(data.length << 2);
glGetBufferSubData(target, offset, copy);
copy.asIntBuffer().get(data);
MemoryUtilities.memFree(copy);
}
public static void glGetBufferSubData(int target, long offset, long[] data) {
final ByteBuffer copy = MemoryUtilities.memAlloc(data.length << 3);
glGetBufferSubData(target, offset, copy);
copy.asLongBuffer().get(data);
MemoryUtilities.memFree(copy);
}
public static void glGetBufferSubData(int target, long offset, float[] data) {
final ByteBuffer copy = MemoryUtilities.memAlloc(data.length << 2);
glGetBufferSubData(target, offset, copy);
copy.asFloatBuffer().get(data);
MemoryUtilities.memFree(copy);
}
public static void glGetBufferSubData(int target, long offset, double[] data) {
final ByteBuffer copy = MemoryUtilities.memAlloc(data.length << 3);
glGetBufferSubData(target, offset, copy);
copy.asDoubleBuffer().get(data);
MemoryUtilities.memFree(copy);
}
public static void nglGetBufferSubData(int target, long offset, long size, long data) { glGetBufferSubData(target, offset, MemoryUtilities.memByteBuffer(data, checkedSize(size))); }
public static int glGetBufferParameteri(int target, int pname) { return RENDER_BACKEND.getBufferParameteri(target, pname); }
public static void glBufferStorage(int target, java.nio.ByteBuffer data, int flags) { RENDER_BACKEND.bufferStorage(target, data, flags); }
public static int glGetBufferParameter(int target, int pname) { return glGetBufferParameteri(target, pname); }
public static void glGetBufferParameter(int target, int pname, IntBuffer params) { params.put(params.position(), glGetBufferParameteri(target, pname)); }
public static void glGetBufferParameteriv(int target, int pname, IntBuffer params) { params.put(params.position(), glGetBufferParameteri(target, pname)); }
public static void glGetBufferParameteriv(int target, int pname, int[] params) { params[0] = glGetBufferParameteri(target, pname); }
public static void glBufferStorage(int target, long size, int flags) { RENDER_BACKEND.bufferStorage(target, size, flags); }
public static void glClearBufferSubData(int target, int internalFormat, long offset, long size, int format, int type, java.nio.ByteBuffer data) { RENDER_BACKEND.clearBufferSubData(target, internalFormat, offset, size, format, type, data); }
public static void glBufferStorage(int target, ByteBuffer data, int flags) { RENDER_BACKEND.bufferStorage(target, data, flags); }
public static void glBufferStorage(int target, ShortBuffer data, int flags) { glBufferStorage(target, MemoryUtilities.memByteBuffer(data), flags); }
public static void glBufferStorage(int target, IntBuffer data, int flags) { glBufferStorage(target, MemoryUtilities.memByteBuffer(data), flags); }
public static void glBufferStorage(int target, FloatBuffer data, int flags) { glBufferStorage(target, MemoryUtilities.memByteBuffer(data), flags); }
public static void glBufferStorage(int target, DoubleBuffer data, int flags) { glBufferStorage(target, MemoryUtilities.memByteBuffer(data), flags); }
public static void glBufferStorage(int target, short[] data, int flags) {
final ByteBuffer copy = copyOf(data);
glBufferStorage(target, copy, flags);
MemoryUtilities.memFree(copy);
}
public static void glBufferStorage(int target, int[] data, int flags) {
final ByteBuffer copy = copyOf(data);
glBufferStorage(target, copy, flags);
MemoryUtilities.memFree(copy);
}
public static void glBufferStorage(int target, float[] data, int flags) {
final ByteBuffer copy = copyOf(data);
glBufferStorage(target, copy, flags);
MemoryUtilities.memFree(copy);
}
public static void glBufferStorage(int target, double[] data, int flags) {
final ByteBuffer copy = copyOf(data);
glBufferStorage(target, copy, flags);
MemoryUtilities.memFree(copy);
}
public static void glNamedBufferData(int buffer, long size, int usage) { RENDER_BACKEND.namedBufferData(buffer, size, usage); }
public static void glNamedBufferData(int buffer, ByteBuffer data, int usage) { RENDER_BACKEND.namedBufferData(buffer, data, usage); }
public static void glNamedBufferData(int buffer, FloatBuffer data, int usage) { RENDER_BACKEND.namedBufferData(buffer, data, usage); }
public static void glNamedBufferData(int buffer, ShortBuffer data, int usage) { glNamedBufferData(buffer, MemoryUtilities.memByteBuffer(data), usage); }
public static void glNamedBufferData(int buffer, IntBuffer data, int usage) { glNamedBufferData(buffer, MemoryUtilities.memByteBuffer(data), usage); }
public static void glNamedBufferData(int buffer, LongBuffer data, int usage) { glNamedBufferData(buffer, MemoryUtilities.memByteBuffer(data), usage); }
public static void glNamedBufferData(int buffer, DoubleBuffer data, int usage) { glNamedBufferData(buffer, MemoryUtilities.memByteBuffer(data), usage); }
public static void glNamedBufferData(int buffer, short[] data, int usage) {
final ByteBuffer copy = copyOf(data);
glNamedBufferData(buffer, copy, usage);
MemoryUtilities.memFree(copy);
}
public static void glNamedBufferData(int buffer, int[] data, int usage) {
final ByteBuffer copy = copyOf(data);
glNamedBufferData(buffer, copy, usage);
MemoryUtilities.memFree(copy);
}
public static void glNamedBufferData(int buffer, long[] data, int usage) {
final ByteBuffer copy = copyOf(data);
glNamedBufferData(buffer, copy, usage);
MemoryUtilities.memFree(copy);
}
public static void glNamedBufferData(int buffer, float[] data, int usage) {
final ByteBuffer copy = copyOf(data);
glNamedBufferData(buffer, copy, usage);
MemoryUtilities.memFree(copy);
}
public static void glNamedBufferData(int buffer, double[] data, int usage) {
final ByteBuffer copy = copyOf(data);
glNamedBufferData(buffer, copy, usage);
MemoryUtilities.memFree(copy);
}
public static void glNamedBufferSubData(int buffer, long offset, ByteBuffer data) { RENDER_BACKEND.namedBufferSubData(buffer, offset, data); }
public static void glNamedBufferSubData(int buffer, long offset, ShortBuffer data) { glNamedBufferSubData(buffer, offset, MemoryUtilities.memByteBuffer(data)); }
public static void glNamedBufferSubData(int buffer, long offset, IntBuffer data) { glNamedBufferSubData(buffer, offset, MemoryUtilities.memByteBuffer(data)); }
public static void glNamedBufferSubData(int buffer, long offset, LongBuffer data) { glNamedBufferSubData(buffer, offset, MemoryUtilities.memByteBuffer(data)); }
public static void glNamedBufferSubData(int buffer, long offset, FloatBuffer data) { glNamedBufferSubData(buffer, offset, MemoryUtilities.memByteBuffer(data)); }
public static void glNamedBufferSubData(int buffer, long offset, DoubleBuffer data) { glNamedBufferSubData(buffer, offset, MemoryUtilities.memByteBuffer(data)); }
public static void glNamedBufferSubData(int buffer, long offset, short[] data) {
final ByteBuffer copy = copyOf(data);
glNamedBufferSubData(buffer, offset, copy);
MemoryUtilities.memFree(copy);
}
public static void glNamedBufferSubData(int buffer, long offset, int[] data) {
final ByteBuffer copy = copyOf(data);
glNamedBufferSubData(buffer, offset, copy);
MemoryUtilities.memFree(copy);
}
public static void glNamedBufferSubData(int buffer, long offset, long[] data) {
final ByteBuffer copy = copyOf(data);
glNamedBufferSubData(buffer, offset, copy);
MemoryUtilities.memFree(copy);
}
public static void glNamedBufferSubData(int buffer, long offset, float[] data) {
final ByteBuffer copy = copyOf(data);
glNamedBufferSubData(buffer, offset, copy);
MemoryUtilities.memFree(copy);
}
public static void glNamedBufferSubData(int buffer, long offset, double[] data) {
final ByteBuffer copy = copyOf(data);
glNamedBufferSubData(buffer, offset, copy);
MemoryUtilities.memFree(copy);
}
public static void glClearBufferSubData(int target, int internalFormat, long offset, long size, int format, int type, ByteBuffer data) { RENDER_BACKEND.clearBufferSubData(target, internalFormat, offset, size, format, type, data); }
public static boolean glIsBuffer(int buffer) { return RENDER_BACKEND.isBuffer(buffer); }
public static void glCopyBufferSubData(int readTarget, int writeTarget, long readOffset, long writeOffset, long size) { RENDER_BACKEND.copyBufferSubData(readTarget, writeTarget, readOffset, writeOffset, size); }
private static int checkedSize(long size) {
if (size < 0 || size > Integer.MAX_VALUE) {
throw new IllegalArgumentException("Buffer range does not fit a ByteBuffer wrapper: " + size);
}
return (int) size;
}
private static ByteBuffer copyOf(short[] data) {
final ByteBuffer bb = MemoryUtilities.memAlloc(data.length << 1);
bb.asShortBuffer().put(data);
return bb;
}
private static ByteBuffer copyOf(int[] data) {
final ByteBuffer bb = MemoryUtilities.memAlloc(data.length << 2);
bb.asIntBuffer().put(data);
return bb;
}
private static ByteBuffer copyOf(long[] data) {
final ByteBuffer bb = MemoryUtilities.memAlloc(data.length << 3);
bb.asLongBuffer().put(data);
return bb;
}
private static ByteBuffer copyOf(float[] data) {
final ByteBuffer bb = MemoryUtilities.memAlloc(data.length << 2);
bb.asFloatBuffer().put(data);
return bb;
}
private static ByteBuffer copyOf(double[] data) {
final ByteBuffer bb = MemoryUtilities.memAlloc(data.length << 3);
bb.asDoubleBuffer().put(data);
return bb;
}
public static void glBindVertexArray(int array) {
if (DisplayListManager.isRecording()) {
DisplayListManager.recordBindVAO(array);
@@ -6165,7 +6418,7 @@ public class GLStateManager {
RENDER_BACKEND.getUniformiv(program, location, params);
}
public static void glGetTexImage(int target, int level, int format, int type, long pixels) {
GL11.glGetTexImage(target, level, format, type, pixels);
RENDER_BACKEND.getTexImage(target, level, format, type, pixels);
}
/**
@@ -146,6 +146,9 @@ public class RenderSystem {
coreProfile = true;
GLStateManager.LOGGER.info("GL 3.3 core profile detected, enabling FFP shader emulation.");
ShaderManager.getInstance().enable();
} else {
throw new IllegalStateException("Non-core GL context (profile mask 0x" + Integer.toHexString(profileMask)
+ "); FFP emulation requires a core profile and nothing would render. Context creation should have rejected this.");
}
}
@@ -301,7 +304,7 @@ public class RenderSystem {
}
public static void bufferData(int target, FloatBuffer data, int usage) {
RENDER_BACKEND.bufferData(target, data, usage);
GLStateManager.glBufferData(target, data, usage);
}
public static int bufferStorage(int target, FloatBuffer data, int usage) {
@@ -447,7 +450,7 @@ public class RenderSystem {
}
public static int createBuffers() {
return RENDER_BACKEND.genBuffers();
return GLStateManager.glGenBuffers();
}
public static void bindBufferBase(int target, int index, int buffer) {
@@ -455,13 +458,13 @@ public class RenderSystem {
}
public static void bufferStorage(int target, long size, int flags) {
RENDER_BACKEND.bufferStorage(target, size, flags);
GLStateManager.glBufferStorage(target, size, flags);
}
public static void clearBufferSubData(int target, int internalFormat, long offset, long size, int format, int type, int[] data) {
final ByteBuffer buf = BufferUtils.createByteBuffer(data.length * 4);
buf.asIntBuffer().put(data);
RENDER_BACKEND.clearBufferSubData(target, internalFormat, offset, size, format, type, buf);
GLStateManager.glClearBufferSubData(target, internalFormat, offset, size, format, type, buf);
}
public static void deleteBuffers(int buffer) {
@@ -549,7 +552,7 @@ public class RenderSystem {
}
}
/** Parse a GL version string (e.g. "4.6.0 NVIDIA ...") into concatenated digits "460". Inlined from StandardMacros.getGlVersion(). */
/** Parse a GL version string (e.g. "4.6.0 NVIDIA ...") into concatenated digits "460" */
static String parseGlVersionString(String info) {
final Matcher matcher = SEMVER_PATTERN.matcher(Objects.requireNonNull(info));
if (!matcher.matches()) {
@@ -561,4 +564,18 @@ public class RenderSystem {
if (bugfix == null || bugfix.isEmpty()) bugfix = "0";
return major + minor + bugfix;
}
/** Parse a GL version string into packed major*10+minor (e.g. "4.3.0 - Build ..." -> 43), or -1 if unparseable. */
public static int parseMajorMinor(String glVersion) {
if (glVersion == null) return -1;
final Matcher matcher = SEMVER_PATTERN.matcher(glVersion.trim());
if (!matcher.matches()) return -1;
return Integer.parseInt(matcher.group("major")) * 10 + Integer.parseInt(matcher.group("minor"));
}
public static boolean isContextValid(int requestedMajor, int requestedMinor, int actualVersion, boolean coreBitSet) {
if (!coreBitSet) return false;
if (actualVersion < 0) return true;
return actualVersion >= requestedMajor * 10 + requestedMinor;
}
}
@@ -327,7 +327,7 @@ public final class Lwjgl2GLRenderBackend extends RenderBackend {
@Override
public void copyBufferSubData(int readTarget, int writeTarget, long readOffset, long writeOffset, long size) {
throw new UnsupportedOperationException("GLRenderBackend.copyBufferSubData should not be called — LWJGL service handles this");
GL31.glCopyBufferSubData(readTarget, writeTarget, readOffset, writeOffset, size);
}
@Override
@@ -622,6 +622,11 @@ public final class Lwjgl2GLRenderBackend extends RenderBackend {
GL11.glGetTexImage(target, level, format, type, pixels);
}
@Override
public void getTexImage(int target, int level, int format, int type, long pixelBufferOffset) {
GL11.glGetTexImage(target, level, format, type, pixelBufferOffset);
}
@Override
public int getFramebufferAttachmentParameteri(int target, int attachment, int pname) {
return GL30.glGetFramebufferAttachmentParameteri(target, attachment, pname);
@@ -1058,6 +1063,11 @@ public final class Lwjgl2GLRenderBackend extends RenderBackend {
return GL30.glMapBufferRange(target, offset, length, access, null);
}
@Override
public void flushMappedBufferRange(int target, long offset, long length) {
GL30.glFlushMappedBufferRange(target, offset, length);
}
@Override
public int genVertexArrays() {
return GL30.glGenVertexArrays();
@@ -1249,6 +1259,11 @@ public final class Lwjgl2GLRenderBackend extends RenderBackend {
return GL45.glCreateBuffers();
}
@Override
public void namedBufferData(int buffer, long size, int usage) {
GL45.glNamedBufferData(buffer, size, usage);
}
@Override
public void namedBufferData(int buffer, ByteBuffer data, int usage) {
GL45.glNamedBufferData(buffer, data, usage);
@@ -151,6 +151,7 @@ public abstract class RenderBackend {
public abstract void readPixels(int x, int y, int width, int height, int format, int type, IntBuffer pixels);
public abstract void getTexImage(int target, int level, int format, int type, ByteBuffer pixels);
public abstract void getTexImage(int target, int level, int format, int type, IntBuffer pixels);
public abstract void getTexImage(int target, int level, int format, int type, long pixelBufferOffset);
public abstract int getFramebufferAttachmentParameteri(int target, int attachment, int pname);
public abstract int createShader(int type);
@@ -249,6 +250,7 @@ public abstract class RenderBackend {
public abstract int getBufferParameteri(int target, int pname);
public abstract boolean isBuffer(int buffer);
public abstract ByteBuffer mapBufferRange(int target, long offset, long length, int access);
public abstract void flushMappedBufferRange(int target, long offset, long length);
public abstract int genVertexArrays();
public abstract void deleteVertexArrays(int array);
@@ -292,6 +294,7 @@ public abstract class RenderBackend {
public abstract void namedFramebufferDrawBuffers(int framebuffer, IntBuffer bufs);
public abstract void blitNamedFramebuffer(int readFramebuffer, int drawFramebuffer, int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, int mask, int filter);
public abstract int createBuffers();
public abstract void namedBufferData(int buffer, long size, int usage);
public abstract void namedBufferData(int buffer, ByteBuffer data, int usage);
public abstract void namedBufferData(int buffer, FloatBuffer data, int usage);
public abstract void namedBufferSubData(int buffer, long offset, ByteBuffer data);
@@ -104,8 +104,8 @@ public class DSAARB extends DSAUnsupported {
@Override
public int bufferStorage(int target, FloatBuffer data, int usage) {
final int buffer = RENDER_BACKEND.createBuffers();
RENDER_BACKEND.namedBufferData(buffer, data, usage);
final int buffer = GLStateManager.glCreateBuffers();
GLStateManager.glNamedBufferData(buffer, data, usage);
return buffer;
}
@@ -121,9 +121,9 @@ public class DSAUnsupported implements DSAAccess {
@Override
public int bufferStorage(int target, FloatBuffer data, int usage) {
final int buffer = RENDER_BACKEND.genBuffers();
final int buffer = GLStateManager.glGenBuffers();
GLStateManager.glBindBuffer(target, buffer);
RENDER_BACKEND.bufferData(target, data, usage);
GLStateManager.glBufferData(target, data, usage);
GLStateManager.glBindBuffer(target, 0);
return buffer;
@@ -48,6 +48,11 @@ public class GLSMRedirector {
private static final String ARBInstancedArrays = "org/lwjgl/opengl/ARBInstancedArrays";
private static final String ARBDrawInstanced = "org/lwjgl/opengl/ARBDrawInstanced";
private static final String EXTDrawInstanced = "org/lwjgl/opengl/EXTDrawInstanced";
private static final String ARBBufferObject = "org/lwjgl/opengl/ARBBufferObject";
private static final String ARBVertexBufferObject = "org/lwjgl/opengl/ARBVertexBufferObject";
private static final String ARBBufferStorage = "org/lwjgl/opengl/ARBBufferStorage";
private static final String ARBCopyBuffer = "org/lwjgl/opengl/ARBCopyBuffer";
private static final String ARBMapBufferRange = "org/lwjgl/opengl/ARBMapBufferRange";
// Redirect VAO related calls from NHLib
private static final String UniversalVAO = "com/gtnewhorizon/gtnhlib/client/opengl/UniversalVAO";
@@ -285,11 +290,16 @@ public class GLSMRedirector {
.add("glBindBuffer")
.add("glDeleteBuffers")
.add("glBufferData")
.add("nglBufferData")
.add("glBufferSubData")
.add("nglBufferSubData")
.add("glMapBuffer")
.add("glUnmapBuffer")
.add("glGetBufferSubData")
.add("nglGetBufferSubData")
.add("glGetBufferParameteri")
.add("glGetBufferParameter")
.add("glGetBufferParameteriv")
.add("glIsBuffer");
final var gl20 = RedirectMap.newMap()
.add("glBlendEquationSeparate")
@@ -356,10 +366,13 @@ public class GLSMRedirector {
.add("glVertexAttribIPointer")
.add("glGenerateMipmap")
.add("glGetFramebufferAttachmentParameteri")
.add("glBlitFramebuffer");
.add("glBlitFramebuffer")
.add("glMapBufferRange")
.add("glFlushMappedBufferRange");
final var gl31 = RedirectMap.newMap()
.add("glDrawElementsInstanced")
.add("glDrawArraysInstanced");
.add("glDrawArraysInstanced")
.add("glCopyBufferSubData");
final var gl32 = RedirectMap.newMap()
.add("glFramebufferTexture");
final var gl33 = RedirectMap.newMap()
@@ -383,6 +396,10 @@ public class GLSMRedirector {
final var gl44 = RedirectMap.newMap()
.add("glBufferStorage")
.add("glClearTexImage");
final var gl45 = RedirectMap.newMap()
.add("glCreateBuffers")
.add("glNamedBufferData")
.add("glNamedBufferSubData");
// Merge all GL version maps into the flat lookup
glMethodRedirects.putAll(gl11);
@@ -398,6 +415,7 @@ public class GLSMRedirector {
glMethodRedirects.putAll(gl42);
glMethodRedirects.putAll(gl43);
glMethodRedirects.putAll(gl44);
glMethodRedirects.putAll(gl45);
// MINECRAFT
methodRedirects.put(OpenGlHelper, RedirectMap.newMap()
@@ -470,6 +488,31 @@ public class GLSMRedirector {
.add("glDrawArraysInstancedEXT", "glDrawArraysInstanced")
.add("glDrawElementsInstancedEXT", "glDrawElementsInstanced")
);
final var arbBufferObject = RedirectMap.newMap()
.add("glBindBufferARB", "glBindBuffer")
.add("glGenBuffersARB", "glGenBuffers")
.add("glDeleteBuffersARB", "glDeleteBuffers")
.add("glIsBufferARB", "glIsBuffer")
.add("glBufferDataARB", "glBufferData")
.add("glBufferSubDataARB", "glBufferSubData")
.add("glGetBufferSubDataARB", "glGetBufferSubData")
.add("glMapBufferARB", "glMapBuffer")
.add("glUnmapBufferARB", "glUnmapBuffer")
.add("glGetBufferParameterARB", "glGetBufferParameter")
.add("glGetBufferParameteriARB", "glGetBufferParameteri")
.add("glGetBufferParameterivARB", "glGetBufferParameteriv");
methodRedirects.put(ARBBufferObject, arbBufferObject);
methodRedirects.put(ARBVertexBufferObject, arbBufferObject);
methodRedirects.put(ARBBufferStorage, RedirectMap.newMap()
.add("glBufferStorage")
);
methodRedirects.put(ARBCopyBuffer, RedirectMap.newMap()
.add("glCopyBufferSubData")
);
methodRedirects.put(ARBMapBufferRange, RedirectMap.newMap()
.add("glMapBufferRange")
.add("glFlushMappedBufferRange")
);
// APPLE
methodRedirects.put(APPLEVertexArrayObject, RedirectMap.newMap()
@@ -0,0 +1,34 @@
package com.gtnewhorizons.angelica.glsm;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
class GLVersionParseTest {
@Test
void parseMajorMinor() {
assertEquals(43, RenderSystem.parseMajorMinor("4.3.0 - Build 20.19.15.4835"));
assertEquals(46, RenderSystem.parseMajorMinor("4.6.0 NVIDIA 551.61"));
assertEquals(41, RenderSystem.parseMajorMinor("4.1 Metal - 88"));
assertEquals(33, RenderSystem.parseMajorMinor("3.3"));
assertEquals(46, RenderSystem.parseMajorMinor("4.6 (Core Profile) Mesa 24.0.3"));
assertEquals(-1, RenderSystem.parseMajorMinor(null));
assertEquals(-1, RenderSystem.parseMajorMinor(""));
assertEquals(-1, RenderSystem.parseMajorMinor("garbage"));
assertEquals(-1, RenderSystem.parseMajorMinor("OpenGL ES 3.2"));
}
@Test
void isContextValid() {
assertTrue(RenderSystem.isContextValid(4, 4, 46, true));
assertTrue(RenderSystem.isContextValid(4, 4, 44, true));
assertFalse(RenderSystem.isContextValid(4, 4, 43, true));
assertFalse(RenderSystem.isContextValid(4, 4, 44, false));
assertTrue(RenderSystem.isContextValid(4, 4, -1, true));
assertFalse(RenderSystem.isContextValid(4, 4, -1, false));
assertTrue(RenderSystem.isContextValid(3, 3, 33, true));
}
}
@@ -659,6 +659,11 @@ public final class Lwjgl3GLRenderBackend extends RenderBackend {
GL11C.glGetTexImage(target, level, format, type, pixels);
}
@Override
public void getTexImage(int target, int level, int format, int type, long pixelBufferOffset) {
GL11C.glGetTexImage(target, level, format, type, pixelBufferOffset);
}
@Override
public int getFramebufferAttachmentParameteri(int target, int attachment, int pname) {
return GL30C.glGetFramebufferAttachmentParameteri(target, attachment, pname);
@@ -1096,6 +1101,11 @@ public final class Lwjgl3GLRenderBackend extends RenderBackend {
return GL30C.glMapBufferRange(target, offset, length, access);
}
@Override
public void flushMappedBufferRange(int target, long offset, long length) {
GL30C.glFlushMappedBufferRange(target, offset, length);
}
@Override
public int genVertexArrays() {
return GL30C.glGenVertexArrays();
@@ -1281,6 +1291,11 @@ public final class Lwjgl3GLRenderBackend extends RenderBackend {
return GL45C.glCreateBuffers();
}
@Override
public void namedBufferData(int buffer, long size, int usage) {
GL45C.glNamedBufferData(buffer, size, usage);
}
@Override
public void namedBufferData(int buffer, ByteBuffer data, int usage) {
GL45C.glNamedBufferData(buffer, data, usage);
@@ -0,0 +1,9 @@
package com.gtnewhorizons.angelica.api;
public interface ExtCeleritasRenderBlocks {
boolean angelica$shouldApplyCeleritasAO();
void angelica$setApplyingCeleritasAO(boolean val);
}
@@ -2,17 +2,25 @@ package com.gtnewhorizons.angelica.client.font;
import com.gtnewhorizons.angelica.config.FontConfig;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.IReloadableResourceManager;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.client.resources.IResourceManagerReloadListener;
import net.minecraft.util.ResourceLocation;
import java.io.IOException;
import java.io.InputStream;
public final class FontProviderUnicode implements FontProvider {
public final class FontProviderUnicode implements FontProvider, IResourceManagerReloadListener {
private FontProviderUnicode() {
onResourceManagerReload(Minecraft.getMinecraft().getResourceManager());
((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(this);
}
@Override
public void onResourceManagerReload(IResourceManager resourceManager) {
try {
InputStream inputstream = Minecraft.getMinecraft().getResourceManager()
.getResource(new ResourceLocation("font/glyph_sizes.bin")).getInputStream();
InputStream inputstream = resourceManager.getResource(new ResourceLocation("font/glyph_sizes.bin")).getInputStream();
//noinspection ResultOfMethodCallIgnored
inputstream.read(this.glyphWidth);
}
@@ -0,0 +1,30 @@
package com.gtnewhorizons.angelica.compat.etfuturum;
import cpw.mods.fml.common.Loader;
import ganymedes01.etfuturum.api.client.EndFlashAPI;
/**
* Use EFR to power End flash uniforms.
*/
public final class EndFlashCompat {
private static final boolean AVAILABLE = Loader.isModLoaded("etfuturum") && EndFlashCompat.class.getResource("/ganymedes01/etfuturum/api/client/EndFlashAPI.class") != null;
private EndFlashCompat() {}
public static boolean isAvailable() {
return AVAILABLE;
}
public static float getIntensity(float partialTicks) {
return AVAILABLE ? EndFlashAPI.getIntensity(partialTicks) : 0.0F;
}
public static float getXAngle() {
return AVAILABLE ? EndFlashAPI.getXAngle() : 0.0F;
}
public static float getYAngle() {
return AVAILABLE ? EndFlashAPI.getYAngle() : 0.0F;
}
}
@@ -211,6 +211,8 @@ public enum Mixins implements IMixins {
.addClientMixins(
"rendering.MixinBlock"
, "rendering.MixinBlockFluidBase"
, "rendering.MixinBlockLiquid"
, "rendering.BlockLiquidFlowInvoker"
, "rendering.AccessorBiomeColorEvent"
, "rendering.MixinBiomeGenBase"
, "rendering.MixinChunk"
@@ -415,6 +417,12 @@ public enum Mixins implements IMixins {
.setApplyIf(() -> AngelicaConfig.removeUnicodeEvenScaling)
.addClientMixins("angelica.bugfixes.MixinScaledResolution_UnicodeFix")),
FARSEEK_WORLDSLICE_COMPAT(new MixinBuilder("Let Farseek resolve celeritas' WorldSlice so Streams' water renders properly")
.setPhase(Phase.LATE)
.addRequiredMod(TargetedMod.FARSEEK)
.setApplyIf(() -> AngelicaConfig.enableCeleritas)
.addClientMixins("client.farseek.MixinFarseekIBlockAccessValue")),
SECURITYCRAFT_COMPAT(new MixinBuilder("Fix reflection in SecurityCraft for compat with Angelica")
.setPhase(Phase.LATE)
.addRequiredMod(TargetedMod.SECURITYCRAFT)
@@ -17,6 +17,7 @@ public enum TargetedMod implements ITargetMod {
DRAGON_API("Reika.DragonAPI.Auxiliary.DragonAPIASMHandler", "DragonAPI"),
ET_FUTURUM_REQUIEM(null, "etfuturum"),
EXTRAUTILS(null, "ExtraUtilities"),
FARSEEK("farseek.core.FarseekCoreMod", "farseek"),
FALSETWEAKS("com.falsepattern.falsetweaks.asm.CoreLoadingPlugin", "falsetweaks"),
MINEFACTORY_RELOADED(null, "MineFactoryReloaded"),
NTM_SPACE("com.hbm.dim.SolarSystem"),
@@ -40,6 +40,7 @@ final class BlockOrientation extends RenderBlockState {
private int altMetadata;
private int metadataBits;
private int renderType;
private boolean iCtmBlock;
private int blockFace;
private int textureFace;
@@ -76,6 +77,11 @@ final class BlockOrientation extends RenderBlockState {
return z;
}
@Override
public int getMetadata() {
return metadata;
}
@Override
public int getBlockFace() {
return blockFace;
@@ -156,8 +162,8 @@ final class BlockOrientation extends RenderBlockState {
@Override
public boolean shouldConnectByBlock(Block neighbor, int neighborX, int neighborY, int neighborZ) {
return block == neighbor
&& (metadataBits & (1 << blockAccess.getBlockMetadata(neighborX, neighborY, neighborZ))) != 0;
return iCtmBlock ? ((ICTMBlock) block).shouldConnectByBlock(this, neighbor, neighborX, neighborY, neighborZ)
: block == neighbor && (metadataBits & (1 << blockAccess.getBlockMetadata(neighborX, neighborY, neighborZ))) != 0;
}
@Override
@@ -175,6 +181,7 @@ final class BlockOrientation extends RenderBlockState {
copy.altMetadata = altMetadata;
copy.metadataBits = metadataBits;
copy.renderType = renderType;
copy.iCtmBlock = iCtmBlock;
copy.blockFace = blockFace;
copy.textureFace = textureFace;
copy.textureFaceOrig = textureFaceOrig;
@@ -203,6 +210,7 @@ final class BlockOrientation extends RenderBlockState {
this.z = z;
renderType = block.getRenderType();
metadata = altMetadata = blockAccess.getBlockMetadata(x, y, z);
iCtmBlock = block instanceof ICTMBlock;
offsetsComputed = false;
}
@@ -223,6 +231,7 @@ final class BlockOrientation extends RenderBlockState {
renderType = block.getRenderType();
blockFace = textureFace = textureFaceOrig = face;
this.metadata = metadata;
iCtmBlock = block instanceof ICTMBlock;
metadataBits = 1 << metadata;
dx = dy = dz = 0;
rotateUV = 0;
@@ -9,6 +9,7 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.StampedLock;
import java.util.function.Consumer;
import com.github.bsideup.jabel.Desugar;
import net.minecraft.block.Block;
@@ -34,10 +35,22 @@ public class CTMUtils {
public static final MCLogger logger = MCLogger.getLogger(MCLogger.Category.CONNECTED_TEXTURES, "CTM");
private static class Overrides {
public static class Overrides {
private final List<TileOverride> all = new ArrayList<>();
private final Map<Block, List<BlockStateMatcher>> block = new IdentityHashMap<>();
private final Map<String, List<TileOverride>> tile = new HashMap<>();
public List<TileOverride> getAll() {
return all;
}
public Map<Block, List<BlockStateMatcher>> getBlock() {
return block;
}
public Map<String, List<TileOverride>> getTile() {
return tile;
}
}
private static Overrides overrides = new Overrides();
@@ -82,6 +95,8 @@ public class CTMUtils {
private static final AtomicInteger texturePackChangeCounter = new AtomicInteger(0);
private static final ArrayList<Consumer<Overrides>> ctmRegistrationCallbacks = new ArrayList<>();
static {
try {
Class.forName(MCPatcherUtils.RENDER_PASS_CLASS)
@@ -117,6 +132,9 @@ public class CTMUtils {
.listResources(TexturePackAPI.MCPATCHER_SUBDIR + "ctm", ".properties", true)) {
registerOverrideWithoutLock(newOverrides, TileOverride.create(resource, tileLoader));
}
for (Consumer<Overrides> callback : ctmRegistrationCallbacks) {
callback.accept(newOverrides);
}
}
for (ResourceLocation resource : BlendMethod.getAllBlankResources()) {
tileLoader.preloadTile(resource, false);
@@ -257,7 +275,7 @@ public class CTMUtils {
return RenderPassAPI.instance.skipDefaultRendering(block);
}
private static void registerOverrideWithoutLock(Overrides overrides, TileOverride override) {
public static void registerOverrideWithoutLock(Overrides overrides, TileOverride override) {
if (override != null && !override.isDisabled()) {
boolean registered = false;
List<BlockStateMatcher> matchingBlocks = override.getMatchingBlocks();
@@ -308,4 +326,8 @@ public class CTMUtils {
private static TileOverrideIterator.Metadata newMetadataIterator() {
return new TileOverrideIterator.Metadata(overrides.block, overrides.tile);
}
public static void addCtmRegistrationCallback(Consumer<Overrides> consumer) {
ctmRegistrationCallbacks.add(consumer);
}
}
@@ -0,0 +1,10 @@
package com.prupe.mcpatcher.ctm;
import net.minecraft.block.Block;
/**
* Implement this interface on blocks that support connected textures to allow them to control if they connect to neighbors or not
*/
public interface ICTMBlock {
boolean shouldConnectByBlock(RenderBlockState renderBlockState, Block neighbor, int neighborX, int neighborY, int neighborZ);
}
@@ -109,6 +109,8 @@ abstract public class RenderBlockState {
abstract public int getZ();
abstract public int getMetadata();
abstract public int getBlockFace();
abstract public int getTextureFace();
@@ -33,7 +33,7 @@ public abstract class TileOverride implements Comparable<TileOverride> {
private static final MCLogger logger = MCLogger.getLogger(MCLogger.Category.CONNECTED_TEXTURES, "CTM");
protected final PropertiesFile properties;
public final PropertiesFile properties;
private final String baseFilename;
protected final TileLoader tileLoader;
protected final int renderPass;
@@ -79,7 +79,10 @@ public abstract class TileOverride implements Comparable<TileOverride> {
if (properties == null) {
return null;
}
return create(properties, tileLoader);
}
public static TileOverride create(PropertiesFile properties, TileLoader tileLoader) {
String method = properties.getString("method", "default")
.toLowerCase();
TileOverride override = null;
@@ -211,7 +214,7 @@ public abstract class TileOverride implements Comparable<TileOverride> {
for (int i = 0;; i++) {
ResourceLocation resource = TileLoader
.parseTileAddress(properties.getResource(), String.valueOf(i), blankResource);
if (!TexturePackAPI.hasResource(resource)) {
if (!TexturePackAPI.hasResource(resource) && !tileLoader.ignoreMissingTextures()) {
break;
}
if (!addIcon(resource)) {
@@ -237,7 +240,7 @@ public abstract class TileOverride implements Comparable<TileOverride> {
.parseTileAddress(properties.getResource(), token, blankResource);
if (resource == null) {
tileNames.add(null);
} else if (TexturePackAPI.hasResource(resource)) {
} else if (TexturePackAPI.hasResource(resource) || tileLoader.ignoreMissingTextures()) {
addIcon(resource);
} else {
properties.warning("could not find image %s", resource);
@@ -252,7 +255,7 @@ public abstract class TileOverride implements Comparable<TileOverride> {
for (int i = from; i <= to; i++) {
ResourceLocation resource = TileLoader
.parseTileAddress(properties.getResource(), String.valueOf(i), blankResource);
if (TexturePackAPI.hasResource(resource)) {
if (TexturePackAPI.hasResource(resource) || tileLoader.ignoreMissingTextures()) {
addIcon(resource);
} else {
properties.warning("could not find image %s", resource);
@@ -9,12 +9,12 @@ import net.minecraft.util.ResourceLocation;
import com.prupe.mcpatcher.MCLogger;
import com.prupe.mcpatcher.MCPatcherUtils;
final public class PropertiesFile {
public class PropertiesFile {
private final MCLogger logger;
private final ResourceLocation resource;
private final String prefix;
private final Properties properties;
protected final MCLogger logger;
protected final ResourceLocation resource;
protected final String prefix;
protected final Properties properties;
private int errorCount;
public static PropertiesFile get(MCLogger logger, ResourceLocation resource) {
@@ -147,4 +147,16 @@ final public class PropertiesFile {
return resource.equals(((PropertiesFile) that).resource);
}
}
public MCLogger getLogger() {
return logger;
}
public String getPrefix() {
return prefix;
}
public Properties getProperties() {
return properties;
}
}
@@ -275,7 +275,7 @@ public class TileLoader {
return false;
}
private boolean registerOneIcon(TextureMap textureMap, String mapName, Map<String, TextureAtlasSprite> map) {
protected boolean registerOneIcon(TextureMap textureMap, String mapName, Map<String, TextureAtlasSprite> map) {
ResourceLocation resource = tilesToRegister.iterator()
.next();
String name = resource.toString();
@@ -304,6 +304,16 @@ public class TileLoader {
return false;
}
}
TextureAtlasSprite icon = registerIconToMap(textureMap, resource, name);
map.put(name, icon);
iconMap.put(name, icon);
String extra = (width == height ? "" : ", " + (height / width) + " frames");
subLogger.finer("%s -> %s icon %dx%d%s", name, mapName, width, width, extra);
tilesToRegister.remove(resource);
return true;
}
protected TextureAtlasSprite registerIconToMap(TextureMap textureMap, ResourceLocation resource, String name) {
TextureAtlasSprite icon;
if(generatedTiles.contains(resource)){
icon = new GeneratedCTMAtlasSprite(this, textureMap.anisotropicFiltering > 1, name);
@@ -311,12 +321,7 @@ public class TileLoader {
}else{
icon = (TextureAtlasSprite)textureMap.registerIcon(name);
}
map.put(name, icon);
iconMap.put(name, icon);
String extra = (width == height ? "" : ", " + (height / width) + " frames");
subLogger.finer("%s -> %s icon %dx%d%s", name, mapName, width, width, extra);
tilesToRegister.remove(resource);
return true;
return icon;
}
public void finish() {
@@ -339,4 +344,8 @@ public class TileLoader {
public IIcon getIcon(ResourceLocation resource) {
return resource == null ? null : getIcon(resource.toString());
}
public boolean ignoreMissingTextures() {
return false;
}
}
+1 -1
View File
@@ -176,7 +176,7 @@ public enum Settings {
},
VOID_FOG(new NotFineOptionTickBox(false, OptionImpact.LOW)),
ZOOM_SMOOTH(new NotFineOptionTickBox(true, OptionImpact.LOW)),
ZOOM_SMOOTH_SPEED(new NotFineOptionSlider(14, 1, 30, 1, OptionImpact.LOW));
ZOOM_SMOOTH_SPEED(new NotFineOptionSlider(20, 1, 30, 1, OptionImpact.LOW));
public final NotFineOption<?> option;
@@ -170,6 +170,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
private final CloudSetting cloudSetting;
private final boolean shouldRenderUnderwaterOverlay;
private final boolean shouldRenderVignette;
private final boolean supportsEndFlash;
private final boolean shouldRenderSun;
private final boolean shouldRenderMoon;
private final boolean shouldRenderStars;
@@ -231,6 +232,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
this.cloudSetting = programs.getPackDirectives().getCloudSetting();
this.shouldRenderUnderwaterOverlay = programs.getPackDirectives().underwaterOverlay();
this.shouldRenderVignette = programs.getPackDirectives().vignette();
this.supportsEndFlash = programs.getPackDirectives().isSupportsEndFlash();
this.shouldRenderSun = programs.getPackDirectives().shouldRenderSun();
this.shouldRenderMoon = programs.getPackDirectives().shouldRenderMoon();
this.shouldRenderStars = programs.getPackDirectives().shouldRenderStars();
@@ -651,6 +653,11 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
return shouldRenderVignette;
}
@Override
public boolean supportsEndFlash() {
return supportsEndFlash;
}
@Override
public boolean shouldRenderSun() {
return shouldRenderSun;
@@ -152,6 +152,11 @@ public class FixedFunctionWorldRenderingPipeline implements WorldRenderingPipeli
return false;
}
@Override
public boolean supportsEndFlash() {
return false;
}
@Override
public CloudSetting getCloudSetting() {
return CloudSetting.DEFAULT;
@@ -49,6 +49,7 @@ public interface WorldRenderingPipeline {
boolean shouldDisableVanillaEntityShadows();
boolean shouldDisableDirectionalShading();
boolean supportsEndFlash();
CloudSetting getCloudSetting();
boolean shouldRenderUnderwaterOverlay();
boolean shouldRenderVignette();
@@ -48,6 +48,7 @@ public class PackDirectives {
@Getter private boolean oldHandLight;
@Getter private boolean prepareBeforeShadow;
@Getter private boolean supportsColorCorrection;
@Getter private boolean supportsEndFlash;
@Getter private int fallbackTex;
private Object2ObjectMap<String, Object2BooleanMap<String>> explicitFlips = new Object2ObjectOpenHashMap<>();
private Object2ObjectMap<String, TextureScaleOverride> scaleOverrides = new Object2ObjectOpenHashMap<>();
@@ -93,6 +94,7 @@ public class PackDirectives {
oldLighting = properties.getOldLighting().orElse(false);
fallbackTex = properties.getFallbackTex();
supportsColorCorrection = properties.getSupportsColorCorrection().orElse(false);
supportsEndFlash = properties.getSupportsEndFlash().orElse(false);
concurrentCompute = properties.getConcurrentCompute().orElse(false);
oldHandLight = properties.getOldHandLight().orElse(true);
explicitFlips = properties.getExplicitFlips();
@@ -112,6 +114,7 @@ public class PackDirectives {
frustumCulling = directives.frustumCulling;
occlusionCulling = directives.occlusionCulling;
oldLighting = directives.oldLighting;
supportsEndFlash = directives.supportsEndFlash;
concurrentCompute = directives.concurrentCompute;
explicitFlips = directives.explicitFlips;
scaleOverrides = directives.scaleOverrides;
@@ -70,6 +70,7 @@ public class ShaderProperties {
@Getter private OptionalBoolean shadowPlayer = OptionalBoolean.DEFAULT;
@Getter private OptionalBoolean shadowBlockEntities = OptionalBoolean.DEFAULT;
@Getter private OptionalBoolean shadowLightBlockEntities = OptionalBoolean.DEFAULT;
@Getter private OptionalBoolean supportsEndFlash = OptionalBoolean.DEFAULT;
@Getter private OptionalBoolean underwaterOverlay = OptionalBoolean.DEFAULT;
@Getter private OptionalBoolean sun = OptionalBoolean.DEFAULT;
@Getter private OptionalBoolean moon = OptionalBoolean.DEFAULT;
@@ -205,6 +206,7 @@ public class ShaderProperties {
handleBooleanDirective(key, value, "shadowPlayer", bool -> shadowPlayer = bool);
handleBooleanDirective(key, value, "shadowBlockEntities", bool -> shadowBlockEntities = bool);
handleBooleanDirective(key, value, "shadowLightBlockEntities", bool -> shadowLightBlockEntities = bool);
handleBooleanDirective(key, value, "endFlashShadows", bool -> supportsEndFlash = bool);
handleBooleanDirective(key, value, "underwaterOverlay", bool -> underwaterOverlay = bool);
handleBooleanDirective(key, value, "sun", bool -> sun = bool);
handleBooleanDirective(key, value, "moon", bool -> moon = bool);
@@ -1,6 +1,12 @@
package net.coderbot.iris.shadow;
import com.gtnewhorizons.angelica.compat.etfuturum.EndFlashCompat;
import com.gtnewhorizons.angelica.compat.toremove.MatrixStack;
import net.coderbot.iris.Iris;
import net.coderbot.iris.pipeline.WorldRenderingPipeline;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.world.WorldProviderEnd;
import org.joml.Matrix4f;
import static com.gtnewhorizons.angelica.compat.mojang.Constants.DEGREES_TO_RADIANS;
@@ -40,23 +46,41 @@ public class ShadowMatrices {
}
public static void createBaselineModelViewMatrix(MatrixStack target, float shadowAngle, float sunPathRotation) {
final float skyAngle;
if (shadowAngle < 0.25f) {
skyAngle = shadowAngle + 0.75f;
} else {
skyAngle = shadowAngle - 0.25f;
}
target.peek().getNormal().identity();
target.peek().getModel().identity();
target.peek().getModel().translate(0.0f, 0.0f, -100.0f);
target.rotateX(90F * DEGREES_TO_RADIANS);
target.rotateZ(skyAngle * -360.0f * DEGREES_TO_RADIANS);
target.rotateX(sunPathRotation * DEGREES_TO_RADIANS);
if (isEndFlashShadow()) {
// Project shadows from the End flash direction instead of the sun/moon.
target.rotateX((0.0f - EndFlashCompat.getXAngle()) * DEGREES_TO_RADIANS);
target.rotateY(EndFlashCompat.getYAngle() * DEGREES_TO_RADIANS);
} else {
final float skyAngle;
if (shadowAngle < 0.25f) {
skyAngle = shadowAngle + 0.75f;
} else {
skyAngle = shadowAngle - 0.25f;
}
target.rotateX(90F * DEGREES_TO_RADIANS);
target.rotateZ(skyAngle * -360.0f * DEGREES_TO_RADIANS);
target.rotateX(sunPathRotation * DEGREES_TO_RADIANS);
}
}
private static boolean isEndFlashShadow() {
final Minecraft mc = Minecraft.getMinecraft();
if (mc == null) {
return false;
}
final WorldClient world = mc.theWorld;
return world != null && world.provider instanceof WorldProviderEnd
&& EndFlashCompat.isAvailable()
&& Iris.getPipelineManager().getPipeline().map(WorldRenderingPipeline::supportsEndFlash).orElse(false);
}
public static void snapModelViewToGrid(MatrixStack target, float shadowIntervalSize, double cameraX, double cameraY, double cameraZ) {
if (Math.abs(shadowIntervalSize) == 0.0F) {
// Avoid a division by zero - semantically, this just means that the snapping does not take place,
@@ -1,10 +1,14 @@
package net.coderbot.iris.uniforms;
import com.gtnewhorizons.angelica.compat.etfuturum.EndFlashCompat;
import com.gtnewhorizons.angelica.compat.mojang.Constants;
import com.gtnewhorizons.angelica.rendering.RenderingState;
import net.coderbot.iris.Iris;
import net.coderbot.iris.gl.uniform.UniformHolder;
import net.coderbot.iris.pipeline.WorldRenderingPipeline;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.world.WorldProviderEnd;
import org.joml.Matrix4f;
import org.joml.Vector4f;
@@ -18,9 +22,12 @@ import static net.coderbot.iris.gl.uniform.UniformUpdateFrequency.PER_FRAME;
public final class CelestialUniforms {
private static final Vector4f upPositionCache = new Vector4f();
private static final Matrix4f upMatrixCache = new Matrix4f();
private static final Vector4f ZERO_VECTOR_4f = new Vector4f(0.0F, 0.0F, 0.0F, 0.0F);
private final Vector4f positionCache = new Vector4f();
private final Matrix4f celestialMatrixCache = new Matrix4f();
private final Vector4f endFlashPositionCache = new Vector4f();
private final Matrix4f endFlashMatrixCache = new Matrix4f();
private final float sunPathRotation;
public CelestialUniforms(float sunPathRotation) {
@@ -34,9 +41,46 @@ public final class CelestialUniforms {
.uniformTruncated3f(PER_FRAME, "moonPosition", this::getMoonPosition)
.uniform1f(PER_FRAME, "shadowAngle", CelestialUniforms::getShadowAngle)
.uniformTruncated3f(PER_FRAME, "shadowLightPosition", this::getShadowLightPosition)
.uniformTruncated3f(PER_FRAME, "endFlashPosition", this::getEndFlashPosition)
.uniformTruncated3f(PER_FRAME, "upPosition", CelestialUniforms::getUpPosition);
}
private Vector4f getEndFlashPosition() {
final WorldClient world = Minecraft.getMinecraft().theWorld;
if (world == null || !(world.provider instanceof WorldProviderEnd) || !EndFlashCompat.isAvailable()) {
return ZERO_VECTOR_4f;
}
final float yAngle = EndFlashCompat.getYAngle();
final float xAngle = EndFlashCompat.getXAngle();
endFlashPositionCache.set(0.0F, 100.0F, 0.0F, 0.0F);
endFlashMatrixCache.set(RenderingState.INSTANCE.getModelViewMatrix());
endFlashMatrixCache.rotateY((180.0F - yAngle) * Constants.DEGREES_TO_RADIANS);
endFlashMatrixCache.rotateX((-90.0F - xAngle) * Constants.DEGREES_TO_RADIANS);
endFlashMatrixCache.transform(endFlashPositionCache);
return endFlashPositionCache;
}
private Vector4f getEndFlashPositionInWorldSpace() {
final float yAngle = EndFlashCompat.getYAngle();
final float xAngle = EndFlashCompat.getXAngle();
endFlashPositionCache.set(0.0F, 100.0F, 0.0F, 0.0F);
endFlashMatrixCache.identity();
endFlashMatrixCache.rotateY((180.0F - yAngle) * Constants.DEGREES_TO_RADIANS);
endFlashMatrixCache.rotateX((-90.0F - xAngle) * Constants.DEGREES_TO_RADIANS);
endFlashMatrixCache.transform(endFlashPositionCache);
return endFlashPositionCache;
}
private static boolean isEndFlashShadowActive() {
final WorldClient world = Minecraft.getMinecraft().theWorld;
return world != null && world.provider instanceof WorldProviderEnd
&& EndFlashCompat.isAvailable()
&& Iris.getPipelineManager().getPipeline().map(WorldRenderingPipeline::supportsEndFlash).orElse(false);
}
public static float getSunAngle() {
final float skyAngle = getSkyAngle();
@@ -66,10 +110,16 @@ public final class CelestialUniforms {
}
public Vector4f getShadowLightPosition() {
if (isEndFlashShadowActive()) {
return getEndFlashPosition();
}
return isDay() ? getSunPosition() : getMoonPosition();
}
public Vector4f getShadowLightPositionInWorldSpace() {
if (isEndFlashShadowActive()) {
return getEndFlashPositionInWorldSpace();
}
return isDay() ? getCelestialPositionInWorldSpace(100.0F) : getCelestialPositionInWorldSpace(-100.0F);
}
@@ -58,7 +58,7 @@ public final class CommonUniforms {
SystemTimeUniforms.addSystemTimeUniforms(uniforms);
BiomeUniforms.addBiomeUniforms(uniforms);
new CelestialUniforms(directives.getSunPathRotation()).addCelestialUniforms(uniforms);
IrisExclusiveUniforms.addIrisExclusiveUniforms(uniforms);
IrisExclusiveUniforms.addIrisExclusiveUniforms(uniforms, updateNotifier);
IdMapUniforms.addIdMapUniforms(updateNotifier, uniforms, idMap, directives.isOldHandLight());
MatrixUniforms.addMatrixUniforms(uniforms, directives);
@@ -0,0 +1,19 @@
package net.coderbot.iris.uniforms;
import com.gtnewhorizons.angelica.compat.etfuturum.EndFlashCompat;
import lombok.Getter;
/**
* Holds the current and previous-frame End flash intensity.
*/
@Getter
public class EndFlashStorage {
private float lastEndFlash;
private float currentEndFlash;
public void tick() {
lastEndFlash = currentEndFlash;
currentEndFlash = EndFlashCompat.getIntensity(CapturedRenderingState.INSTANCE.getTickDelta());
}
}
@@ -1,5 +1,6 @@
package net.coderbot.iris.uniforms;
import com.gtnewhorizons.angelica.compat.etfuturum.EndFlashCompat;
import com.gtnewhorizons.angelica.compat.etfuturum.EtFuturumCompat;
import com.gtnewhorizons.angelica.compat.mojang.Camera;
import com.gtnewhorizons.angelica.compat.mojang.GameModeUtil;
@@ -41,9 +42,15 @@ public class IrisExclusiveUniforms {
private static int cachedSelectedFrame = -1;
private static int cachedSelectedBlockId;
public static void addIrisExclusiveUniforms(UniformHolder uniforms) {
public static void addIrisExclusiveUniforms(UniformHolder uniforms, FrameUpdateNotifier updateNotifier) {
WorldInfoUniforms.addWorldInfoUniforms(uniforms);
// Et Futurum Requiem backports the End Flash
final EndFlashStorage endFlashStorage = new EndFlashStorage();
if (EndFlashCompat.isAvailable()) {
updateNotifier.addListener(endFlashStorage::tick);
}
//All Iris-exclusive uniforms (uniforms which do not exist in either OptiFine or ShadersMod) should be registered here.
uniforms.uniform1f(UniformUpdateFrequency.PER_FRAME, "thunderStrength", IrisExclusiveUniforms::getThunderStrength);
uniforms.uniform1f(UniformUpdateFrequency.PER_TICK, "currentPlayerHealth", IrisExclusiveUniforms::getCurrentHealth);
@@ -59,6 +66,8 @@ public class IrisExclusiveUniforms {
uniforms.uniform3d(UniformUpdateFrequency.PER_FRAME, "relativeEyePosition", IrisExclusiveUniforms::getRelativeEyePosition);
uniforms.uniform4f(UniformUpdateFrequency.PER_TICK, "lightningBoltPosition", IrisExclusiveUniforms::getLightningBoltPosition);
uniforms.uniform1f(UniformUpdateFrequency.PER_FRAME, "cloudTime", IrisExclusiveUniforms::getCloudTime);
uniforms.uniform1f(UniformUpdateFrequency.PER_TICK, "endFlashIntensity", endFlashStorage::getCurrentEndFlash);
uniforms.uniform1f(UniformUpdateFrequency.PER_TICK, "previousEndFlashIntensity", endFlashStorage::getLastEndFlash);
uniforms.uniform1b(UniformUpdateFrequency.PER_TICK, "feetInWater", IrisExclusiveUniforms::isFeetInWater);
uniforms.uniform1b(UniformUpdateFrequency.PER_TICK, "isRiding", IrisExclusiveUniforms::isRiding);
uniforms.uniform1b(UniformUpdateFrequency.PER_TICK, "vehicleInWater", IrisExclusiveUniforms::isVehicleInWater);
@@ -12,9 +12,9 @@ public final class ExtendedDataHelper {
public static int computeMidBlock(float x, float y, float z, int localPosX, int localPosY, int localPosZ) {
return packMidBlock(
localPosX + 0.5f - x,
localPosY + 0.5f - y,
localPosZ + 0.5f - z
(localPosX & 0xFFFF) + 0.5f - x,
(localPosY & 0xFFFF) + 0.5f - y,
(localPosZ & 0xFFFF) + 0.5f - z
);
}
}
@@ -3,6 +3,7 @@ package com.gtnewhorizons.angelica.mixins.early.angelica;
import com.gtnewhorizon.gtnhlib.config.ConfigurationManager;
import com.gtnewhorizons.angelica.AngelicaMod;
import com.gtnewhorizons.angelica.config.AngelicaConfig;
import com.gtnewhorizons.angelica.glsm.RenderSystem;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import net.minecraftforge.client.ForgeHooksClient;
import org.apache.logging.log4j.LogManager;
@@ -11,6 +12,7 @@ import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.ContextAttribs;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL32;
import org.lwjgl.opengl.PixelFormat;
import org.lwjgl.LWJGLUtil;
import org.spongepowered.asm.mixin.Mixin;
@@ -63,15 +65,22 @@ public abstract class MixinForgeHooksClient_CoreProfile {
final int platformMaxMinor = (LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_MACOSX) ? 1 : 6;
final int platformMax = platformMaxMajor * 10 + platformMaxMinor;
int maxProbe = platformMax;
// Try pinned version first if configured
final int pinned = angelica$clampPinned(AngelicaConfig.pinnedGLVersion, platformMax);
if (pinned >= 33) {
final Exception e = angelica$tryCreate(attribs, format, setMajor, setMinor, pinned / 10, pinned % 10);
if (e == null) {
LOGGER.info("Created GL {}.{} core profile context (pinned)", pinned / 10, pinned % 10);
return;
final int cap = angelica$validateContext(pinned / 10, pinned % 10);
if (cap == 0) {
LOGGER.info("Created GL {}.{} core profile context (pinned)", pinned / 10, pinned % 10);
return;
}
maxProbe = Math.min(maxProbe, cap);
} else {
LOGGER.warn("Pinned GL version {}.{} failed, probing from highest", pinned / 10, pinned % 10);
}
LOGGER.warn("Pinned GL version {}.{} failed, probing from highest", pinned / 10, pinned % 10);
}
// Probe from highest to lowest
@@ -80,8 +89,14 @@ public abstract class MixinForgeHooksClient_CoreProfile {
final int maxMinor = (major == 4) ? platformMaxMinor : 3;
final int minMinor = (major == 3) ? 3 : 0;
for (int minor = maxMinor; minor >= minMinor; --minor) {
if (major * 10 + minor > maxProbe) continue;
final Exception e = angelica$tryCreate(attribs, format, setMajor, setMinor, major, minor);
if (e == null) {
final int cap = angelica$validateContext(major, minor);
if (cap != 0) {
maxProbe = Math.min(maxProbe, cap);
continue;
}
final int version = major * 10 + minor;
LOGGER.info("Created GL {}.{} core profile context", major, minor);
// Auto-pin if below platform max, or update a stale pin
@@ -127,6 +142,20 @@ public abstract class MixinForgeHooksClient_CoreProfile {
}
}
@Unique
private static int angelica$validateContext(int major, int minor) {
final String glVersion = GLStateManager.glGetString(GL11.GL_VERSION);
final int actual = RenderSystem.parseMajorMinor(glVersion);
final boolean core = (GLStateManager.glGetInteger(GL32.GL_CONTEXT_PROFILE_MASK) & GL32.GL_CONTEXT_CORE_PROFILE_BIT) != 0;
if (RenderSystem.isContextValid(major, minor, actual, core)) {
return 0;
}
LOGGER.warn("Requested GL {}.{} core context but driver returned \"{}\" (core profile: {}, GPU: {}); falling back to a lower version", major, minor, glVersion, core, GLStateManager.glGetString(GL11.GL_RENDERER));
try { Display.destroy(); } catch (Exception ignored) {}
final int requested = major * 10 + minor;
return (actual >= 0 && actual < requested) ? actual : requested - 1;
}
@Unique
private static void angelica$savePin(int version) {
AngelicaConfig.pinnedGLVersion = version;
@@ -27,6 +27,7 @@ package com.gtnewhorizons.angelica.mixins.early.angelica.itemrenderer;
import com.gtnewhorizon.gtnhlib.client.renderer.DirectTessellator;
import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.rendering.items.ItemRenderListManager;
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
@@ -43,6 +44,10 @@ public abstract class MixinItemRenderer {
@WrapMethod(method = "renderItemIn2D")
private static void angelica$cacheItem(Tessellator tessellator, float minU, float minV, float maxU, float maxV, int widthSubdivisions, int heightSubdivisions, float thickness, Operation<Void> original) {
if (GLStateManager.isRecordingDisplayList() || TessellatorManager.isCurrentlyCapturing() || TessellatorManager.shouldInterceptDraw(Tessellator.instance)) {
original.call(tessellator, minU, minV, maxU, maxV, widthSubdivisions, heightSubdivisions, thickness);
return;
}
final ItemRenderListManager.CachedVBO vbo = ItemRenderListManager.pre(minU, minV, maxU, maxV, widthSubdivisions, heightSubdivisions, thickness);
if (vbo != null) {
final DirectTessellator tess = TessellatorManager.startCapturingDirect();
@@ -1,12 +1,15 @@
package com.gtnewhorizons.angelica.mixins.early.angelica.itemrenderer;
import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.rendering.items.BlockRenderListManager;
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -23,6 +26,15 @@ public abstract class MixinRenderBlocks {
@Shadow
public IIcon overrideBlockTexture;
@Shadow public IBlockAccess blockAccess;
@Shadow public int uvRotateEast;
@Shadow public int uvRotateWest;
@Shadow public int uvRotateSouth;
@Shadow public int uvRotateNorth;
@Shadow public int uvRotateTop;
@Shadow public int uvRotateBottom;
@WrapMethod(method = "renderBlockAsItem")
private void angelica$cacheBlockItemRenderer(Block block, int meta, float brightness, Operation<Void> original) {
if (BlockRenderListManager.isISBRH(block.getRenderType())
@@ -30,6 +42,11 @@ public abstract class MixinRenderBlocks {
|| this.overrideBlockTexture != null
|| brightness != 1.0F
|| !this.useInventoryTint
|| this.blockAccess != null
|| (uvRotateEast | uvRotateWest | uvRotateSouth | uvRotateNorth | uvRotateTop | uvRotateBottom) != 0
|| GLStateManager.isRecordingDisplayList()
|| TessellatorManager.isCurrentlyCapturing()
|| TessellatorManager.shouldInterceptDraw(Tessellator.instance)
) {
// Do not cache those
original.call(block, meta, brightness);
@@ -0,0 +1,14 @@
package com.gtnewhorizons.angelica.mixins.early.rendering;
import net.minecraft.block.BlockLiquid;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(BlockLiquid.class)
public interface BlockLiquidFlowInvoker {
@Invoker("getFlowVector")
Vec3 angelica$getFlowVector(IBlockAccess world, int x, int y, int z);
}
@@ -0,0 +1,22 @@
package com.gtnewhorizons.angelica.mixins.early.rendering;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLiquid;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(BlockLiquid.class)
public class MixinBlockLiquid {
@Redirect(
method = "getFlowDirection",
at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockLiquid;getFlowVector(Lnet/minecraft/world/IBlockAccess;III)Lnet/minecraft/util/Vec3;"))
private static Vec3 angelica$flowVectorOfActualBlock(BlockLiquid singleton, IBlockAccess world, int x, int y, int z) {
final Block block = world.getBlock(x, y, z);
final BlockLiquid liquid = block instanceof BlockLiquid ? (BlockLiquid) block : singleton;
return ((BlockLiquidFlowInvoker) liquid).angelica$getFlowVector(world, x, y, z);
}
}
@@ -1,5 +1,6 @@
package com.gtnewhorizons.angelica.mixins.early.rendering;
import com.gtnewhorizons.angelica.api.ExtCeleritasRenderBlocks;
import com.gtnewhorizons.angelica.common.BlockError;
import com.gtnewhorizons.angelica.loading.AngelicaClientTweaker;
import com.gtnewhorizons.angelica.proxy.ClientProxy;
@@ -33,7 +34,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(RenderBlocks.class)
public abstract class MixinRenderBlocks {
public abstract class MixinRenderBlocks implements ExtCeleritasRenderBlocks {
@Shadow
public abstract boolean renderStandardBlockWithColorMultiplier(Block p_147736_1_, int p_147736_2_, int p_147736_3_, int p_147736_4_, float p_147736_5_, float p_147736_6_, float p_147736_7_);
@@ -109,8 +110,7 @@ public abstract class MixinRenderBlocks {
*/
@Inject(method = { "renderStandardBlockWithAmbientOcclusion", "renderStandardBlockWithAmbientOcclusionPartial" }, at = @At("HEAD"), cancellable = true)
private void handleCeleritasAo(Block block, int x, int y, int z, float r, float g, float b, CallbackInfoReturnable<Boolean> cir) {
if ((this.isRenderingByType && Minecraft.isAmbientOcclusionEnabled() && ClientProxy.options().quality.useCeleritasSmoothLighting) ||
(Iris.enabled && BlockRenderingSettings.INSTANCE.shouldUseSeparateAo())) {
if (angelica$shouldApplyCeleritasAO()) {
this.applyingCeleritasAO = true;
try {
cir.setReturnValue(this.renderStandardBlockWithColorMultiplier(block, x, y, z, r, g, b));
@@ -120,6 +120,17 @@ public abstract class MixinRenderBlocks {
}
}
@Override
public boolean angelica$shouldApplyCeleritasAO() {
return (this.isRenderingByType && Minecraft.isAmbientOcclusionEnabled() && ClientProxy.options().quality.useCeleritasSmoothLighting) ||
(Iris.enabled && BlockRenderingSettings.INSTANCE.shouldUseSeparateAo());
}
@Override
public void angelica$setApplyingCeleritasAO(boolean val) {
this.applyingCeleritasAO = val;
}
/**
* Widen the grass identity check ({@code block != Blocks.grass}) to cover any BlockGrass subclass
* (e.g. BOP's loamy/sandy/silty grass). When the block being rendered IS a BlockGrass, we return
@@ -237,4 +248,9 @@ public abstract class MixinRenderBlocks {
private void compactCtm_resetAfterBlock(Block block, int x, int y, int z, CallbackInfoReturnable<Boolean> cir) {
CTMUtils.clearCurrentCompact();
}
@Inject(method = "renderBlockAsItem", at = @At("HEAD"))
private void compactCtm_resetBeforeItem(Block block, int meta, float brightness, CallbackInfo ci) {
CTMUtils.clearCurrentCompact();
}
}
@@ -0,0 +1,22 @@
package com.gtnewhorizons.angelica.mixins.late.client.farseek;
import com.gtnewhorizons.angelica.rendering.celeritas.world.WorldSlice;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.WorldProvider;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Pseudo;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Pseudo
@Mixin(targets = "farseek.world.package$IBlockAccessValue$", remap = false)
public class MixinFarseekIBlockAccessValue {
@Inject(method = "worldProvider$extension", at = @At("HEAD"), cancellable = true, remap = false)
private void angelica$worldSliceProvider(IBlockAccess bac, CallbackInfoReturnable<WorldProvider> cir) {
if (bac instanceof WorldSlice slice) {
cir.setReturnValue(slice.getWorld().provider);
}
}
}