Compare commits

...
Author SHA1 Message Date
Caedis f118211257 Fix IC2 universal cell rendering w/offhand (#876) 2025-02-18 10:49:29 -08:00
RecursivePineapple 81d03ea552 Fix PBR specular & normal textures getting ignored (#874)
* Fix PBR textures not loading

- Stack was being overfilled by MemoryStack
- Added tons of logging for ignored important exceptions
- Added missing interface on mixin (should it be moved to gtnhlib?)

* Move PBR debug to angelica config

* Free malloc'd memory
2025-02-18 18:34:38 +00:00
RecursivePineapple 67c8628aeb Fix a handful of broken animations (#868)
* Fix warning

* Improve animated sprite tracking

* Fix NPE in animation code

* Fix animations for abnormally rendered items

* Swap Stack for ArrayDeque
2025-02-18 18:28:54 +00:00
embeddedt f9b9873637 Avoid checking frustum visibility of infinite bounding boxes 2025-02-18 10:24:09 -08:00
DarkShadow44 c66bf8658e Fix issue with dynamic lights world mixin not respecting opaque blocks (#872) 2025-02-17 10:36:34 -06:00
DarkShadow44 052824017d Fix crash when keycode is negative (#871) 2025-02-16 21:43:15 +00:00
Caedis 6a5d914a43 add offhand support via Backhand (up required version to 1.6.9) (#859) 2025-02-04 12:41:47 -05:00
Calvin Reveraster 208373deaa Fix any dimension without a sky getting flagged as the nether (#857)
* fix crash when connected textures are disabled, but custom colors are enabled.

* Dimension Check Fix

Dimension check set any dimension with no sky as the nether; this includes the end, and several custom dims such as Witchery's mirror dim, etc.
2025-02-01 09:18:29 -08:00
TotallyNotOndre f22a3f612b Fix slider dragging in iris options (#858) 2025-02-01 09:17:26 -08:00
TotallyNotOndre 9ff1015d19 Fix shadow render distance reset to 32 (#856) 2025-01-31 11:18:09 -08:00
Calvin Reveraster 0023fe3da2 fix crash when connected textures are disabled, but custom colors are enabled. (#855) 2025-01-29 08:19:50 -08:00
Raven Szewczyk 7e2399714c Use GTNHLib MemoryUtils instead of the builtin compat ones (#853) 2025-01-26 11:20:43 -08:00
George Paton 9029182353 Fix Hodgepodge animation speedup breaking animated textures (#850) 2025-01-25 15:34:51 -08:00
Caedis e6039691b5 Remove forced even unicode gui scaling (#840) 2025-01-15 14:39:21 -06:00
paulzzh 5db1edba33 fix MC-76356 Bold unicode characters appear doubled (#834) 2025-01-05 15:24:16 +00:00
Martin Robertz d450461726 update bs + deps (#823) 2025-01-04 13:50:46 -08:00
embeddedt 95f8afc0f3 Remove use of empty build tasks, submit empty data directly to result queue (#821) 2024-12-27 21:39:05 -08:00
Caedis 19635e20ec Disable optimizeInWorldItemRendering by default for now (#820) 2024-12-25 23:25:42 -06:00
BucketBrigade ead4e11376 Expose texture updates to API (#805)
* Expose texture updates to API

* Expose for blocks as well

* Fix mistake

* Fixed API
2024-12-19 19:04:24 -08:00
FM Bellomy b0ceb5306a the most boring typo PR of all time (#810) 2024-12-19 13:25:56 -08:00
embeddedt 99a81369f0 fix origin weirdness (#799) 2024-12-17 10:09:22 -08:00
nshepperd e2ee822948 Only clear the translucency sorting render queue when we're not rendering shadows. (#798) 2024-12-16 13:30:20 -08:00
nshepperd 9fe7e800f6 Remove broken reflection in ChunkBufferSorter. (#797) 2024-12-16 21:11:05 +00:00
embeddedt debfcdfda0 Properly prevent block face culling when TS is active (#796) 2024-12-16 13:07:00 -08:00
embeddedt df662188f4 Fix terrain rendering incorrectly when far from origin (#790) 2024-12-13 18:14:00 +00:00
embeddedt 842916405f Fix rebuild check being wrong when shaders are on (#788) 2024-12-13 16:55:58 +00:00
embeddedt 09afe81290 Fix chunk render manager state not swapping, causing lower render distance with shaders on 2024-12-13 08:52:32 -08:00
Caedis 292809d8e8 Actually fix xaero's crosshair (#781) 2024-12-11 21:50:04 +00:00
Caedis 47503ce254 Fix invisible crosshair with Xaero's Minimap (#775) 2024-12-11 16:32:49 -05:00
ah-OOG-ah f738adbdef Frametime exploration (#742)
* Sleep before swap

* Add a config

* I think this is slightly less jittery
2024-12-06 09:09:26 -08:00
80 changed files with 693 additions and 1176 deletions

No files matched your search

+17 -17
View File
@@ -49,19 +49,19 @@ configurations {
}
dependencies {
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.5.78")
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.6.23")
compileOnly("com.gtnewhorizons.retrofuturabootstrap:RetroFuturaBootstrap:0.4.0") { transitive = false }
compileOnly("com.gtnewhorizons.retrofuturabootstrap:RetroFuturaBootstrap:1.0.7") { transitive = false }
compileOnly("org.projectlombok:lombok:1.18.22") { transitive = false }
annotationProcessor("org.projectlombok:lombok:1.18.22")
compileOnly("org.projectlombok:lombok:1.18.34") { transitive = false }
annotationProcessor("org.projectlombok:lombok:1.18.34")
// Use modern models+textures to inject QuadProviders
devOnlyNonPublishable('com.github.GTNewHorizons:TX-Loader:1.7.2:dev')
devOnlyNonPublishable('com.github.GTNewHorizons:TX-Loader:1.8.0:dev')
// Iris Shaders
compileOnly('org.jetbrains:annotations:24.0.1')
api("com.github.GTNewHorizons:GTNHLib:0.5.20:dev")
compileOnly('org.jetbrains:annotations:26.0.2')
api("com.github.GTNewHorizons:GTNHLib:0.6.8:dev")
shadowImplementation("org.anarres:jcpp:1.4.14") // Apache 2.0
shadowImplementation("org.taumc:glsl-transformation-lib:0.2.0-4.g6b42bca") {
exclude module: "antlr4" // we only want to shadow the runtime module
@@ -70,21 +70,21 @@ dependencies {
compileOnly "org.apache.ant:ant:1.8.2"
// Because who doesn't want NEI
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.6.45-GTNH:dev')
devOnlyNonPublishable('com.github.GTNewHorizons:CodeChickenCore:1.3.10:dev')
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.7.27-GTNH:dev')
devOnlyNonPublishable('com.github.GTNewHorizons:CodeChickenCore:1.4.1:dev')
// Notfine Deps
compileOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev")
devOnlyNonPublishable("com.github.GTNewHorizons:Baubles:1.0.4:dev")
compileOnly("com.github.GTNewHorizons:twilightforest:2.6.35:dev") { transitive = false }
compileOnly("com.github.GTNewHorizons:twilightforest:2.7.4:dev") { transitive = false }
compileOnly(rfg.deobf('curse.maven:witchery-69673:2234410'))
compileOnly("com.github.GTNewHorizons:TinkersConstruct:1.12.14-GTNH:dev") { transitive = false }
compileOnly("com.github.GTNewHorizons:Natura:2.7.5:dev")
compileOnly("com.github.GTNewHorizons:TinkersConstruct:1.13.8-GTNH:dev") { transitive = false }
compileOnly("com.github.GTNewHorizons:Natura:2.8.2:dev")
compileOnly("com.github.GTNewHorizons:ThaumicHorizons:1.6.4:dev")
compileOnly("com.github.GTNewHorizons:ThaumicHorizons:1.7.1:dev")
compileOnly("com.github.GTNewHorizons:Battlegear2:1.4.1:dev") { transitive = false }
compileOnly(rfg.deobf('maven.modrinth:backhand:1.4.1')) { transitive = false }
compileOnly("com.github.GTNewHorizons:Battlegear2:1.4.2:dev") { transitive = false }
compileOnly('com.github.GTNewHorizons:Backhand:1.6.9') { transitive = false }
compileOnly("com.falsepattern:chunkapi-mc1.7.10:0.5.1:api") { transitive = false }
compileOnly("com.falsepattern:endlessids-mc1.7.10:1.5-beta0003:dev") { transitive = false }
@@ -100,7 +100,7 @@ dependencies {
compileOnly(rfg.deobf("curse.maven:campfirebackport-387444:4611675"))
compileOnly(rfg.deobf("curse.maven:xaeros-minimap-263420:5060684"))
compileOnly("com.github.GTNewHorizons:HoloInventory:2.4.13-GTNH:dev")
compileOnly("com.github.GTNewHorizons:HoloInventory:2.5.0-GTNH:dev")
runtimeOnlyNonPublishable(rfg.deobf("CoreTweaks:CoreTweaks:0.3.3.2"))
@@ -111,7 +111,7 @@ dependencies {
compileOnly("com.github.GTNewHorizons:BetterCrashes:1.4.0-GTNH:dev")
// Tests
testImplementation(platform('org.junit:junit-bom:5.9.2'))
testImplementation(platform('org.junit:junit-bom:5.11.4'))
testImplementation('org.junit.jupiter:junit-jupiter')
testImplementation("org.mockito:mockito-core:3.+")
testImplementation("org.lwjgl.lwjgl:lwjgl:2.9.4-nightly-20150209")
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
+1 -1
View File
@@ -16,5 +16,5 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.29'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.32'
}
@@ -16,7 +16,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
name = "Angelica",
version = Tags.VERSION,
dependencies = " before:lwjgl3ify@[1.5.3,);" + " after:hodgepodge@[2.4.4,);" + " after:CodeChickenCore@[1.2.0,);"
+ " after:archaicfix@[0.7.0,);" + " required-after:gtnhlib@[0.4.2,);",
+ " after:archaicfix@[0.7.0,);" + " required-after:gtnhlib@[0.6.6,);",
acceptedMinecraftVersions = "[1.7.10]",
acceptableRemoteVersions = "*",
guiFactory = "com.gtnewhorizons.angelica.config.AngelicaGuiConfigFactory")
@@ -0,0 +1,27 @@
package com.gtnewhorizons.angelica.api;
import com.gtnewhorizons.angelica.mixins.interfaces.IPatchedTextureAtlasSprite;
import com.gtnewhorizons.angelica.mixins.interfaces.ITexturesCache;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.util.IIcon;
/**
* Exposes a method to the API that allow mods to add texture update compat
*/
@SuppressWarnings("unused")
public class TextureServices {
@SuppressWarnings("unused")
public static void updateBlockTextureAnimation(IIcon icon, RenderBlocks renderBlocks) {
if (renderBlocks instanceof ITexturesCache texturesCache) {
texturesCache.getRenderedTextures().add(icon);
}
}
@SuppressWarnings("unused")
public static void updateTextureAnimation(IIcon icon) {
if(icon instanceof IPatchedTextureAtlasSprite patchedSprite) {
patchedSprite.markNeedsAnimationUpdate();
}
}
}
@@ -1,6 +1,7 @@
package com.gtnewhorizons.angelica.client.font;
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.mixins.interfaces.FontRendererAccessor;
import it.unimi.dsi.fastutil.chars.Char2ShortOpenHashMap;
@@ -10,7 +11,6 @@ import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import java.nio.ByteBuffer;
@@ -97,10 +97,10 @@ public class BatchingFontRenderer {
private static final int INITIAL_BATCH_SIZE = 256;
private static final ResourceLocation DUMMY_RESOURCE_LOCATION = new ResourceLocation("angelica$dummy",
"this is invalid!");
private FloatBuffer batchVtxPositions = BufferUtils.createFloatBuffer(INITIAL_BATCH_SIZE * 2);
private ByteBuffer batchVtxColors = BufferUtils.createByteBuffer(INITIAL_BATCH_SIZE * 4);
private FloatBuffer batchVtxTexCoords = BufferUtils.createFloatBuffer(INITIAL_BATCH_SIZE * 2);
private IntBuffer batchIndices = BufferUtils.createIntBuffer(INITIAL_BATCH_SIZE / 2 * 3);
private FloatBuffer batchVtxPositions = memAllocFloat(INITIAL_BATCH_SIZE * 2);
private ByteBuffer batchVtxColors = memAlloc(INITIAL_BATCH_SIZE * 4);
private FloatBuffer batchVtxTexCoords = memAllocFloat(INITIAL_BATCH_SIZE * 2);
private IntBuffer batchIndices = memAllocInt(INITIAL_BATCH_SIZE / 2 * 3);
private final ObjectArrayList<FontDrawCmd> batchCommands = ObjectArrayList.wrap(new FontDrawCmd[64], 0);
private final ObjectArrayList<FontDrawCmd> batchCommandPool = ObjectArrayList.wrap(new FontDrawCmd[64], 0);
@@ -109,12 +109,12 @@ public class BatchingFontRenderer {
final int oldCap = batchVtxPositions.capacity() / 2;
if (vtxWriterIndex >= oldCap) {
final int newCap = oldCap * 2;
batchVtxPositions = CompatMemoryUtil.memReallocDirect(batchVtxPositions, newCap * 2);
batchVtxColors = CompatMemoryUtil.memReallocDirect(batchVtxColors, newCap * 4);
batchVtxTexCoords = CompatMemoryUtil.memReallocDirect(batchVtxTexCoords, newCap * 2);
batchVtxPositions = memRealloc(batchVtxPositions, newCap * 2);
batchVtxColors = memRealloc(batchVtxColors, newCap * 4);
batchVtxTexCoords = memRealloc(batchVtxTexCoords, newCap * 2);
final int oldIdxCap = batchIndices.capacity();
final int newIdxCap = oldIdxCap * 2;
batchIndices = CompatMemoryUtil.memReallocDirect(batchIndices, newIdxCap);
batchIndices = memRealloc(batchIndices, newIdxCap);
}
final int idx = vtxWriterIndex;
final int idx2 = idx * 2;
@@ -437,8 +437,6 @@ public class BatchingFontRenderer {
chr = MCFONT_CHARS.charAt(lutIndex);
}
final float shadowOffset = unicodeFlag ? 0.5F : 1.0F;
// Check ASCII space, NBSP, NNBSP
if (chr == ' ' || chr == '\u00A0' || chr == '\u202F') {
curX += 4;
@@ -452,6 +450,7 @@ public class BatchingFontRenderer {
final float uSz;
final float vSz;
final float itOff = curItalic ? 1.0F : 0.0F; // italic offset
final float shadowOffset;
final ResourceLocation texture;
if (lutIndex == -1 || unicodeFlag) {
@@ -459,6 +458,7 @@ public class BatchingFontRenderer {
continue;
}
// Draw unicode char
shadowOffset = 0.5F;
final int uniPage = chr / 256;
texture = getUnicodePageLocation(uniPage);
final int startColumn = this.glyphWidth[chr] >>> 4;
@@ -475,6 +475,7 @@ public class BatchingFontRenderer {
} else {
// Draw "ASCII" char
shadowOffset = 1.0F;
uStart = ((lutIndex % 16) * 8) / 128.0F;
vStart = (float) ((lutIndex / 16) * 8) / 128.0F;
xAdvance = this.charWidth[lutIndex];
@@ -62,7 +62,7 @@ public class ModStatus {
}
if (isBackhandLoaded){
isBackhandLoaded = new DefaultArtifactVersion("1.4.1")
isBackhandLoaded = new DefaultArtifactVersion("1.6.9")
.compareTo(
LoadControllerHelper.getOwningMod(Backhand.class).getProcessedVersion()
) <= 0;
@@ -1,327 +0,0 @@
package com.gtnewhorizons.angelica.compat.lwjgl;
import static com.gtnewhorizons.angelica.compat.lwjgl.Pointer.BITS64;
import it.unimi.dsi.fastutil.longs.LongPredicate;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import org.lwjgl.BufferUtils;
/**
* Backported from LWJGL3 under the BSD 3-Clause "New" or "Revised" License license
*
* <p>This class provides functionality for managing native memory.
*
* <p>All methods in this class will make use of {@link sun.misc.Unsafe} if it's available, for performance. If Unsafe is not available, the fallback
* implementations make use of reflection and, in the worst-case, JNI.</p>
*
* <p>Method names in this class are prefixed with {@code mem} to avoid ambiguities when used with static imports.</p>
*/
public class CompatMemoryUtil {
public static final long NULL = 0;
static final sun.misc.Unsafe UNSAFE;
private static final Class<? extends ByteBuffer> BUFFER_BYTE;
private static final Class<? extends IntBuffer> BUFFER_INT;
private static final Class<? extends FloatBuffer> BUFFER_FLOAT;
private static final long MARK;
private static final long POSITION;
private static final long LIMIT;
private static final long CAPACITY;
private static final long ADDRESS;
static {
ByteBuffer bb = ByteBuffer.allocateDirect(0).order(ByteOrder.nativeOrder());
BUFFER_BYTE = bb.getClass();
BUFFER_INT = bb.asIntBuffer().getClass();
BUFFER_FLOAT = bb.asFloatBuffer().getClass();
UNSAFE = getUnsafeInstance();
MARK = getMarkOffset();
POSITION = getPositionOffset();
LIMIT = getLimitOffset();
CAPACITY = getCapacityOffset();
ADDRESS = getAddressOffset();
}
public static ByteBuffer memReallocDirect(ByteBuffer old, int capacity) {
ByteBuffer newBuf = BufferUtils.createByteBuffer(capacity);
int oldPos = old.position();
old.rewind();
newBuf.put(old);
newBuf.position(Math.min(capacity, oldPos));
return newBuf;
}
public static IntBuffer memReallocDirect(IntBuffer old, int capacity) {
IntBuffer newBuf = BufferUtils.createIntBuffer(capacity);
int oldPos = old.position();
old.rewind();
newBuf.put(old);
newBuf.position(Math.min(capacity, oldPos));
return newBuf;
}
public static FloatBuffer memReallocDirect(FloatBuffer old, int capacity) {
FloatBuffer newBuf = BufferUtils.createFloatBuffer(capacity);
int oldPos = old.position();
old.rewind();
newBuf.put(old);
newBuf.position(Math.min(capacity, oldPos));
return newBuf;
}
/* -------------------------------------
-------------------------------------
UNSAFE MEMORY ACCESS API
-------------------------------------
------------------------------------- */
private static final int FILL_PATTERN_32 = Integer.divideUnsigned(-1, 255);
private static final long FILL_PATTERN_64 = Long.divideUnsigned(-1L, 255L);
/**
* Sets all bytes in a specified block of memory to a fixed value (usually zero).
*
* @param ptr the starting memory address
* @param value the value to set (memSet will convert it to unsigned byte)
* @param bytes the number of bytes to set
*/
public static void memSet(long ptr, int value, long bytes) {
if (/*DEBUG*/ false && (ptr == NULL || bytes < 0)) {
throw new IllegalArgumentException();
}
/*
- Unsafe.setMemory is very slow.
- A custom Java loop is fastest at small sizes, approximately up to 256 bytes.
- The native memset becomes fastest at bigger sizes, when the JNI overhead becomes negligible.
TODO: verify this
*/
//UNSAFE.setMemory(ptr, bytes, (byte)(value & 0xFF));
//if (bytes < 256L) {
int p = (int)ptr;
if (BITS64) {
if ((p & 7) == 0) {
memSet64(ptr, value, (int)bytes & 0xFF);
return;
}
} else {
if ((p & 3) == 0) {
memSet32(p, value, (int)bytes & 0xFF);
return;
}
}
//}
//nmemset(ptr, value, bytes);
}
private static void memSet64(long ptr, int value, int bytes) {
int aligned = bytes & ~7;
// Aligned body
long valuel = (value & 0xFF) * FILL_PATTERN_64;
for (int i = 0; i < aligned; i += 8) {
UNSAFE.putLong(null, ptr + i, valuel);
}
// Unaligned tail
byte valueb = (byte)(value & 0xFF);
for (int i = aligned; i < bytes; i++) {
UNSAFE.putByte(null, ptr + i, valueb);
}
}
private static void memSet32(int ptr, int value, int bytes) {
int aligned = bytes & ~3;
// Aligned body
int vi = (value & 0xFF) * FILL_PATTERN_32;
for (int i = 0; i < aligned; i += 4) {
UNSAFE.putInt(null, (ptr + i) & 0xFFFF_FFFFL, vi);
}
// Unaligned tail
byte vb = (byte)(value & 0xFF);
for (int i = aligned; i < bytes; i++) {
UNSAFE.putByte(null, (ptr + i) & 0xFFFF_FFFFL, vb);
}
}
public static boolean memGetBoolean(long ptr) { return UNSAFE.getByte(null, ptr) != 0; }
public static byte memGetByte(long ptr) { return UNSAFE.getByte(null, ptr); }
public static short memGetShort(long ptr) { return UNSAFE.getShort(null, ptr); }
public static int memGetInt(long ptr) { return UNSAFE.getInt(null, ptr); }
public static long memGetLong(long ptr) { return UNSAFE.getLong(null, ptr); }
public static float memGetFloat(long ptr) { return UNSAFE.getFloat(null, ptr); }
public static double memGetDouble(long ptr) { return UNSAFE.getDouble(null, ptr); }
public static void memPutByte(long ptr, byte value) { UNSAFE.putByte(null, ptr, value); }
public static void memPutShort(long ptr, short value) { UNSAFE.putShort(null, ptr, value); }
public static void memPutInt(long ptr, int value) { UNSAFE.putInt(null, ptr, value); }
public static void memPutLong(long ptr, long value) { UNSAFE.putLong(null, ptr, value); }
public static void memPutFloat(long ptr, float value) { UNSAFE.putFloat(null, ptr, value); }
public static void memPutDouble(long ptr, double value) { UNSAFE.putDouble(null, ptr, value); }
// -------------------------------------------------
// -------------------------------------------------
// -------------------------------------------------
private static sun.misc.Unsafe getUnsafeInstance() {
java.lang.reflect.Field[] fields = sun.misc.Unsafe.class.getDeclaredFields();
/*
Different runtimes use different names for the Unsafe singleton,
so we cannot use .getDeclaredField and we scan instead. For example:
Oracle: theUnsafe
PERC : m_unsafe_instance
Android: THE_ONE
*/
for (java.lang.reflect.Field field : fields) {
if (!field.getType().equals(sun.misc.Unsafe.class)) {
continue;
}
int modifiers = field.getModifiers();
if (!(java.lang.reflect.Modifier.isStatic(modifiers) && java.lang.reflect.Modifier.isFinal(modifiers))) {
continue;
}
try {
field.setAccessible(true);
return (sun.misc.Unsafe)field.get(null);
} catch (Exception ignored) {
}
break;
}
throw new UnsupportedOperationException("LWJGL requires sun.misc.Unsafe to be available.");
}
/**
* Recursively searches an object and its superclasses for a field with the same name and type. If the field isn't
* public, it may not be stable across library/JVM versions, and these calls are likely not portable. You have been
* warned!
*/
private static long getFieldOffset(Class<?> containerType, Class<?> fieldType, String name) {
Class<?> c = containerType;
while (c != Object.class) {
Field[] fields = c.getDeclaredFields();
for (Field field : fields) {
if (!field.getType().isAssignableFrom(fieldType) || Modifier.isStatic(field.getModifiers()) || field.isSynthetic()) {
continue;
}
long offset = UNSAFE.objectFieldOffset(field);
if (field.getName().equals(name)) {
return offset;
}
}
c = c.getSuperclass();
}
throw new UnsupportedOperationException("Failed to find field offset in class.");
}
private static long getFieldOffset(Class<?> containerType, Class<?> fieldType, LongPredicate predicate) {
Class<?> c = containerType;
while (c != Object.class) {
Field[] fields = c.getDeclaredFields();
for (Field field : fields) {
if (!field.getType().isAssignableFrom(fieldType) || Modifier.isStatic(field.getModifiers()) || field.isSynthetic()) {
continue;
}
long offset = UNSAFE.objectFieldOffset(field);
if (predicate.test(offset)) {
return offset;
}
}
c = c.getSuperclass();
}
throw new UnsupportedOperationException("Failed to find field offset in class.");
}
private static long getFieldOffsetInt(Object container, int value) {
return getFieldOffset(container.getClass(), int.class, offset -> UNSAFE.getInt(container, offset) == value);
}
private static long getAddressOffset() {
final ByteBuffer bb = ByteBuffer.allocateDirect(0);
return getFieldOffset(bb.getClass(), long.class, "address");
// TODO: do this portably
// long MAGIC_ADDRESS = 0xDEADBEEF8BADF00DL & (BITS32 ? 0xFFFF_FFFFL : 0xFFFF_FFFF_FFFF_FFFFL);
// ByteBuffer bb = Objects.requireNonNull(NewDirectByteBuffer(MAGIC_ADDRESS, 0));
//return getFieldOffset(bb.getClass(), long.class, offset -> UNSAFE.getLong(bb, offset) == MAGIC_ADDRESS);
}
private static final int MAGIC_CAPACITY = 0x0D15EA5E;
private static final int MAGIC_POSITION = 0x00FACADE;
private static long getMarkOffset() {
// TODO: is this actually reliable without NewDirectByteBuffer?
ByteBuffer bb = ByteBuffer.allocateDirect(0);
return getFieldOffsetInt(bb, -1);
// ByteBuffer bb = Objects.requireNonNull(NewDirectByteBuffer(1L, 0));
// return getFieldOffsetInt(bb, -1);
}
private static long getPositionOffset() {
ByteBuffer bb = ByteBuffer.allocateDirect(MAGIC_CAPACITY);
bb.position(MAGIC_POSITION);
return getFieldOffsetInt(bb, MAGIC_POSITION);
}
private static long getLimitOffset() {
ByteBuffer bb = ByteBuffer.allocateDirect(MAGIC_CAPACITY);
bb.limit(MAGIC_POSITION);
return getFieldOffsetInt(bb, MAGIC_POSITION);
}
private static long getCapacityOffset() {
ByteBuffer bb = ByteBuffer.allocateDirect(MAGIC_CAPACITY);
bb.limit(0);
return getFieldOffsetInt(bb, MAGIC_CAPACITY);
}
static IntBuffer wrapBufferInt(long address, int capacity) {
IntBuffer buffer;
try {
buffer = (IntBuffer)UNSAFE.allocateInstance(BUFFER_INT);
} catch (InstantiationException e) {
throw new UnsupportedOperationException(e);
}
UNSAFE.putLong(buffer, ADDRESS, address);
UNSAFE.putInt(buffer, MARK, -1);
UNSAFE.putInt(buffer, LIMIT, capacity);
UNSAFE.putInt(buffer, CAPACITY, capacity);
return buffer;
}
static FloatBuffer wrapBufferFloat(long address, int capacity) {
FloatBuffer buffer;
try {
buffer = (FloatBuffer)UNSAFE.allocateInstance(BUFFER_FLOAT);
} catch (InstantiationException e) {
throw new UnsupportedOperationException(e);
}
UNSAFE.putLong(buffer, ADDRESS, address);
UNSAFE.putInt(buffer, MARK, -1);
UNSAFE.putInt(buffer, LIMIT, capacity);
UNSAFE.putInt(buffer, CAPACITY, capacity);
return buffer;
}
}
@@ -1,382 +0,0 @@
/*
* This class is backported from LWJGL3 under the BSD 3-clause "New" or "Revised" License
*/
package com.gtnewhorizons.angelica.compat.lwjgl;
import static com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil.memPutDouble;
import static com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil.memPutFloat;
import static com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil.memPutInt;
import static com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil.memPutLong;
import static com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil.memPutShort;
import static com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil.memSet;
import static com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil.wrapBufferFloat;
import static com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil.wrapBufferInt;
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.util.Arrays;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.BufferUtils;
import org.lwjgl.MemoryUtil;
/**
* An off-heap memory stack.
*
* <p>This class should be used in a thread-local manner for stack allocations.</p>
*
* @ see Configuration#STACK_SIZE
* @ see Configuration#DEBUG_STACK
*/
@SuppressWarnings("LombokGetterMayBeUsed")
public class MemoryStack extends Pointer.Default implements AutoCloseable {
private static final int DEFAULT_STACK_SIZE = /*Configuration.STACK_SIZE.get(64)*/ 64 * 1024;
private static final int DEFAULT_STACK_FRAMES = 8;
private static final ThreadLocal<MemoryStack> TLS = ThreadLocal.withInitial(MemoryStack::create);
static {
if (DEFAULT_STACK_SIZE < 0) {
throw new IllegalStateException("Invalid stack size.");
}
}
@SuppressWarnings({"FieldCanBeLocal", "unused"})
private final @Nullable ByteBuffer container;
private final int size;
private int pointer;
private int[] frames;
protected int frameIndex;
/**
* Creates a new {@code MemoryStack} backed by the specified memory region.
*
* <p>In the initial state, there is no active stack frame. The {@link #push} method must be used before any allocations.</p>
*
* @param container the backing memory buffer, may be null
* @param address the backing memory address
* @param size the backing memory size
*/
protected MemoryStack(@Nullable ByteBuffer container, long address, int size) {
super(address);
this.container = container;
this.size = size;
this.pointer = size;
this.frames = new int[DEFAULT_STACK_FRAMES];
}
/**
* Creates a new {@code MemoryStack} with the default size.
*
* <p>In the initial state, there is no active stack frame. The {@link #push} method must be used before any allocations.</p>
*/
public static MemoryStack create() {
return create(DEFAULT_STACK_SIZE);
}
/**
* Creates a new {@code MemoryStack} with the specified size.
*
* <p>In the initial state, there is no active stack frame. The {@link #push} method must be used before any allocations.</p>
*
* @param capacity the maximum number of bytes that may be allocated on the stack
*/
public static MemoryStack create(int capacity) {
return create(BufferUtils.createByteBuffer(capacity));
}
/**
* Creates a new {@code MemoryStack} backed by the specified memory buffer.
*
* <p>In the initial state, there is no active stack frame. The {@link #push} method must be used before any allocations.</p>
*
* @param buffer the backing memory buffer
*/
public static MemoryStack create(ByteBuffer buffer) {
long address = MemoryUtil.getAddress(buffer);
int size = buffer.remaining();
return new MemoryStack(buffer, address, size);
}
/**
* Creates a new {@code MemoryStack} backed by the specified memory region.
*
* <p>In the initial state, there is no active stack frame. The {@link #push} method must be used before any allocations.</p>
*
* @param address the backing memory address
* @param size the backing memory size
*/
public static MemoryStack ncreate(long address, int size) {
return new MemoryStack(null, address, size);
}
/**
* Stores the current stack pointer and pushes a new frame to the stack.
*
* <p>This method should be called when entering a method, before doing any stack allocations. When exiting a method, call the {@link #pop} method to
* restore the previous stack frame.</p>
*
* <p>Pairs of push/pop calls may be nested. Care must be taken to:</p>
* <ul>
* <li>match every push with a pop</li>
* <li>not call pop before push has been called at least once</li>
* <li>not nest push calls to more than the maximum supported depth</li>
* </ul>
*
* @return this stack
*/
public MemoryStack push() {
if (frameIndex == frames.length) {
frameOverflow();
}
frames[frameIndex++] = pointer;
return this;
}
private void frameOverflow() {
if (/*DEBUG*/ false) {
AngelicaTweaker.LOGGER.warn("[WARNING] Out of frame stack space (" + frames.length + ") in thread: " + Thread.currentThread());
}
frames = Arrays.copyOf(frames, frames.length * 3 / 2);
}
/**
* Pops the current stack frame and moves the stack pointer to the end of the previous stack frame.
*
* @return this stack
*/
public MemoryStack pop() {
pointer = frames[--frameIndex];
return this;
}
/**
* Calls {@link #pop} on this {@code MemoryStack}.
*
* <p>This method should not be used directly. It is called automatically when the {@code MemoryStack} is used as a resource in a try-with-resources
* statement.</p>
*/
@Override
public void close() {
//noinspection resource
pop();
}
/**
* Returns the address of the backing off-heap memory.
*
* <p>The stack grows "downwards", so the bottom of the stack is at {@code address + size}, while the top is at {@code address}.</p>
*/
public long getAddress() {
return address;
}
/**
* Returns the size of the backing off-heap memory.
*
* <p>This is the maximum number of bytes that may be allocated on the stack.</p>
*/
public int getSize() {
return size;
}
/**
* Returns the current frame index.
*
* <p>This is the current number of nested {@link #push} calls.</p>
*/
public int getFrameIndex() {
return frameIndex;
}
/** Returns the memory address at the current stack pointer. */
public long getPointerAddress() {
return address + (pointer & 0xFFFF_FFFFL);
}
/**
* Returns the current stack pointer.
*
* <p>The stack grows "downwards", so when the stack is empty {@code pointer} is equal to {@code size}. On every allocation {@code pointer} is reduced by
* the allocated size (after alignment) and {@code address + pointer} points to the first byte of the last allocation.</p>
*
* <p>Effectively, this methods returns how many more bytes may be allocated on the stack.</p>
*/
public int getPointer() {
return pointer;
}
/**
* Sets the current stack pointer.
*
* <p>This method directly manipulates the stack pointer. Using it irresponsibly may break the internal state of the stack. It should only be used in rare
* cases or in auto-generated code.</p>
*/
public void setPointer(int pointer) {
if (/*CHECKS*/ false) {
checkPointer(pointer);
}
this.pointer = pointer;
}
private void checkPointer(int pointer) {
if (pointer < 0 || size < pointer) {
throw new IndexOutOfBoundsException("Invalid stack pointer");
}
}
private static void checkAlignment(int alignment) {
if (Integer.bitCount(alignment) != 1) {
throw new IllegalArgumentException("Alignment must be a power-of-two value.");
}
}
/**
* Calls {@link #nmalloc(int, int)} with {@code alignment} equal to {@link Pointer#POINTER_SIZE POINTER_SIZE}.
*
* @param size the allocation size
*
* @return the memory address on the stack for the requested allocation
*/
public long nmalloc(int size) {
return nmalloc(POINTER_SIZE, size);
}
/**
* Allocates a block of {@code size} bytes of memory on the stack. The content of the newly allocated block of memory is not initialized, remaining with
* indeterminate values.
*
* @param alignment the required alignment
* @param size the allocation size
*
* @return the memory address on the stack for the requested allocation
*/
public long nmalloc(int alignment, int size) {
// Align address to the specified alignment
long address = (this.address + pointer - size) & ~Integer.toUnsignedLong(alignment - 1);
pointer = (int)(address - this.address);
if (/*CHECKS*/ false && pointer < 0) {
throw new OutOfMemoryError("Out of stack space.");
}
return address;
}
/**
* Allocates a block of memory on the stack for an array of {@code num} elements, each of them {@code size} bytes long, and initializes all its bits to
* zero.
*
* @param alignment the required element alignment
* @param num num the number of elements to allocate
* @param size the size of each element
*
* @return the memory address on the stack for the requested allocation
*/
public long ncalloc(int alignment, int num, int size) {
int bytes = num * size;
long address = nmalloc(alignment, bytes);
memSet(address, 0, bytes);
return address;
}
// -------------------------------------------------
/** Unsafe version of {@link #shorts(short)}. */
public long nshort(short value) {
long a = nmalloc(2, 2);
memPutShort(a, value);
return a;
}
// -------------------------------------------------
/** Int version of {@link #malloc(int)}. */
public IntBuffer mallocInt(int size) { return wrapBufferInt(nmalloc(4, size << 2), size); }
/** Unsafe version of {@link #ints(int)}. */
public long nint(int value) {
long a = nmalloc(4, 4);
memPutInt(a, value);
return a;
}
// -------------------------------------------------
/** Unsafe version of {@link #longs(long)}. */
public long nlong(long value) {
long a = nmalloc(8, 8);
memPutLong(a, value);
return a;
}
// -------------------------------------------------
/** Float version of {@link #malloc(int)}. */
public FloatBuffer mallocFloat(int size) { return wrapBufferFloat(nmalloc(4, size << 2), size); }
/** Unsafe version of {@link #floats(float)}. */
public long nfloat(float value) {
long a = nmalloc(4, 4);
memPutFloat(a, value);
return a;
}
// -------------------------------------------------
/** Unsafe version of {@link #doubles(double)}. */
public long ndouble(double value) {
long a = nmalloc(8, 8);
memPutDouble(a, value);
return a;
}
// -------------------------------------------------
// -------------------------------------------------
// -------------------------------------------------
/** Returns the stack of the current thread. */
public static MemoryStack stackGet() {
return TLS.get();
}
/**
* Calls {@link #push} on the stack of the current thread.
*
* @return the stack of the current thread.
*/
public static MemoryStack stackPush() {
return stackGet().push();
}
/**
* Calls {@link #pop} on the stack of the current thread.
*
* @return the stack of the current thread.
*/
public static MemoryStack stackPop() {
return stackGet().pop();
}
/** Thread-local version of {@link #nmalloc(int)}. */
public static long nstackMalloc(int size) { return stackGet().nmalloc(size); }
/** Thread-local version of {@link #nmalloc(int, int)}. */
public static long nstackMalloc(int alignment, int size) { return stackGet().nmalloc(alignment, size); }
/** Thread-local version of {@link #ncalloc}. */
public static long nstackCalloc(int alignment, int num, int size) { return stackGet().ncalloc(alignment, num, size); }
// -------------------------------------------------
}
@@ -1,93 +0,0 @@
/*
* This class is backported from LWJGL3 under the BSD 3-clause "New" or "Revised" License
*/
package com.gtnewhorizons.angelica.compat.lwjgl;
import static com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil.NULL;
import static com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil.UNSAFE;
import static org.lwjgl.LWJGLUtil.CHECKS;
import net.minecraft.util.Util;
import org.jetbrains.annotations.Nullable;
/**
* Pointer interface.
*
* <p>LWJGL can run on both 32bit and 64bit architectures. Since LWJGL applications deal with native memory directly, this interface provides necessary
* information about the underlying architecture of the running JVM process.</p>
*
* <p>When interacting with native functions, pointer values are mapped to Java {@code long}. LWJGL automatically converts long values to the correct pointer
* addresses when used in native code. Native functions sometimes require arrays of pointer values; the {@link PointerBuffer} class may be used for that
* purpose. It has an API similar to a {@link java.nio.LongBuffer} but handles pointer casts automatically.</p>
*/
public interface Pointer {
/** The pointer size in bytes. Will be 4 on a 32bit JVM and 8 on a 64bit one. */
int POINTER_SIZE = UNSAFE.addressSize();
/** The pointer size power-of-two. Will be 2 on a 32bit JVM and 3 on a 64bit one. */
int POINTER_SHIFT = POINTER_SIZE == 8 ? 3 : 2;
/** The value of {@code sizeof(long)} for the current platform. */
int CLONG_SIZE = POINTER_SIZE == 8 && Util.getOSType() == Util.EnumOS.WINDOWS ? 4 : POINTER_SIZE;
/** The value of {@code sizeof(long)} as a power-of-two. */
int CLONG_SHIFT = CLONG_SIZE == 8 ? 3 : 2;
/** Will be true on a 32bit JVM. */
boolean BITS32 = POINTER_SIZE * 8 == 32;
/** Will be true on a 64bit JVM. */
boolean BITS64 = POINTER_SIZE * 8 == 64;
/**
* Returns the raw pointer address as a {@code long} value.
*
* @return the pointer address
*/
long address();
/** Default {@link Pointer} implementation. */
abstract class Default implements Pointer {
// Removed final due to JDK-8139758. TODO: Restore if the fix is backported to JDK 8.
protected long address;
protected Default(long address) {
if (CHECKS && address == NULL) {
throw new NullPointerException();
}
this.address = address;
}
@Override
public long address() {
return address;
}
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Pointer)) {
return false;
}
Pointer that = (Pointer)o;
return address == that.address();
}
public int hashCode() {
return (int)(address ^ (address >>> 32));
}
@Override
public String toString() {
return String.format("%s pointer [0x%X]", getClass().getSimpleName(), address);
}
}
}
@@ -1,10 +1,24 @@
package com.gtnewhorizons.angelica.compat.mojang;
import com.gtnewhorizons.angelica.compat.ModStatus;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import xonin.backhand.api.core.BackhandUtils;
public enum InteractionHand {
MAIN_HAND,
OFF_HAND;
InteractionHand() {
}
public ItemStack getItemInHand(EntityPlayer player){
if (ModStatus.isBackhandLoaded && this == InteractionHand.OFF_HAND){ // off hand (requires backhand)
return BackhandUtils.getOffhandItem(player);
}
else { // main hand
return player.getHeldItem();
}
}
}
@@ -1,6 +1,7 @@
package com.gtnewhorizons.angelica.compat.mojang;
import com.gtnewhorizons.angelica.compat.lwjgl.MemoryStack;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryStack.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
@@ -8,6 +9,9 @@ import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import javax.imageio.ImageIO;
import com.gtnewhorizon.gtnhlib.bytebuf.MemoryStack;
import com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities;
import lombok.Getter;
import net.coderbot.iris.Iris;
import org.lwjgl.opengl.GL11;
@@ -58,15 +62,20 @@ public class NativeImage extends BufferedImage {
// final int width = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, GL11.GL_TEXTURE_WIDTH);
// final int height = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, GL11.GL_TEXTURE_HEIGHT);
try (final MemoryStack stack = MemoryStack.stackPush()) {
final IntBuffer buffer = stack.mallocInt(size);
final IntBuffer buffer = MemoryUtilities.memAllocInt(size);
try {
GL11.glGetTexImage(GL11.GL_TEXTURE_2D, level, format.glFormat, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, buffer);
int[] data = new int[size];
buffer.get(data);
setRGB(0, 0, width, height, data, 0, width);
} finally {
MemoryUtilities.memFree(buffer);
}
}
public void writeToFile(File file) throws IOException{
try {
ImageIO.write(this, "png", file);
@@ -133,15 +133,20 @@ public class AngelicaConfig {
@Config.RequiresMcRestart
public static boolean enableDebugLogging;
@Config.Comment("Enables PBR atlas dumping")
@Config.DefaultBoolean(false)
@Config.Name("Enable PBR Debug")
public static boolean enablePBRDebug;
@Config.Comment("Enable Zoom")
@Config.DefaultBoolean(true)
@Config.RequiresMcRestart
public static boolean enableZoom;
@Config.Comment("Optimizes in-world item rendering")
@Config.DefaultBoolean(true)
@Config.Comment("Optimizes in-world item rendering [Experimental]")
@Config.DefaultBoolean(false)
@Config.RequiresMcRestart
public static boolean optimizeInWorldItemRendering;
public static boolean optimizeInWorldItemRendering_WIP;
@Config.Comment("Max amount of display lists to cache for optimized item rendering. Higher number will use more VRAM")
@Config.DefaultInt(256)
@@ -153,4 +158,12 @@ public class AngelicaConfig {
@Config.RangeDouble(min = 16D, max = 64D)
public static double mobSpawnerRenderDistance;
@Config.Comment("Switches to an alternate FPS limiter that gives more stable frametimes, in exchange for slightly " +
"more latency. Will never introduce more than one frame of latency, and has a lower impact at higher framerates.")
@Config.DefaultBoolean(false)
public static boolean sleepBeforeSwap;
@Config.Comment("Allows unicode languages to use an odd gui scale")
@Config.DefaultBoolean(true)
public static boolean removeUnicodeEvenScaling;
}
@@ -28,9 +28,10 @@ import static org.lwjgl.opengl.GL20.glUniform1;
import static org.lwjgl.opengl.GL20.glUniform1f;
import static org.lwjgl.opengl.GL20.glUniform1i;
import static org.lwjgl.opengl.GL20.glVertexAttribPointer;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryStack.*;
import com.gtnewhorizon.gtnhlib.bytebuf.MemoryStack;
import com.gtnewhorizon.gtnhlib.client.renderer.shader.ShaderProgram;
import com.gtnewhorizons.angelica.compat.lwjgl.MemoryStack;
import java.nio.FloatBuffer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
@@ -131,7 +132,7 @@ public abstract class F3Graph {
// Load vertex buffer
vertBuf = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vertBuf);
try (final MemoryStack stack = MemoryStack.stackPush()) {
try (final MemoryStack stack = stackPush()) {
final FloatBuffer vertices = stack.mallocFloat(VERT_COUNT * VERT_FLOATS);
// Since we use a triangle strip, we only need 4 vertices. The quad extends to the top of the screen so spikes
// don't get truncated. The max height is replaced in the vert shader, no need to be precise.
@@ -136,6 +136,10 @@ public class HUDCaching {
guiForge.callRenderPortal(width, height, partialTicks);
}
if (renderCrosshairsCaptured) {
if (ModStatus.isXaerosMinimapLoaded){
// this fixes the crosshair going invisible when no lines are being drawn under the minimap
GLStateManager.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}
guiForge.callRenderCrosshairs(width, height);
}
if (ModStatus.isThaumcraftLoaded || ModStatus.isThaumicHorizonsLoaded){
@@ -80,7 +80,7 @@ public enum Mixins {
ANGELICA_ITEM_DISPLAY_LIST_OPTIMIZATION(new Builder("Optimized item rendering by wrapping them with display lists")
.setPhase(Phase.EARLY).addMixinClasses("angelica.itemrenderer.MixinItemRenderer").setSide(Side.CLIENT)
.setApplyIf(() -> AngelicaConfig.optimizeInWorldItemRendering)
.setApplyIf(() -> AngelicaConfig.optimizeInWorldItemRendering_WIP)
.addTargetedMod(TargetedMod.VANILLA)),
// Not compatible with the lwjgl debug callbacks, so disable if that's enabled
@@ -152,7 +152,6 @@ public enum Mixins {
,"shaders.MixinGuiIngameForge"
,"shaders.MixinFramebuffer"
,"shaders.MixinItem"
,"shaders.MixinItemRenderer"
,"shaders.MixinLocale"
,"shaders.MixinOpenGlHelper"
,"shaders.MixinRender"
@@ -162,6 +161,19 @@ public enum Mixins {
)
),
IRIS_RENDERING_NOBACKHAND(new Builder("Iris Hand Shaders").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableIris).addExcludedMod(TargetedMod.BACKHAND).addMixinClasses(
"shaders.MixinItemRenderer"
)
),
IRIS_RENDERING_BACKHAND(new Builder("Iris Hand Shaders (Backhand)").addTargetedMod(TargetedMod.VANILLA)
.addTargetedMod(TargetedMod.BACKHAND).setSide(Side.CLIENT)
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableIris).addMixinClasses(
"shaders.MixinItemRendererBackhand"
)
),
IRIS_ACCESSORS(new Builder("Iris Accessors").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableIris).addMixinClasses(
"shaders.accessors.MixinMinecraft"
@@ -219,6 +231,11 @@ public enum Mixins {
"angelica.animation.MixinWorldRenderer",
"angelica.animation.MixinRenderItem")),
SCALED_RESOUTION_UNICODE_FIX(new Builder("Removes unicode languages gui scaling being forced to even values").setPhase(Phase.EARLY)
.setSide(Side.CLIENT).addTargetedMod(TargetedMod.VANILLA)
.setApplyIf(() -> AngelicaConfig.removeUnicodeEvenScaling)
.addMixinClasses("angelica.bugfixes.MixinScaledResolution_UnicodeFix")),
EXTRA_UTILITIES_THREAD_SAFETY(new Builder("Enable thread safety fixes in Extra Utilities").setPhase(Phase.LATE)
.addTargetedMod(TargetedMod.EXTRAUTILS).setSide(Side.CLIENT)
.setApplyIf(() -> CompatConfig.fixExtraUtils)
@@ -520,7 +537,7 @@ public enum Mixins {
&& !MCPatcherForgeConfig.ConnectedTextures.enabled
&& MCPatcherForgeConfig.CustomColors.enabled)
.addTargetedMod(TargetedMod.VANILLA)
.addMixinClasses("mcpatcherforge.cc_ctm.MixinRenderBlocksNoCTM")
.addMixinClasses("mcpatcherforge.ctm_cc.MixinRenderBlocksNoCTM")
),
MCPATCHER_FORGE_CTM_NO_CC(new Builder("MCP:F Connected Textures, no Custom Colours")
.setSide(Side.CLIENT).setPhase(Phase.EARLY)
@@ -8,6 +8,7 @@ public enum TargetedMod {
, FASTCRAFT("FastCraft", "fastcraft.Tweaker")
, OPTIFINE("Optifine", "optifine.OptiFineForgeTweaker", "Optifine")
, ARCHAICFIX("ArchaicFix", "org.embeddedt.archaicfix.ArchaicCore", "archaicfix")
, BACKHAND("Backhand","xonin.backhand.coremod.BackhandLoadingPlugin", "backhand")
, BOTANIA("Botania", null, "Botania")
, CAMPFIRE_BACKPORT("CampfireBackport", null, "campfirebackport")
, CHICKENCHUNKS("ChickenChunks", null, "ChickenChunks")
@@ -8,4 +8,5 @@ public interface ITexturesCache {
Set<IIcon> getRenderedTextures();
void enableTextureTracking();
void track(IPatchedTextureAtlasSprite sprite);
}
@@ -47,6 +47,7 @@ import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiMainMenu;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.server.integrated.IntegratedServer;
import net.minecraft.util.Direction;
@@ -152,7 +153,7 @@ public class ClientProxy extends CommonProxy {
@SubscribeEvent
public void onKeypress(TickEvent.ClientTickEvent event) {
final boolean isPressed = glsmKeyBinding.getKeyCode() != 0 && Keyboard.isKeyDown(glsmKeyBinding.getKeyCode());
final boolean isPressed = glsmKeyBinding.getKeyCode() != 0 && GameSettings.isKeyDown(glsmKeyBinding);
if (isPressed && !wasGLSMKeyPressed) {
OpenGLDebugging.checkGLSM();
}
@@ -1,5 +1,7 @@
package com.gtnewhorizons.angelica.utils;
import java.util.ArrayDeque;
import com.gtnewhorizons.angelica.mixins.interfaces.IPatchedTextureAtlasSprite;
import com.gtnewhorizons.angelica.mixins.interfaces.ITexturesCache;
import net.minecraft.client.Minecraft;
@@ -28,4 +30,26 @@ public class AnimationsRenderUtils {
}
}
}
private final static ThreadLocal<ArrayDeque<ITexturesCache>> TEXTURE_CACHE_STACK = ThreadLocal.withInitial(ArrayDeque::new);
public static void onSpriteUsed(IPatchedTextureAtlasSprite sprite) {
ArrayDeque<ITexturesCache> stack = TEXTURE_CACHE_STACK.get();
if (stack == null || stack.isEmpty()) {
// icon was used outside of chunk building, it's probably an item in an inventory or something
sprite.markNeedsAnimationUpdate();
return;
}
stack.peek().track(sprite);
}
public static void pushCache(ITexturesCache cache) {
TEXTURE_CACHE_STACK.get().push(cache);
}
public static void popCache() {
TEXTURE_CACHE_STACK.get().pop();
}
}
@@ -1,6 +1,7 @@
package me.jellysquid.mods.sodium.client.gl.util;
import org.lwjgl.BufferUtils;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
import org.lwjgl.opengl.GL20;
@@ -17,8 +18,8 @@ public class GlMultiDrawBatch {
private boolean isBuilding;
public GlMultiDrawBatch(int capacity) {
this.bufIndices = BufferUtils.createIntBuffer(capacity);
this.bufLen = BufferUtils.createIntBuffer(capacity);
this.bufIndices = memAllocInt(capacity);
this.bufLen = memAllocInt(capacity);
}
public IntBuffer getIndicesBuffer() {
@@ -59,8 +60,8 @@ public class GlMultiDrawBatch {
}
public void delete() {
this.bufIndices.clear();
this.bufLen.clear();
memFree(this.bufIndices);
memFree(this.bufLen);
this.bufIndices = null;
this.bufLen = null;
@@ -127,6 +127,15 @@ public class SodiumGameOptionPages {
}
}, (opts) -> opts.fullScreen)
.build())
.add(OptionImpl.createBuilder(boolean.class, angelicaOpts)
.setName(I18n.format("options.angelica.sleepbeforeswap"))
.setTooltip(I18n.format("options.angelica.sleepbeforeswap.tooltip"))
.setControl(TickBoxControl::new)
.setBinding((opts, value) -> {
AngelicaConfig.sleepBeforeSwap = value;
}, opts -> AngelicaConfig.sleepBeforeSwap)
.setImpact(OptionImpact.VARIES)
.build())
.add(OptionImpl.createBuilder(boolean.class, vanillaOpts)
.setName(I18n.format("options.vsync"))
.setTooltip(I18n.format("sodium.options.v_sync.tooltip"))
@@ -1,6 +1,7 @@
package me.jellysquid.mods.sodium.client.model.vertex.buffer;
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
import me.jellysquid.mods.sodium.client.gl.attribute.BufferVertexFormat;
import org.lwjgl.BufferUtils;
@@ -16,7 +17,7 @@ public class VertexBufferBuilder implements VertexBufferView {
public VertexBufferBuilder(BufferVertexFormat vertexFormat, int initialCapacity) {
this.vertexFormat = vertexFormat;
this.buffer = BufferUtils.createByteBuffer(initialCapacity);
this.buffer = memAlloc(initialCapacity);
this.capacity = initialCapacity;
this.writerOffset = 0;
}
@@ -25,7 +26,7 @@ public class VertexBufferBuilder implements VertexBufferView {
// The new capacity will at least as large as the write it needs to service
final int cap = Math.max(this.capacity * 2, this.capacity + len);
this.buffer = CompatMemoryUtil.memReallocDirect(this.buffer, cap);
this.buffer = memRealloc(this.buffer, cap);
this.capacity = cap;
}
@@ -1,6 +1,7 @@
package me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.writer;
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
import me.jellysquid.mods.sodium.client.model.vertex.VanillaVertexTypes;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterUnsafe;
@@ -15,13 +16,13 @@ public class GlyphVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe impl
public void writeGlyph(float x, float y, float z, int color, float u, float v, int light) {
long i = this.writePointer;
CompatMemoryUtil.memPutFloat(i, x);
CompatMemoryUtil.memPutFloat(i + 4, y);
CompatMemoryUtil.memPutFloat(i + 8, z);
CompatMemoryUtil.memPutInt(i + 12, color);
CompatMemoryUtil.memPutFloat(i + 16, u);
CompatMemoryUtil.memPutFloat(i + 20, v);
CompatMemoryUtil.memPutInt(i + 24, light);
memPutFloat(i, x);
memPutFloat(i + 4, y);
memPutFloat(i + 8, z);
memPutInt(i + 12, color);
memPutFloat(i + 16, u);
memPutFloat(i + 20, v);
memPutInt(i + 24, light);
this.advance();
@@ -1,6 +1,7 @@
package me.jellysquid.mods.sodium.client.model.vertex.formats.line.writer;
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
import me.jellysquid.mods.sodium.client.model.vertex.VanillaVertexTypes;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterUnsafe;
@@ -15,10 +16,10 @@ public class LineVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe imple
public void vertexLine(float x, float y, float z, int color) {
long i = this.writePointer;
CompatMemoryUtil.memPutFloat(i, x);
CompatMemoryUtil.memPutFloat(i + 4, y);
CompatMemoryUtil.memPutFloat(i + 8, z);
CompatMemoryUtil.memPutInt(i + 12, color);
memPutFloat(i, x);
memPutFloat(i + 4, y);
memPutFloat(i + 8, z);
memPutInt(i + 12, color);
this.advance();
}
@@ -1,6 +1,7 @@
package me.jellysquid.mods.sodium.client.model.vertex.formats.particle.writer;
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
import me.jellysquid.mods.sodium.client.model.vertex.VanillaVertexTypes;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterUnsafe;
@@ -15,13 +16,13 @@ public class ParticleVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe i
public void writeParticle(float x, float y, float z, float u, float v, int color, int light) {
long i = this.writePointer;
CompatMemoryUtil.memPutFloat(i, x);
CompatMemoryUtil.memPutFloat(i + 4, y);
CompatMemoryUtil.memPutFloat(i + 8, z);
CompatMemoryUtil.memPutFloat(i + 12, u);
CompatMemoryUtil.memPutFloat(i + 16, v);
CompatMemoryUtil.memPutInt(i + 20, color);
CompatMemoryUtil.memPutInt(i + 24, light);
memPutFloat(i, x);
memPutFloat(i + 4, y);
memPutFloat(i + 8, z);
memPutFloat(i + 12, u);
memPutFloat(i + 16, v);
memPutInt(i + 20, color);
memPutInt(i + 24, light);
this.advance();
}
@@ -1,6 +1,7 @@
package me.jellysquid.mods.sodium.client.model.vertex.formats.quad.writer;
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
import me.jellysquid.mods.sodium.client.model.vertex.VanillaVertexTypes;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterUnsafe;
@@ -15,15 +16,15 @@ public class QuadVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe imple
public void writeQuad(float x, float y, float z, int color, float u, float v, int light, int overlay, int normal) {
final long i = this.writePointer;
CompatMemoryUtil.memPutFloat(i, x);
CompatMemoryUtil.memPutFloat(i + 4, y);
CompatMemoryUtil.memPutFloat(i + 8, z);
CompatMemoryUtil.memPutInt(i + 12, color);
CompatMemoryUtil.memPutFloat(i + 16, u);
CompatMemoryUtil.memPutFloat(i + 20, v);
CompatMemoryUtil.memPutInt(i + 24, overlay);
CompatMemoryUtil.memPutInt(i + 28, light);
CompatMemoryUtil.memPutInt(i + 32, normal);
memPutFloat(i, x);
memPutFloat(i + 4, y);
memPutFloat(i + 8, z);
memPutInt(i + 12, color);
memPutFloat(i + 16, u);
memPutFloat(i + 20, v);
memPutInt(i + 24, overlay);
memPutInt(i + 28, light);
memPutInt(i + 32, normal);
this.advance();
}
@@ -1,6 +1,7 @@
package me.jellysquid.mods.sodium.client.model.vertex.formats.screen_quad.writer;
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
import me.jellysquid.mods.sodium.client.model.vertex.VanillaVertexTypes;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterUnsafe;
@@ -15,10 +16,10 @@ public class BasicScreenQuadVertexBufferWriterUnsafe extends VertexBufferWriterU
public void writeQuad(float x, float y, float z, int color) {
long i = this.writePointer;
CompatMemoryUtil.memPutFloat(i, x);
CompatMemoryUtil.memPutFloat(i + 4, y);
CompatMemoryUtil.memPutFloat(i + 8, z);
CompatMemoryUtil.memPutInt(i + 12, color);
memPutFloat(i, x);
memPutFloat(i + 4, y);
memPutFloat(i + 8, z);
memPutInt(i + 12, color);
this.advance();
}
@@ -1,6 +1,6 @@
package me.jellysquid.mods.sodium.client.render;
import com.gtnewhorizons.angelica.compat.lwjgl.MemoryStack;
import com.gtnewhorizon.gtnhlib.bytebuf.MemoryStack;
import com.gtnewhorizons.angelica.compat.toremove.MatrixStack;
import com.gtnewhorizons.angelica.config.AngelicaConfig;
import com.gtnewhorizons.angelica.rendering.RenderingState;
@@ -348,7 +348,11 @@ public class SodiumWorldRenderer {
}
private boolean checkBEVisibility(TileEntity entity) {
return frustum.isBoundingBoxInFrustum(entity.getRenderBoundingBox());
var aabb = entity.getRenderBoundingBox();
if (aabb == TileEntity.INFINITE_EXTENT_AABB) {
return true;
}
return frustum.isBoundingBoxInFrustum(aabb);
}
private void renderTE(TileEntity tileEntity, int pass, float partialTicks) {
@@ -35,6 +35,7 @@ import me.jellysquid.mods.sodium.client.world.ChunkStatusListener;
import me.jellysquid.mods.sodium.common.util.IdTable;
import me.jellysquid.mods.sodium.common.util.collections.FutureDequeDrain;
import net.coderbot.iris.shadows.ShadowRenderingState;
import net.coderbot.iris.sodium.shadow_map.SwappableChunkRenderManager;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.tileentity.TileEntity;
@@ -47,7 +48,7 @@ import java.util.Collection;
import java.util.Deque;
import java.util.concurrent.CompletableFuture;
public class ChunkRenderManager<T extends ChunkGraphicsState> implements ChunkStatusListener {
public class ChunkRenderManager<T extends ChunkGraphicsState> implements ChunkStatusListener, SwappableChunkRenderManager {
/**
* The maximum distance a chunk can be from the player's camera in order to be eligible for blocking updates.
*/
@@ -249,7 +250,11 @@ public class ChunkRenderManager<T extends ChunkGraphicsState> implements ChunkSt
}
private void addChunk(ChunkRenderContainer<T> render) {
final boolean canRebuild = AngelicaConfig.enableIris ? !ShadowRenderingState.areShadowsCurrentlyBeingRendered() : render.canRebuild();
boolean canRebuild = render.canRebuild();
if (AngelicaConfig.enableIris && ShadowRenderingState.areShadowsCurrentlyBeingRendered()) {
canRebuild = false;
}
if (render.needsRebuild() && canRebuild) {
if (!this.alwaysDeferChunkUpdates && render.needsImportantRebuild()) {
@@ -366,9 +371,7 @@ public class ChunkRenderManager<T extends ChunkGraphicsState> implements ChunkSt
private void reset() {
if(!AngelicaConfig.enableIris || !ShadowRenderingState.areShadowsCurrentlyBeingRendered()) this.rebuildQueue.clear();
if(!AngelicaConfig.enableIris || !ShadowRenderingState.areShadowsCurrentlyBeingRendered()) this.importantRebuildQueue.clear();
this.sortQueue.clear();
if(!AngelicaConfig.enableIris || !ShadowRenderingState.areShadowsCurrentlyBeingRendered()) this.sortQueue.clear();
this.visibleTileEntities.clear();
@@ -549,25 +552,39 @@ public class ChunkRenderManager<T extends ChunkGraphicsState> implements ChunkSt
continue;
}
// Do not allow distant chunks to block rendering
if (this.alwaysDeferChunkUpdates || !this.isChunkPrioritized(render)) {
this.builder.deferRebuild(render);
} else {
futures.add(this.builder.scheduleRebuildTaskAsync(render));
}
CompletableFuture<ChunkBuildResult<T>> futureTask = this.builder.scheduleRebuildTaskAsync(render);
this.dirty = true;
submitted++;
// Limit quantity of updates submitted if we are deferring all important builds
if (this.alwaysDeferChunkUpdates && submitted >= budget)
break;
if (futureTask != null) {
this.dirty = true;
// Do not allow distant chunks to block rendering
if (this.alwaysDeferChunkUpdates || !this.isChunkPrioritized(render)) {
this.builder.handleCompletion(futureTask);
} else {
futures.add(futureTask);
}
submitted++;
// Limit quantity of updates submitted if we are deferring all important builds
if (this.alwaysDeferChunkUpdates && submitted >= budget)
break;
} else {
// Immediately submit empty data to the queue and do not count this against the budget
this.builder.enqueueUpload(new ChunkBuildResult<>(render, ChunkRenderData.EMPTY));
}
}
while (submitted < budget && !this.rebuildQueue.isEmpty()) {
ChunkRenderContainer<T> render = this.rebuildQueue.dequeue();
this.builder.deferRebuild(render);
submitted++;
CompletableFuture<ChunkBuildResult<T>> futureTask = this.builder.scheduleRebuildTaskAsync(render);
if(futureTask != null) {
this.builder.handleCompletion(futureTask);
submitted++;
} else {
// Immediately submit empty data to the queue and do not count this against the budget
this.builder.enqueueUpload(new ChunkBuildResult<>(render, ChunkRenderData.EMPTY));
}
}
// always do at least one sort
@@ -1,6 +1,7 @@
package me.jellysquid.mods.sodium.client.render.chunk.backends.multidraw;
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
import com.gtnewhorizons.angelica.compat.mojang.CompatMathHelper;
import me.jellysquid.mods.sodium.client.SodiumClientMod;
import org.lwjgl.MemoryUtil;
@@ -83,10 +84,10 @@ public abstract class ChunkDrawCallBatcher extends StructBuffer {
throw new BufferUnderflowException();
}
CompatMemoryUtil.memPutInt(this.writePointer , count); // Vertex Count
CompatMemoryUtil.memPutInt(this.writePointer + 4, instanceCount); // Instance Count
CompatMemoryUtil.memPutInt(this.writePointer + 8, first); // Vertex Start
CompatMemoryUtil.memPutInt(this.writePointer + 12, baseInstance); // Base Instance
memPutInt(this.writePointer , count); // Vertex Count
memPutInt(this.writePointer + 4, instanceCount); // Instance Count
memPutInt(this.writePointer + 8, first); // Vertex Start
memPutInt(this.writePointer + 12, baseInstance); // Base Instance
this.writePointer += this.stride;
}
@@ -1,6 +1,7 @@
package me.jellysquid.mods.sodium.client.render.chunk.backends.multidraw;
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
import me.jellysquid.mods.sodium.client.SodiumClientMod;
import org.lwjgl.MemoryUtil;
@@ -32,7 +33,7 @@ public abstract class ChunkDrawParamsVector extends StructBuffer {
protected void growBuffer() {
this.capacity = this.capacity * 2;
this.buffer = CompatMemoryUtil.memReallocDirect(this.buffer, this.capacity * this.stride);
this.buffer = memRealloc(this.buffer, this.capacity * this.stride);
}
public static class UnsafeChunkDrawCallVector extends ChunkDrawParamsVector {
@@ -51,9 +52,9 @@ public abstract class ChunkDrawParamsVector extends StructBuffer {
this.growBuffer();
}
CompatMemoryUtil.memPutFloat(this.writePointer , x);
CompatMemoryUtil.memPutFloat(this.writePointer + 4, y);
CompatMemoryUtil.memPutFloat(this.writePointer + 8, z);
memPutFloat(this.writePointer , x);
memPutFloat(this.writePointer + 4, y);
memPutFloat(this.writePointer + 8, z);
this.writePointer += this.stride;
}
@@ -64,7 +65,7 @@ public abstract class ChunkDrawParamsVector extends StructBuffer {
long offset = this.writePointer - this.basePointer;
this.basePointer = MemoryUtil.getAddress(this.buffer);
this.basePointer = memAddress(this.buffer);
this.writePointer = this.basePointer + offset;
}
@@ -1,6 +1,6 @@
package me.jellysquid.mods.sodium.client.render.chunk.backends.multidraw;
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
public class IndirectCommandBufferVector extends StructBuffer {
protected IndirectCommandBufferVector(int capacity) {
@@ -32,6 +32,6 @@ public class IndirectCommandBufferVector extends StructBuffer {
}
protected void growBuffer(int n) {
this.buffer = CompatMemoryUtil.memReallocDirect(this.buffer, Math.max(this.buffer.capacity() * 2, this.buffer.capacity() + n));
this.buffer = memRealloc(this.buffer, Math.max(this.buffer.capacity() * 2, this.buffer.capacity() + n));
}
}
@@ -1,7 +1,6 @@
package me.jellysquid.mods.sodium.client.render.chunk.backends.multidraw;
import org.lwjgl.BufferUtils;
import org.lwjgl.MemoryUtil;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
import java.nio.ByteBuffer;
@@ -11,7 +10,7 @@ public abstract class StructBuffer {
protected final int stride;
protected StructBuffer(int bytes, int stride) {
this.buffer = BufferUtils.createByteBuffer(bytes * stride);
this.buffer = memAlloc(bytes * stride);
this.stride = stride;
}
@@ -20,7 +19,7 @@ public abstract class StructBuffer {
}
public long getBufferAddress() {
return MemoryUtil.getAddress(this.buffer);
return memAddress(this.buffer);
}
public void delete() {
@@ -5,6 +5,7 @@ import it.unimi.dsi.fastutil.ints.IntArrays;
import me.jellysquid.mods.sodium.client.model.vertex.type.ChunkVertexType;
import me.jellysquid.mods.sodium.client.render.chunk.format.hfp.HFPModelVertexType;
import me.jellysquid.mods.sodium.client.render.chunk.format.sfp.SFPModelVertexType;
import net.coderbot.iris.sodium.vertex_format.terrain_xhfp.XHFPModelVertexType;
import java.nio.Buffer;
import java.nio.ByteBuffer;
@@ -14,22 +15,10 @@ import java.util.BitSet;
public class ChunkBufferSorter {
private static final Class<?> OCULUS_VERTEX_TYPE;
static {
Class<?> clz;
try {
clz = Class.forName("net.coderbot.iris.compat.sodium.impl.vertex_format.terrain_xhfp.XHFPModelVertexType");
} catch(Throwable e) {
clz = null;
}
OCULUS_VERTEX_TYPE = clz;
}
public static void sortStandardFormat(ChunkVertexType vertexType, ByteBuffer buffer, int bufferLen, float x, float y, float z) {
boolean isCompact;
if(vertexType.getClass() == HFPModelVertexType.class || vertexType.getClass() == OCULUS_VERTEX_TYPE) {
if(vertexType.getClass() == HFPModelVertexType.class || vertexType.getClass() == XHFPModelVertexType.class) {
isCompact = true;
} else if(vertexType.getClass() == SFPModelVertexType.class) {
isCompact = false;
@@ -142,6 +142,8 @@ public class ChunkBuildBuffers implements ChunkBuildBuffersExt {
if (sortTranslucent && pass.isTranslucent()) {
ChunkBufferSorter.sortStandardFormat(vertexType, buffer, bufferLen, x, y, z);
meshData.clearSlices();
meshData.setModelSlice(ModelQuadFacing.UNASSIGNED, new BufferSlice(0, bufferLen));
}
meshData.setVertexData(new VertexData(buffer, this.vertexType.getCustomVertexFormat()));
@@ -10,7 +10,6 @@ import me.jellysquid.mods.sodium.client.render.chunk.ChunkGraphicsState;
import me.jellysquid.mods.sodium.client.render.chunk.ChunkRenderBackend;
import me.jellysquid.mods.sodium.client.render.chunk.ChunkRenderContainer;
import me.jellysquid.mods.sodium.client.render.chunk.tasks.ChunkRenderBuildTask;
import me.jellysquid.mods.sodium.client.render.chunk.tasks.ChunkRenderEmptyBuildTask;
import me.jellysquid.mods.sodium.client.render.chunk.tasks.ChunkRenderRebuildTask;
import me.jellysquid.mods.sodium.client.render.chunk.tasks.ChunkRenderTranslucencySortTask;
import me.jellysquid.mods.sodium.client.render.pipeline.context.ChunkRenderCacheLocal;
@@ -26,6 +25,7 @@ import net.minecraft.util.ReportedException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.joml.Vector3d;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Deque;
@@ -294,7 +294,10 @@ public class ChunkBuilder<T extends ChunkGraphicsState> {
return Runtime.getRuntime().availableProcessors();
}
private void handleCompletion(CompletableFuture<ChunkBuildResult<T>> future) {
/**
* Add a completion handler to the given future task so that the result will be processed on the main thread.
*/
public void handleCompletion(CompletableFuture<ChunkBuildResult<T>> future) {
future.whenComplete((res, ex) -> {
if (ex != null) {
this.failureQueue.add(ex);
@@ -304,16 +307,6 @@ public class ChunkBuilder<T extends ChunkGraphicsState> {
});
}
/**
* Creates a rebuild task and defers it to the work queue. When the task is completed, it will be moved onto the
* completed uploads queued which will then be drained during the next available synchronization point with the
* main thread.
* @param render The render to rebuild
*/
public void deferRebuild(ChunkRenderContainer<T> render) {
handleCompletion(this.scheduleRebuildTaskAsync(render));
}
/**
* Creates a rebuild task and defers it to the work queue. When the task is completed, it will be moved onto the
* completed uploads queued which will then be drained during the next available synchronization point with the
@@ -330,16 +323,24 @@ public class ChunkBuilder<T extends ChunkGraphicsState> {
* synchronization point on the main thread.
* @param result The build task's result
*/
private void enqueueUpload(ChunkBuildResult<T> result) {
public void enqueueUpload(ChunkBuildResult<T> result) {
this.uploadQueue.add(result);
}
/**
* Schedules the rebuild task asynchronously on the worker pool, returning a future wrapping the task.
* @param render The render to rebuild
* @return a future representing the rebuild task, or null if the chunk section is empty
*/
@Nullable
public CompletableFuture<ChunkBuildResult<T>> scheduleRebuildTaskAsync(ChunkRenderContainer<T> render) {
return this.schedule(this.createRebuildTask(render));
ChunkRenderBuildTask<T> task = this.createRebuildTask(render);
if(task != null) {
return this.schedule(task);
} else {
return null;
}
}
/**
@@ -360,7 +361,7 @@ public class ChunkBuilder<T extends ChunkGraphicsState> {
ChunkRenderContext context = WorldSlice.prepare(this.world, render.getChunkPos(), this.sectionCache);
if (context == null) {
return new ChunkRenderEmptyBuildTask<>(render);
return null;
} else {
return new ChunkRenderRebuildTask<>(render, context, render.getRenderOrigin()).withCameraPosition(this.cameraPosition);
}
@@ -17,6 +17,10 @@ public class ChunkMeshData {
this.vertexData = vertexData;
}
public void clearSlices() {
this.parts.clear();
}
public void setModelSlice(ModelQuadFacing facing, BufferSlice slice) {
this.parts.put(facing, slice);
}
@@ -1,6 +1,7 @@
package me.jellysquid.mods.sodium.client.render.chunk.format.hfp;
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterUnsafe;
import me.jellysquid.mods.sodium.client.render.chunk.format.DefaultModelVertexFormats;
@@ -28,13 +29,13 @@ public class HFPModelVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe i
private void writeQuadInternal(short x, short y, short z, int color, short u, short v, int light) {
long i = this.writePointer;
CompatMemoryUtil.memPutShort(i, x);
CompatMemoryUtil.memPutShort(i + 2, y);
CompatMemoryUtil.memPutShort(i + 4, z);
CompatMemoryUtil.memPutInt(i + 8, color);
CompatMemoryUtil.memPutShort(i + 12, u);
CompatMemoryUtil.memPutShort(i + 14, v);
CompatMemoryUtil.memPutInt(i + 16, light);
memPutShort(i, x);
memPutShort(i + 2, y);
memPutShort(i + 4, z);
memPutInt(i + 8, color);
memPutShort(i + 12, u);
memPutShort(i + 14, v);
memPutInt(i + 16, light);
this.advance();
}
@@ -1,6 +1,7 @@
package me.jellysquid.mods.sodium.client.render.chunk.format.sfp;
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterUnsafe;
import me.jellysquid.mods.sodium.client.render.chunk.format.DefaultModelVertexFormats;
@@ -15,13 +16,13 @@ public class SFPModelVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe i
public void writeQuad(float x, float y, float z, int color, float u, float v, int light) {
long i = this.writePointer;
CompatMemoryUtil.memPutFloat(i, x);
CompatMemoryUtil.memPutFloat(i + 4, y);
CompatMemoryUtil.memPutFloat(i + 8, z);
CompatMemoryUtil.memPutInt(i + 12, color);
CompatMemoryUtil.memPutFloat(i + 16, u);
CompatMemoryUtil.memPutFloat(i + 20, v);
CompatMemoryUtil.memPutInt(i + 24, encodeLightMapTexCoord(light));
memPutFloat(i, x);
memPutFloat(i + 4, y);
memPutFloat(i + 8, z);
memPutInt(i + 12, color);
memPutFloat(i + 16, u);
memPutFloat(i + 20, v);
memPutInt(i + 24, encodeLightMapTexCoord(light));
this.advance();
}
@@ -1,6 +1,8 @@
package me.jellysquid.mods.sodium.client.render.chunk.shader;
import com.gtnewhorizons.angelica.compat.lwjgl.MemoryStack;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryStack.*;
import com.gtnewhorizon.gtnhlib.bytebuf.MemoryStack;
import com.gtnewhorizons.angelica.compat.toremove.MatrixStack;
import me.jellysquid.mods.sodium.client.gl.device.RenderDevice;
import me.jellysquid.mods.sodium.client.gl.shader.GlProgram;
@@ -49,7 +51,7 @@ public class ChunkProgram extends GlProgram {
this.fogShader.setup();
if (this.uModelViewProjectionMatrix == -1) return;
try (MemoryStack stack = MemoryStack.stackPush()) {
try (MemoryStack stack = stackPush()) {
GL20.glUniformMatrix4(
this.uModelViewProjectionMatrix,
false,
@@ -1,33 +0,0 @@
package me.jellysquid.mods.sodium.client.render.chunk.tasks;
import me.jellysquid.mods.sodium.client.render.chunk.ChunkGraphicsState;
import me.jellysquid.mods.sodium.client.render.chunk.ChunkRenderContainer;
import me.jellysquid.mods.sodium.client.render.chunk.compile.ChunkBuildBuffers;
import me.jellysquid.mods.sodium.client.render.chunk.compile.ChunkBuildResult;
import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderData;
import me.jellysquid.mods.sodium.client.render.pipeline.context.ChunkRenderCacheLocal;
import me.jellysquid.mods.sodium.client.util.task.CancellationSource;
/**
* A build task which does no computation and always return an empty build result. These tasks are created whenever
* chunk meshes need to be deleted as the only way to change graphics state is to send a message to the main
* actor thread. In cases where new chunk renders are being created and scheduled, the scheduler will prefer to just
* synchronously update the render's data to an empty state to speed things along.
*/
public class ChunkRenderEmptyBuildTask<T extends ChunkGraphicsState> extends ChunkRenderBuildTask<T> {
private final ChunkRenderContainer<T> render;
public ChunkRenderEmptyBuildTask(ChunkRenderContainer<T> render) {
this.render = render;
}
@Override
public ChunkBuildResult<T> performBuild(ChunkRenderCacheLocal cache, ChunkBuildBuffers buffers, CancellationSource cancellationSource) {
return new ChunkBuildResult<>(this.render, ChunkRenderData.EMPTY);
}
@Override
public void releaseResources() {
}
}
@@ -8,6 +8,7 @@ import com.gtnewhorizons.angelica.config.AngelicaConfig;
import com.gtnewhorizons.angelica.mixins.interfaces.ITexturesCache;
import com.gtnewhorizons.angelica.rendering.AngelicaBlockSafetyRegistry;
import com.gtnewhorizons.angelica.rendering.AngelicaRenderQueue;
import com.gtnewhorizons.angelica.utils.AnimationsRenderUtils;
import it.unimi.dsi.fastutil.longs.LongArrayFIFOQueue;
import me.jellysquid.mods.sodium.client.SodiumClientMod;
import me.jellysquid.mods.sodium.client.render.chunk.ChunkGraphicsState;
@@ -132,7 +133,10 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
final WorldSlice slice = cache.getWorldSlice();
final RenderBlocks renderBlocks = new RenderBlocks(slice);
if(renderBlocks instanceof ITexturesCache) ((ITexturesCache)renderBlocks).enableTextureTracking();
if(renderBlocks instanceof ITexturesCache textureCache) {
textureCache.enableTextureTracking();
AnimationsRenderUtils.pushCache(textureCache);
}
final int baseX = this.render.getOriginX();
final int baseY = this.render.getOriginY();
@@ -217,6 +221,10 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
}
}
if(renderBlocks instanceof ITexturesCache) {
AnimationsRenderUtils.popCache();
}
handleRenderBlocksTextures(renderBlocks, renderData);
if(hasMainThreadBlocks) {
@@ -263,7 +271,10 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
final int baseZ = this.render.getOriginZ();
final BlockPos renderOffset = this.offset;
final RenderBlocks rb = new RenderBlocks(slice.getWorld());
if(rb instanceof ITexturesCache) ((ITexturesCache)rb).enableTextureTracking();
if(rb instanceof ITexturesCache textureCache) {
textureCache.enableTextureTracking();
AnimationsRenderUtils.pushCache(textureCache);
}
while(!mainThreadBlocks.isEmpty()) {
final long longPos = mainThreadBlocks.dequeueLong();
if (cancellationSource.isCancelled()) {
@@ -303,6 +314,10 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
if(AngelicaConfig.enableIris) buffers.iris$resetBlockContext();
}
if(rb instanceof ITexturesCache) {
AnimationsRenderUtils.popCache();
}
handleRenderBlocksTextures(rb, renderData);
}
@@ -37,6 +37,7 @@ import java.util.List;
import java.util.Random;
public class BlockRenderer {
private static final BlockPos POS_ZERO = new BlockPos(0, 0, 0);
private final Random random = new XoRoShiRoRandom();
@@ -97,9 +98,10 @@ public class BlockRenderer {
TessellatorManager.startCapturing();
final CapturingTessellator tess = (CapturingTessellator) TessellatorManager.get();
tess.startDrawingQuads();
// RenderBlocks adds the subchunk-relative coordinates as the offset, cancel it out here
tess.setOffset(pos);
// Use setTranslation rather than setOffset so that the float data written to the internal buffer
// is done in subchunk-relative coordinates
tess.setOffset(POS_ZERO);
tess.setTranslation(-pos.x, -pos.y, -pos.z);
renderBlocks.renderBlockByRenderType(block, pos.x, pos.y, pos.z);
final List<QuadView> quads = TessellatorManager.stopCapturingToPooledQuads();
tess.resetOffset();
+1 -1
View File
@@ -537,7 +537,7 @@ public class Iris {
if (level != null) {
if (level.provider == null) return DimensionId.OVERWORLD;
if ((level.provider.isHellWorld || level.provider.hasNoSky) || level.provider.dimensionId == -1) {
if (level.provider.isHellWorld || level.provider.dimensionId == -1) {
return DimensionId.NETHER;
} else if (level.provider.dimensionId == 1) {
return DimensionId.END;
@@ -1,6 +1,7 @@
package net.coderbot.iris.config;
import net.coderbot.iris.Iris;
import net.coderbot.iris.gui.option.IrisVideoSettings;
import java.io.IOException;
import java.io.InputStream;
@@ -122,13 +123,13 @@ public class IrisConfig {
enableShaders = !"false".equals(properties.getProperty("enableShaders"));
disableUpdateMessage = "true".equals(properties.getProperty("disableUpdateMessage"));
// TODO: GUI
// try {
// IrisVideoSettings.shadowDistance = Integer.parseInt(properties.getProperty("maxShadowRenderDistance", "32"));
// } catch (NumberFormatException e) {
// Iris.logger.error("Shadow distance setting reset; value is invalid.");
// IrisVideoSettings.shadowDistance = 32;
// save();
// }
try {
IrisVideoSettings.shadowDistance = Integer.parseInt(properties.getProperty("maxShadowRenderDistance", "32"));
} catch (NumberFormatException e) {
Iris.logger.error("Shadow distance setting reset; value is invalid.");
IrisVideoSettings.shadowDistance = 32;
save();
}
if (shaderPackName != null) {
if (shaderPackName.equals("(internal)") || shaderPackName.isEmpty()) {
@@ -147,8 +148,7 @@ public class IrisConfig {
properties.setProperty("shaderPack", getShaderPackName().orElse(""));
properties.setProperty("enableShaders", enableShaders ? "true" : "false");
properties.setProperty("disableUpdateMessage", disableUpdateMessage ? "true" : "false");
// properties.setProperty("maxShadowRenderDistance", String.valueOf(IrisVideoSettings.shadowDistance));
properties.setProperty("maxShadowRenderDistance", String.valueOf(32));
properties.setProperty("maxShadowRenderDistance", String.valueOf(IrisVideoSettings.shadowDistance));
// NB: This uses ISO-8859-1 with unicode escapes as the encoding
try (OutputStream os = Files.newOutputStream(propertiesPath)) {
properties.store(os, COMMENT);
@@ -1,6 +1,8 @@
package net.coderbot.iris.gl.framebuffer;
import com.gtnewhorizons.angelica.compat.lwjgl.MemoryStack;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryStack.*;
import com.gtnewhorizon.gtnhlib.bytebuf.MemoryStack;
import com.gtnewhorizons.angelica.glsm.RenderSystem;
import com.gtnewhorizons.angelica.glsm.texture.TextureInfoCache;
import it.unimi.dsi.fastutil.ints.Int2IntArrayMap;
@@ -51,7 +53,7 @@ public class GlFramebuffer extends GlResource {
}
public void noDrawBuffers() {
try (MemoryStack stack = MemoryStack.stackPush()) {
try (MemoryStack stack = stackPush()) {
final IntBuffer buffer = stack.mallocInt(1);
buffer.put(GL11.GL_NONE);
RenderSystem.drawBuffers(getGlId(), buffer);
@@ -59,7 +61,7 @@ public class GlFramebuffer extends GlResource {
}
public void drawBuffers(int[] buffers) {
try (MemoryStack stack = MemoryStack.stackPush()) {
try (MemoryStack stack = stackPush()) {
final IntBuffer glBuffers = stack.mallocInt(buffers.length);
int index = 0;
@@ -91,6 +91,17 @@ public class ShaderPackOptionList extends IrisGuiSlot {
final BaseEntry entry = this.entries.get(index);
return entry.mouseClicked(mouseX, mouseY, mouseButton);
}
@Override
public boolean mouseReleased( int mouseX, int mouseY, int button) {
final int relativeY = mouseY - this.top - this.headerPadding + (int) this.amountScrolled - 4;
final int index = relativeY / this.slotHeight;
if (index < 0 || index >= this.entries.size())
return false;
final BaseEntry entry = this.entries.get(index);
return entry.mouseReleased(mouseX, mouseY, button);
}
@Override
protected boolean isSelected(int idx) {
@@ -12,6 +12,7 @@ public abstract class BaseEntry {
}
public abstract boolean mouseClicked(int mouseX, int mouseY, int button);
public abstract boolean mouseReleased(int mouseX, int mouseY, int button);
public abstract void drawEntry(ShaderPackScreen screen, int index, int x, int y, int slotWidth, int slotHeight, Tessellator tessellator, int mouseX, int mouseY, boolean isMouseOver);
@@ -108,6 +108,11 @@ public class HeaderEntry extends BaseEntry {
return backButtonResult || utilButtonResult;
}
@Override
public boolean mouseReleased(int mouseX, int mouseY, int button) {
return false;
}
private boolean backButtonClicked(IrisElementRow.TextButtonElement button) {
this.navigation.back();
GuiUtil.playButtonClickSound();
@@ -11,8 +11,8 @@ public class IrisVideoSettings {
public static int shadowDistance = 32;
// TODO: Tell the user to check in the shader options once that's supported.
private static final String DISABLED_TOOLTIP = I18n.format("options.iris.shadowDistance.disabled");
private static final String ENABLED_TOOLTIP = I18n.format("options.iris.shadowDistance.enabled");
// private static final String DISABLED_TOOLTIP = I18n.format("options.iris.shadowDistance.disabled");
// private static final String ENABLED_TOOLTIP = I18n.format("options.iris.shadowDistance.enabled");
public static int getOverriddenShadowDistance(int base) {
return Iris.getPipelineManager().getPipeline()
@@ -78,9 +78,8 @@ public class HandRenderer {
}
public boolean isHandTranslucent(InteractionHand hand) {
// TODO: Offhand
// Item item = Minecraft.getMinecraft().thePlayer.getItemBySlot(hand == InteractionHand.OFF_HAND ? EquipmentSlot.OFFHAND : EquipmentSlot.MAINHAND).getItem();
ItemStack heldItem = Minecraft.getMinecraft().thePlayer.getHeldItem();
ItemStack heldItem = hand.getItemInHand(Minecraft.getMinecraft().thePlayer);
if (heldItem == null) {
return false;
}
@@ -14,6 +14,7 @@ import java.util.List;
import java.util.Objects;
import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer;
import net.coderbot.iris.Iris;
import net.coderbot.iris.gui.option.IrisVideoSettings;
import net.coderbot.iris.shaderpack.OptionalBoolean;
import net.coderbot.iris.shaderpack.PackDirectives;
import net.coderbot.iris.shaderpack.PackShadowDirectives;
@@ -284,8 +285,8 @@ public class ShadowRenderer {
if (renderMultiplier < 0) {
// TODO: GUI
// distance = IrisVideoSettings.shadowDistance * 16;
distance = 32 * 16;
distance = IrisVideoSettings.shadowDistance * 16; // can be zero :(
//distance = 32 * 16;
setter = "(set by user)";
}
@@ -1,6 +1,8 @@
package net.coderbot.iris.rendertarget;
import com.gtnewhorizons.angelica.compat.lwjgl.MemoryStack;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryStack.*;
import com.gtnewhorizon.gtnhlib.bytebuf.MemoryStack;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.glsm.RenderSystem;
import lombok.Getter;
@@ -41,7 +43,7 @@ public class RenderTarget {
this.width = builder.width;
this.height = builder.height;
try (MemoryStack stack = MemoryStack.stackPush()) {
try (MemoryStack stack = stackPush()) {
IntBuffer textures = stack.mallocInt(2);
GL11.glGenTextures(textures);
@@ -1,6 +1,8 @@
package net.coderbot.iris.sodium.shader_overrides;
import com.gtnewhorizons.angelica.compat.lwjgl.MemoryStack;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryStack.*;
import com.gtnewhorizon.gtnhlib.bytebuf.MemoryStack;
import com.gtnewhorizons.angelica.compat.toremove.MatrixStack;
import com.gtnewhorizons.angelica.glsm.RenderSystem;
import java.nio.FloatBuffer;
@@ -86,7 +88,7 @@ public class IrisChunkProgram extends ChunkProgram {
return;
}
try (MemoryStack stack = MemoryStack.stackPush()) {
try (MemoryStack stack = stackPush()) {
FloatBuffer buffer = stack.mallocFloat(16);
matrix.get(buffer);
@@ -1,6 +1,7 @@
package net.coderbot.iris.sodium.vertex_format.entity_xhfp;
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterUnsafe;
import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.GlyphVertexSink;
@@ -32,14 +33,14 @@ public class EntityVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe imp
uSum += u;
vSum += v;
CompatMemoryUtil.memPutFloat(i, x);
CompatMemoryUtil.memPutFloat(i + 4, y);
CompatMemoryUtil.memPutFloat(i + 8, z);
CompatMemoryUtil.memPutInt(i + 12, color);
CompatMemoryUtil.memPutFloat(i + 16, u);
CompatMemoryUtil.memPutFloat(i + 20, v);
CompatMemoryUtil.memPutInt(i + 24, overlay);
CompatMemoryUtil.memPutInt(i + 28, light);
memPutFloat(i, x);
memPutFloat(i + 4, y);
memPutFloat(i + 8, z);
memPutInt(i + 12, color);
memPutFloat(i + 16, u);
memPutFloat(i + 20, v);
memPutInt(i + 24, overlay);
memPutInt(i + 28, light);
if (vertexCount == 4) {
this.endQuad(normal);
@@ -80,10 +81,10 @@ public class EntityVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe imp
int tangent = NormalHelper.computeTangent(normalX, normalY, normalZ, quad);
for (long vertex = 0; vertex < 4; vertex++) {
CompatMemoryUtil.memPutFloat(i + 36 - STRIDE * vertex, uSum);
CompatMemoryUtil.memPutFloat(i + 40 - STRIDE * vertex, vSum);
CompatMemoryUtil.memPutInt(i + 32 - STRIDE * vertex, normal);
CompatMemoryUtil.memPutInt(i + 44 - STRIDE * vertex, tangent);
memPutFloat(i + 36 - STRIDE * vertex, uSum);
memPutFloat(i + 40 - STRIDE * vertex, vSum);
memPutInt(i + 32 - STRIDE * vertex, normal);
memPutInt(i + 44 - STRIDE * vertex, tangent);
}
uSum = 0;
@@ -1,6 +1,7 @@
package net.coderbot.iris.sodium.vertex_format.entity_xhfp;
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterUnsafe;
import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.GlyphVertexSink;
@@ -32,13 +33,13 @@ public class GlyphVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe impl
uSum += u;
vSum += v;
CompatMemoryUtil.memPutFloat(i, x);
CompatMemoryUtil.memPutFloat(i + 4, y);
CompatMemoryUtil.memPutFloat(i + 8, z);
CompatMemoryUtil.memPutInt(i + 12, color);
CompatMemoryUtil.memPutFloat(i + 16, u);
CompatMemoryUtil.memPutFloat(i + 20, v);
CompatMemoryUtil.memPutInt(i + 24, light);
memPutFloat(i, x);
memPutFloat(i + 4, y);
memPutFloat(i + 8, z);
memPutInt(i + 12, color);
memPutFloat(i + 16, u);
memPutFloat(i + 20, v);
memPutInt(i + 24, light);
if (vertexCount == 4) {
this.endQuad(normal);
@@ -79,10 +80,10 @@ public class GlyphVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe impl
int tangent = NormalHelper.computeTangent(normalX, normalY, normalZ, quad);
for (long vertex = 0; vertex < 4; vertex++) {
CompatMemoryUtil.memPutFloat(i + 36 - STRIDE * vertex, uSum);
CompatMemoryUtil.memPutFloat(i + 40 - STRIDE * vertex, vSum);
CompatMemoryUtil.memPutInt(i + 28 - STRIDE * vertex, normal);
CompatMemoryUtil.memPutInt(i + 44 - STRIDE * vertex, tangent);
memPutFloat(i + 36 - STRIDE * vertex, uSum);
memPutFloat(i + 40 - STRIDE * vertex, vSum);
memPutInt(i + 28 - STRIDE * vertex, normal);
memPutInt(i + 44 - STRIDE * vertex, tangent);
}
uSum = 0;
@@ -1,6 +1,7 @@
package net.coderbot.iris.sodium.vertex_format.entity_xhfp;
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
import net.coderbot.iris.vertices.IrisQuadView;
import java.nio.ByteBuffer;
@@ -44,7 +45,7 @@ public abstract class QuadViewEntity implements IrisQuadView {
@Override
float getFloat(long writePointer) {
return CompatMemoryUtil.memGetFloat(writePointer);
return memGetFloat(writePointer);
}
}
@@ -1,6 +1,7 @@
package net.coderbot.iris.sodium.vertex_format.terrain_xhfp;
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
import net.coderbot.iris.vertices.IrisQuadView;
import java.nio.ByteBuffer;
@@ -52,7 +53,7 @@ public abstract class QuadViewTerrain implements IrisQuadView {
@Override
short getShort(long writePointer) {
return CompatMemoryUtil.memGetShort(writePointer);
return memGetShort(writePointer);
}
}
@@ -1,6 +1,7 @@
package net.coderbot.iris.sodium.vertex_format.terrain_xhfp;
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterUnsafe;
import me.jellysquid.mods.sodium.client.render.chunk.format.ModelVertexSink;
@@ -54,21 +55,21 @@ public class XHFPModelVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe
vertexCount++;
// NB: uSum and vSum must already be incremented outside of this function.
CompatMemoryUtil.memPutShort(i, x);
CompatMemoryUtil.memPutShort(i + 2, y);
CompatMemoryUtil.memPutShort(i + 4, z);
CompatMemoryUtil.memPutInt(i + 8, color);
CompatMemoryUtil.memPutShort(i + 12, u);
CompatMemoryUtil.memPutShort(i + 14, v);
CompatMemoryUtil.memPutShort(i + 16, (short) (light & 0xFFFF));
CompatMemoryUtil.memPutShort(i + 18, (short) (light >> 16 & 0xFFFF));
memPutShort(i, x);
memPutShort(i + 2, y);
memPutShort(i + 4, z);
memPutInt(i + 8, color);
memPutShort(i + 12, u);
memPutShort(i + 14, v);
memPutShort(i + 16, (short) (light & 0xFFFF));
memPutShort(i + 18, (short) (light >> 16 & 0xFFFF));
// NB: We don't set midTexCoord, normal, and tangent here, they will be filled in later.
// block ID: We only set the first 2 values, any legacy shaders using z or w will get filled in based on the GLSL spec
// https://www.khronos.org/opengl/wiki/Vertex_Specification#Vertex_format
// TODO: can we pack this into one short?
CompatMemoryUtil.memPutShort(i + 36, materialId);
CompatMemoryUtil.memPutShort(i + 38, renderType);
CompatMemoryUtil.memPutInt(i + 40, packedMidBlock);
memPutShort(i + 36, materialId);
memPutShort(i + 38, renderType);
memPutInt(i + 40, packedMidBlock);
if (vertexCount == 4) {
vertexCount = 0;
@@ -103,15 +104,15 @@ public class XHFPModelVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe
uSum *= 0.25f;
vSum *= 0.25f;
CompatMemoryUtil.memPutFloat(i + 20, uSum);
CompatMemoryUtil.memPutFloat(i + 20 - STRIDE, uSum);
CompatMemoryUtil.memPutFloat(i + 20 - STRIDE * 2, uSum);
CompatMemoryUtil.memPutFloat(i + 20 - STRIDE * 3, uSum);
memPutFloat(i + 20, uSum);
memPutFloat(i + 20 - STRIDE, uSum);
memPutFloat(i + 20 - STRIDE * 2, uSum);
memPutFloat(i + 20 - STRIDE * 3, uSum);
CompatMemoryUtil.memPutFloat(i + 24, vSum);
CompatMemoryUtil.memPutFloat(i + 24 - STRIDE, vSum);
CompatMemoryUtil.memPutFloat(i + 24 - STRIDE * 2, vSum);
CompatMemoryUtil.memPutFloat(i + 24 - STRIDE * 3, vSum);
memPutFloat(i + 24, vSum);
memPutFloat(i + 24 - STRIDE, vSum);
memPutFloat(i + 24 - STRIDE * 2, vSum);
memPutFloat(i + 24 - STRIDE * 3, vSum);
uSum = 0;
vSum = 0;
@@ -124,17 +125,17 @@ public class XHFPModelVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe
NormalHelper.computeFaceNormal(normal, quad);
int packedNormal = NormalHelper.packNormal(normal, 0.0f);
CompatMemoryUtil.memPutInt(i + 32, packedNormal);
CompatMemoryUtil.memPutInt(i + 32 - STRIDE, packedNormal);
CompatMemoryUtil.memPutInt(i + 32 - STRIDE * 2, packedNormal);
CompatMemoryUtil.memPutInt(i + 32 - STRIDE * 3, packedNormal);
memPutInt(i + 32, packedNormal);
memPutInt(i + 32 - STRIDE, packedNormal);
memPutInt(i + 32 - STRIDE * 2, packedNormal);
memPutInt(i + 32 - STRIDE * 3, packedNormal);
int tangent = NormalHelper.computeTangent(normal.x, normal.y, normal.z, quad);
CompatMemoryUtil.memPutInt(i + 28, tangent);
CompatMemoryUtil.memPutInt(i + 28 - STRIDE, tangent);
CompatMemoryUtil.memPutInt(i + 28 - STRIDE * 2, tangent);
CompatMemoryUtil.memPutInt(i + 28 - STRIDE * 3, tangent);
memPutInt(i + 28, tangent);
memPutInt(i + 28 - STRIDE, tangent);
memPutInt(i + 28 - STRIDE * 2, tangent);
memPutInt(i + 28 - STRIDE * 3, tangent);
}
this.advance();
@@ -1,9 +1,11 @@
package net.coderbot.iris.texture.pbr;
import com.gtnewhorizons.angelica.compat.mojang.AutoClosableAbstractTexture;
import com.gtnewhorizons.angelica.config.AngelicaConfig;
import com.gtnewhorizons.angelica.mixins.interfaces.TextureAtlasSpriteAccessor;
import com.gtnewhorizons.angelica.mixins.interfaces.TextureMapAccessor;
import lombok.Getter;
import net.coderbot.iris.Iris;
import net.coderbot.iris.texture.util.TextureExporter;
import net.coderbot.iris.texture.util.TextureManipulationUtil;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
@@ -88,7 +90,7 @@ public class PBRAtlasTexture extends AutoClosableAbstractTexture {
}
}
if (PBRTextureManager.DEBUG) {
if (AngelicaConfig.enablePBRDebug) {
TextureExporter.exportTextures("pbr_debug/atlas", id.getResourceDomain() + "_" + id.getResourcePath().replaceAll("/", "_"), glId, mipLevel, atlasWidth, atlasHeight);
}
}
@@ -98,6 +100,7 @@ public class PBRAtlasTexture extends AutoClosableAbstractTexture {
upload(atlasWidth, atlasHeight, mipLevel, anisotropicFiltering);
return true;
} catch (Throwable t) {
Iris.logger.error("Could not upload PBR texture", t);
return false;
}
}
@@ -18,8 +18,6 @@ import org.lwjgl.opengl.GL11;
public class PBRTextureManager {
public static final PBRTextureManager INSTANCE = new PBRTextureManager();
public static final boolean DEBUG = System.getProperty("iris.pbr.debug") != null;
// TODO: Figure out how to merge these two.
private static Runnable normalTextureChangeListener;
private static Runnable specularTextureChangeListener;
@@ -85,7 +83,7 @@ public class PBRTextureManager {
loader.load(texture, Minecraft.getMinecraft().getResourceManager(), consumer);
return consumer.toHolder();
} catch (Exception e) {
Iris.logger.debug("Failed to load PBR textures for texture " + id, e);
Iris.logger.error("Failed to load PBR textures for texture " + id, e);
} finally {
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, previousTextureBinding);
}
@@ -2,6 +2,8 @@ package net.coderbot.iris.texture.util;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.compat.mojang.NativeImage;
import net.coderbot.iris.Iris;
import net.minecraft.client.Minecraft;
import org.apache.commons.io.FilenameUtils;
import org.lwjgl.opengl.GL11;
@@ -28,6 +30,8 @@ public class TextureExporter {
try {
nativeImage.writeToFile(file);
} catch (Exception ignored) {}
} catch (Exception e) {
Iris.logger.error("Could not export texture", e);
}
}
}
@@ -1,5 +1,8 @@
package net.coderbot.iris.texture.util;
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryStack.*;
import com.gtnewhorizon.gtnhlib.bytebuf.MemoryStack;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.OpenGlHelper;
@@ -14,43 +17,60 @@ public class TextureManipulationUtil {
private static int colorFillFBO = -1;
public static void fillWithColor(int textureId, int maxLevel, int rgba) {
if (colorFillFBO == -1) {
colorFillFBO = OpenGlHelper.func_153165_e/*glGenFramebuffers*/();
}
final int previousFramebufferId = GL11.glGetInteger(GL30.GL_FRAMEBUFFER_BINDING);
// TODO: allocations
final FloatBuffer previousClearColorBuffer = BufferUtils.createFloatBuffer(4);
GL11.glGetFloat(GL11.GL_COLOR_CLEAR_VALUE, previousClearColorBuffer);
final int previousTextureId = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
final IntBuffer previousViewportBuffer = BufferUtils.createIntBuffer(4);
GL11.glGetInteger(GL11.GL_VIEWPORT, previousViewportBuffer);
OpenGlHelper.func_153171_g/*glBindFramebuffer*/(GL30.GL_FRAMEBUFFER, colorFillFBO);
GL11.glClearColor(
(rgba >> 24 & 0xFF) / 255.0f,
(rgba >> 16 & 0xFF) / 255.0f,
(rgba >> 8 & 0xFF) / 255.0f,
(rgba & 0xFF) / 255.0f
);
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, textureId);
for (int level = 0; level <= maxLevel; ++level) {
final int width = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, GL11.GL_TEXTURE_WIDTH);
final int height = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, GL11.GL_TEXTURE_HEIGHT);
GL11.glViewport(0, 0, width, height);
GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, textureId, level);
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
if (Minecraft.isRunningOnMac) {
GL11.glGetError();
try(final MemoryStack stack = stackPush()) {
if (colorFillFBO == -1) {
colorFillFBO = OpenGlHelper.func_153165_e/*glGenFramebuffers*/();
}
final int previousFramebufferId = GL11.glGetInteger(GL30.GL_FRAMEBUFFER_BINDING);
final FloatBuffer previousClearColorBuffer = stack.mallocFloat(4);
GL11.glGetFloat(GL11.GL_COLOR_CLEAR_VALUE, previousClearColorBuffer);
final int previousTextureId = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
final IntBuffer previousViewportBuffer = stack.mallocInt(4);
GL11.glGetInteger(GL11.GL_VIEWPORT, previousViewportBuffer);
GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, 0, level);
}
OpenGlHelper.func_153171_g/*glBindFramebuffer*/(GL30.GL_FRAMEBUFFER, colorFillFBO);
GL11.glClearColor(
(rgba >> 24 & 0xFF) / 255.0f,
(rgba >> 16 & 0xFF) / 255.0f,
(rgba >> 8 & 0xFF) / 255.0f,
(rgba & 0xFF) / 255.0f);
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, textureId);
for (int level = 0; level <= maxLevel; ++level) {
final int width = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, GL11.GL_TEXTURE_WIDTH);
final int height = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, GL11.GL_TEXTURE_HEIGHT);
GL11.glViewport(0, 0, width, height);
GL30.glFramebufferTexture2D(
GL30.GL_FRAMEBUFFER,
GL30.GL_COLOR_ATTACHMENT0,
GL11.GL_TEXTURE_2D,
textureId,
level);
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
if (Minecraft.isRunningOnMac) {
GL11.glGetError();
}
OpenGlHelper.func_153171_g/*glBindFramebuffer*/(GL30.GL_FRAMEBUFFER, previousFramebufferId);
GL11.glClearColor(previousClearColorBuffer.get(0), previousClearColorBuffer.get(1), previousClearColorBuffer.get(2), previousClearColorBuffer.get(3));
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, previousTextureId);
GL11.glViewport(previousViewportBuffer.get(0), previousViewportBuffer.get(1), previousViewportBuffer.get(2), previousViewportBuffer.get(3));
GL30.glFramebufferTexture2D(
GL30.GL_FRAMEBUFFER,
GL30.GL_COLOR_ATTACHMENT0,
GL11.GL_TEXTURE_2D,
0,
level);
}
OpenGlHelper.func_153171_g/*glBindFramebuffer*/(GL30.GL_FRAMEBUFFER, previousFramebufferId);
GL11.glClearColor(
previousClearColorBuffer.get(0),
previousClearColorBuffer.get(1),
previousClearColorBuffer.get(2),
previousClearColorBuffer.get(3));
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, previousTextureId);
GL11.glViewport(
previousViewportBuffer.get(0),
previousViewportBuffer.get(1),
previousViewportBuffer.get(2),
previousViewportBuffer.get(3));
}
}
}
@@ -76,9 +76,8 @@ public final class IdMapUniforms {
invalidate();
return;
}
// ItemStack heldStack = player.getItemInHand(hand);
// TODO: Offhand
ItemStack heldStack = player.getHeldItem();
ItemStack heldStack = hand.getItemInHand(player);
if (heldStack == null) {
invalidate();
@@ -106,9 +105,7 @@ public final class IdMapUniforms {
}
private IrisItemLightProvider applyOldHandLighting(@NotNull EntityPlayer player, IrisItemLightProvider existing) {
// TODO: Offhand
// ItemStack offHandStack = player.getItemInHand(InteractionHand.OFF_HAND);
ItemStack offHandStack = null;
ItemStack offHandStack = InteractionHand.OFF_HAND.getItemInHand(player);
if (offHandStack == null) {
return existing;
@@ -137,10 +137,12 @@ options.dynamic_lights_shader_force=Dynamic Lights - Forced With Shaders
options.dynamic_lights_shader_force.tooltip=Enabled - Dynamic Lights are shown even when a shader is active, Disabled - Dynamic Lights are disabled when a shader is active.
options.angelica.droppedItemLimit=Dropped Item Render Limit
options.angelica.droppedItemLimit.tooltip=The maximum number of dropped items that will be rendered. Lower values can improve performance.
options.angelica.mobSpawnerRenderDistance=Mod spawner render distance
options.angelica.mobSpawnerRenderDistance=Mob spawner render distance
options.angelica.mobSpawnerRenderDistance.tooltip=Render distance for the spinning mob inside mod spawners
options.angelica.itemdisplaylistcount=Item Renderer Display List Cache Size
options.angelica.itemdisplaylistcount.tooltip=The maximum number of display lists to cache in the optimized item renderer. Higher values will increase performance but increase VRAM usage.
options.angelica.sleepbeforeswap=Alternate FPS Limiter
options.angelica.sleepbeforeswap.tooltip=Switches to an alternate FPS limiter that gives more stable frametimes, in exchange for slightly more latency. Will never introduce more than one frame of latency, and has a lower impact at higher framerates.
pack.iris.select.title=Select
pack.iris.configure.title=Configure
label.iris.true=On
@@ -1,7 +1,10 @@
package com.gtnewhorizons.angelica.mixins.early.angelica;
import com.gtnewhorizons.angelica.AngelicaMod;
import com.gtnewhorizons.angelica.config.AngelicaConfig;
import com.gtnewhorizons.angelica.mixins.interfaces.IGameSettingsExt;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.GameSettings;
import org.lwjgl.input.Keyboard;
@@ -14,10 +17,16 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(Minecraft.class)
public class MixinMinecraft {
public abstract class MixinMinecraft {
@Shadow
public GameSettings gameSettings;
@Shadow
public abstract boolean isFramerateLimitBelowMax();
@Shadow
public abstract int getLimitFramerate();
@Unique
private long angelica$lastFrameTime = 0;
@@ -29,6 +38,20 @@ public class MixinMinecraft {
GL11.glEnable(GL11.GL_LIGHTING);
}
@Inject(
method = "func_147120_f",
at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;update()V", shift = At.Shift.BEFORE, remap = false)
)
private void angelica$limitFPS(CallbackInfo ci) {
if (!AngelicaConfig.sleepBeforeSwap) return;
if (isFramerateLimitBelowMax()) {
final long target = angelica$lastFrameTime + (long) (1.0 / getLimitFramerate() * 1_000_000) * 1_000;
while (target - System.nanoTime() > 100) {
Thread.yield();
}
}
}
@Inject(
method = "func_147120_f",
at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;update()V", shift = At.Shift.AFTER, remap = false)
@@ -41,6 +64,12 @@ public class MixinMinecraft {
angelica$lastFrameTime = time;
}
@WrapOperation(method = "runGameLoop", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;sync(I)V", remap = false))
private void angelica$noopFPSLimiter(int fps, Operation<Void> original) {
if (AngelicaConfig.sleepBeforeSwap) return;
original.call(fps);
}
@Inject(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiScreen;isShiftKeyDown()Z", shift = At.Shift.AFTER))
private void angelica$setShowFpsGraph(CallbackInfo ci) {
((IGameSettingsExt) gameSettings).angelica$setShowFpsGraph(Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU));
@@ -1,5 +1,6 @@
package com.gtnewhorizons.angelica.mixins.early.angelica.animation;
import com.gtnewhorizons.angelica.mixins.interfaces.IPatchedTextureAtlasSprite;
import com.gtnewhorizons.angelica.mixins.interfaces.ITexturesCache;
import net.minecraft.util.IIcon;
import net.minecraft.world.ChunkCache;
@@ -23,4 +24,9 @@ public class MixinChunkCache implements ITexturesCache {
public void enableTextureTracking() {
}
@Override
public void track(IPatchedTextureAtlasSprite sprite) {
}
}
@@ -1,7 +1,9 @@
package com.gtnewhorizons.angelica.mixins.early.angelica.animation;
import com.gtnewhorizons.angelica.mixins.interfaces.IPatchedTextureAtlasSprite;
import com.gtnewhorizons.angelica.mixins.interfaces.ITexturesCache;
import com.gtnewhorizons.angelica.utils.AnimationsRenderUtils;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFire;
@@ -12,7 +14,6 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@@ -38,49 +39,40 @@ public class MixinRenderBlocks implements ITexturesCache {
* apply Occlusion Querry (Basically that means that we will only mark those textures for update that are
* visible (on the viewport) at the moment)
*/
@Inject(method = "*(Lnet/minecraft/block/Block;DDDLnet/minecraft/util/IIcon;)V", at = @At("HEAD"))
@Inject(method = {
"renderFaceYNeg",
"renderFaceYPos",
"renderFaceZNeg",
"renderFaceZPos",
"renderFaceXNeg",
"renderFaceXPos"
}, at = @At("HEAD"))
public void angelica$beforeRenderFace(Block p_147761_1_, double p_147761_2_, double p_147761_4_,
double p_147761_6_, IIcon icon, CallbackInfo ci) {
if (overrideBlockTexture != null) {
icon = overrideBlockTexture;
}
AnimationsRenderUtils.markBlockTextureForUpdate(icon, blockAccess);
if (icon != null) {
AnimationsRenderUtils.markBlockTextureForUpdate(icon, blockAccess);
if(this.enableSpriteTracking)
this.renderedSprites.add(icon);
}
@Inject(method = "renderBlockFire", at = @At("HEAD"))
public void angelica$markFireBlockAnimationForUpdate(BlockFire instance, int x, int y, int z,
CallbackInfoReturnable<Boolean> cir) {
if(this.enableSpriteTracking) {
this.renderedSprites.add(instance.getFireIcon(0));
this.renderedSprites.add(instance.getFireIcon(1));
if(this.enableSpriteTracking) {
this.renderedSprites.add(icon);
}
}
AnimationsRenderUtils.markBlockTextureForUpdate(instance.getFireIcon(0), blockAccess);
AnimationsRenderUtils.markBlockTextureForUpdate(instance.getFireIcon(1), blockAccess);
}
@ModifyVariable(method = "renderBlockLiquid", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/client/renderer/RenderBlocks;getBlockIconFromSideAndMetadata(Lnet/minecraft/block/Block;II)Lnet/minecraft/util/IIcon;"))
public IIcon angelica$markFluidAnimationForUpdate(IIcon icon) {
@ModifyReturnValue(method = "getIconSafe", at = @At("RETURN"))
public IIcon angelica$markBlockSideAnimationForUpdate(IIcon icon) {
AnimationsRenderUtils.markBlockTextureForUpdate(icon, blockAccess);
if(this.enableSpriteTracking)
if(this.enableSpriteTracking) {
this.renderedSprites.add(icon);
}
return icon;
}
@Inject(method = "drawCrossedSquares", at = @At("HEAD"))
public void angelica$markCrossedSquaresAnimationForUpdate(IIcon icon, double p_147765_2_, double p_147765_4_, double p_147765_6_, float p_147765_8_,
CallbackInfo ci) {
AnimationsRenderUtils.markBlockTextureForUpdate(icon, blockAccess);
if(this.enableSpriteTracking)
this.renderedSprites.add(icon);
}
@Override
public Set<IIcon> getRenderedTextures() {
return renderedSprites;
@@ -90,4 +82,11 @@ public class MixinRenderBlocks implements ITexturesCache {
public void enableTextureTracking() {
enableSpriteTracking = true;
}
@Override
public void track(IPatchedTextureAtlasSprite sprite) {
if(this.enableSpriteTracking) {
renderedSprites.add((IIcon) sprite);
}
}
}
@@ -1,11 +1,17 @@
package com.gtnewhorizons.angelica.mixins.early.angelica.animation;
import com.gtnewhorizons.angelica.mixins.interfaces.IPatchedTextureAtlasSprite;
import com.gtnewhorizons.angelica.mixins.interfaces.ISpriteExt;
import com.gtnewhorizons.angelica.utils.AnimationsRenderUtils;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import net.minecraft.block.BlockPortal;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.resources.data.AnimationMetadataSection;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import java.util.List;
@@ -54,4 +60,13 @@ public abstract class MixinTextureAtlasSprite implements IPatchedTextureAtlasSpr
this.tickCounter = 0;
}
}
@ModifyReturnValue(method = "getMinU", at = @At("RETURN"))
private float angelica$onUVAccessed(float value) {
if (((ISpriteExt)this).isAnimation()) {
AnimationsRenderUtils.onSpriteUsed(this);
needsAnimationUpdate = true;
}
return value;
}
}
@@ -49,4 +49,9 @@ public class MixinWorldRenderer implements ITexturesCache {
public void enableTextureTracking() {
}
@Override
public void track(IPatchedTextureAtlasSprite sprite) {
}
}
@@ -0,0 +1,21 @@
package com.gtnewhorizons.angelica.mixins.early.angelica.bugfixes;
import net.minecraft.client.gui.ScaledResolution;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
@Mixin(ScaledResolution.class)
public class MixinScaledResolution_UnicodeFix {
// Force unicode languages to use the calculated scaleFactor and not adjust it.
// Can lead to blurry text
@ModifyConstant(method = "<init>", constant = @Constant(intValue = 1, ordinal = 5))
int angelica$ScaledResolutionInit(int constant){
return 0;
}
}
@@ -29,9 +29,9 @@ public abstract class MixinWorld {
}
@ModifyReturnValue(method = "getLightBrightnessForSkyBlocks", at = @At(value = "RETURN"))
private int angelica$dynamiclights_getLightBrightnessForSkyBlocks(int lightmap, int p_72802_1_, int p_72802_2_, int p_72802_3_, int p_72802_4_){
if (DynamicLights.isEnabled()){
return DynamicLights.get().getLightmapWithDynamicLight(p_72802_1_, p_72802_2_, p_72802_3_, lightmap);
private int angelica$dynamiclights_getLightBrightnessForSkyBlocks(int lightmap, int x, int y, int z, int p_72802_4_){
if (DynamicLights.isEnabled() && !getBlock(x, y, z).isOpaqueCube()){
return DynamicLights.get().getLightmapWithDynamicLight(x, y, z, lightmap);
}
return lightmap;
}
@@ -1,6 +1,7 @@
package com.gtnewhorizons.angelica.mixins.early.angelica.textures.ic2;
import com.gtnewhorizons.angelica.mixins.interfaces.IPatchedTextureAtlasSprite;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import ic2.core.item.ItemFluidCell;
import ic2.core.item.RenderLiquidCell;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
@@ -15,13 +16,19 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@Mixin(RenderLiquidCell.class)
@Mixin(value = RenderLiquidCell.class, remap = false)
public class MixinRenderLiquidCell {
@Inject(at = @At(ordinal = 0, remap = false, shift = Shift.AFTER, target = "Lorg/lwjgl/opengl/GL11;glColor3ub(BBB)V", value = "INVOKE"), locals = LocalCapture.CAPTURE_FAILSOFT, method = "renderItem", remap = false)
@Inject(at = @At(ordinal = 0, shift = Shift.AFTER, target = "Lorg/lwjgl/opengl/GL11;glColor3ub(BBB)V", value = "INVOKE"), locals = LocalCapture.CAPTURE_FAILSOFT, method = "renderItem", remap = false)
private void angelica$markNeedsAnimationUpdate(ItemRenderType type, ItemStack item, Object[] data, CallbackInfo ci, ItemFluidCell cell, IIcon icon, FluidStack fs, IIcon windowIcon, IIcon fluidicon) {
if (fluidicon instanceof TextureAtlasSprite) {
((IPatchedTextureAtlasSprite) fluidicon).markNeedsAnimationUpdate();
}
}
// nop the disabling of the alpha test
@WrapWithCondition(method = "renderItem", at= @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glDisable(I)V", ordinal = 0))
private boolean angelica$renderItemGLDisable(int cap){
return false;
}
}
@@ -14,7 +14,6 @@ public class MixinItemRenderer {
@Inject(method = "renderItemInFirstPerson", at = @At("HEAD"), cancellable = true)
private void iris$skipTranslucentHands(float partialTicks, CallbackInfo ci) {
if (IrisApi.getInstance().isShaderPackInUse()) {
// TODO: Offhand
boolean isHandTranslucent = HandRenderer.INSTANCE.isHandTranslucent(InteractionHand.MAIN_HAND);
if (HandRenderer.INSTANCE.isRenderingSolid() && isHandTranslucent) {
ci.cancel();
@@ -0,0 +1,48 @@
package com.gtnewhorizons.angelica.mixins.early.shaders;
import com.gtnewhorizons.angelica.compat.ModStatus;
import com.gtnewhorizons.angelica.compat.mojang.InteractionHand;
import net.coderbot.iris.pipeline.HandRenderer;
import net.irisshaders.iris.api.v0.IrisApi;
import net.minecraft.client.renderer.ItemRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import xonin.backhand.client.hooks.ItemRendererHooks;
@Mixin(ItemRenderer.class)
public class MixinItemRendererBackhand {
@Inject(method = "renderItemInFirstPerson", at = @At("HEAD"), cancellable = true)
private void iris$skipTranslucentHands(float partialTicks, CallbackInfo ci) {
if (IrisApi.getInstance().isShaderPackInUse()) {
boolean isHandTranslucent = HandRenderer.INSTANCE.isHandTranslucent(InteractionHand.MAIN_HAND);
if (HandRenderer.INSTANCE.isRenderingSolid() && isHandTranslucent) {
ci.cancel();
if (ModStatus.isBackhandLoaded){
iris$skipTranslucentHandsBackhand(partialTicks, ci);
ItemRendererHooks.renderOffhandReturn(partialTicks);
}
} else if (!HandRenderer.INSTANCE.isRenderingSolid() && !isHandTranslucent) {
ci.cancel();
if (ModStatus.isBackhandLoaded){
iris$skipTranslucentHandsBackhand(partialTicks, ci);
ItemRendererHooks.renderOffhandReturn(partialTicks);
}
}
}
}
// change injection to before Backhand's inject
@Inject(method = "renderItemInFirstPerson", at = @At("RETURN"), cancellable = true, order = 900)
private void iris$skipTranslucentHandsBackhand(float partialTicks, CallbackInfo ci) {
if (ModStatus.isBackhandLoaded && IrisApi.getInstance().isShaderPackInUse()) {
boolean isHandTranslucent = HandRenderer.INSTANCE.isHandTranslucent(InteractionHand.OFF_HAND);
if (HandRenderer.INSTANCE.isRenderingSolid() && isHandTranslucent) {
ci.cancel();
} else if (!HandRenderer.INSTANCE.isRenderingSolid() && !isHandTranslucent) {
ci.cancel();
}
}
}
}
@@ -7,8 +7,10 @@ import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.Map;
import com.gtnewhorizons.angelica.mixins.interfaces.TextureMapAccessor;
@Mixin(TextureMap.class)
public abstract class MixinTextureMap {
public abstract class MixinTextureMap implements TextureMapAccessor {
@Accessor("mapUploadedSprites")
public abstract Map getMapUploadedSprites();
@@ -7,6 +7,7 @@ import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.culling.Frustrum;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
@@ -39,7 +40,7 @@ public class MixinEffectRenderer {
@Redirect(method = "renderParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/EntityFX;renderParticle(Lnet/minecraft/client/renderer/Tessellator;FFFFFF)V"))
private void renderParticles(EntityFX particle, Tessellator tessellator, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
if(cullingFrustum == null || cullingFrustum.isBoundingBoxInFrustum(particle.boundingBox)) {
if(cullingFrustum == null || particle.boundingBox == TileEntity.INFINITE_EXTENT_AABB || cullingFrustum.isBoundingBoxInFrustum(particle.boundingBox)) {
particle.renderParticle(tessellator, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ);
}
}
@@ -51,7 +52,7 @@ public class MixinEffectRenderer {
@Redirect(method = "renderLitParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/EntityFX;renderParticle(Lnet/minecraft/client/renderer/Tessellator;FFFFFF)V"))
private void renderLitParticles(EntityFX particle, Tessellator tessellator, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
if(cullingFrustum == null || cullingFrustum.isBoundingBoxInFrustum(particle.boundingBox)) {
if(cullingFrustum == null || particle.boundingBox == TileEntity.INFINITE_EXTENT_AABB || cullingFrustum.isBoundingBoxInFrustum(particle.boundingBox)) {
particle.renderParticle(tessellator, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ);
}
}