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

dimension.properties #1829

Merged
merged 8 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -17,6 +17,7 @@
import net.coderbot.iris.shaderpack.ProgramSet;
import net.coderbot.iris.shaderpack.ShaderPack;
import net.coderbot.iris.shaderpack.discovery.ShaderpackDirectoryManager;
import net.coderbot.iris.shaderpack.materialmap.NamespacedId;
import net.coderbot.iris.shaderpack.option.OptionSet;
import net.coderbot.iris.shaderpack.option.Profile;
import net.coderbot.iris.shaderpack.option.values.MutableOptionValues;
Expand Down Expand Up @@ -631,19 +632,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 @@ -652,7 +647,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 @@ -4,6 +4,7 @@
import net.coderbot.iris.Iris;
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
import net.coderbot.iris.shaderpack.DimensionId;
import net.coderbot.iris.shaderpack.materialmap.NamespacedId;
import net.coderbot.iris.uniforms.SystemTimeUniforms;
import net.minecraft.client.Minecraft;
import org.jetbrains.annotations.Nullable;
Expand All @@ -16,16 +17,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
10 changes: 6 additions & 4 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");
}
24 changes: 24 additions & 0 deletions src/main/java/net/coderbot/iris/shaderpack/IdMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
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.Object2ObjectArrayMap;
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 +254,29 @@ 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 @@ -15,7 +15,7 @@
import java.util.Optional;
import java.util.function.Function;

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,8 @@
package net.coderbot.iris.shaderpack;

public interface ProgramSetInterface {
class Empty implements ProgramSetInterface {

public static final ProgramSetInterface INSTANCE = new Empty();
}
}
Loading