aboutsummaryrefslogtreecommitdiff
path: root/common/src/main/java/dev/isxander/yacl3/api/OptionFlag.java
blob: 6f354953e2c0b3e113d43ca2e83efa833cf9397b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package dev.isxander.yacl3.api;

import dev.isxander.yacl3.gui.RequireRestartScreen;
import net.minecraft.client.Minecraft;

import java.util.function.Consumer;

/**
 * Code that is executed upon certain options being applied.
 * Each flag is executed only once per save, no matter the amount of options with the flag.
 */
@FunctionalInterface
public interface OptionFlag extends Consumer<Minecraft> {
    /** Warns the user that a game restart is required for the changes to take effect */
    OptionFlag GAME_RESTART = client -> client.setScreen(new RequireRestartScreen(client.screen));

    /** Reloads chunks upon applying (F3+A) */
    OptionFlag RELOAD_CHUNKS = client -> client.levelRenderer.allChanged();

    OptionFlag WORLD_RENDER_UPDATE = client -> client.levelRenderer.needsUpdate();

    OptionFlag ASSET_RELOAD = Minecraft::delayTextureReload;
}