diff --git a/assets/gui.png b/assets/gui.png index 7803906..2e98006 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 index 99a7d6f..e72d24c 100644 Binary files a/assets/second_gui.png and b/assets/second_gui.png differ diff --git a/build.gradle b/build.gradle index 56cf7c2..3864059 100644 --- a/build.gradle +++ b/build.gradle @@ -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.2-0.0.6-BETA.jar") + modImplementation files("libs/ImproperUI-1-20.2-0.0.6-BETA.jar") } processResources { diff --git a/gradle.properties b/gradle.properties index e79cb9a..020aedf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.15.11 # Mod Properties - mod_version = 7.0-1.20.2-fabric + mod_version = 8.0-1.20.2-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 fbcd304..ee2f8e2 100644 --- a/src/main/java/net/i_no_am/viewmodel/ViewModel.java +++ b/src/main/java/net/i_no_am/viewmodel/ViewModel.java @@ -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; @@ -26,7 +26,7 @@ public void onInitialize() { while (BIND.wasPressed()) { ImproperUIAPI.parseAndRunFile(modId, "screen.ui",new SecondMenuCallBack()); } - ViewModelSettings.loadConfigValues(); + ConfigManager.loadConfigValues(); }); } } \ No newline at end of file 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 b5efbbf..440b762 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 @@ -1,8 +1,10 @@ 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", diff --git a/src/main/java/net/i_no_am/viewmodel/config/ConfigManager.java b/src/main/java/net/i_no_am/viewmodel/config/ConfigManager.java new file mode 100644 index 0000000..b7e5754 --- /dev/null +++ b/src/main/java/net/i_no_am/viewmodel/config/ConfigManager.java @@ -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> 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); + } +} \ No newline at end of file diff --git a/src/main/java/net/i_no_am/viewmodel/config/SettingStructure.java b/src/main/java/net/i_no_am/viewmodel/config/SettingStructure.java new file mode 100644 index 0000000..713f30e --- /dev/null +++ b/src/main/java/net/i_no_am/viewmodel/config/SettingStructure.java @@ -0,0 +1,31 @@ +package net.i_no_am.viewmodel.config; + +public abstract class SettingStructure { + private final T value; + + public SettingStructure(T value) { + this.value = value; + } + + public T getVal() { + return value; + } +} + +class FloatSettingStructure extends SettingStructure { + public FloatSettingStructure(Float value) { + super(value); + } +} + +class BooleanSetting extends SettingStructure { + public BooleanSetting(Boolean value) { + super(value); + } +} + +class IntegerSettingStructure extends SettingStructure { + public IntegerSettingStructure(Integer value) { + super(value); + } +} \ No newline at end of file diff --git a/src/main/java/net/i_no_am/viewmodel/config/settings/SettingsManager.java b/src/main/java/net/i_no_am/viewmodel/config/settings/SettingsManager.java new file mode 100644 index 0000000..76f231b --- /dev/null +++ b/src/main/java/net/i_no_am/viewmodel/config/settings/SettingsManager.java @@ -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; +} \ No newline at end of file diff --git a/src/main/java/net/i_no_am/viewmodel/config/settings/ViewModelSettings.java b/src/main/java/net/i_no_am/viewmodel/config/settings/ViewModelSettings.java new file mode 100644 index 0000000..295a78a --- /dev/null +++ b/src/main/java/net/i_no_am/viewmodel/config/settings/ViewModelSettings.java @@ -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; + } +} \ 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 deleted file mode 100644 index ca19e1f..0000000 --- a/src/main/java/net/i_no_am/viewmodel/gui/ViewModelSettings.java +++ /dev/null @@ -1,112 +0,0 @@ - -package net.i_no_am.viewmodel.gui; - - -import io.github.itzispyder.improperui.ImproperUIAPI; -import io.github.itzispyder.improperui.config.ConfigReader; -import net.i_no_am.viewmodel.client.Global; - -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; - private static float main_position_z; - private static float main_rotation_y; - private static float main_position_y; - - private static float off_rotation_x; - private static float off_position_x; - private static float off_rotation_z; - private static float off_position_z; - private static float off_rotation_y; - private static float off_position_y; - - public static void loadConfigValues() { - ConfigReader VmConfig = ImproperUIAPI.getConfigReader(modId, "config.properties"); -// view model - main_rotation_x = (float) VmConfig.readFloat("main-rotation-x", 0.0F); - main_position_x = (float) VmConfig.readFloat("main_position_x", 0.0F) / normal_division; - main_rotation_z = (float) VmConfig.readFloat("main-rotation-z", 0.0F); - main_position_z = (float) VmConfig.readFloat("main-position-z", 0.0F) / normal_division; - main_rotation_y = (float) VmConfig.readFloat("main-rotation-y", 0.0F); - main_position_y = (float) VmConfig.readFloat("main-position-y", 0.0F) / normal_division; - off_rotation_x = (float) VmConfig.readFloat("off-rotation-x", 0.0F); - off_position_x = (float) VmConfig.readFloat("off-position-x", 0.0F) / normal_division; - off_rotation_z = (float) VmConfig.readFloat("off-rotation-z", 0.0F); - off_position_z = (float) VmConfig.readFloat("off-position-z", 0.0F) / normal_division; - off_rotation_y = (float) VmConfig.readFloat("off-rotation-y", 0.0F); - 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); - } - - - public static float getMainRotationX() { - return main_rotation_x; - } - - public static float getMainPositionX() { - return main_position_x; - } - - public static float getMainRotationZ() { - return main_rotation_z; - } - - public static float getMainPositionZ() { - return main_position_z; - } - - public static float getMainRotationY() { - return main_rotation_y; - } - - public static float getMainPositionY() { - return main_position_y; - } - - public static float getOffRotationX() { - return off_rotation_x; - } - - public static float getOffPositionX() { - return off_position_x; - } - - public static float getOffRotationZ() { - return off_rotation_z; - } - - public static float getOffPositionZ() { - return off_position_z; - } - - public static float getOffRotationY() { - return off_rotation_y; - } - - public static float getOffPositionY() { - return off_position_y; - } -} \ No newline at end of file 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 c1dd0b0..d10961b 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 @@ -1,7 +1,8 @@ package net.i_no_am.viewmodel.mixin; import net.i_no_am.viewmodel.client.Global; -import net.i_no_am.viewmodel.gui.ViewModelSettings; +import net.i_no_am.viewmodel.config.ConfigManager; +import net.i_no_am.viewmodel.config.settings.ViewModelSettings; import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.item.HeldItemRenderer; @@ -20,46 +21,46 @@ @Mixin(HeldItemRenderer.class) public abstract class MixinHeldItemRenderer implements Global { - @Inject(method = "applyEatOrDrinkTransformation", at = @At("HEAD"), cancellable = true) - 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(); - double mainPosX = ViewModelSettings.getMainPositionX(); - double mainRotZ = ViewModelSettings.getMainRotationZ(); - double mainPosZ = ViewModelSettings.getMainPositionZ(); - double mainRotY = ViewModelSettings.getMainRotationY(); - double mainPosY = ViewModelSettings.getMainPositionY(); - - double offRotX = ViewModelSettings.getOffRotationX(); - double offPosX = ViewModelSettings.getOffPositionX(); - double offRotZ = ViewModelSettings.getOffRotationZ(); - double offPosZ = ViewModelSettings.getOffPositionZ(); - double offRotY = ViewModelSettings.getOffRotationY(); - double offPosY = ViewModelSettings.getOffPositionY(); - + public void viewmodel(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack m, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { + m.push(); if (hand == Hand.MAIN_HAND) { - m.multiply(RotationAxis.POSITIVE_X.rotationDegrees((float) mainRotX)); - m.multiply(RotationAxis.POSITIVE_Y.rotationDegrees((float) mainRotY)); - m.multiply(RotationAxis.POSITIVE_Z.rotationDegrees((float) mainRotZ)); + float mainRotX = (Float) ConfigManager.get(ViewModelSettings.MAIN_ROT_X).getVal(); + float mainPosX = (Float) ConfigManager.get(ViewModelSettings.MAIN_POS_X).getVal(); + float mainRotZ = (Float) ConfigManager.get(ViewModelSettings.MAIN_ROT_Z).getVal(); + float mainPosZ = (Float) ConfigManager.get(ViewModelSettings.MAIN_POS_Z).getVal(); + float mainRotY = (Float) ConfigManager.get(ViewModelSettings.MAIN_ROT_Y).getVal(); + float mainPosY = (Float) ConfigManager.get(ViewModelSettings.MAIN_POS_Y).getVal(); + + m.multiply(RotationAxis.POSITIVE_X.rotationDegrees(mainRotX)); + m.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(mainRotY)); + m.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(mainRotZ)); 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)); + float offRotX = (Float) ConfigManager.get(ViewModelSettings.OFF_ROT_X).getVal(); + float offPosX = (Float) ConfigManager.get(ViewModelSettings.OFF_POS_X).getVal(); + float offRotZ = (Float) ConfigManager.get(ViewModelSettings.OFF_ROT_Z).getVal(); + float offPosZ = (Float) ConfigManager.get(ViewModelSettings.OFF_POS_Z).getVal(); + float offRotY = (Float) ConfigManager.get(ViewModelSettings.OFF_ROT_Y).getVal(); + float offPosY = (Float) ConfigManager.get(ViewModelSettings.OFF_POS_Y).getVal(); + + m.multiply(RotationAxis.POSITIVE_X.rotationDegrees(offRotX)); + m.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(offRotY)); + m.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(offRotZ)); m.translate(offPosX, offPosY, offPosZ); } } + @Inject(method = "renderFirstPersonItem", at = @At("TAIL")) + public void popMatrixAfterRenderFirstPersonItem(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack m, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { + m.pop(); + } + + @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; + private void scaleForItems(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack ms, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { + float mainScale = (Float) ConfigManager.get(ViewModelSettings.MAIN_SCALE).getVal(); + float offScale = (Float) ConfigManager.get(ViewModelSettings.OFF_SCALE).getVal(); if (hand == Hand.MAIN_HAND) { ms.scale(mainScale, mainScale, mainScale); } else { @@ -68,22 +69,30 @@ private void onRenderFirstPersonItem(AbstractClientPlayerEntity player, float ti } @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; + private void scaleForHands(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack ms, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { + float mainScale = (Float) ConfigManager.get(ViewModelSettings.MAIN_SCALE).getVal(); + float offScale = (Float) ConfigManager.get(ViewModelSettings.OFF_SCALE).getVal(); if (hand == Hand.MAIN_HAND) { ms.scale(mainScale, mainScale, mainScale); } else { ms.scale(offScale, offScale, offScale); } - if (ViewModelSettings.no_hand) { + if ((boolean) ConfigManager.get(ViewModelSettings.NO_HAND).getVal()) { ms.scale(0, 0, 0); } } + + @Inject(method = "applyEatOrDrinkTransformation", at = @At("HEAD"), cancellable = true) + public void OnApplyEatOrDrinkTransformation(MatrixStack matrices, float tickDelta, Arm arm, ItemStack stack, CallbackInfo ci) { + if ((Boolean) ConfigManager.get(ViewModelSettings.NO_FOOD_SWING).getVal()) { + ci.cancel(); + } + } + @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")) private void renderItem(Args args) { - if (ViewModelSettings.no_swing) { + if ((Boolean) ConfigManager.get(ViewModelSettings.NO_SWING).getVal() && !(boolean) ConfigManager.get(ViewModelSettings.NO_SWING_V2).getVal()) { 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 7c99166..1b7ba8b 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 @@ -1,6 +1,7 @@ package net.i_no_am.viewmodel.mixin; -import net.i_no_am.viewmodel.gui.ViewModelSettings; +import net.i_no_am.viewmodel.config.ConfigManager; +import net.i_no_am.viewmodel.config.settings.ViewModelSettings; import net.minecraft.entity.LivingEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -9,14 +10,14 @@ @Mixin(LivingEntity.class) public class MixinLivingEntity { - @Inject(method = "getHandSwingDuration", at= @At("HEAD"), cancellable = true) - public void onGetHandSwingDuration(CallbackInfoReturnable cir){ - if (ViewModelSettings.no_swing) { + @Inject(method = "getHandSwingDuration", at = @At("HEAD"), cancellable = true) + private void onGetHandSwingDuration(CallbackInfoReturnable cir) { + if ((boolean) ConfigManager.get(ViewModelSettings.NO_SWING).getVal() || (boolean) ConfigManager.get(ViewModelSettings.NO_SWING_V2).getVal()) { cir.setReturnValue(0); cir.cancel(); } - if (!ViewModelSettings.no_swing) { - cir.setReturnValue(ViewModelSettings.hand_swing_speed); + if (!(boolean) ConfigManager.get(ViewModelSettings.NO_SWING).getVal() && !(boolean) ConfigManager.get(ViewModelSettings.NO_SWING_V2).getVal()){ + cir.setReturnValue((int) ConfigManager.get(ViewModelSettings.HAND_SWING_SPEED).getVal()); cir.cancel(); } } diff --git a/src/main/java/net/i_no_am/viewmodel/utils/Utils.java b/src/main/java/net/i_no_am/viewmodel/utils/Utils.java index 75a64e7..0ba4faa 100644 --- a/src/main/java/net/i_no_am/viewmodel/utils/Utils.java +++ b/src/main/java/net/i_no_am/viewmodel/utils/Utils.java @@ -1,5 +1,6 @@ package net.i_no_am.viewmodel.utils; +import net.fabricmc.loader.api.FabricLoader; import net.i_no_am.viewmodel.client.Global; import net.i_no_am.viewmodel.client.ModVersionChecker; import net.minecraft.client.MinecraftClient; @@ -20,4 +21,14 @@ public static boolean isUpdateAvailable(String latestVersion) { public static void setChecked(boolean bool) { ModVersionChecker.checked = bool; } + public static String getModVersion() { + String fullVersionString = FabricLoader.getInstance().getModContainer(modId).get().getMetadata().getVersion().getFriendlyString(); + String[] parts = fullVersionString.split("-"); + for (String part : parts) { + if (part.matches("\\d+\\.\\d+")) { + return part; + } + } + return "Unknown"; + } } \ 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 index 3298ea4..dcf6eee 100644 --- a/src/main/resources/assets/viewmodel/improperui/secondScreen.ui +++ b/src/main/resources/assets/viewmodel/improperui/secondScreen.ui @@ -6,9 +6,8 @@ div #background { } div #main { - size: 150 160 - background-color: black - opacity: 0.5 + size: 150 185 + background-color: #80000000 border-radius: 3 shadow-distance: 3 shadow-color: green @@ -16,12 +15,12 @@ div #main { div #title { size: 100% 10 - inner-text: "Hands Settings" + inner-text: "&aAdvanced Settings" text-scale: 1.2 text-shadow: true text-color: green text-align: center - background-color: #00000000 + background-color: none margin-top: 7 } @@ -33,15 +32,7 @@ div #main { 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 - } - + margin-top: 15% checkbox #no-food-swing -viewmodel:config.properties:no-food-swing {margin-top: 6} label { @@ -59,10 +50,10 @@ div #main { div {} div { - margin-top: 20 + margin-top: 16 } - div { inner-text: "Main Item Scale"; } + div { inner-text: "Main Item Scale";} slider -viewmodel:config.properties:main-hand-scale { min: 0.1 max: 3.0 @@ -83,5 +74,31 @@ div #main { val: 3.0 width: 75% } + div #v1{ + inner-text: "Mode 1" + margin-top: 16 + margin-left: 43 + } + div{ + inner-text: "&2No Swing:" + text-align: center + background-color: none + margin-top: 2 + margin-left: 11 + } + div #enums{ + margin-top: 10 + margin-right: 1 + child-align: grid + grid-columns: 1 + height: 15 + radio -viewmodel:config.properties:no-hand-swing {margin-left: 27;} + radio -viewmodel:config.properties:no-hand-swing-v2 {margin-left: 27; margin-top: 5;} + } + div #text{ + inner-text: "Mode 2" + margin-top: 32 + margin-left: 43 + } } } \ No newline at end of file