Skip to content

Commit cbc4f53

Browse files
committed
Version 8.0
*Improved the mod config system *Fixed a bug with off hand moving whenever moving the main hand slider *Improved GUI
1 parent e80fef9 commit cbc4f53

15 files changed

+253
-177
lines changed

assets/gui.png

520 KB
Loading

assets/second_gui.png

588 KB
Loading

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ dependencies {
2727
// Fabric API. This is technically optional, but you probably want it anyway.
2828
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
2929

30-
compileOnly files("libs/ImproperUI-1.21-0.0.6-BETA.jar")
30+
modImplementation files("libs/ImproperUI-1.21-0.0.6-BETA.jar")
3131
}
3232

3333
processResources {

gradle.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ org.gradle.jvmargs=-Xmx1G
88
loader_version=0.15.11
99

1010
# Mod Properties
11-
mod_version = 7.0-1.21-fabric
11+
mod_version = 8.0-1.21-fabric
1212
maven_group=net.i_no_am.view_model
1313
archives_base_name=view-model
1414

1515
# Dependencies
1616
# check this on https://modmuss50.me/fabric.html
17-
fabric_version=0.100.3+1.21
17+
fabric_version=0.100.4+1.21

src/main/java/net/i_no_am/viewmodel/ViewModel.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import net.fabricmc.api.ModInitializer;
66
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
77
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
8-
import net.i_no_am.viewmodel.gui.ViewModelSettings;
8+
import net.i_no_am.viewmodel.config.ConfigManager;
99
import net.i_no_am.viewmodel.event.SecondMenuCallBack;
1010
import net.minecraft.client.option.KeyBinding;
1111
import net.minecraft.client.util.InputUtil;
@@ -26,7 +26,7 @@ public void onInitialize() {
2626
while (BIND.wasPressed()) {
2727
ImproperUIAPI.parseAndRunFile(modId, "screen.ui",new SecondMenuCallBack());
2828
}
29-
ViewModelSettings.loadConfigValues();
29+
ConfigManager.loadConfigValues();
3030
});
3131
}
3232
}

src/main/java/net/i_no_am/viewmodel/client/Global.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package net.i_no_am.viewmodel.client;
22

3+
import net.i_no_am.viewmodel.utils.Utils;
4+
35
public interface Global {
46
String PREFIX = "§7[§aViewModel§7]§r ";
5-
String CURRENT_VERSION = "7.0";
7+
String CURRENT_VERSION = Utils.getModVersion();
68
String modId = "viewmodel";
79
String[] screens = {
810
"assets/viewmodel/improperui/screen.ui",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package net.i_no_am.viewmodel.config;
2+
3+
import io.github.itzispyder.improperui.ImproperUIAPI;
4+
import io.github.itzispyder.improperui.config.ConfigReader;
5+
import net.i_no_am.viewmodel.client.Global;
6+
import net.i_no_am.viewmodel.config.settings.ViewModelSettings;
7+
import net.i_no_am.viewmodel.config.settings.SettingsManager;
8+
9+
import java.util.HashMap;
10+
import java.util.Map;
11+
12+
public class ConfigManager implements Global, SettingsManager {
13+
14+
private static final Map<ViewModelSettings, SettingStructure<?>> system = new HashMap<>();
15+
16+
/**
17+
* If you want to add more features, do it via using {@link SettingsManager} + {@link ViewModelSettings}.
18+
*/
19+
20+
21+
public static void loadConfigValues() {
22+
ConfigReader VMconfig = ImproperUIAPI.getConfigReader(modId, "config.properties");
23+
24+
system.put(ViewModelSettings.MAIN_ROT_X, new FloatSettingStructure((float) VMconfig.readFloat(ViewModelSettings.MAIN_ROT_X.getKey(), MAIN_ROTATION_X)));
25+
system.put(ViewModelSettings.MAIN_POS_X, new FloatSettingStructure((float) (VMconfig.readFloat(ViewModelSettings.MAIN_POS_X.getKey(), MAIN_POSITION_X) / DIVISION)));
26+
system.put(ViewModelSettings.MAIN_ROT_Z, new FloatSettingStructure((float) VMconfig.readFloat(ViewModelSettings.MAIN_ROT_Z.getKey(), MAIN_ROTATION_Z)));
27+
system.put(ViewModelSettings.MAIN_POS_Z, new FloatSettingStructure((float) (VMconfig.readFloat(ViewModelSettings.MAIN_POS_Z.getKey(), MAIN_POSITION_Z) / DIVISION)));
28+
system.put(ViewModelSettings.MAIN_ROT_Y, new FloatSettingStructure((float) VMconfig.readFloat(ViewModelSettings.MAIN_ROT_Y.getKey(), MAIN_ROTATION_Y)));
29+
system.put(ViewModelSettings.MAIN_POS_Y, new FloatSettingStructure((float) (VMconfig.readFloat(ViewModelSettings.MAIN_POS_Y.getKey(), MAIN_POSITION_Y) / DIVISION)));
30+
31+
system.put(ViewModelSettings.OFF_ROT_X, new FloatSettingStructure((float) VMconfig.readFloat(ViewModelSettings.OFF_ROT_X.getKey(), OFF_ROTATION_X)));
32+
system.put(ViewModelSettings.OFF_POS_X, new FloatSettingStructure((float) (VMconfig.readFloat(ViewModelSettings.OFF_POS_X.getKey(), OFF_POSITION_X) / DIVISION)));
33+
system.put(ViewModelSettings.OFF_ROT_Z, new FloatSettingStructure((float) VMconfig.readFloat(ViewModelSettings.OFF_ROT_Z.getKey(), OFF_ROTATION_Z)));
34+
system.put(ViewModelSettings.OFF_POS_Z, new FloatSettingStructure((float) (VMconfig.readFloat(ViewModelSettings.OFF_POS_Z.getKey(), OFF_POSITION_Z) / DIVISION)));
35+
system.put(ViewModelSettings.OFF_ROT_Y, new FloatSettingStructure((float) VMconfig.readFloat(ViewModelSettings.OFF_ROT_Y.getKey(), OFF_ROTATION_Y)));
36+
system.put(ViewModelSettings.OFF_POS_Y, new FloatSettingStructure((float) (VMconfig.readFloat(ViewModelSettings.OFF_POS_Y.getKey(), OFF_POSITION_Y) / DIVISION)));
37+
38+
system.put(ViewModelSettings.NO_SWING_V2, new BooleanSetting(VMconfig.readBool(ViewModelSettings.NO_SWING_V2.getKey(), NO_SWING_V2)));
39+
system.put(ViewModelSettings.NO_SWING, new BooleanSetting(VMconfig.readBool(ViewModelSettings.NO_SWING.getKey(), NO_SWING)));
40+
system.put(ViewModelSettings.HAND_SWING_SPEED, new IntegerSettingStructure(2 * VMconfig.readInt(ViewModelSettings.HAND_SWING_SPEED.getKey(), HAND_SWING_SPEED)));
41+
system.put(ViewModelSettings.NO_FOOD_SWING, new BooleanSetting(VMconfig.readBool(ViewModelSettings.NO_FOOD_SWING.getKey(), NO_FOOD_SWING)));
42+
system.put(ViewModelSettings.MAIN_SCALE, new FloatSettingStructure((float) VMconfig.readFloat(ViewModelSettings.MAIN_SCALE.getKey(), MAIN_SCALE)));
43+
system.put(ViewModelSettings.OFF_SCALE, new FloatSettingStructure((float) VMconfig.readFloat(ViewModelSettings.OFF_SCALE.getKey(), OFF_SCALE)));
44+
system.put(ViewModelSettings.NO_HAND, new BooleanSetting(VMconfig.readBool(ViewModelSettings.NO_HAND.getKey(), NO_HAND)));
45+
}
46+
47+
public static SettingStructure<?> get(ViewModelSettings key) {
48+
return system.get(key);
49+
}
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package net.i_no_am.viewmodel.config;
2+
3+
public abstract class SettingStructure<T> {
4+
private final T value;
5+
6+
public SettingStructure(T value) {
7+
this.value = value;
8+
}
9+
10+
public T getVal() {
11+
return value;
12+
}
13+
}
14+
15+
class FloatSettingStructure extends SettingStructure<Float> {
16+
public FloatSettingStructure(Float value) {
17+
super(value);
18+
}
19+
}
20+
21+
class BooleanSetting extends SettingStructure<Boolean> {
22+
public BooleanSetting(Boolean value) {
23+
super(value);
24+
}
25+
}
26+
27+
class IntegerSettingStructure extends SettingStructure<Integer> {
28+
public IntegerSettingStructure(Integer value) {
29+
super(value);
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package net.i_no_am.viewmodel.config.settings;
2+
3+
import net.i_no_am.viewmodel.config.ConfigManager;
4+
5+
public interface SettingsManager {
6+
/**
7+
* @Param Add here the default settings to every setting
8+
* After that go to:
9+
* {@link ConfigManager}
10+
*/
11+
boolean NO_HAND = false;
12+
int HAND_SWING_SPEED = 6;
13+
int DIVISION = 10;
14+
boolean NO_SWING_V2 = false;
15+
boolean NO_SWING = false;
16+
boolean NO_FOOD_SWING = false;
17+
float MAIN_SCALE = 1.0F;
18+
float OFF_SCALE = 1.0F;
19+
float MAIN_ROTATION_X = 0.0F;
20+
float MAIN_POSITION_X = 0.0F;
21+
float MAIN_ROTATION_Z = 0.0F;
22+
float MAIN_POSITION_Z = 0.0F;
23+
float MAIN_ROTATION_Y = 0.0F;
24+
float MAIN_POSITION_Y = 0.0F;
25+
float OFF_ROTATION_X = 0.0F;
26+
float OFF_POSITION_X = 0.0F;
27+
float OFF_ROTATION_Z = 0.0F;
28+
float OFF_POSITION_Z = 0.0F;
29+
float OFF_ROTATION_Y = 0.0F;
30+
float OFF_POSITION_Y = 0.0F;
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package net.i_no_am.viewmodel.config.settings;
2+
3+
public enum ViewModelSettings {
4+
MAIN_ROT_X("main-rotation-x"),
5+
MAIN_POS_X("main-position-x"),
6+
MAIN_ROT_Z("main-rotation-z"),
7+
MAIN_POS_Z("main-position-z"),
8+
MAIN_ROT_Y("main-rotation-y"),
9+
MAIN_POS_Y("main-position-y"),
10+
OFF_ROT_X("off-rotation-x"),
11+
OFF_POS_X("off-position-x"),
12+
OFF_ROT_Z("off-rotation-z"),
13+
OFF_POS_Z("off-position-z"),
14+
OFF_ROT_Y("off-rotation-y"),
15+
OFF_POS_Y("off-position-y"),
16+
NO_SWING("no-hand-swing"),
17+
NO_SWING_V2("no-hand-swing-v2"),
18+
HAND_SWING_SPEED("hand-speed-swing"),
19+
NO_FOOD_SWING("no-food-swing"),
20+
MAIN_SCALE("main-hand-scale"),
21+
OFF_SCALE("off-hand-scale"),
22+
NO_HAND("no-hand-render");
23+
24+
private final String key;
25+
26+
ViewModelSettings(String setting) {
27+
this.key = setting;
28+
}
29+
30+
public String getKey() {
31+
return key;
32+
}
33+
}

src/main/java/net/i_no_am/viewmodel/gui/ViewModelSettings.java

-112
This file was deleted.

0 commit comments

Comments
 (0)