Skip to content

Commit

Permalink
Version 6.0
Browse files Browse the repository at this point in the history
*Changed ImproperUI Library version

*Now using ImproperUI config system

*Updated Fabric Loom Version

*Added No Hand Swing Animation + No Eating Animation
  • Loading branch information
I-No-oNe committed Jun 18, 2024
1 parent e864392 commit e59ea3c
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 53 deletions.
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.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'maven-publish'
}

Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Binary file not shown.
29 changes: 0 additions & 29 deletions src/main/java/net/i_no_am/viewmodel/config/Config.java

This file was deleted.

43 changes: 29 additions & 14 deletions src/main/java/net/i_no_am/viewmodel/gui/ViewModelSettings.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
}
}
19 changes: 19 additions & 0 deletions src/main/java/net/i_no_am/viewmodel/mixin/MixinLivingEntity.java
Original file line number Diff line number Diff line change
@@ -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<Integer> cir){
if (ViewModelSettings.no_swing) {
cir.setReturnValue(0);
cir.cancel();
}
}
}
20 changes: 15 additions & 5 deletions src/main/resources/assets/viewmodel/improperui/screen.ui
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}
}
}
4 changes: 3 additions & 1 deletion src/main/resources/viewmodel.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"minVersion": "0.8",
"package": "net.i_no_am.viewmodel.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [],
"mixins": [
"MixinLivingEntity"
],
"client": [
"MixinClientPlayNetworkHandler",
"MixinHeldItemRenderer"
Expand Down

0 comments on commit e59ea3c

Please sign in to comment.