This commit is contained in:
Cameron Reed 2024-11-04 19:22:54 -07:00
parent 371f5effad
commit 551c74ad13
14 changed files with 33 additions and 10 deletions

View File

@ -1,15 +1,15 @@
# Done to increase the memory available to gradle. # Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G org.gradle.jvmargs=-Xmx4G
org.gradle.parallel=true org.gradle.parallel=true
# Fabric Properties # Fabric Properties
# check these on https://modmuss50.me/fabric.html # check these on https://modmuss50.me/fabric.html
minecraft_version=1.21 minecraft_version=1.21.3
yarn_mappings=1.21+build.7 yarn_mappings=1.21.3+build.2
loader_version=0.15.11 loader_version=0.16.7
# Mod Properties # Mod Properties
mod_version=1.2.2 mod_version=1.2.3
maven_group=cmods maven_group=cmods
archives_base_name=cmods archives_base_name=cmods
# Dependencies # Dependencies
# check this on https://modmuss50.me/fabric.html # check this on https://modmuss50.me/fabric.html
fabric_version=0.100.4+1.21 fabric_version=0.107.0+1.21.3

View File

@ -5,6 +5,7 @@ import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi; import com.terraformersmc.modmenu.api.ModMenuApi;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
@SuppressWarnings("unused")
public class ModMenuConfig implements ModMenuApi { public class ModMenuConfig implements ModMenuApi {
@Override @Override
public ConfigScreenFactory<?> getModConfigScreenFactory() { public ConfigScreenFactory<?> getModConfigScreenFactory() {

View File

@ -9,6 +9,7 @@ public class PropertyUtils {
return Boolean.parseBoolean(properties.getProperty(key, default_value.toString())); return Boolean.parseBoolean(properties.getProperty(key, default_value.toString()));
} }
@SuppressWarnings("unused")
public static int getIntegerProperty(@Nullable java.util.Properties properties, String key, Integer default_value) { public static int getIntegerProperty(@Nullable java.util.Properties properties, String key, Integer default_value) {
if (properties == null) if (properties == null)
return default_value; return default_value;

View File

@ -1,5 +1,6 @@
package cmods.cmods.mixin; package cmods.cmods.mixin;
import cmods.cmods.options.CmodsOptions;
import cmods.cmods.ui.CmodsOptionsScreen; import cmods.cmods.ui.CmodsOptionsScreen;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.option.OptionsScreen; import net.minecraft.client.gui.screen.option.OptionsScreen;
@ -19,7 +20,7 @@ public class OptionsMixin extends Screen {
@Inject(at = @At("TAIL"), method = "init") @Inject(at = @At("TAIL"), method = "init")
private void init(CallbackInfo ci) { private void init(CallbackInfo ci) {
if (client == null) if (client == null || !CmodsOptions.getInstance().uiOptions.show_in_options.get())
return; return;
addDrawableChild(ButtonWidget.builder(Text.translatable("cmods.options"), addDrawableChild(ButtonWidget.builder(Text.translatable("cmods.options"),

View File

@ -1,6 +1,7 @@
package cmods.cmods.mixin; package cmods.cmods.mixin;
import cmods.cmods.options.CmodsOptions;
import cmods.cmods.ui.CmodsOptionsScreen; import cmods.cmods.ui.CmodsOptionsScreen;
import net.minecraft.client.gui.screen.GameMenuScreen; import net.minecraft.client.gui.screen.GameMenuScreen;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
@ -20,7 +21,7 @@ public class PauseMixin extends Screen {
@Inject(at = @At("TAIL"), method = "init") @Inject(at = @At("TAIL"), method = "init")
public void init(CallbackInfo ci) { public void init(CallbackInfo ci) {
if (client == null) if (client == null || !CmodsOptions.getInstance().uiOptions.show_in_pause.get())
return; return;
addDrawableChild(ButtonWidget.builder(Text.translatable("cmods.options"), addDrawableChild(ButtonWidget.builder(Text.translatable("cmods.options"),

View File

@ -5,6 +5,7 @@ public class BooleanOption extends Option<Boolean> {
super(default_value); super(default_value);
} }
@SuppressWarnings("UnusedReturnValue")
public boolean toggle() { public boolean toggle() {
return value = !value; return value = !value;
} }

View File

@ -91,6 +91,8 @@ public final class CmodsOptions {
public BooleanOption enabled = new BooleanOption(true); public BooleanOption enabled = new BooleanOption(true);
public BooleanOption show_coordinates = new BooleanOption(true); public BooleanOption show_coordinates = new BooleanOption(true);
public BooleanOption show_fps = new BooleanOption(true); public BooleanOption show_fps = new BooleanOption(true);
public BooleanOption show_in_pause = new BooleanOption(true);
public BooleanOption show_in_options = new BooleanOption(true);
UIOptions() { } UIOptions() { }
@ -100,12 +102,16 @@ public final class CmodsOptions {
enabled.value = getBooleanProperty(properties, PREFIX + "enabled", enabled.value); enabled.value = getBooleanProperty(properties, PREFIX + "enabled", enabled.value);
show_coordinates.value = getBooleanProperty(properties, PREFIX + "show_coordinates", show_coordinates.value); show_coordinates.value = getBooleanProperty(properties, PREFIX + "show_coordinates", show_coordinates.value);
show_fps.value = getBooleanProperty(properties, PREFIX + "show_fps", show_coordinates.value); show_fps.value = getBooleanProperty(properties, PREFIX + "show_fps", show_coordinates.value);
show_in_pause.value = getBooleanProperty(properties, PREFIX + "show_in_pause", show_in_pause.value);
show_in_options.value = getBooleanProperty(properties, PREFIX + "show_in_options", show_in_options.value);
} }
void save(Properties properties) { void save(Properties properties) {
properties.setProperty(PREFIX + "enabled", enabled.value.toString()); properties.setProperty(PREFIX + "enabled", enabled.value.toString());
properties.setProperty(PREFIX + "show_coordinates", show_coordinates.value.toString()); properties.setProperty(PREFIX + "show_coordinates", show_coordinates.value.toString());
properties.setProperty(PREFIX + "show_fps", show_fps.value.toString()); properties.setProperty(PREFIX + "show_fps", show_fps.value.toString());
properties.setProperty(PREFIX + "show_in_pause", show_in_pause.value.toString());
properties.setProperty(PREFIX + "show_in_options", show_in_options.value.toString());
} }
} }
} }

View File

@ -1,5 +1,6 @@
package cmods.cmods.options; package cmods.cmods.options;
@SuppressWarnings("unused")
public class IntegerOption extends Option<Integer> { public class IntegerOption extends Option<Integer> {
public IntegerOption(Integer default_value) { public IntegerOption(Integer default_value) {
super(default_value); super(default_value);

View File

@ -1,5 +1,6 @@
package cmods.cmods.options; package cmods.cmods.options;
@SuppressWarnings("unused")
public class Option<T> { public class Option<T> {
public T value; public T value;

View File

@ -1,5 +1,6 @@
package cmods.cmods.ui; package cmods.cmods.ui;
@SuppressWarnings("unused")
public class Constants { public class Constants {
public static final int buttonWidth = 150; public static final int buttonWidth = 150;
public static final int buttonHeight = 20; public static final int buttonHeight = 20;

View File

@ -9,6 +9,7 @@ import net.minecraft.text.Text;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.function.Consumer; import java.util.function.Consumer;
@SuppressWarnings("unused")
public class IntegerAdjustWidget extends WrapperWidget { public class IntegerAdjustWidget extends WrapperWidget {
private final ArrayList<ButtonWidget> elements; private final ArrayList<ButtonWidget> elements;
private final IntegerOption option; private final IntegerOption option;

View File

@ -45,6 +45,12 @@ public class UIOptionsScreen extends Screen {
adder.add(new ToggleButton(0, 0, buttonWidth, buttonHeight, adder.add(new ToggleButton(0, 0, buttonWidth, buttonHeight,
Text.translatable("cmods.options.ui.show_fps"), options.uiOptions.show_fps)); Text.translatable("cmods.options.ui.show_fps"), options.uiOptions.show_fps));
adder.add(new ToggleButton(0, 0, buttonWidth, buttonHeight,
Text.translatable("cmods.options.ui.show_in_pause"), options.uiOptions.show_in_pause));
adder.add(new ToggleButton(0, 0, buttonWidth, buttonHeight,
Text.translatable("cmods.options.ui.show_in_options"), options.uiOptions.show_in_options));
for (Pair<ArrayList<ButtonBuilder>, Integer> buttonArray : extraButtons) { for (Pair<ArrayList<ButtonBuilder>, Integer> buttonArray : extraButtons) {
for (ButtonBuilder buttonBuilder : buttonArray.getLeft()) { for (ButtonBuilder buttonBuilder : buttonArray.getLeft()) {
adder.add(buttonBuilder.build(this, client)); adder.add(buttonBuilder.build(this, client));

View File

@ -11,5 +11,7 @@
"cmods.options.ui.title": "UI Options", "cmods.options.ui.title": "UI Options",
"cmods.options.ui.hud_enabled": "Show HUD", "cmods.options.ui.hud_enabled": "Show HUD",
"cmods.options.ui.show_coordinates": "Show Coordinates", "cmods.options.ui.show_coordinates": "Show Coordinates",
"cmods.options.ui.show_fps": "Show FPS" "cmods.options.ui.show_fps": "Show FPS",
"cmods.options.ui.show_in_pause": "Show In Pause",
"cmods.options.ui.show_in_options": "Show In Options"
} }

View File

@ -29,7 +29,7 @@
], ],
"depends": { "depends": {
"fabricloader": ">=0.14.10", "fabricloader": ">=0.14.10",
"minecraft": "1.21.0", "minecraft": "1.21.3",
"java": ">=21", "java": ">=21",
"fabric-api": "*" "fabric-api": "*"
} }