diff --git a/README.md b/README.md index 806d352..b500564 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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** 🙏 \ No newline at end of file diff --git a/assets/gui.png b/assets/gui.png index 231f39d..7803906 100644 Binary files a/assets/gui.png and b/assets/gui.png differ diff --git a/assets/second_gui.png b/assets/second_gui.png new file mode 100644 index 0000000..99a7d6f Binary files /dev/null and b/assets/second_gui.png differ diff --git a/gradle.properties b/gradle.properties index 8b5d35a..dbdcbd7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/src/main/java/net/i_no_am/viewmodel/ViewModel.java b/src/main/java/net/i_no_am/viewmodel/ViewModel.java index dab6e60..bbc75fe 100644 --- a/src/main/java/net/i_no_am/viewmodel/ViewModel.java +++ b/src/main/java/net/i_no_am/viewmodel/ViewModel.java @@ -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; @@ -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(); }); diff --git a/src/main/java/net/i_no_am/viewmodel/client/Global.java b/src/main/java/net/i_no_am/viewmodel/client/Global.java index eb72c17..b5efbbf 100644 --- a/src/main/java/net/i_no_am/viewmodel/client/Global.java +++ b/src/main/java/net/i_no_am/viewmodel/client/Global.java @@ -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" }; } \ No newline at end of file diff --git a/src/main/java/net/i_no_am/viewmodel/event/SecondMenuCallBack.java b/src/main/java/net/i_no_am/viewmodel/event/SecondMenuCallBack.java new file mode 100644 index 0000000..208ab49 --- /dev/null +++ b/src/main/java/net/i_no_am/viewmodel/event/SecondMenuCallBack.java @@ -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"); + } +} \ No newline at end of file diff --git a/src/main/java/net/i_no_am/viewmodel/gui/ViewModelSettings.java b/src/main/java/net/i_no_am/viewmodel/gui/ViewModelSettings.java index 95ca34e..ca19e1f 100644 --- a/src/main/java/net/i_no_am/viewmodel/gui/ViewModelSettings.java +++ b/src/main/java/net/i_no_am/viewmodel/gui/ViewModelSettings.java @@ -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; @@ -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); } diff --git a/src/main/java/net/i_no_am/viewmodel/mixin/MixinHeldItemRenderer.java b/src/main/java/net/i_no_am/viewmodel/mixin/MixinHeldItemRenderer.java index 350f299..c1dd0b0 100644 --- a/src/main/java/net/i_no_am/viewmodel/mixin/MixinHeldItemRenderer.java +++ b/src/main/java/net/i_no_am/viewmodel/mixin/MixinHeldItemRenderer.java @@ -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(); @@ -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); } diff --git a/src/main/java/net/i_no_am/viewmodel/mixin/MixinLivingEntity.java b/src/main/java/net/i_no_am/viewmodel/mixin/MixinLivingEntity.java index 00670ea..7c99166 100644 --- a/src/main/java/net/i_no_am/viewmodel/mixin/MixinLivingEntity.java +++ b/src/main/java/net/i_no_am/viewmodel/mixin/MixinLivingEntity.java @@ -15,5 +15,9 @@ public void onGetHandSwingDuration(CallbackInfoReturnable cir){ cir.setReturnValue(0); cir.cancel(); } + if (!ViewModelSettings.no_swing) { + cir.setReturnValue(ViewModelSettings.hand_swing_speed); + cir.cancel(); + } } } \ No newline at end of file diff --git a/src/main/resources/assets/viewmodel/improperui/screen.ui b/src/main/resources/assets/viewmodel/improperui/screen.ui index 8b474cd..8cbc291 100644 --- a/src/main/resources/assets/viewmodel/improperui/screen.ui +++ b/src/main/resources/assets/viewmodel/improperui/screen.ui @@ -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 @@ -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 @@ -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; } + } + + } } } \ No newline at end of file diff --git a/src/main/resources/assets/viewmodel/improperui/secondScreen.ui b/src/main/resources/assets/viewmodel/improperui/secondScreen.ui new file mode 100644 index 0000000..3298ea4 --- /dev/null +++ b/src/main/resources/assets/viewmodel/improperui/secondScreen.ui @@ -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% + } + } +} \ No newline at end of file