forked from FoundationGames/Animatica
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
155 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
pluginManagement { | ||
repositories { | ||
maven { | ||
name = 'Fabric' | ||
url = 'https://maven.fabricmc.net/' | ||
} | ||
maven { url "https://maven.fabricmc.net/" } | ||
maven { url "https://maven.architectury.dev/" } | ||
maven { url "https://maven.neoforged.net/releases/" } | ||
gradlePluginPortal() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 51 additions & 70 deletions
121
src/main/java/io/github/foundationgames/animatica/config/AnimaticaConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,68 @@ | ||
package io.github.foundationgames.animatica.config; | ||
|
||
import io.github.foundationgames.animatica.Animatica; | ||
import net.fabricmc.loader.api.FabricLoader; | ||
import me.jellysquid.mods.sodium.client.gui.options.OptionFlag; | ||
import me.jellysquid.mods.sodium.client.gui.options.OptionGroup; | ||
import me.jellysquid.mods.sodium.client.gui.options.OptionImpact; | ||
import me.jellysquid.mods.sodium.client.gui.options.OptionImpl; | ||
import me.jellysquid.mods.sodium.client.gui.options.control.TickBoxControl; | ||
import me.jellysquid.mods.sodium.client.gui.options.storage.SodiumOptionsStorage; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.option.SimpleOption; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.Properties; | ||
import net.minecraft.text.Text; | ||
import net.neoforged.neoforge.common.ModConfigSpec; | ||
|
||
public class AnimaticaConfig { | ||
public static String ANIMATED_TEXTURES_KEY = "animated_textures"; | ||
|
||
public static final String FILE_NAME = "animatica.properties"; | ||
|
||
private final SimpleOption<Boolean> animatedTexturesOption; | ||
public boolean animatedTextures; | ||
|
||
public AnimaticaConfig() { | ||
try { | ||
load(); | ||
} catch (IOException e) { | ||
Animatica.LOG.error("Error loading config during initialization!", e); | ||
} | ||
|
||
this.animatedTexturesOption = SimpleOption.ofBoolean( | ||
"option.animatica.animated_textures", | ||
this.animatedTextures, | ||
value -> { | ||
this.animatedTextures = value; | ||
try { | ||
this.save(); | ||
} catch (IOException e) { Animatica.LOG.error("Error saving config while changing in game!", e); } | ||
MinecraftClient.getInstance().reloadResources(); | ||
} | ||
); | ||
} | ||
|
||
public void writeTo(Properties properties) { | ||
properties.put(ANIMATED_TEXTURES_KEY, Boolean.toString(animatedTextures)); | ||
} | ||
|
||
public void readFrom(Properties properties) { | ||
this.animatedTextures = boolFrom(properties.getProperty(ANIMATED_TEXTURES_KEY), true); | ||
private static final ModConfigSpec.Builder BUILDER; | ||
public static final ModConfigSpec.BooleanValue ANIMATED_TEXTURES; | ||
public static final ModConfigSpec SPEC; | ||
|
||
static { | ||
BUILDER = new ModConfigSpec.Builder(); | ||
BUILDER.push("animatica"); | ||
ANIMATED_TEXTURES = BUILDER.translation("option.animatica.animated_textures").define("animated_textures", true); | ||
SPEC = BUILDER.build(); | ||
} | ||
|
||
public Path getFile() throws IOException { | ||
var file = FabricLoader.getInstance().getConfigDir().resolve(FILE_NAME); | ||
if (!Files.exists(file)) { | ||
Files.createFile(file); | ||
public static class VanillaExtended { | ||
private static final SimpleOption<Boolean> animatedTexturesOption; | ||
|
||
static { | ||
animatedTexturesOption = SimpleOption.ofBoolean( | ||
"option.animatica.animated_textures", | ||
AnimaticaConfig.ANIMATED_TEXTURES.getAsBoolean(), | ||
value -> { | ||
AnimaticaConfig.ANIMATED_TEXTURES.set(value); | ||
MinecraftClient.getInstance().reloadResources(); | ||
} | ||
); | ||
} | ||
|
||
return file; | ||
} | ||
|
||
public SimpleOption<Boolean> getAnimatedTexturesOption() { | ||
return animatedTexturesOption; | ||
} | ||
|
||
public void save() throws IOException { | ||
var file = getFile(); | ||
var properties = new Properties(); | ||
|
||
writeTo(properties); | ||
|
||
try (var out = Files.newOutputStream(file)) { | ||
properties.store(out, "Configuration file for Animatica"); | ||
public static SimpleOption<Boolean> getAnimatedTexturesOption() { | ||
return animatedTexturesOption; | ||
} | ||
} | ||
|
||
public void load() throws IOException { | ||
var file = getFile(); | ||
var properties = new Properties(); | ||
|
||
try (var in = Files.newInputStream(file)) { | ||
properties.load(in); | ||
public static class EmbeddiumExtended { | ||
private static final SodiumOptionsStorage sodiumOpts = new SodiumOptionsStorage(); | ||
private static final OptionGroup animatedTextures; | ||
|
||
static { | ||
animatedTextures = OptionGroup.createBuilder() | ||
.setId(Animatica.id("animated_textures")) | ||
.add(OptionImpl.createBuilder(Boolean.TYPE, sodiumOpts) | ||
.setName(Text.translatable("option.animatica.animated_textures")) | ||
.setTooltip(Text.of("")) | ||
.setControl(TickBoxControl::new) | ||
.setBinding((sodiumGameOptions, aBoolean) -> AnimaticaConfig.ANIMATED_TEXTURES.set(aBoolean), sodiumGameOptions -> AnimaticaConfig.ANIMATED_TEXTURES.get()) | ||
.setImpact(OptionImpact.VARIES) | ||
.setFlags(new OptionFlag[]{OptionFlag.REQUIRES_ASSET_RELOAD}) | ||
.build() | ||
).build(); | ||
} | ||
|
||
readFrom(properties); | ||
} | ||
|
||
private static boolean boolFrom(String s, boolean defaultVal) { | ||
return s == null ? defaultVal : "true".equals(s); | ||
public static OptionGroup getAnimatedTextures() { | ||
return animatedTextures; | ||
} | ||
} | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
src/main/java/io/github/foundationgames/animatica/mixin/RenderSystemMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.