diff --git a/assets/gui.png b/assets/gui.png index edb7b0d..231f39d 100644 Binary files a/assets/gui.png and b/assets/gui.png differ diff --git a/build.gradle b/build.gradle index 4279e53..9ad7b7d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.6-SNAPSHOT' + id 'fabric-loom' version '1.7-SNAPSHOT' id 'maven-publish' } @@ -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-0.0.5-BETA.jar") + compileOnly files("libs/ImproperUI-1-20-0.0.6-BETA.jar") } processResources { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b82aa23..a441313 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/libs/ImproperUI-1.20-0.0.5-BETA.jar b/libs/ImproperUI-1-20-0.0.6-BETA.jar similarity index 84% rename from libs/ImproperUI-1.20-0.0.5-BETA.jar rename to libs/ImproperUI-1-20-0.0.6-BETA.jar index ac6fb4d..abbcdd5 100644 Binary files a/libs/ImproperUI-1.20-0.0.5-BETA.jar and b/libs/ImproperUI-1-20-0.0.6-BETA.jar differ diff --git a/src/main/java/net/i_no_am/viewmodel/config/Config.java b/src/main/java/net/i_no_am/viewmodel/config/Config.java deleted file mode 100644 index 4d7c23b..0000000 --- a/src/main/java/net/i_no_am/viewmodel/config/Config.java +++ /dev/null @@ -1,29 +0,0 @@ -package net.i_no_am.viewmodel.config; - -import net.i_no_am.viewmodel.client.Global; -import io.github.itzispyder.improperui.config.ConfigKey; -import io.github.itzispyder.improperui.config.Properties; -import io.github.itzispyder.improperui.script.ScriptParser; - -public class Config implements Global { - - private static ConfigKey createConfigKey(String property) { - return new ConfigKey("%s:config.properties:%s".formatted(modId, property)); - } - - public static Properties.Value read(String property) { - return ScriptParser.getCache(modId).getProperty(createConfigKey(property)); - } - - public static void write(String property, Object value, boolean save) { - ScriptParser.getCache(modId).setProperty(createConfigKey(property), value, save); - } - public static double readDouble(String property) { - var val = read(property); - if (val == null) { - write(property, 0.0, true); - val = read(property); - } - return val.get(0).toDouble(); - } -} 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 ed27895..95ca34e 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 @@ -1,10 +1,18 @@ + package net.i_no_am.viewmodel.gui; -import net.i_no_am.viewmodel.config.Config; -public class ViewModelSettings { +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 boolean no_swing = false; + public static boolean no_food_swing = false; public static int normal_division = 10; + private static float main_rotation_x; private static float main_position_x; private static float main_rotation_z; @@ -20,20 +28,27 @@ public class ViewModelSettings { private static float off_position_y; public static void loadConfigValues() { - main_rotation_x = (float) Config.readDouble("main-rotation-x"); - main_position_x = (float) Config.readDouble("main-position-x") / normal_division; - main_rotation_z = (float) Config.readDouble("main-rotation-z"); - main_position_z = (float) Config.readDouble("main-position-z") / normal_division; - main_rotation_y = (float) Config.readDouble("main-rotation-y"); - main_position_y = (float) Config.readDouble("main-position-y") / normal_division; - off_rotation_x = (float) Config.readDouble("off-rotation-x"); - off_position_x = (float) Config.readDouble("off-position-x") / normal_division; - off_rotation_z = (float) Config.readDouble("off-rotation-z"); - off_position_z = (float) Config.readDouble("off-position-z") / normal_division; - off_rotation_y = (float) Config.readDouble("off-rotation-y"); - off_position_y = (float) Config.readDouble("off-position-y") / normal_division; + 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); +// No Eating Hand Animation + no_food_swing = VmConfig.readBool("no-food-swing", false); } + public static float getMainRotationX() { return main_rotation_x; } 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 4c98d20..350f299 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 @@ -7,16 +7,27 @@ import net.minecraft.client.render.item.HeldItemRenderer; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.ItemStack; +import net.minecraft.util.Arm; import net.minecraft.util.Hand; import net.minecraft.util.math.RotationAxis; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyArgs; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.invoke.arg.Args; @Mixin(HeldItemRenderer.class) 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) { + 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(); @@ -45,4 +56,11 @@ public void renderFirstPersonItem(AbstractClientPlayerEntity player, float tickD m.translate((float) offPosX, (float) offPosY, (float) offPosZ); } } -} + + @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) { + if (ViewModelSettings.no_swing) { + args.set(6, 0.0F); + } + } +} \ No newline at end of file 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 new file mode 100644 index 0000000..00670ea --- /dev/null +++ b/src/main/java/net/i_no_am/viewmodel/mixin/MixinLivingEntity.java @@ -0,0 +1,19 @@ +package net.i_no_am.viewmodel.mixin; + +import net.i_no_am.viewmodel.gui.ViewModelSettings; +import net.minecraft.entity.LivingEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(LivingEntity.class) +public class MixinLivingEntity { + @Inject(method = "getHandSwingDuration", at= @At("HEAD"), cancellable = true) + public void onGetHandSwingDuration(CallbackInfoReturnable cir){ + if (ViewModelSettings.no_swing) { + cir.setReturnValue(0); + 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 f8fe489..8b474cd 100644 --- a/src/main/resources/assets/viewmodel/improperui/screen.ui +++ b/src/main/resources/assets/viewmodel/improperui/screen.ui @@ -1,11 +1,11 @@ div #background { size: 100% background-color: black - opacity: 0.1 + opacity: 0 } div #content { - size: 420 200 + size: 420 210 background-color: none child-align: grid @@ -36,7 +36,7 @@ div #title { } div #panel -right { margin: 5 - size: 200 140 + size: 200 145 background-color: #80000000 background-clip: margin border-radius: 3 @@ -112,12 +112,17 @@ div #title { 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 140 + size: 200 145 background-color: #80000000 background-clip: margin border-radius: 3 @@ -194,6 +199,11 @@ div #title { val: 0 width: 75% } + checkbox #no-hand-swing -viewmodel:config.properties:no-hand-swing {} + label { + inner-text: "No Swing Animations" + margin-left: 4 + } } } } \ No newline at end of file diff --git a/src/main/resources/viewmodel.mixins.json b/src/main/resources/viewmodel.mixins.json index 665b80c..4d3cae5 100644 --- a/src/main/resources/viewmodel.mixins.json +++ b/src/main/resources/viewmodel.mixins.json @@ -3,7 +3,9 @@ "minVersion": "0.8", "package": "net.i_no_am.viewmodel.mixin", "compatibilityLevel": "JAVA_17", - "mixins": [], + "mixins": [ + "MixinLivingEntity" + ], "client": [ "MixinClientPlayNetworkHandler", "MixinHeldItemRenderer"