Skip to content

Commit

Permalink
dimension.properties
Browse files Browse the repository at this point in the history
https: //github.com/IrisShaders/Iris/commit/26a323686958bebec59bbcd128defa2717f64759
Co-Authored-By: IMS <[email protected]>
  • Loading branch information
Asek3 and IMS212 committed Nov 21, 2023
1 parent dc42724 commit 799f19b
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 70 deletions.
15 changes: 5 additions & 10 deletions src/main/java/net/coderbot/iris/Iris.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.zip.ZipError;
import java.util.zip.ZipException;

import net.coderbot.iris.shaderpack.materialmap.NamespacedId;
import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.ExtensionPoint;
Expand Down Expand Up @@ -588,19 +589,13 @@ private static void destroyEverything() {
}
}

public static DimensionId lastDimension = null;
public static NamespacedId lastDimension = null;

public static DimensionId getCurrentDimension() {
public static NamespacedId getCurrentDimension() {
ClientLevel level = Minecraft.getInstance().level;

if (level != null) {
if (level.dimensionType().effectsLocation().equals(DimensionType.END_EFFECTS) || level.dimension().equals(net.minecraft.world.level.Level.END)) {
return DimensionId.END;
} else if (level.dimensionType().effectsLocation().equals(DimensionType.NETHER_EFFECTS) || level.dimension().equals(net.minecraft.world.level.Level.NETHER)) {
return DimensionId.NETHER;
} else {
return DimensionId.OVERWORLD;
}
return new NamespacedId(level.dimension().location().getNamespace(), level.dimension().location().getPath());
} 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
Expand All @@ -609,7 +604,7 @@ public static DimensionId getCurrentDimension() {
}
}

private static WorldRenderingPipeline createPipeline(DimensionId dimensionId) {
private static WorldRenderingPipeline createPipeline(NamespacedId dimensionId) {
if (currentPack == null) {
// Completely disables shader-based rendering
return new FixedFunctionWorldRenderingPipeline();
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/net/coderbot/iris/pipeline/PipelineManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Optional;
import java.util.function.Function;

import net.coderbot.iris.shaderpack.materialmap.NamespacedId;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.opengl.GL20C;

Expand All @@ -18,16 +19,16 @@

public class PipelineManager {
private static PipelineManager instance;
private final Function<DimensionId, WorldRenderingPipeline> pipelineFactory;
private final Map<DimensionId, WorldRenderingPipeline> pipelinesPerDimension = new HashMap<>();
private final Function<NamespacedId, WorldRenderingPipeline> pipelineFactory;
private final Map<NamespacedId, WorldRenderingPipeline> pipelinesPerDimension = new HashMap<>();
private WorldRenderingPipeline pipeline = new FixedFunctionWorldRenderingPipeline();
private int versionCounterForSodiumShaderReload = 0;

public PipelineManager(Function<DimensionId, WorldRenderingPipeline> pipelineFactory) {
public PipelineManager(Function<NamespacedId, WorldRenderingPipeline> pipelineFactory) {
this.pipelineFactory = pipelineFactory;
}

public WorldRenderingPipeline preparePipeline(DimensionId currentDimension) {
public WorldRenderingPipeline preparePipeline(NamespacedId currentDimension) {
if (!pipelinesPerDimension.containsKey(currentDimension)) {
SystemTimeUniforms.COUNTER.reset();
SystemTimeUniforms.TIMER.reset();
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/net/coderbot/iris/shaderpack/DimensionId.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package net.coderbot.iris.shaderpack;

public enum DimensionId {
OVERWORLD,
NETHER,
END
}
import net.coderbot.iris.shaderpack.materialmap.NamespacedId;

public class DimensionId {
public static NamespacedId OVERWORLD = new NamespacedId("minecraft", "overworld");
public static NamespacedId NETHER = new NamespacedId("minecraft", "the_nether");
public static NamespacedId END = new NamespacedId("minecraft", "the_end");
}
27 changes: 23 additions & 4 deletions src/main/java/net/coderbot/iris/shaderpack/IdMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2IntFunction;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntMaps;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import it.unimi.dsi.fastutil.objects.*;
import net.coderbot.iris.Iris;
import net.coderbot.iris.shaderpack.materialmap.BlockEntry;
import net.coderbot.iris.shaderpack.materialmap.BlockRenderType;
Expand Down Expand Up @@ -253,6 +250,28 @@ private static Map<NamespacedId, BlockRenderType> parseRenderTypeMap(Properties
return overrides;
}

private static Map<NamespacedId, String> parseDimensionMap(Properties properties, String keyPrefix, String fileName) {
Map<NamespacedId, String> overrides = new Object2ObjectArrayMap<>();

properties.forEach((keyObject, valueObject) -> {
String key = (String) keyObject;
String value = (String) valueObject;

if (!key.startsWith(keyPrefix)) {
// Not a valid line, ignore it
return;
}

key = key.substring(keyPrefix.length());

for (String part : value.split("\\s+")) {
overrides.put(new NamespacedId(part), key);
}
});

return overrides;
}

public Int2ObjectMap<List<BlockEntry>> getBlockProperties() {
return blockPropertiesMap;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/coderbot/iris/shaderpack/ProgramSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import net.coderbot.iris.shaderpack.include.AbsolutePackPath;
import net.coderbot.iris.shaderpack.loading.ProgramId;

public class ProgramSet {
public class ProgramSet implements ProgramSetInterface {
private final PackDirectives packDirectives;

private final ProgramSource shadow;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package net.coderbot.iris.shaderpack;

public interface ProgramSetInterface {
class Empty implements ProgramSetInterface {
public static final ProgramSetInterface INSTANCE = new Empty();
}
}
Loading

0 comments on commit 799f19b

Please sign in to comment.