Skip to content

Commit

Permalink
v1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
KingContaria committed Aug 14, 2022
1 parent ac4238a commit 8c37f4a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 22 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ To stop a setting from being reset, remove the corresponding line from the file

Depending on the Minecraft version you are playing some of these might not be included.

**entityCulling**: Sets the sodium option Entity Culling. (Set to 'true' or 'false')

**sneaking**: If you are using togglesneak, this resets the state of sneaking. (Set to 'true' or 'false')

**sprinting**: If you are using togglesprint, this resets the state of sprinting. (Set to 'true' or 'false')
Expand Down Expand Up @@ -61,6 +63,8 @@ To do this, you have to replace the text in the 'standardoptions.txt' of all you

C:\Users\KingContaria\Desktop\speedrunning stuff\standardoptions\globalstandardoptions_116.txt

By putting another file directory into that file, you can now create chains of file paths. This can be useful if you use a lot of different settings for different categories.

#

### Common piechart directories
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,6 @@ private static void load(String[] lines) {
}
String[] string0_split = strings[0].split("_", 2);
switch (string0_split[0]) {
case "key":
for (KeyBinding keyBinding : options.keysAll) {
if (string0_split[1].equals(keyBinding.getTranslationKey())) {
keyBinding.setBoundKey(InputUtil.fromTranslationKey(strings[1])); break;
}
} break;
case "soundCategory":
for (SoundCategory soundCategory : SoundCategory.values()) {
if (string0_split[1].equals(soundCategory.getName())) {
options.setSoundVolume(soundCategory, Float.parseFloat(strings[1])); break;
}
} break;
case "modelPart":
for (PlayerModelPart playerModelPart : PlayerModelPart.values()) {
if (string0_split[1].equals(playerModelPart.getName())) {
options.setPlayerModelPart(playerModelPart, Boolean.parseBoolean(strings[1])); break;
}
} break;
case "autoJump": options.autoJump = Boolean.parseBoolean(strings[1]);
case "autoSuggestions": options.autoSuggestions = Boolean.parseBoolean(strings[1]); break;
case "chatColors": options.chatColors = Boolean.parseBoolean(strings[1]); break;
Expand Down Expand Up @@ -211,6 +193,24 @@ private static void load(String[] lines) {
case "biomeBlendRadius": options.biomeBlendRadius = Integer.parseInt(strings[1]); break;
case "mouseWheelSensitivity": options.mouseWheelSensitivity = Double.parseDouble(strings[1]); break;
case "rawMouseInput": window.setRawMouseMotion(options.rawMouseInput = Boolean.parseBoolean(strings[1])); break;
case "key":
for (KeyBinding keyBinding : options.keysAll) {
if (string0_split[1].equals(keyBinding.getTranslationKey())) {
keyBinding.setBoundKey(InputUtil.fromTranslationKey(strings[1])); break;
}
} break;
case "soundCategory":
for (SoundCategory soundCategory : SoundCategory.values()) {
if (string0_split[1].equals(soundCategory.getName())) {
options.setSoundVolume(soundCategory, Float.parseFloat(strings[1])); break;
}
} break;
case "modelPart":
for (PlayerModelPart playerModelPart : PlayerModelPart.values()) {
if (string0_split[1].equals(playerModelPart.getName())) {
options.setPlayerModelPart(playerModelPart, Boolean.parseBoolean(strings[1])); break;
}
} break;
case "entityCulling":
if (FabricLoader.getInstance().getModContainer("sodium").isPresent()) {
if (SodiumClientMod.options().advanced.useEntityCulling != (SodiumClientMod.options().advanced.useEntityCulling = Boolean.parseBoolean(strings[1]))) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.kingcontaria.standardsettings.mixins;

import com.kingcontaria.standardsettings.StandardSettings;
import net.minecraft.entity.player.PlayerEntity;
import com.mojang.datafixers.DataFixer;
import net.minecraft.world.WorldSaveHandler;
import net.minecraft.world.level.storage.LevelStorage;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -19,10 +20,16 @@
public class WorldSaveHandlerMixin {

@Shadow @Final private File playerDataDir;
private boolean isNewWorld;

@Inject(method = "savePlayerData", at = @At("TAIL"))
private void saveStandardoptionsTxt(PlayerEntity playerEntity, CallbackInfo ci) {
if (!new File(playerDataDir.getParentFile(), "standardoptions.txt").exists() && StandardSettings.standardoptionsCache != null) {
@Inject(method = "<init>", at = @At(value = "INVOKE", target = "Ljava/io/File;mkdirs()Z", ordinal = 0))
private void isNewWorld(LevelStorage.Session session, DataFixer dataFixer, CallbackInfo ci) {
isNewWorld = !playerDataDir.exists();
}

@Inject(method = "<init>", at = @At("TAIL"))
private void saveStandardoptionsTxt(LevelStorage.Session session, DataFixer dataFixer, CallbackInfo ci) {
if (isNewWorld && StandardSettings.standardoptionsCache != null) {
try {
Files.write(playerDataDir.getParentFile().toPath().resolve("standardoptions.txt"), String.join(System.lineSeparator(), StandardSettings.standardoptionsCache).getBytes());
StandardSettings.LOGGER.info("Saved standardoptions.txt to world file");
Expand Down

0 comments on commit 8c37f4a

Please sign in to comment.