Skip to content

Commit

Permalink
Reload renderer when the experimental light pipeline is toggled
Browse files Browse the repository at this point in the history
  • Loading branch information
XFactHD committed Nov 9, 2024
1 parent 1be3110 commit daa633b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/net/neoforged/neoforge/client/ClientHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -1094,4 +1094,8 @@ public static boolean isInTranslucentBlockOutlinePass(Level level, BlockPos pos,
ChunkRenderTypeSet renderTypes = model.getRenderTypes(state, OUTLINE_PASS_RANDOM, level.getModelData(pos));
return renderTypes.contains(RenderType.TRANSLUCENT) || renderTypes.contains(RenderType.TRIPWIRE);
}

public static void reloadRenderer() {
Minecraft.getInstance().levelRenderer.allChanged();
}
}
14 changes: 14 additions & 0 deletions src/main/java/net/neoforged/neoforge/common/NeoForgeConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.Logging;
import net.neoforged.fml.event.config.ModConfigEvent;
import net.neoforged.neoforge.client.ClientHooks;
import net.neoforged.neoforge.common.ModConfigSpec.BooleanValue;
import net.neoforged.neoforge.common.ModConfigSpec.ConfigValue;
import org.apache.commons.lang3.tuple.Pair;
Expand Down Expand Up @@ -84,6 +85,7 @@ public static class Common {
*/
public static class Client {
public final BooleanValue experimentalForgeLightPipelineEnabled;
boolean experimentalPipelineActive;

public final BooleanValue showLoadWarnings;

Expand Down Expand Up @@ -134,11 +136,23 @@ public static class Client {
@SubscribeEvent
public static void onLoad(final ModConfigEvent.Loading configEvent) {
LogManager.getLogger().debug(Logging.FORGEMOD, "Loaded NeoForge config file {}", configEvent.getConfig().getFileName());

if (configEvent.getConfig().getSpec() == clientSpec) {
CLIENT.experimentalPipelineActive = CLIENT.experimentalForgeLightPipelineEnabled.getAsBoolean();
}
}

@SubscribeEvent
public static void onFileChange(final ModConfigEvent.Reloading configEvent) {
LogManager.getLogger().debug(Logging.FORGEMOD, "NeoForge config just got changed on the file system!");

if (configEvent.getConfig().getSpec() == clientSpec) {
boolean experimentalPipelineActive = CLIENT.experimentalForgeLightPipelineEnabled.getAsBoolean();
if (experimentalPipelineActive != CLIENT.experimentalPipelineActive) {
CLIENT.experimentalPipelineActive = experimentalPipelineActive;
ClientHooks.reloadRenderer();
}
}
}

//General
Expand Down

0 comments on commit daa633b

Please sign in to comment.