Skip to content

Commit

Permalink
Fix #44
Browse files Browse the repository at this point in the history
  • Loading branch information
makamys committed Jan 20, 2024
1 parent 7da5fb9 commit 3a842c2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/main/java/makamys/neodymium/Compat.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class Compat {
private static boolean IS_RPLE_PRESENT;

private static boolean IS_FALSE_TWEAKS_PRESENT;

private static boolean IS_HODGEPODGE_SPEEDUP_ANIMATIONS_ENABLED;

private static boolean isShadersEnabled;

Expand All @@ -44,6 +46,28 @@ public static void init() {
if (Loader.isModLoaded("falsetweaks")) {
IS_FALSE_TWEAKS_PRESENT = true;
}

IS_HODGEPODGE_SPEEDUP_ANIMATIONS_ENABLED = checkIfHodgepodgeSpeedupAnimationsIsEnabled();
}

private static boolean checkIfHodgepodgeSpeedupAnimationsIsEnabled() {
boolean result = false;
if (Loader.isModLoaded("hodgepodge")) {
try {
Class<?> CommonCls = Class.forName("com.mitchej123.hodgepodge.Common");
Object config = CommonCls.getField("config").get(null);
Class<?> configCls = config.getClass();
boolean speedupAnimations = (Boolean)configCls.getField("speedupAnimations").get(config);
LOGGER.debug("Hodgepodge's speedupAnimations is set to " + speedupAnimations);
result = speedupAnimations;
} catch(Exception e) {
LOGGER.warn("Failed to determine if Hodgepodge's speedupAnimations is enabled, assuming false");
}
} else {
LOGGER.debug("Hodgepodge is missing, treating speedupAnimations as false");
}
LOGGER.debug("Compat fix will " + (result ? "" : "not") + " be enabled");
return result;
}

public static boolean isRPLEModPresent() {
Expand All @@ -53,7 +77,10 @@ public static boolean isRPLEModPresent() {
public static boolean isFalseTweaksModPresent() {
return IS_FALSE_TWEAKS_PRESENT;
}


public static boolean isHodgepodgeSpeedupAnimationsEnabled() {
return IS_HODGEPODGE_SPEEDUP_ANIMATIONS_ENABLED;
}

public static boolean isOptiFineShadersEnabled() {
return isShadersEnabled;
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/makamys/neodymium/renderer/NeoRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.falsepattern.rple.api.client.RPLEShaderConstants;
import lombok.val;
import makamys.neodymium.Compat;
import makamys.neodymium.Constants;
import makamys.neodymium.Neodymium;
import makamys.neodymium.config.Config;
import makamys.neodymium.ducks.IWorldRenderer;
Expand Down Expand Up @@ -205,6 +206,10 @@ private void initIndexBuffers() {
for (int j = piCount[i].position() - meshes; j < piCount[i].position(); j++) {
renderedQuads += piCount[i].get(j) / 4;
}
if(Compat.isHodgepodgeSpeedupAnimationsEnabled() && !Constants.KEEP_RENDER_LIST_LOGIC) {
// Hodgepodge hooks this method to decide what animations to play, make sure it runs
wr.getGLCallListForPass(i);
}
}
}
region.batchLimit[i] = piFirst[i].position();
Expand Down

0 comments on commit 3a842c2

Please sign in to comment.