Skip to content

Commit

Permalink
Merge pull request #193 from LostLuma/optimization-opt-out-neoforge
Browse files Browse the repository at this point in the history
Allow other mods to disable the overlay optimization on (Neo)Forge
  • Loading branch information
LostLuma authored Jun 15, 2024
2 parents 3c19d6a + a64e04a commit 499419a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,22 @@ Instead of having to wait for up to a second until the next rendered frame comes

## Developer Info

> [!IMPORTANT]
> These features are currently only accurate for the Fabric and Quilt versions of Dynamic FPS!
If Dynamic FPS' optimizations conflict with a feature of your mod you can request to disable them.
The process of doing so is as simple as adding some additional metadata Dynamic FPS reads to your mod metadata.

If Dynamic FPS' optimizations conflict with a feature of your mod you can disable them.
This is done by adding a `dynamic_fps` object to your mod's metadata (inside `quilt`/`fabric.mod.json`).
**Disable the loading overlay optimization:**

Force disable the loading overlay optimization:
Fabric / Quilt:

```json
"dynamic_fps": {
"optimized_overlay": false
},
```

Forge / NeoForge

```toml
[modproperties.your_mod_id]
dynamic_fps = {optimized_overlay = false}
```
Original file line number Diff line number Diff line change
@@ -1,16 +1,38 @@
package net.lostluma.dynamic_fps.impl.neoforge.service;

import com.electronwill.nightconfig.core.CommentedConfig;
import dynamic_fps.impl.service.ModCompat;
import net.neoforged.fml.ModList;
import net.neoforged.neoforgespi.language.IModInfo;

public class NeoForgeModCompat implements ModCompat {
private static boolean disableOverlayOptimization = false;

static {
ModList.get().getMods().forEach(NeoForgeModCompat::parseModMetadata);
}

@Override
public boolean isDisabled() {
return false;
}

@Override
public boolean disableOverlayOptimization() {
return ModList.get().isLoaded("rrls");
return disableOverlayOptimization || ModList.get().isLoaded("rrls");
}

private static void parseModMetadata(IModInfo modInfo) {
Object config = modInfo.getModProperties().get("dynamic_fps");

if (config == null) {
return;
}

Boolean value = ((CommentedConfig) config).get("optimized_overlay");

if (value != null && !value) {
disableOverlayOptimization = true;
}
}
}

0 comments on commit 499419a

Please sign in to comment.