Skip to content

Commit fa95e21

Browse files
committed
Version 7.0
*Added new Screen Page *Added new settings to the mod *Tweaked Sliders
1 parent e59ea3c commit fa95e21

File tree

12 files changed

+189
-27
lines changed

12 files changed

+189
-27
lines changed

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ How to use?
55
# Install the latest version and install ImproperUI Library.
66
# Press the keybind V on your keyboard to open the GUI.
77
# Set the sizes as you want with the sliders.
8+
# Turn on/off the settings as you want.
89
```
910
--------------------
1011
## Showcase:
1112
### GUI
1213
![GUI showcase demonstrating sliders for model positioning](assets/gui.png)
14+
### Advanced Settings GUI:
15+
![Second GUI with more settings](assets/second_gui.png)
1316
----------
1417
### Setting The Keybind
1518
![Screenshot showcasing the View Model Keybind Open Menu set to V](assets/keybind.png)
@@ -21,5 +24,4 @@ How to use?
2124
**BE AWARE THAT YOU MUST TO DOWNLOAD THE [**IMPROPER-UI**](https://github.com/ItziSpyder/ImproperUI/releases) LIBRARY IN ORDER TO THE MOD TO WORK!**
2225

2326
------------------
24-
**tysm for using this mod** 🙏
25-
27+
**tysm for using this mod** 🙏

assets/gui.png

570 KB
Loading

assets/second_gui.png

1.03 MB
Loading

gradle.properties

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

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

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +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.event.SecondMenuCallBack;
89
import net.i_no_am.viewmodel.gui.ViewModelSettings;
910
import net.minecraft.client.option.KeyBinding;
1011
import net.minecraft.client.util.InputUtil;
@@ -23,7 +24,7 @@ public void onInitialize() {
2324
ImproperUIAPI.init(modId, ViewModel.class, screens);
2425
ClientTickEvents.END_CLIENT_TICK.register(client -> {
2526
while (BIND.wasPressed()) {
26-
ImproperUIAPI.parseAndRunFile(modId, "screen.ui");
27+
ImproperUIAPI.parseAndRunFile(modId, "screen.ui", new SecondMenuCallBack());
2728
}
2829
ViewModelSettings.loadConfigValues();
2930
});

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
public interface Global {
44
String PREFIX = "§7[§aViewModel§7]§r ";
5-
String CURRENT_VERSION = "6.0";
5+
String CURRENT_VERSION = "7.0";
66
String modId = "viewmodel";
77
String[] screens = {
8-
"assets/viewmodel/improperui/screen.ui"
8+
"assets/viewmodel/improperui/screen.ui",
9+
"assets/viewmodel/improperui/secondScreen.ui"
910
};
1011
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package net.i_no_am.viewmodel.event;
2+
3+
import io.github.itzispyder.improperui.ImproperUIAPI;
4+
import io.github.itzispyder.improperui.script.CallbackHandler;
5+
import io.github.itzispyder.improperui.script.CallbackListener;
6+
import io.github.itzispyder.improperui.script.events.MouseEvent;
7+
import net.i_no_am.viewmodel.client.Global;
8+
9+
10+
public class SecondMenuCallBack implements CallbackListener, Global {
11+
12+
13+
@CallbackHandler
14+
public void openHandsSettingScreen(MouseEvent e) {
15+
if (e.input.isDown())
16+
ImproperUIAPI.parseAndRunFile(modId, "secondScreen.ui");
17+
}
18+
}

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

+13
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,18 @@
88

99
public class ViewModelSettings implements Global {
1010

11+
public static int hand_swing_speed = 6;
1112
public static boolean no_swing = false;
13+
1214
public static boolean no_food_swing = false;
1315

1416
public static int normal_division = 10;
1517

18+
public static float main_scale = 1.0F;
19+
public static float off_scale = 1.0F;
20+
21+
public static boolean no_hand = false;
22+
1623
private static float main_rotation_x;
1724
private static float main_position_x;
1825
private static float main_rotation_z;
@@ -44,8 +51,14 @@ public static void loadConfigValues() {
4451
off_position_y = (float) VmConfig.readFloat("off-position-y", 0.0F) / normal_division;
4552
// No Hand Swing Animation
4653
no_swing = VmConfig.readBool("no-hand-swing", false);
54+
hand_swing_speed = 2*VmConfig.readInt("hand-speed-swing", 3);
4755
// No Eating Hand Animation
4856
no_food_swing = VmConfig.readBool("no-food-swing", false);
57+
// Scale
58+
main_scale = (float) VmConfig.readFloat("main-hand-scale", 1.0F);
59+
off_scale = (float) VmConfig.readFloat("off-hand-scale", 1.0F);
60+
// No hand Rendering
61+
no_hand = VmConfig.readBool("no-hand-render", false);
4962
}
5063

5164

src/main/java/net/i_no_am/viewmodel/mixin/MixinHeldItemRenderer.java

+29-5
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@
2121
public abstract class MixinHeldItemRenderer implements Global {
2222

2323
@Inject(method = "applyEatOrDrinkTransformation", at = @At("HEAD"), cancellable = true)
24-
public void OnApplyEatOrDrinkTransformation(MatrixStack MatrixStack, float tickDelta, Arm arm, ItemStack stack, CallbackInfo ci) {
24+
public void OnApplyEatOrDrinkTransformation(MatrixStack matrices, float tickDelta, Arm arm, ItemStack stack, CallbackInfo ci) {
2525
if (ViewModelSettings.no_food_swing) {
2626
ci.cancel();
2727
}
2828
}
2929

30-
3130
@Inject(method = "renderFirstPersonItem", at = @At("HEAD"))
3231
public void renderFirstPersonItem(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack m, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
3332
double mainRotX = ViewModelSettings.getMainRotationX();
@@ -48,17 +47,42 @@ public void renderFirstPersonItem(AbstractClientPlayerEntity player, float tickD
4847
m.multiply(RotationAxis.POSITIVE_X.rotationDegrees((float) mainRotX));
4948
m.multiply(RotationAxis.POSITIVE_Y.rotationDegrees((float) mainRotY));
5049
m.multiply(RotationAxis.POSITIVE_Z.rotationDegrees((float) mainRotZ));
51-
m.translate((float) mainPosX, (float) mainPosY, (float) mainPosZ);
50+
m.translate(mainPosX, mainPosY, mainPosZ);
5251
} else {
5352
m.multiply(RotationAxis.POSITIVE_X.rotationDegrees((float) offRotX));
5453
m.multiply(RotationAxis.POSITIVE_Y.rotationDegrees((float) offRotY));
5554
m.multiply(RotationAxis.POSITIVE_Z.rotationDegrees((float) offRotZ));
56-
m.translate((float) offPosX, (float) offPosY, (float) offPosZ);
55+
m.translate(offPosX, offPosY, offPosZ);
56+
}
57+
}
58+
59+
@Inject(method = "renderFirstPersonItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V"))
60+
private void onRenderFirstPersonItem(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack ms, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
61+
float mainScale = ViewModelSettings.main_scale;
62+
float offScale = ViewModelSettings.off_scale;
63+
if (hand == Hand.MAIN_HAND) {
64+
ms.scale(mainScale, mainScale, mainScale);
65+
} else {
66+
ms.scale(offScale, offScale, offScale);
67+
}
68+
}
69+
70+
@Inject(method = "renderFirstPersonItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderArmHoldingItem(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IFFLnet/minecraft/util/Arm;)V"))
71+
private void OnRenderFirstPersonItem(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack ms, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
72+
float mainScale = ViewModelSettings.main_scale;
73+
float offScale = ViewModelSettings.off_scale;
74+
if (hand == Hand.MAIN_HAND) {
75+
ms.scale(mainScale, mainScale, mainScale);
76+
} else {
77+
ms.scale(offScale, offScale, offScale);
78+
}
79+
if (ViewModelSettings.no_hand) {
80+
ms.scale(0, 0, 0);
5781
}
5882
}
5983

6084
@ModifyArgs(method = "renderItem(FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;Lnet/minecraft/client/network/ClientPlayerEntity;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderFirstPersonItem(Lnet/minecraft/client/network/AbstractClientPlayerEntity;FFLnet/minecraft/util/Hand;FLnet/minecraft/item/ItemStack;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V"))
61-
public void renderItem(Args args) {
85+
private void renderItem(Args args) {
6286
if (ViewModelSettings.no_swing) {
6387
args.set(6, 0.0F);
6488
}

src/main/java/net/i_no_am/viewmodel/mixin/MixinLivingEntity.java

+4
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,9 @@ public void onGetHandSwingDuration(CallbackInfoReturnable<Integer> cir){
1515
cir.setReturnValue(0);
1616
cir.cancel();
1717
}
18+
if (!ViewModelSettings.no_swing) {
19+
cir.setReturnValue(ViewModelSettings.hand_swing_speed);
20+
cir.cancel();
21+
}
1822
}
1923
}

src/main/resources/assets/viewmodel/improperui/screen.ui

+28-16
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ div #title {
3636
}
3737
div #panel -right {
3838
margin: 5
39-
size: 200 145
39+
size: 200 130
4040
background-color: #80000000
4141
background-clip: margin
4242
border-radius: 3
@@ -107,22 +107,17 @@ div #title {
107107
}
108108
div { inner-text: "Rotation Z axis"; height: 0; margin-top: 0; }
109109
slider -viewmodel:config.properties:off-rotation-z {
110-
min: -45
111-
max: 45
110+
min: -60
111+
max: 60
112112
val: 0
113113
width: 75%
114114
}
115-
checkbox #no-food-swing -viewmodel:config.properties:no-food-swing {}
116-
label {
117-
inner-text: "No Eating Animations"
118-
margin-left: 4
119-
}
120115
}
121116
}
122117

123118
div #panel -left {
124119
margin: 5
125-
size: 200 145
120+
size: 200 130
126121
background-color: #80000000
127122
background-clip: margin
128123
border-radius: 3
@@ -194,16 +189,33 @@ div #title {
194189
}
195190
div { inner-text: "Rotation Z axis"; height: 0; margin-top: 0; }
196191
slider -viewmodel:config.properties:main-rotation-z {
197-
min: -45
198-
max: 45
192+
min: -60
193+
max: 60
199194
val: 0
200195
width: 75%
201196
}
202-
checkbox #no-hand-swing -viewmodel:config.properties:no-hand-swing {}
203-
label {
204-
inner-text: "No Swing Animations"
205-
margin-left: 4
206-
}
207197
}
198+
}
199+
button #secondGui {
200+
text-align: center
201+
inner-text: "&aAdvanced Settings"
202+
text-color: green
203+
background-color: #80000000
204+
border-radius: 3
205+
border-color: green
206+
margin: 5
207+
width: 99%
208+
padding-top: 4
209+
padding-bottom: 4
210+
center: both
211+
shadow-color: green
212+
shadow-distance: 3
213+
214+
on-click: openHandsSettingScreen
215+
216+
hovered => { padding: 4; border-thickness: 0; border-radius: 4; shadow-distance: 5; }
217+
}
218+
219+
}
208220
}
209221
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
2+
div #background {
3+
size: 100%
4+
background-color: black
5+
opacity: 0.0
6+
}
7+
8+
div #main {
9+
size: 150 160
10+
background-color: black
11+
opacity: 0.5
12+
border-radius: 3
13+
shadow-distance: 3
14+
shadow-color: green
15+
center: both
16+
17+
div #title {
18+
size: 100% 10
19+
inner-text: "Hands Settings"
20+
text-scale: 1.2
21+
text-shadow: true
22+
text-color: green
23+
text-align: center
24+
background-color: #00000000
25+
margin-top: 7
26+
}
27+
28+
29+
div #settings {
30+
size: 80% 90%
31+
margin-top: 10%
32+
child-align: grid
33+
grid-columns: 2
34+
opacity: 0
35+
margin: 10%
36+
margin-top: 20%
37+
38+
39+
checkbox #no-hand-swing -viewmodel:config.properties:no-hand-swing {}
40+
label {
41+
inner-text: "No Swing Animations"
42+
margin-left: 4
43+
}
44+
45+
46+
checkbox #no-food-swing -viewmodel:config.properties:no-food-swing {margin-top: 6}
47+
label {
48+
margin-top: 6
49+
inner-text: "No Eating Animations"
50+
margin-left: 4
51+
}
52+
checkbox #no-hand-render -viewmodel:config.properties:no-hand-render {margin-top: 6}
53+
label {
54+
margin-top: 6
55+
inner-text: "No Hands Render"
56+
margin-left: 4
57+
}
58+
59+
60+
div {}
61+
div {
62+
margin-top: 20
63+
}
64+
65+
div { inner-text: "Main Item Scale"; }
66+
slider -viewmodel:config.properties:main-hand-scale {
67+
min: 0.1
68+
max: 3.0
69+
val: 1.0
70+
width: 75%
71+
}
72+
div { inner-text: "Off Item Scale"; }
73+
slider -viewmodel:config.properties:off-hand-scale {
74+
min: 0.1
75+
max: 3.0
76+
val: 1.0
77+
width: 75%
78+
}
79+
div { inner-text: "Hand Swing Speed"; }
80+
slider -viewmodel:config.properties:hand-speed-swing {
81+
min: 1.0
82+
max: 7.0
83+
val: 3.0
84+
width: 75%
85+
}
86+
}
87+
}

0 commit comments

Comments
 (0)