Compare commits
11 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4442cf595f | ||
|
|
26af3d15d8 | ||
|
|
364e5749e0 | ||
|
|
149ea5deec | ||
|
|
2ba38a6a5b | ||
|
|
49abe94d04 | ||
|
|
ae35603bf7 | ||
|
|
b34de740f0 | ||
|
|
3c43614e27 | ||
|
|
358eba97b9 | ||
|
|
6b632ee4b1 |
18 changed files with 189 additions and 199 deletions
21
README.md
21
README.md
|
|
@ -2,30 +2,23 @@
|
|||
|
||||
[](https://modrinth.com/mod/options-profiles)
|
||||
[](https://curseforge.com/minecraft/mc-mods/options-profiles)
|
||||
[](https://github.com/AxolotlMaid/options-profiles)
|
||||
|
||||
---
|
||||
|
||||
### ⚠️⚠️ Mod requires Architectury API ⚠️⚠️
|
||||
[](https://github.com/AxolotlMaid/options-profiles)
|
||||
|
||||
Options Profiles lets you load and save your options as profiles from in-game.
|
||||
|
||||
You may use this mod in modpacks / clients.
|
||||
If you would like a version ported, open an issue.
|
||||
|
||||
You may use this mod in modpacks / clients with credit.<br/>
|
||||
Contact: hello@axolotlmaid.com
|
||||
|
||||
## Features
|
||||
- Profiles are saved in a folder called "options-profiles" in the specified ".minecraft" directory.
|
||||
- Sodium support
|
||||
- Forge, Fabric and Quilt support
|
||||
- Sodium and Optifine support
|
||||
- Forge and Fabric support
|
||||
- Resource packs support
|
||||
- Save current options
|
||||
- Edit profiles in-game (deleting, renaming, overwriting)
|
||||
|
||||
## Possible Features?
|
||||
- Save profiles globally (Use profiles across minecraft instances that are in different folders)
|
||||
- Profiles that only change certain options (Changing only keybinds)
|
||||
- Profile descriptions
|
||||
- Sharing platform? (Export and import options from a website where people can share their options)
|
||||
|
||||
## Gallery
|
||||
|
||||
Profiles Menu | Edit Profile Screen | Options Screen
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ allprojects {
|
|||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = "UTF-8"
|
||||
options.release = 17
|
||||
options.release = 8
|
||||
}
|
||||
|
||||
java {
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@ dependencies {
|
|||
// Do NOT use other classes from fabric loader
|
||||
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||
// Remove the next line if you don't want to depend on the API
|
||||
modApi "dev.architectury:architectury:${rootProject.architectury_version}"
|
||||
// modApi "dev.architectury:architectury:${rootProject.architectury_version}"
|
||||
|
||||
// sodium
|
||||
modImplementation "maven.modrinth:sodium:mc1.20.4-0.5.8"
|
||||
modImplementation "maven.modrinth:sodium:mc1.16.5-0.2.0"
|
||||
}
|
||||
|
||||
publishing {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
package com.axolotlmaid.optionsprofiles.gui;
|
||||
|
||||
import com.axolotlmaid.optionsprofiles.profiles.Profiles;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.CommonComponents;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
public class EditProfileScreen extends Screen {
|
||||
private final Screen lastScreen;
|
||||
|
|
@ -16,40 +17,41 @@ public class EditProfileScreen extends Screen {
|
|||
private EditBox profileNameEdit;
|
||||
|
||||
public EditProfileScreen(Screen screen, Component profileName) {
|
||||
super(Component.literal(Component.translatable("gui.optionsprofiles.editing-profile-title").getString() + profileName.getString()));
|
||||
super(Component.nullToEmpty(new TranslatableComponent("gui.optionsprofiles.editing-profile-title").getString() + profileName.getString()));
|
||||
this.lastScreen = screen;
|
||||
this.profileName = profileName;
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
this.profileNameEdit = new EditBox(this.font, this.width / 2 - 102, this.height - 130, 204, 20, Component.empty());
|
||||
this.profileNameEdit = new EditBox(this.font, this.width / 2 - 100, 116, 200, 20, new TranslatableComponent("gui.optionsprofiles.profile-name-text"));
|
||||
this.profileNameEdit.setValue(profileName.getString());
|
||||
this.addWidget(this.profileNameEdit);
|
||||
|
||||
this.addRenderableWidget(Button.builder(Component.translatable("gui.optionsprofiles.overwrite-options"), (button) -> {
|
||||
new Profiles().writeOptionsFilesIntoProfile(profileName.getString());
|
||||
this.addButton(new Button(this.width / 2 - 50, 145, 100, 20, new TranslatableComponent("gui.optionsprofiles.overwrite-options"), (button -> {
|
||||
Profiles.writeOptionsFilesIntoProfile(profileName.getString());
|
||||
this.minecraft.setScreen(this.lastScreen);
|
||||
}).size(100, 20).pos(this.width / 2 - 50, this.height - 85).build());
|
||||
})));
|
||||
|
||||
this.addRenderableWidget(Button.builder(Component.translatable("gui.optionsprofiles.rename-profile"), (button) -> {
|
||||
new Profiles().renameProfile(profileName.getString(), this.profileNameEdit.getValue());
|
||||
this.minecraft.setScreen(new EditProfileScreen(lastScreen, Component.literal(this.profileNameEdit.getValue())));
|
||||
}).size(100, 20).pos(this.width / 2 - 50, this.height - 65).build());
|
||||
this.addButton(new Button(this.width / 2 - 50, 166, 100, 20, new TranslatableComponent("gui.optionsprofiles.rename-profile"), (button -> {
|
||||
Profiles.renameProfile(profileName.getString(), this.profileNameEdit.getValue());
|
||||
this.minecraft.setScreen(new EditProfileScreen(lastScreen, Component.nullToEmpty(this.profileNameEdit.getValue())));
|
||||
})));
|
||||
|
||||
this.addRenderableWidget(Button.builder(Component.translatable("gui.optionsprofiles.delete-profile").withStyle(ChatFormatting.RED), (button) -> {
|
||||
new Profiles().deleteProfile(profileName.getString());
|
||||
this.addButton(new Button(5, this.height - 25, 100, 20, new TranslatableComponent("gui.optionsprofiles.delete-profile").withStyle(ChatFormatting.RED), (button -> {
|
||||
Profiles.deleteProfile(profileName.getString());
|
||||
this.minecraft.setScreen(this.lastScreen);
|
||||
}).size(100, 20).pos(5, this.height - 25).build());
|
||||
})));
|
||||
|
||||
this.addRenderableWidget(Button.builder(CommonComponents.GUI_DONE, (button) -> {
|
||||
this.addButton(new Button(this.width / 2 - 75, this.height - 40, 150, 20, CommonComponents.GUI_DONE, (button -> {
|
||||
this.minecraft.setScreen(this.lastScreen);
|
||||
}).size(100, 20).pos(this.width / 2 - 50, this.height - 40).build());
|
||||
})));
|
||||
}
|
||||
|
||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) {
|
||||
super.render(guiGraphics, mouseX, mouseY, delta);
|
||||
this.profileNameEdit.render(guiGraphics, mouseX, mouseY, delta);
|
||||
guiGraphics.drawCenteredString(this.font, this.title, this.width / 2, 8, 16777215);
|
||||
guiGraphics.drawCenteredString(this.font, Component.translatable("gui.optionsprofiles.profile-name-text"), this.width / 2, this.height - 145, 16777215);
|
||||
public void render(PoseStack poseStack, int mouseX, int mouseY, float delta) {
|
||||
this.renderBackground(poseStack);
|
||||
this.profileNameEdit.render(poseStack, mouseX, mouseY, delta);
|
||||
drawCenteredString(poseStack, this.font, this.title, this.width / 2, 8, 16777215);
|
||||
drawCenteredString(poseStack, this.font, new TranslatableComponent("gui.optionsprofiles.profile-name-text"), this.width / 2, 100, 16777215);
|
||||
super.render(poseStack, mouseX, mouseY, delta);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,14 +2,14 @@ package com.axolotlmaid.optionsprofiles.gui;
|
|||
|
||||
import com.axolotlmaid.optionsprofiles.profiles.Profiles;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraft.client.gui.narration.NarratableEntry;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
import java.nio.file.DirectoryStream;
|
||||
import java.nio.file.Files;
|
||||
|
|
@ -22,7 +22,7 @@ public class ProfilesList extends ContainerObjectSelectionList<ProfilesList.Entr
|
|||
final ProfilesScreen profilesScreen;
|
||||
|
||||
public ProfilesList(ProfilesScreen profilesScreen, Minecraft minecraft) {
|
||||
super(minecraft, profilesScreen.width + 45, profilesScreen.height - 52, 20, 20);
|
||||
super(minecraft, profilesScreen.width + 45, profilesScreen.height, 20, profilesScreen.height - 32, 20);
|
||||
this.profilesScreen = profilesScreen;
|
||||
|
||||
refreshEntries();
|
||||
|
|
@ -35,7 +35,7 @@ public class ProfilesList extends ContainerObjectSelectionList<ProfilesList.Entr
|
|||
|
||||
try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(profilesDirectory)) {
|
||||
for (Path profile : directoryStream) {
|
||||
this.addEntry(new ProfilesList.ProfileEntry(Component.literal(profile.getFileName().toString())));
|
||||
this.addEntry(new ProfilesList.ProfileEntry(Component.nullToEmpty(profile.getFileName().toString())));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("An error occurred when listing profiles.");
|
||||
|
|
@ -59,12 +59,12 @@ public class ProfilesList extends ContainerObjectSelectionList<ProfilesList.Entr
|
|||
ProfileEntry(Component profileName) {
|
||||
this.profileName = profileName;
|
||||
|
||||
this.editButton = Button.builder(Component.translatable("gui.optionsprofiles.edit-profile"), (button) -> {
|
||||
this.editButton = new Button(0, 0, 75, 20, new TranslatableComponent("gui.optionsprofiles.edit-profile"), (button) -> {
|
||||
minecraft.setScreen(new EditProfileScreen(profilesScreen, profileName));
|
||||
}).size(75, 20).createNarration((supplier) -> Component.translatable("gui.optionsprofiles.edit-profile")).build();
|
||||
});
|
||||
|
||||
this.loadButton = Button.builder(Component.translatable("gui.optionsprofiles.load-profile"), (button) -> {
|
||||
new Profiles().loadProfile(profileName.getString());
|
||||
this.loadButton = new Button(0, 0, 75, 20, new TranslatableComponent("gui.optionsprofiles.load-profile"), (button) -> {
|
||||
Profiles.loadProfile(profileName.getString());
|
||||
|
||||
minecraft.options.load();
|
||||
minecraft.options.loadSelectedResourcePacks(minecraft.getResourcePackRepository());
|
||||
|
|
@ -73,35 +73,35 @@ public class ProfilesList extends ContainerObjectSelectionList<ProfilesList.Entr
|
|||
minecraft.options.save();
|
||||
|
||||
button.active = false;
|
||||
}).size(75, 20).createNarration((supplier) -> Component.translatable("gui.optionsprofiles.load-profile")).build();
|
||||
});
|
||||
|
||||
this.loadButton.active = !new Profiles().isProfileLoaded(profileName.getString());
|
||||
this.loadButton.active = !Profiles.isProfileLoaded(profileName.getString());
|
||||
}
|
||||
|
||||
public void render(GuiGraphics guiGraphics, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
|
||||
public void render(PoseStack poseStack, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
|
||||
Font fontRenderer = ProfilesList.this.minecraft.font;
|
||||
|
||||
int textY = y + entryHeight / 2;
|
||||
|
||||
Objects.requireNonNull(ProfilesList.this.minecraft.font);
|
||||
guiGraphics.drawString(fontRenderer, this.profileName, x - 50, textY - 9 / 2, 16777215, false);
|
||||
drawString(poseStack, fontRenderer, this.profileName, x - 50, textY - 9 / 2, 16777215);
|
||||
|
||||
this.editButton.setX(x + 115);
|
||||
this.editButton.setY(y);
|
||||
this.editButton.render(guiGraphics, mouseX, mouseY, tickDelta);
|
||||
this.editButton.x = x + 115;
|
||||
this.editButton.y = y;
|
||||
this.editButton.render(poseStack, mouseX, mouseY, tickDelta);
|
||||
|
||||
this.loadButton.setX(x + 190);
|
||||
this.loadButton.setY(y);
|
||||
this.loadButton.render(guiGraphics, mouseX, mouseY, tickDelta);
|
||||
this.loadButton.x = x + 190;
|
||||
this.loadButton.y = y;
|
||||
this.loadButton.render(poseStack, mouseX, mouseY, tickDelta);
|
||||
}
|
||||
|
||||
public List<? extends GuiEventListener> children() {
|
||||
return ImmutableList.of(this.editButton, this.loadButton);
|
||||
}
|
||||
|
||||
public List<? extends NarratableEntry> narratables() {
|
||||
return ImmutableList.of(this.editButton, this.loadButton);
|
||||
}
|
||||
// public List<? extends NarratableEntry> narratables() {
|
||||
// return ImmutableList.of(this.editButton, this.loadButton);
|
||||
// }
|
||||
}
|
||||
|
||||
public abstract static class Entry extends ContainerObjectSelectionList.Entry<ProfilesList.Entry> {
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
package com.axolotlmaid.optionsprofiles.gui;
|
||||
|
||||
import com.axolotlmaid.optionsprofiles.profiles.Profiles;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.CommonComponents;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
public class ProfilesScreen extends Screen {
|
||||
private final Screen lastScreen;
|
||||
private ProfilesList profilesList;
|
||||
|
||||
public ProfilesScreen(Screen screen) {
|
||||
super(Component.translatable("gui.optionsprofiles.profiles-menu"));
|
||||
super(new TranslatableComponent("gui.optionsprofiles.profiles-menu"));
|
||||
this.lastScreen = screen;
|
||||
}
|
||||
|
||||
|
|
@ -21,19 +21,19 @@ public class ProfilesScreen extends Screen {
|
|||
this.addWidget(this.profilesList);
|
||||
|
||||
// buttons
|
||||
this.addRenderableWidget(Button.builder(Component.translatable("gui.optionsprofiles.save-current-options"), (button) -> {
|
||||
new Profiles().createProfile();
|
||||
this.addButton(new Button(this.width / 2 - 155, this.height - 29, 150, 20, new TranslatableComponent("gui.optionsprofiles.save-current-options"), (button -> {
|
||||
Profiles.createProfile();
|
||||
this.profilesList.refreshEntries();
|
||||
}).size(150, 20).pos(this.width / 2 - 155, this.height - 29).build());
|
||||
})));
|
||||
|
||||
this.addRenderableWidget(Button.builder(CommonComponents.GUI_DONE, (button) -> {
|
||||
this.addButton(new Button(this.width / 2 + 5, this.height - 29, 150, 20, CommonComponents.GUI_DONE, (button -> {
|
||||
this.minecraft.setScreen(this.lastScreen);
|
||||
}).size(150, 20).pos(this.width / 2 + 5, this.height - 29).build());
|
||||
})));
|
||||
}
|
||||
|
||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) {
|
||||
super.render(guiGraphics, mouseX, mouseY, delta);
|
||||
this.profilesList.render(guiGraphics, mouseX, mouseY, delta);
|
||||
guiGraphics.drawCenteredString(this.font, this.title, this.width / 2, 8, 16777215);
|
||||
public void render(PoseStack poseStack, int mouseX, int mouseY, float delta) {
|
||||
this.profilesList.render(poseStack, mouseX, mouseY, delta);
|
||||
drawCenteredString(poseStack, this.font, this.title, this.width / 2, 8, 16777215);
|
||||
super.render(poseStack, mouseX, mouseY, delta);
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import net.minecraft.client.gui.components.Button;
|
|||
import net.minecraft.client.gui.screens.OptionsScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
|
|
@ -18,8 +19,8 @@ public class MixinOptionsScreen extends Screen {
|
|||
|
||||
@Inject(at = @At("HEAD"), method = "init")
|
||||
private void init(CallbackInfo info) {
|
||||
this.addRenderableWidget(Button.builder(Component.translatable("gui.optionsprofiles.profiles-menu"), (button) -> {
|
||||
this.addButton(new Button(5, 5, 100, 20, new TranslatableComponent("gui.optionsprofiles.profiles-menu"), (button -> {
|
||||
this.minecraft.setScreen(new ProfilesScreen(this));
|
||||
}).width(100).pos(5, 5).build());
|
||||
})));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
package com.axolotlmaid.optionsprofiles.profiles;
|
||||
|
||||
import dev.architectury.platform.Platform;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
|
@ -13,7 +11,7 @@ import java.util.List;
|
|||
import java.util.stream.Stream;
|
||||
|
||||
public class Profiles {
|
||||
public void createProfile() {
|
||||
public static void createProfile() {
|
||||
String profileName = "Profile 1";
|
||||
Path profile = Paths.get("options-profiles/" + profileName);
|
||||
|
||||
|
|
@ -26,24 +24,29 @@ public class Profiles {
|
|||
Files.createDirectory(profile);
|
||||
|
||||
if (Files.exists(profile)) {
|
||||
System.out.println("Profile created.");
|
||||
System.out.println("[Options Profiles] Profile created.");
|
||||
|
||||
writeOptionsFilesIntoProfile(profileName);
|
||||
} else {
|
||||
System.out.println("Profile was not created successfully.");
|
||||
System.out.println("[Options Profiles] Profile was not created successfully.");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.out.println("An error occurred when creating a profile.");
|
||||
System.out.println("[Options Profiles] An error occurred when creating a profile.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void writeOptionsFilesIntoProfile(String profileName) {
|
||||
private static void writeOptionFile(String profileName, String optionsFile, boolean isSodium) {
|
||||
Path profile = Paths.get("options-profiles/" + profileName);
|
||||
|
||||
// options.txt
|
||||
Path options = Paths.get("options.txt");
|
||||
Path profileOptions = Paths.get(profile.toAbsolutePath() + "/options.txt");
|
||||
Path options;
|
||||
Path profileOptions = Paths.get(profile.toAbsolutePath() + "/" + optionsFile);
|
||||
|
||||
if (isSodium) {
|
||||
options = Paths.get("config/" + optionsFile);
|
||||
} else {
|
||||
options = Paths.get(optionsFile);
|
||||
}
|
||||
|
||||
try (Stream<String> paths = Files.lines(options)) {
|
||||
if (Files.exists(profileOptions))
|
||||
|
|
@ -54,43 +57,32 @@ public class Profiles {
|
|||
Files.write(profileOptions, line.getBytes(), StandardOpenOption.CREATE, StandardOpenOption.APPEND);
|
||||
Files.write(profileOptions, "\n".getBytes(), StandardOpenOption.APPEND);
|
||||
} catch (IOException e) {
|
||||
System.out.println("An error occurred when writing a profile.");
|
||||
System.out.println("[Options Profiles] An error occurred when writing a profile.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
} catch (IOException e) {
|
||||
System.out.println("An error occurred when reading options.txt.");
|
||||
System.out.println("[Options Profiles] An error occurred when reading an options file.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeOptionsFilesIntoProfile(String profileName) {
|
||||
// options.txt
|
||||
writeOptionFile(profileName, "options.txt", false);
|
||||
|
||||
// sodium-options.json
|
||||
if (Platform.isFabric()) {
|
||||
if (Platform.isModLoaded("sodium")) {
|
||||
Path sodiumConfiguration = Paths.get("config/sodium-options.json");
|
||||
Path sodiumConfigurationProfile = Paths.get(profile.toAbsolutePath() + "/sodium-options.json");
|
||||
if (Files.exists(Paths.get("config/sodium-options.json"))) {
|
||||
writeOptionFile(profileName, "sodium-options.json", true);
|
||||
}
|
||||
|
||||
try (Stream<String> paths = Files.lines(sodiumConfiguration)) {
|
||||
if (Files.exists(sodiumConfigurationProfile))
|
||||
Files.newBufferedWriter(sodiumConfigurationProfile, StandardOpenOption.TRUNCATE_EXISTING);
|
||||
|
||||
paths.forEach(line -> {
|
||||
try {
|
||||
Files.write(sodiumConfigurationProfile, line.getBytes(), StandardOpenOption.CREATE, StandardOpenOption.APPEND);
|
||||
Files.write(sodiumConfigurationProfile, "\n".getBytes(), StandardOpenOption.APPEND);
|
||||
} catch (IOException e) {
|
||||
System.out.println("An error occurred when writing a profile.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
} catch (IOException e) {
|
||||
System.out.println("An error occurred when reading options.txt.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// optionsof.txt
|
||||
if (Files.exists(Paths.get("optionsof.txt"))) {
|
||||
writeOptionFile(profileName, "optionsof.txt", false);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isProfileLoaded(String profileName) {
|
||||
public static boolean isProfileLoaded(String profileName) {
|
||||
Path profile = Paths.get("options-profiles/" + profileName);
|
||||
|
||||
Path options = Paths.get("options.txt");
|
||||
|
|
@ -100,8 +92,7 @@ public class Profiles {
|
|||
List<String> linesOptions = Files.readAllLines(options);
|
||||
List<String> linesProfileOptions = Files.readAllLines(profileOptions);
|
||||
|
||||
if (Platform.isFabric()) {
|
||||
if (Platform.isModLoaded("sodium")) {
|
||||
// sodium-options.json
|
||||
Path sodiumConfiguration = Paths.get("config/sodium-options.json");
|
||||
Path sodiumConfigurationProfile = Paths.get(profile.toAbsolutePath() + "/sodium-options.json");
|
||||
|
||||
|
|
@ -111,7 +102,16 @@ public class Profiles {
|
|||
|
||||
return linesOptions.equals(linesProfileOptions) && linesSodiumConfig.equals(linesSodiumConfigProfile);
|
||||
}
|
||||
}
|
||||
|
||||
// optionsof.txt
|
||||
Path optifineConfiguration = Paths.get("optionsof.txt");
|
||||
Path optifineConfigurationProfile = Paths.get(profile.toAbsolutePath() + "/optionsof.txt");
|
||||
|
||||
if (Files.exists(optifineConfigurationProfile)) {
|
||||
List<String> linesOptifineConfig = Files.readAllLines(optifineConfiguration);
|
||||
List<String> linesOptifineConfigProfile = Files.readAllLines(optifineConfigurationProfile);
|
||||
|
||||
return linesOptions.equals(linesProfileOptions) && linesOptifineConfig.equals(linesOptifineConfigProfile);
|
||||
}
|
||||
|
||||
return linesOptions.equals(linesProfileOptions);
|
||||
|
|
@ -122,12 +122,11 @@ public class Profiles {
|
|||
return false;
|
||||
}
|
||||
|
||||
public void loadProfile(String profileName) {
|
||||
private static void loadOptionFile(String profileName, String optionsFile) {
|
||||
Path profile = Paths.get("options-profiles/" + profileName);
|
||||
|
||||
// options.txt
|
||||
Path options = Paths.get("options.txt");
|
||||
Path profileOptions = Paths.get(profile.toAbsolutePath() + "/options.txt");
|
||||
Path options = Paths.get(optionsFile);
|
||||
Path profileOptions = Paths.get(profile.toAbsolutePath() + "/" + optionsFile);
|
||||
|
||||
try (Stream<String> paths = Files.lines(profileOptions)) {
|
||||
Files.newBufferedWriter(options, StandardOpenOption.TRUNCATE_EXISTING);
|
||||
|
|
@ -137,49 +136,55 @@ public class Profiles {
|
|||
Files.write(options, line.getBytes(), StandardOpenOption.APPEND);
|
||||
Files.write(options, "\n".getBytes(), StandardOpenOption.APPEND);
|
||||
} catch (IOException e) {
|
||||
System.out.println("An error occurred when loading a profile.");
|
||||
System.out.println("[Options Profiles] An error occurred when loading a profile.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
} catch (IOException e) {
|
||||
System.out.println("An error occurred when loading a profile.");
|
||||
System.out.println("[Options Profiles] An error occurred when loading a profile.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadProfile(String profileName) {
|
||||
Path profile = Paths.get("options-profiles/" + profileName);
|
||||
|
||||
// options.txt
|
||||
loadOptionFile(profileName, "options.txt");
|
||||
|
||||
// sodium-options.json
|
||||
if (Platform.isFabric()) {
|
||||
if (Platform.isModLoaded("sodium")) {
|
||||
Path sodiumConfigurationProfile = Paths.get(profile.toAbsolutePath() + "/sodium-options.json");
|
||||
|
||||
if (Files.exists(sodiumConfigurationProfile)) {
|
||||
if (Files.exists(Paths.get(profile.toAbsolutePath() + "/sodium-options.json")))
|
||||
SodiumConfigLoader.load(sodiumConfigurationProfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// optionsof.txt
|
||||
if (Files.exists(Paths.get(profile.toAbsolutePath() + "/optionsof.txt")))
|
||||
loadOptionFile(profileName, "optionsof.txt");
|
||||
}
|
||||
|
||||
public void renameProfile(String profileName, String newProfileName) {
|
||||
public static void renameProfile(String profileName, String newProfileName) {
|
||||
Path profile = Paths.get("options-profiles/" + profileName);
|
||||
Path newProfile = Paths.get("options-profiles/" + newProfileName);
|
||||
|
||||
if (Files.exists(newProfile))
|
||||
System.out.println("New profile already exists!");
|
||||
System.out.println("[Options Profiles] New profile already exists!");
|
||||
|
||||
try {
|
||||
Files.move(profile, newProfile);
|
||||
|
||||
if (Files.exists(newProfile)) {
|
||||
System.out.println("Profile renamed.");
|
||||
System.out.println("[Options Profiles] Profile renamed.");
|
||||
} else {
|
||||
System.out.println("Profile was not renamed successfully.");
|
||||
System.out.println("[Options Profiles] Profile was not renamed successfully.");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.out.println("Profile was not renamed successfully.");
|
||||
System.out.println("[Options Profiles] Profile was not renamed successfully.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteProfile(String profileName) {
|
||||
public static void deleteProfile(String profileName) {
|
||||
Path profile = Paths.get("options-profiles/" + profileName);
|
||||
|
||||
try (Stream<Path> files = Files.walk(profile)) {
|
||||
|
|
@ -188,10 +193,10 @@ public class Profiles {
|
|||
.map(Path::toFile)
|
||||
.forEach(File::delete);
|
||||
} catch (IOException e) {
|
||||
System.out.println("Profile was not deleted.");
|
||||
System.out.println("[Options Profiles] Profile was not deleted.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
System.out.println("Profile deleted.");
|
||||
System.out.println("[Options Profiles] Profile deleted.");
|
||||
}
|
||||
}
|
||||
|
|
@ -22,27 +22,27 @@ public class SodiumConfigLoader {
|
|||
}
|
||||
|
||||
private static void apply(ConfigData configData) {
|
||||
SodiumClientMod.options().notifications.hideDonationButton = configData.notifications.hide_donation_button;
|
||||
|
||||
SodiumClientMod.options().quality.cloudQuality = SodiumGameOptions.GraphicsQuality.valueOf(configData.quality.cloud_quality);
|
||||
SodiumClientMod.options().quality.weatherQuality = SodiumGameOptions.GraphicsQuality.valueOf(configData.quality.weather_quality);
|
||||
SodiumClientMod.options().quality.leavesQuality = SodiumGameOptions.GraphicsQuality.valueOf(configData.quality.leaves_quality);
|
||||
SodiumClientMod.options().quality.enableVignette = configData.quality.enable_vignette;
|
||||
SodiumClientMod.options().quality.enableClouds = configData.quality.enable_clouds;
|
||||
SodiumClientMod.options().quality.smoothLighting = SodiumGameOptions.LightingQuality.valueOf(configData.quality.smooth_lighting);
|
||||
|
||||
SodiumClientMod.options().advanced.enableMemoryTracing = configData.advanced.enable_memory_tracing;
|
||||
SodiumClientMod.options().advanced.useAdvancedStagingBuffers = configData.advanced.use_advanced_staging_buffers;
|
||||
SodiumClientMod.options().advanced.cpuRenderAheadLimit = configData.advanced.cpu_render_ahead_limit;
|
||||
|
||||
SodiumClientMod.options().performance.chunkBuilderThreads = configData.performance.chunk_builder_threads;
|
||||
SodiumClientMod.options().performance.alwaysDeferChunkUpdates = configData.performance.always_defer_chunk_updates_v2;
|
||||
SodiumClientMod.options().performance.animateOnlyVisibleTextures = configData.performance.animate_only_visible_textures;
|
||||
SodiumClientMod.options().performance.useEntityCulling = configData.performance.use_entity_culling;
|
||||
SodiumClientMod.options().performance.useFogOcclusion = configData.performance.use_fog_occlusion;
|
||||
SodiumClientMod.options().performance.useBlockFaceCulling = configData.performance.use_block_face_culling;
|
||||
SodiumClientMod.options().performance.useNoErrorGLContext = configData.performance.use_no_error_g_l_context;
|
||||
|
||||
SodiumClientMod.options().notifications.hasClearedDonationButton = configData.notifications.has_cleared_donation_button;
|
||||
SodiumClientMod.options().notifications.hasSeenDonationPrompt = configData.notifications.has_seen_donation_prompt;
|
||||
SodiumClientMod.options().advanced.useVertexArrayObjects = configData.advanced.use_vertex_array_objects;
|
||||
SodiumClientMod.options().advanced.useChunkMultidraw = configData.advanced.use_chunk_multidraw;
|
||||
SodiumClientMod.options().advanced.animateOnlyVisibleTextures = configData.advanced.animate_only_visible_textures;
|
||||
SodiumClientMod.options().advanced.useEntityCulling = configData.advanced.use_entity_culling;
|
||||
SodiumClientMod.options().advanced.useParticleCulling = configData.advanced.use_particle_culling;
|
||||
SodiumClientMod.options().advanced.useFogOcclusion = configData.advanced.use_fog_occlusion;
|
||||
SodiumClientMod.options().advanced.useCompactVertexFormat = configData.advanced.use_compact_vertex_format;
|
||||
SodiumClientMod.options().advanced.useBlockFaceCulling = configData.advanced.use_block_face_culling;
|
||||
SodiumClientMod.options().advanced.allowDirectMemoryAccess = configData.advanced.allow_direct_memory_access;
|
||||
SodiumClientMod.options().advanced.ignoreDriverBlacklist = configData.advanced.ignore_driver_blacklist;
|
||||
|
||||
try {
|
||||
SodiumGameOptions.writeToDisk(SodiumClientMod.options());
|
||||
SodiumClientMod.options().writeChanges();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
@ -51,34 +51,31 @@ public class SodiumConfigLoader {
|
|||
public static class ConfigData {
|
||||
public Quality quality;
|
||||
public Advanced advanced;
|
||||
public Performance performance;
|
||||
public Notifications notifications;
|
||||
|
||||
public static class Quality {
|
||||
public String cloud_quality;
|
||||
public String weather_quality;
|
||||
public String leaves_quality;
|
||||
public boolean enable_vignette;
|
||||
public boolean enable_clouds;
|
||||
public String smooth_lighting;
|
||||
}
|
||||
|
||||
public static class Advanced {
|
||||
public boolean enable_memory_tracing;
|
||||
public boolean use_advanced_staging_buffers;
|
||||
public int cpu_render_ahead_limit;
|
||||
}
|
||||
|
||||
public static class Performance {
|
||||
public int chunk_builder_threads;
|
||||
public boolean always_defer_chunk_updates_v2;
|
||||
public boolean use_vertex_array_objects;
|
||||
public boolean use_chunk_multidraw;
|
||||
public boolean animate_only_visible_textures;
|
||||
public boolean use_entity_culling;
|
||||
public boolean use_particle_culling;
|
||||
public boolean use_fog_occlusion;
|
||||
public boolean use_compact_vertex_format;
|
||||
public boolean use_block_face_culling;
|
||||
public boolean use_no_error_g_l_context;
|
||||
public boolean allow_direct_memory_access;
|
||||
public boolean ignore_driver_blacklist;
|
||||
}
|
||||
|
||||
public static class Notifications {
|
||||
public boolean has_cleared_donation_button;
|
||||
public boolean has_seen_donation_prompt;
|
||||
public boolean hide_donation_button;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"required": true,
|
||||
"package": "com.axolotlmaid.optionsprofiles.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"minVersion": "0.8",
|
||||
"client": [
|
||||
"MixinOptionsScreen"
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ dependencies {
|
|||
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
|
||||
// Remove the next line if you don't want to depend on the API
|
||||
modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}"
|
||||
// modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}"
|
||||
|
||||
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
],
|
||||
"depends": {
|
||||
"fabric": "*",
|
||||
"minecraft": ">=1.20.4",
|
||||
"architectury": ">=11.0.10"
|
||||
"minecraft": ">=1.16.5"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"required": true,
|
||||
"package": "com.axolotlmaid.optionsprofiles.mixin.fabric",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"minVersion": "0.8",
|
||||
"client": [
|
||||
],
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ configurations {
|
|||
dependencies {
|
||||
forge "net.minecraftforge:forge:${rootProject.forge_version}"
|
||||
// Remove the next line if you don't want to depend on the API
|
||||
modApi "dev.architectury:architectury-forge:${rootProject.architectury_version}"
|
||||
// modApi "dev.architectury:architectury-forge:${rootProject.architectury_version}"
|
||||
|
||||
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
modLoader = "javafml"
|
||||
loaderVersion = "[49,)"
|
||||
loaderVersion = "[36,)"
|
||||
#issueTrackerURL = ""
|
||||
license = "GNU GPL 3.0"
|
||||
|
||||
|
|
@ -16,20 +16,13 @@ logoFile = "icon.png"
|
|||
[[dependencies.optionsprofiles]]
|
||||
modId = "forge"
|
||||
mandatory = true
|
||||
versionRange = "[49,)"
|
||||
versionRange = "[36,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.optionsprofiles]]
|
||||
modId = "minecraft"
|
||||
mandatory = true
|
||||
versionRange = "[1.20.4,)"
|
||||
versionRange = "[1.16.5,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.optionsprofiles]]
|
||||
modId = "architectury"
|
||||
mandatory = true
|
||||
versionRange = "[11.0.10,)"
|
||||
ordering = "AFTER"
|
||||
side = "BOTH"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"required": true,
|
||||
"package": "com.axolotlmaid.optionsprofiles.mixin.forge",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"minVersion": "0.8",
|
||||
"client": [
|
||||
],
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
org.gradle.jvmargs=-Xmx6G
|
||||
|
||||
minecraft_version=1.20.4
|
||||
minecraft_version=1.16.5
|
||||
enabled_platforms=fabric,forge
|
||||
|
||||
archives_base_name=optionsprofiles
|
||||
mod_version=1.1
|
||||
mod_version=1.2
|
||||
maven_group=com.axolotlmaid.optionsprofiles
|
||||
|
||||
architectury_version=11.0.10
|
||||
# architectury_version=1.32.68
|
||||
|
||||
fabric_loader_version=0.15.3
|
||||
fabric_api_version=0.92.1+1.20.4
|
||||
fabric_loader_version=0.13.2
|
||||
fabric_api_version=0.42.0+1.16
|
||||
|
||||
forge_version=1.20.4-49.0.14
|
||||
forge_version=1.16.5-36.2.42
|
||||
|
|
@ -11,4 +11,4 @@ include("common")
|
|||
include("fabric")
|
||||
include("forge")
|
||||
|
||||
rootProject.name = "optionsprofiles-v1.1-1.20.4"
|
||||
rootProject.name = "optionsprofiles-v1.2-1.16.5"
|
||||
|
|
|
|||
Loading…
Reference in a new issue