Skip to content

Commit

Permalink
[1.21.3] Reload renderer when the experimental light pipeline is togg…
Browse files Browse the repository at this point in the history
…led (#1674)
  • Loading branch information
XFactHD authored Nov 15, 2024
1 parent 1888883 commit c33ede1
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 @@ -1096,6 +1096,10 @@ public static boolean isInTranslucentBlockOutlinePass(Level level, BlockPos pos,
return renderTypes.contains(RenderType.TRANSLUCENT) || renderTypes.contains(RenderType.TRIPWIRE);
}

public static void reloadRenderer() {
Minecraft.getInstance().levelRenderer.allChanged();
}

public static Map<ResourceLocation, ResourceLocation> gatherMaterialAtlases(Map<ResourceLocation, ResourceLocation> vanillaAtlases) {
vanillaAtlases = new HashMap<>(vanillaAtlases);
ModLoader.postEvent(new RegisterMaterialAtlasesEvent(vanillaAtlases));
Expand Down
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 c33ede1

Please sign in to comment.