Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPLE and OptiFine compatibility #43

Merged
merged 11 commits into from
Jan 8, 2024
21 changes: 18 additions & 3 deletions src/main/java/makamys/neodymium/Neodymium.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
import java.util.ArrayList;
import java.util.List;

import makamys.neodymium.renderer.compat.RenderUtil;
import makamys.neodymium.renderer.compat.RenderUtilRPLE;
import makamys.neodymium.renderer.compat.RenderUtilShaderRPLE;
import makamys.neodymium.renderer.compat.RenderUtilShaders;
import makamys.neodymium.renderer.compat.RenderUtilVanilla;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import cpw.mods.fml.client.event.ConfigChangedEvent;
import cpw.mods.fml.common.FMLCommonHandler;
Expand All @@ -18,7 +21,6 @@
import cpw.mods.fml.common.event.FMLConstructionEvent;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent;
Expand Down Expand Up @@ -49,6 +51,8 @@ public class Neodymium
private boolean renderDebugText = false;

public static NeoRenderer renderer;

public static RenderUtil util;

private static World rendererWorld;

Expand Down Expand Up @@ -97,6 +101,17 @@ private void onPlayerWorldChanged(World newWorld) {
List<Warning> criticalWarns = warnsAndCriticalWarns.getRight();

if(criticalWarns.isEmpty()) {
boolean rple = Compat.isRPLEModPresent();
boolean optiFineShaders = Compat.isOptiFineShadersEnabled();
if (rple && optiFineShaders) {
util = RenderUtilShaderRPLE.INSTANCE;
} else if (optiFineShaders) {
util = RenderUtilShaders.INSTANCE;
} else if (rple) {
util = RenderUtilRPLE.INSTANCE;
} else {
util = RenderUtilVanilla.INSTANCE;
}
renderer = new NeoRenderer(newWorld);
renderer.hasIncompatibilities = !warns.isEmpty() || !criticalWarns.isEmpty();
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/makamys/neodymium/renderer/ChunkMesh.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ private ByteBuffer createBuffer(List<? extends MeshQuad> quads, int quadCount) {
if(subMeshStart[subMeshStartIdx] == -1) {
subMeshStart[subMeshStartIdx] = i;
}
quad.writeToBuffer(out, stride);
Neodymium.util.writeMeshQuadToBuffer(quad, out, stride);
i++;
} else if(sortByNormals){
break;
Expand Down Expand Up @@ -301,12 +301,12 @@ public double distSq(Entity player) {
public static void setCaptureTarget(ChunkMesh cm) {
meshCaptureTarget = cm;
}

public static class Flags {
boolean hasTexture;
boolean hasBrightness;
boolean hasColor;
boolean hasNormals;
public boolean hasTexture;
public boolean hasBrightness;
public boolean hasColor;
public boolean hasNormals;

public Flags(byte flags) {
hasTexture = (flags & 1) != 0;
Expand Down
Loading