Skip to content

Commit

Permalink
Version 8.0
Browse files Browse the repository at this point in the history
*Improved the mod config system

*Fixed a bug with off hand moving whenever moving the main hand slider

*Improved GUI
  • Loading branch information
I-No-oNe committed Jun 27, 2024
1 parent 68481a7 commit 23ec4c1
Show file tree
Hide file tree
Showing 15 changed files with 254 additions and 178 deletions.
Binary file modified assets/gui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/second_gui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

compileOnly files("libs/ImproperUI-1-20.6-0.0.6-BETA.jar")
modImplementation files("libs/ImproperUI-1-20.6-0.0.6-BETA.jar")
}

processResources {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.15.11

# Mod Properties
mod_version = 7.0-1.20.6-fabric
mod_version = 8.0-1.20.6-fabric
maven_group=net.i_no_am.view_model
archives_base_name=view-model

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/i_no_am/viewmodel/ViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.i_no_am.viewmodel.gui.ViewModelSettings;
import net.i_no_am.viewmodel.config.ConfigManager;
import net.i_no_am.viewmodel.event.SecondMenuCallBack;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
Expand All @@ -26,7 +26,7 @@ public void onInitialize() {
while (BIND.wasPressed()) {
ImproperUIAPI.parseAndRunFile(modId, "screen.ui",new SecondMenuCallBack());
}
ViewModelSettings.loadConfigValues();
ConfigManager.loadConfigValues();
});
}
}
6 changes: 4 additions & 2 deletions src/main/java/net/i_no_am/viewmodel/client/Global.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package net.i_no_am.viewmodel.client;

import net.i_no_am.viewmodel.utils.Utils;

public interface Global {
String PREFIX = "§7[§aViewModel§7]§r ";
String CURRENT_VERSION = "7.0";
String CURRENT_VERSION = Utils.getModVersion();
String modId = "viewmodel";
String[] screens = {
"assets/viewmodel/improperui/screen.ui",
"assets/viewmodel/improperui/secondScreen.ui"
};
}
}
50 changes: 50 additions & 0 deletions src/main/java/net/i_no_am/viewmodel/config/ConfigManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package net.i_no_am.viewmodel.config;

import io.github.itzispyder.improperui.ImproperUIAPI;
import io.github.itzispyder.improperui.config.ConfigReader;
import net.i_no_am.viewmodel.client.Global;
import net.i_no_am.viewmodel.config.settings.ViewModelSettings;
import net.i_no_am.viewmodel.config.settings.SettingsManager;

import java.util.HashMap;
import java.util.Map;

public class ConfigManager implements Global, SettingsManager {

private static final Map<ViewModelSettings, SettingStructure<?>> system = new HashMap<>();

/**
* If you want to add more features, do it via using {@link SettingsManager} + {@link ViewModelSettings}.
*/


public static void loadConfigValues() {
ConfigReader VMconfig = ImproperUIAPI.getConfigReader(modId, "config.properties");

system.put(ViewModelSettings.MAIN_ROT_X, new FloatSettingStructure((float) VMconfig.readFloat(ViewModelSettings.MAIN_ROT_X.getKey(), MAIN_ROTATION_X)));
system.put(ViewModelSettings.MAIN_POS_X, new FloatSettingStructure((float) (VMconfig.readFloat(ViewModelSettings.MAIN_POS_X.getKey(), MAIN_POSITION_X) / DIVISION)));
system.put(ViewModelSettings.MAIN_ROT_Z, new FloatSettingStructure((float) VMconfig.readFloat(ViewModelSettings.MAIN_ROT_Z.getKey(), MAIN_ROTATION_Z)));
system.put(ViewModelSettings.MAIN_POS_Z, new FloatSettingStructure((float) (VMconfig.readFloat(ViewModelSettings.MAIN_POS_Z.getKey(), MAIN_POSITION_Z) / DIVISION)));
system.put(ViewModelSettings.MAIN_ROT_Y, new FloatSettingStructure((float) VMconfig.readFloat(ViewModelSettings.MAIN_ROT_Y.getKey(), MAIN_ROTATION_Y)));
system.put(ViewModelSettings.MAIN_POS_Y, new FloatSettingStructure((float) (VMconfig.readFloat(ViewModelSettings.MAIN_POS_Y.getKey(), MAIN_POSITION_Y) / DIVISION)));

system.put(ViewModelSettings.OFF_ROT_X, new FloatSettingStructure((float) VMconfig.readFloat(ViewModelSettings.OFF_ROT_X.getKey(), OFF_ROTATION_X)));
system.put(ViewModelSettings.OFF_POS_X, new FloatSettingStructure((float) (VMconfig.readFloat(ViewModelSettings.OFF_POS_X.getKey(), OFF_POSITION_X) / DIVISION)));
system.put(ViewModelSettings.OFF_ROT_Z, new FloatSettingStructure((float) VMconfig.readFloat(ViewModelSettings.OFF_ROT_Z.getKey(), OFF_ROTATION_Z)));
system.put(ViewModelSettings.OFF_POS_Z, new FloatSettingStructure((float) (VMconfig.readFloat(ViewModelSettings.OFF_POS_Z.getKey(), OFF_POSITION_Z) / DIVISION)));
system.put(ViewModelSettings.OFF_ROT_Y, new FloatSettingStructure((float) VMconfig.readFloat(ViewModelSettings.OFF_ROT_Y.getKey(), OFF_ROTATION_Y)));
system.put(ViewModelSettings.OFF_POS_Y, new FloatSettingStructure((float) (VMconfig.readFloat(ViewModelSettings.OFF_POS_Y.getKey(), OFF_POSITION_Y) / DIVISION)));

system.put(ViewModelSettings.NO_SWING_V2, new BooleanSetting(VMconfig.readBool(ViewModelSettings.NO_SWING_V2.getKey(), NO_SWING_V2)));
system.put(ViewModelSettings.NO_SWING, new BooleanSetting(VMconfig.readBool(ViewModelSettings.NO_SWING.getKey(), NO_SWING)));
system.put(ViewModelSettings.HAND_SWING_SPEED, new IntegerSettingStructure(2 * VMconfig.readInt(ViewModelSettings.HAND_SWING_SPEED.getKey(), HAND_SWING_SPEED)));
system.put(ViewModelSettings.NO_FOOD_SWING, new BooleanSetting(VMconfig.readBool(ViewModelSettings.NO_FOOD_SWING.getKey(), NO_FOOD_SWING)));
system.put(ViewModelSettings.MAIN_SCALE, new FloatSettingStructure((float) VMconfig.readFloat(ViewModelSettings.MAIN_SCALE.getKey(), MAIN_SCALE)));
system.put(ViewModelSettings.OFF_SCALE, new FloatSettingStructure((float) VMconfig.readFloat(ViewModelSettings.OFF_SCALE.getKey(), OFF_SCALE)));
system.put(ViewModelSettings.NO_HAND, new BooleanSetting(VMconfig.readBool(ViewModelSettings.NO_HAND.getKey(), NO_HAND)));
}

public static SettingStructure<?> get(ViewModelSettings key) {
return system.get(key);
}
}
31 changes: 31 additions & 0 deletions src/main/java/net/i_no_am/viewmodel/config/SettingStructure.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package net.i_no_am.viewmodel.config;

public abstract class SettingStructure<T> {
private final T value;

public SettingStructure(T value) {
this.value = value;
}

public T getVal() {
return value;
}
}

class FloatSettingStructure extends SettingStructure<Float> {
public FloatSettingStructure(Float value) {
super(value);
}
}

class BooleanSetting extends SettingStructure<Boolean> {
public BooleanSetting(Boolean value) {
super(value);
}
}

class IntegerSettingStructure extends SettingStructure<Integer> {
public IntegerSettingStructure(Integer value) {
super(value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package net.i_no_am.viewmodel.config.settings;

import net.i_no_am.viewmodel.config.ConfigManager;

public interface SettingsManager {
/**
* @Param Add here the default settings to every setting
* After that go to:
* {@link ConfigManager}
*/
boolean NO_HAND = false;
int HAND_SWING_SPEED = 6;
int DIVISION = 10;
boolean NO_SWING_V2 = false;
boolean NO_SWING = false;
boolean NO_FOOD_SWING = false;
float MAIN_SCALE = 1.0F;
float OFF_SCALE = 1.0F;
float MAIN_ROTATION_X = 0.0F;
float MAIN_POSITION_X = 0.0F;
float MAIN_ROTATION_Z = 0.0F;
float MAIN_POSITION_Z = 0.0F;
float MAIN_ROTATION_Y = 0.0F;
float MAIN_POSITION_Y = 0.0F;
float OFF_ROTATION_X = 0.0F;
float OFF_POSITION_X = 0.0F;
float OFF_ROTATION_Z = 0.0F;
float OFF_POSITION_Z = 0.0F;
float OFF_ROTATION_Y = 0.0F;
float OFF_POSITION_Y = 0.0F;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package net.i_no_am.viewmodel.config.settings;

public enum ViewModelSettings {
MAIN_ROT_X("main-rotation-x"),
MAIN_POS_X("main-position-x"),
MAIN_ROT_Z("main-rotation-z"),
MAIN_POS_Z("main-position-z"),
MAIN_ROT_Y("main-rotation-y"),
MAIN_POS_Y("main-position-y"),
OFF_ROT_X("off-rotation-x"),
OFF_POS_X("off-position-x"),
OFF_ROT_Z("off-rotation-z"),
OFF_POS_Z("off-position-z"),
OFF_ROT_Y("off-rotation-y"),
OFF_POS_Y("off-position-y"),
NO_SWING("no-hand-swing"),
NO_SWING_V2("no-hand-swing-v2"),
HAND_SWING_SPEED("hand-speed-swing"),
NO_FOOD_SWING("no-food-swing"),
MAIN_SCALE("main-hand-scale"),
OFF_SCALE("off-hand-scale"),
NO_HAND("no-hand-render");

private final String key;

ViewModelSettings(String setting) {
this.key = setting;
}

public String getKey() {
return key;
}
}
112 changes: 0 additions & 112 deletions src/main/java/net/i_no_am/viewmodel/gui/ViewModelSettings.java

This file was deleted.

Loading

0 comments on commit 23ec4c1

Please sign in to comment.