Fix potential null pointers if other mods mess with the MVM or Proj matricies
This commit is contained in:
@@ -88,25 +88,25 @@ public class DhApiMat4f implements IDhApiCopyable
|
||||
/** Expects the values of the input array to be in row major order (AKA rows then columns) */
|
||||
public DhApiMat4f(float[] values)
|
||||
{
|
||||
m00 = values[0];
|
||||
m01 = values[1];
|
||||
m02 = values[2];
|
||||
m03 = values[3];
|
||||
this.m00 = values[0];
|
||||
this.m01 = values[1];
|
||||
this.m02 = values[2];
|
||||
this.m03 = values[3];
|
||||
|
||||
m10 = values[4];
|
||||
m11 = values[5];
|
||||
m12 = values[6];
|
||||
m13 = values[7];
|
||||
this.m10 = values[4];
|
||||
this.m11 = values[5];
|
||||
this.m12 = values[6];
|
||||
this.m13 = values[7];
|
||||
|
||||
m20 = values[8];
|
||||
m21 = values[9];
|
||||
m22 = values[10];
|
||||
m23 = values[11];
|
||||
this.m20 = values[8];
|
||||
this.m21 = values[9];
|
||||
this.m22 = values[10];
|
||||
this.m23 = values[11];
|
||||
|
||||
m30 = values[12];
|
||||
m31 = values[13];
|
||||
m32 = values[14];
|
||||
m33 = values[15];
|
||||
this.m30 = values[12];
|
||||
this.m31 = values[13];
|
||||
this.m32 = values[14];
|
||||
this.m33 = values[15];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.seibel.distanthorizons.api.enums.rendering.EDhApiRenderPass;
|
||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.*;
|
||||
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
|
||||
import com.seibel.distanthorizons.core.file.structure.ClientOnlySaveStructure;
|
||||
import com.seibel.distanthorizons.core.logging.f3.F3Screen;
|
||||
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||
import com.seibel.distanthorizons.core.render.DhApiRenderProxy;
|
||||
import com.seibel.distanthorizons.core.render.renderer.FadeRenderer;
|
||||
@@ -430,7 +431,9 @@ public class ClientApi
|
||||
|
||||
try
|
||||
{
|
||||
if (!RenderUtil.shouldLodsRender(levelWrapper))
|
||||
// TODO write this message to the F3 menu so people can see when a different mod screws with the lightmap
|
||||
String reasonLodsCannotRender = RenderUtil.shouldLodsRender(levelWrapper, renderEventParam);
|
||||
if (reasonLodsCannotRender != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.seibel.distanthorizons.core.util;
|
||||
|
||||
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
|
||||
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
@@ -164,37 +165,43 @@ public class RenderUtil
|
||||
return -1.0f;
|
||||
}
|
||||
|
||||
/** @return false if LODs shouldn't be rendered for any reason */
|
||||
public static boolean shouldLodsRender(ILevelWrapper levelWrapper)
|
||||
/** @return a message if LODs shouldn't be rendered, null if the LODs can render */
|
||||
public static String shouldLodsRender(ILevelWrapper levelWrapper, DhApiRenderParam renderEventParam)
|
||||
{
|
||||
if (!MC.playerExists())
|
||||
{
|
||||
return false;
|
||||
return "No Player Exists";
|
||||
}
|
||||
|
||||
if (levelWrapper == null)
|
||||
{
|
||||
return false;
|
||||
return "No Level Given";
|
||||
}
|
||||
|
||||
IDhClientWorld clientWorld = SharedApi.getIDhClientWorld();
|
||||
if (clientWorld == null)
|
||||
{
|
||||
return false;
|
||||
return "No Client World Loaded";
|
||||
}
|
||||
|
||||
IDhClientLevel level = clientWorld.getClientLevel(levelWrapper);
|
||||
if (level == null)
|
||||
{
|
||||
return false; //Level is not ready yet.
|
||||
return "No Client Level Loaded"; //Level is not ready yet.
|
||||
}
|
||||
|
||||
if (MC_RENDER.getLightmapWrapper(levelWrapper) == null)
|
||||
{
|
||||
return false;
|
||||
return "No Lightmap loaded";
|
||||
}
|
||||
|
||||
return true;
|
||||
if (renderEventParam.dhModelViewMatrix == null
|
||||
|| renderEventParam.mcModelViewMatrix == null)
|
||||
{
|
||||
return "No MVM or Proj Matrix Given";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user