mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-13 17:04:15 +00:00
Add support for dimension.properties (#1283)
This commit is contained in:
1 parent
26300bbb1b
commit
2f2fc22df3
5 files changed
+350
-73
No files matched your search
@@ -27,7 +27,6 @@ import net.coderbot.iris.gbuffer_overrides.matching.InputAvailability;
|
||||
import net.coderbot.iris.pipeline.FixedFunctionWorldRenderingPipeline;
|
||||
import net.coderbot.iris.pipeline.PipelineManager;
|
||||
import net.coderbot.iris.pipeline.WorldRenderingPipeline;
|
||||
import net.coderbot.iris.shaderpack.DimensionId;
|
||||
import net.coderbot.iris.shaderpack.OptionalBoolean;
|
||||
import net.coderbot.iris.shaderpack.ProgramSet;
|
||||
import net.coderbot.iris.shaderpack.ShaderPack;
|
||||
@@ -410,8 +409,8 @@ public class Iris {
|
||||
// Initialize the pipeline now so that we don't increase world loading time. Just going to guess that
|
||||
// the player is in the overworld.
|
||||
// See: https://github.com/IrisShaders/Iris/issues/323
|
||||
lastDimension = DimensionId.OVERWORLD;
|
||||
Iris.getPipelineManager().preparePipeline(DimensionId.OVERWORLD);
|
||||
lastDimensionName = "Overworld";
|
||||
Iris.getPipelineManager().preparePipeline("Overworld");
|
||||
|
||||
BlockRenderingSettings.INSTANCE.reloadRendererIfRequired();
|
||||
}
|
||||
@@ -715,7 +714,7 @@ public class Iris {
|
||||
// Very important - we need to re-create the pipeline straight away.
|
||||
// https://github.com/IrisShaders/Iris/issues/1330
|
||||
if (Minecraft.getMinecraft().theWorld != null) {
|
||||
Iris.getPipelineManager().preparePipeline(Iris.getCurrentDimension());
|
||||
Iris.getPipelineManager().preparePipeline(Iris.getCurrentDimensionName());
|
||||
|
||||
BlockRenderingSettings.INSTANCE.reloadRendererIfRequired();
|
||||
}
|
||||
@@ -743,44 +742,64 @@ public class Iris {
|
||||
}
|
||||
}
|
||||
|
||||
public static DimensionId lastDimension = null;
|
||||
public static String lastDimensionName = null;
|
||||
public static int lastDimensionId = 0;
|
||||
|
||||
public static DimensionId getCurrentDimension() {
|
||||
/**
|
||||
* Gets the dimension name for the current world.
|
||||
* Returns the dimension name from WorldProvider.getDimensionName() if available.
|
||||
* Falls back to lastDimensionName when no world is loaded.
|
||||
*/
|
||||
public static String getCurrentDimensionName() {
|
||||
final WorldClient level = Minecraft.getMinecraft().theWorld;
|
||||
|
||||
if (level != null) {
|
||||
if (level.provider == null) return DimensionId.OVERWORLD;
|
||||
|
||||
if (level.provider.isHellWorld || level.provider.dimensionId == -1) {
|
||||
return DimensionId.NETHER;
|
||||
} else if (level.provider.dimensionId == 1) {
|
||||
return DimensionId.END;
|
||||
} else {
|
||||
return DimensionId.OVERWORLD;
|
||||
if (level != null && level.provider != null) {
|
||||
String dimensionName = level.provider.getDimensionName();
|
||||
if (dimensionName == null) {
|
||||
dimensionName = "Overworld";
|
||||
logger.warn("WorldProvider.getDimensionName() returned null for dimension ID {}, defaulting to 'Overworld'", level.provider.dimensionId);
|
||||
}
|
||||
lastDimensionName = dimensionName;
|
||||
lastDimensionId = level.provider.dimensionId;
|
||||
return dimensionName;
|
||||
} else {
|
||||
// This prevents us from reloading the shaderpack unless we need to. Otherwise, if the player is in the
|
||||
// nether and quits the game, we might end up reloading the shaders on exit and on entry to the level
|
||||
// This prevents us from reloading the shaderpack unless we need to. Otherwise, if the player is in
|
||||
// another dimension and quits the game, we might end up reloading the shaders on exit and on entry to the level
|
||||
// because the code thinks that the dimension changed.
|
||||
return lastDimension;
|
||||
return lastDimensionName != null ? lastDimensionName : "Overworld";
|
||||
}
|
||||
}
|
||||
|
||||
private static WorldRenderingPipeline createPipeline(DimensionId dimensionId) {
|
||||
/**
|
||||
* Gets the current dimension ID.
|
||||
*/
|
||||
public static int getCurrentDimensionId() {
|
||||
final WorldClient level = Minecraft.getMinecraft().theWorld;
|
||||
if (level != null && level.provider != null) {
|
||||
return level.provider.dimensionId;
|
||||
}
|
||||
return lastDimensionId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a pipeline for a dimension using the dimension name from WorldProvider.getDimensionName().
|
||||
* Supports dimension.properties mappings with wildcard fallback.
|
||||
*/
|
||||
private static WorldRenderingPipeline createPipeline(String dimensionName) {
|
||||
if (currentPack == null) {
|
||||
// Completely disables shader-based rendering
|
||||
return new FixedFunctionWorldRenderingPipeline();
|
||||
}
|
||||
|
||||
final ProgramSet programs = currentPack.getProgramSet(dimensionId);
|
||||
|
||||
final ProgramSet programs = currentPack.getProgramSet(dimensionName);
|
||||
|
||||
try {
|
||||
shaderPackLoadId++;
|
||||
long startTime = System.nanoTime();
|
||||
WorldRenderingPipeline pipeline = new DeferredWorldRenderingPipeline(programs);
|
||||
long endTime = System.nanoTime();
|
||||
logger.info("[Load #{}] Total shaderpack load time for '{}': {} ms", shaderPackLoadId, currentPackName, String.format("%.1f", (endTime - startTime) / 1_000_000.0));
|
||||
logger.info("[Load #{}] Total shaderpack load time for '{}' in dimension '{}': {} ms", shaderPackLoadId, currentPackName, dimensionName, String.format("%.1f", (endTime - startTime) / 1_000_000.0));
|
||||
return pipeline;
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed to create shader rendering pipeline, disabling shaders!", e);
|
||||
|
||||
Reference in new issue
Block a user