Skip to content

Commit

Permalink
Version 7.0
Browse files Browse the repository at this point in the history
*Added new Screen Page

*Added new settings to the mod

*Tweaked Sliders
  • Loading branch information
I-No-oNe committed Jun 23, 2024
1 parent e59ea3c commit fa95e21
Show file tree
Hide file tree
Showing 12 changed files with 189 additions and 27 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ How to use?
# Install the latest version and install ImproperUI Library.
# Press the keybind V on your keyboard to open the GUI.
# Set the sizes as you want with the sliders.
# Turn on/off the settings as you want.
```
--------------------
## Showcase:
### GUI
![GUI showcase demonstrating sliders for model positioning](assets/gui.png)
### Advanced Settings GUI:
![Second GUI with more settings](assets/second_gui.png)
----------
### Setting The Keybind
![Screenshot showcasing the View Model Keybind Open Menu set to V](assets/keybind.png)
Expand All @@ -21,5 +24,4 @@ How to use?
**BE AWARE THAT YOU MUST TO DOWNLOAD THE [**IMPROPER-UI**](https://github.com/ItziSpyder/ImproperUI/releases) LIBRARY IN ORDER TO THE MOD TO WORK!**

------------------
**tysm for using this mod** 🙏

**tysm for using this mod** 🙏
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 added 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 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 = 6.0-1.20-fabric
mod_version = 7.0-1.20-fabric
maven_group=net.i_no_am.view_model
archives_base_name=view-model

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/i_no_am/viewmodel/ViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +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.event.SecondMenuCallBack;
import net.i_no_am.viewmodel.gui.ViewModelSettings;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
Expand All @@ -23,7 +24,7 @@ public void onInitialize() {
ImproperUIAPI.init(modId, ViewModel.class, screens);
ClientTickEvents.END_CLIENT_TICK.register(client -> {
while (BIND.wasPressed()) {
ImproperUIAPI.parseAndRunFile(modId, "screen.ui");
ImproperUIAPI.parseAndRunFile(modId, "screen.ui", new SecondMenuCallBack());
}
ViewModelSettings.loadConfigValues();
});
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/i_no_am/viewmodel/client/Global.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

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

import io.github.itzispyder.improperui.ImproperUIAPI;
import io.github.itzispyder.improperui.script.CallbackHandler;
import io.github.itzispyder.improperui.script.CallbackListener;
import io.github.itzispyder.improperui.script.events.MouseEvent;
import net.i_no_am.viewmodel.client.Global;


public class SecondMenuCallBack implements CallbackListener, Global {


@CallbackHandler
public void openHandsSettingScreen(MouseEvent e) {
if (e.input.isDown())
ImproperUIAPI.parseAndRunFile(modId, "secondScreen.ui");
}
}
13 changes: 13 additions & 0 deletions src/main/java/net/i_no_am/viewmodel/gui/ViewModelSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@

public class ViewModelSettings implements Global {

public static int hand_swing_speed = 6;
public static boolean no_swing = false;

public static boolean no_food_swing = false;

public static int normal_division = 10;

public static float main_scale = 1.0F;
public static float off_scale = 1.0F;

public static boolean no_hand = false;

private static float main_rotation_x;
private static float main_position_x;
private static float main_rotation_z;
Expand Down Expand Up @@ -44,8 +51,14 @@ public static void loadConfigValues() {
off_position_y = (float) VmConfig.readFloat("off-position-y", 0.0F) / normal_division;
// No Hand Swing Animation
no_swing = VmConfig.readBool("no-hand-swing", false);
hand_swing_speed = 2*VmConfig.readInt("hand-speed-swing", 3);
// No Eating Hand Animation
no_food_swing = VmConfig.readBool("no-food-swing", false);
// Scale
main_scale = (float) VmConfig.readFloat("main-hand-scale", 1.0F);
off_scale = (float) VmConfig.readFloat("off-hand-scale", 1.0F);
// No hand Rendering
no_hand = VmConfig.readBool("no-hand-render", false);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@
public abstract class MixinHeldItemRenderer implements Global {

@Inject(method = "applyEatOrDrinkTransformation", at = @At("HEAD"), cancellable = true)
public void OnApplyEatOrDrinkTransformation(MatrixStack MatrixStack, float tickDelta, Arm arm, ItemStack stack, CallbackInfo ci) {
public void OnApplyEatOrDrinkTransformation(MatrixStack matrices, float tickDelta, Arm arm, ItemStack stack, CallbackInfo ci) {
if (ViewModelSettings.no_food_swing) {
ci.cancel();
}
}


@Inject(method = "renderFirstPersonItem", at = @At("HEAD"))
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) {
double mainRotX = ViewModelSettings.getMainRotationX();
Expand All @@ -48,17 +47,42 @@ public void renderFirstPersonItem(AbstractClientPlayerEntity player, float tickD
m.multiply(RotationAxis.POSITIVE_X.rotationDegrees((float) mainRotX));
m.multiply(RotationAxis.POSITIVE_Y.rotationDegrees((float) mainRotY));
m.multiply(RotationAxis.POSITIVE_Z.rotationDegrees((float) mainRotZ));
m.translate((float) mainPosX, (float) mainPosY, (float) mainPosZ);
m.translate(mainPosX, mainPosY, mainPosZ);
} else {
m.multiply(RotationAxis.POSITIVE_X.rotationDegrees((float) offRotX));
m.multiply(RotationAxis.POSITIVE_Y.rotationDegrees((float) offRotY));
m.multiply(RotationAxis.POSITIVE_Z.rotationDegrees((float) offRotZ));
m.translate((float) offPosX, (float) offPosY, (float) offPosZ);
m.translate(offPosX, offPosY, offPosZ);
}
}

@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"))
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) {
float mainScale = ViewModelSettings.main_scale;
float offScale = ViewModelSettings.off_scale;
if (hand == Hand.MAIN_HAND) {
ms.scale(mainScale, mainScale, mainScale);
} else {
ms.scale(offScale, offScale, offScale);
}
}

@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"))
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) {
float mainScale = ViewModelSettings.main_scale;
float offScale = ViewModelSettings.off_scale;
if (hand == Hand.MAIN_HAND) {
ms.scale(mainScale, mainScale, mainScale);
} else {
ms.scale(offScale, offScale, offScale);
}
if (ViewModelSettings.no_hand) {
ms.scale(0, 0, 0);
}
}

@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"))
public void renderItem(Args args) {
private void renderItem(Args args) {
if (ViewModelSettings.no_swing) {
args.set(6, 0.0F);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@ public void onGetHandSwingDuration(CallbackInfoReturnable<Integer> cir){
cir.setReturnValue(0);
cir.cancel();
}
if (!ViewModelSettings.no_swing) {
cir.setReturnValue(ViewModelSettings.hand_swing_speed);
cir.cancel();
}
}
}
44 changes: 28 additions & 16 deletions src/main/resources/assets/viewmodel/improperui/screen.ui
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ div #title {
}
div #panel -right {
margin: 5
size: 200 145
size: 200 130
background-color: #80000000
background-clip: margin
border-radius: 3
Expand Down Expand Up @@ -107,22 +107,17 @@ div #title {
}
div { inner-text: "Rotation Z axis"; height: 0; margin-top: 0; }
slider -viewmodel:config.properties:off-rotation-z {
min: -45
max: 45
min: -60
max: 60
val: 0
width: 75%
}
checkbox #no-food-swing -viewmodel:config.properties:no-food-swing {}
label {
inner-text: "No Eating Animations"
margin-left: 4
}
}
}

div #panel -left {
margin: 5
size: 200 145
size: 200 130
background-color: #80000000
background-clip: margin
border-radius: 3
Expand Down Expand Up @@ -194,16 +189,33 @@ div #title {
}
div { inner-text: "Rotation Z axis"; height: 0; margin-top: 0; }
slider -viewmodel:config.properties:main-rotation-z {
min: -45
max: 45
min: -60
max: 60
val: 0
width: 75%
}
checkbox #no-hand-swing -viewmodel:config.properties:no-hand-swing {}
label {
inner-text: "No Swing Animations"
margin-left: 4
}
}
}
button #secondGui {
text-align: center
inner-text: "&aAdvanced Settings"
text-color: green
background-color: #80000000
border-radius: 3
border-color: green
margin: 5
width: 99%
padding-top: 4
padding-bottom: 4
center: both
shadow-color: green
shadow-distance: 3

on-click: openHandsSettingScreen

hovered => { padding: 4; border-thickness: 0; border-radius: 4; shadow-distance: 5; }
}

}
}
}
87 changes: 87 additions & 0 deletions src/main/resources/assets/viewmodel/improperui/secondScreen.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@

div #background {
size: 100%
background-color: black
opacity: 0.0
}

div #main {
size: 150 160
background-color: black
opacity: 0.5
border-radius: 3
shadow-distance: 3
shadow-color: green
center: both

div #title {
size: 100% 10
inner-text: "Hands Settings"
text-scale: 1.2
text-shadow: true
text-color: green
text-align: center
background-color: #00000000
margin-top: 7
}


div #settings {
size: 80% 90%
margin-top: 10%
child-align: grid
grid-columns: 2
opacity: 0
margin: 10%
margin-top: 20%


checkbox #no-hand-swing -viewmodel:config.properties:no-hand-swing {}
label {
inner-text: "No Swing Animations"
margin-left: 4
}


checkbox #no-food-swing -viewmodel:config.properties:no-food-swing {margin-top: 6}
label {
margin-top: 6
inner-text: "No Eating Animations"
margin-left: 4
}
checkbox #no-hand-render -viewmodel:config.properties:no-hand-render {margin-top: 6}
label {
margin-top: 6
inner-text: "No Hands Render"
margin-left: 4
}


div {}
div {
margin-top: 20
}

div { inner-text: "Main Item Scale"; }
slider -viewmodel:config.properties:main-hand-scale {
min: 0.1
max: 3.0
val: 1.0
width: 75%
}
div { inner-text: "Off Item Scale"; }
slider -viewmodel:config.properties:off-hand-scale {
min: 0.1
max: 3.0
val: 1.0
width: 75%
}
div { inner-text: "Hand Swing Speed"; }
slider -viewmodel:config.properties:hand-speed-swing {
min: 1.0
max: 7.0
val: 3.0
width: 75%
}
}
}

0 comments on commit fa95e21

Please sign in to comment.