Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.moulberry.lattice.annotation.LatticeOption;
import com.moulberry.lattice.annotation.constraint.LatticeDisableIf;
import com.moulberry.lattice.annotation.constraint.LatticeFloatRange;
import com.moulberry.lattice.annotation.constraint.LatticeIntRange;
import com.moulberry.lattice.annotation.widget.LatticeWidgetButton;
import com.moulberry.lattice.annotation.widget.LatticeWidgetSlider;
import net.fabricmc.loader.api.FabricLoader;
Expand All @@ -33,6 +34,9 @@ public class SmallViewModelConfig {
@LatticeCategory(name = "smallviewmodel.arm")
public Arm arm = new Arm();

@LatticeCategory(name = "smallviewmodel.swing_animation")
public Swing swing = new Swing();

public static class MainHand {

@LatticeCategory(name = "smallviewmodel.position")
Expand Down Expand Up @@ -164,6 +168,24 @@ private boolean checkDisabled() {
}
}

public static class Swing {

@LatticeOption(title = "smallviewmodel.swing.duration")
@LatticeDisableIf(function = "checkDisabled", frequency = LatticeDynamicFrequency.EVERY_TICK)
@LatticeIntRange(min = 1, max = 20, clampMin = 1, clampMax = 20)
@LatticeWidgetSlider
public int swingDuration = 6;

@LatticeOption(title = "smallviewmodel.enabled")
@LatticeWidgetButton
public boolean enabled = true;

private boolean checkDisabled() {
return !this.enabled;
}

}

public static SmallViewModelConfig get() {
if (INSTANCE == null) {
load();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package wales.cosmic.smallviewmodel.mixin;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis;
import net.minecraft.client.player.AbstractClientPlayer;
Expand Down Expand Up @@ -73,4 +74,17 @@ private void applyConfig(PoseStack poseStack, SmallViewModelConfig.Rotation rota
}
}

@ModifyExpressionValue(
method = "tick",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/player/LocalPlayer;getItemSwapScale(F)F"
)
)
public float smallviewmodel$tick(
float original
) {
return 1f;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package wales.cosmic.smallviewmodel.mixin;

import net.minecraft.world.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;
import wales.cosmic.smallviewmodel.config.SmallViewModelConfig;

@Mixin(LivingEntity.class)
public class MixinLocalPlayer {

@Inject(
method = "getCurrentSwingDuration",
at = @At("HEAD"),
cancellable = true
)
private void smallviewmodel$getCurrentSwingDuration(CallbackInfoReturnable<Integer> cir) {
final var config = SmallViewModelConfig.get();
if (config.swing.enabled) {
cir.setReturnValue(config.swing.swingDuration);
}
}

}
4 changes: 3 additions & 1 deletion src/main/resources/assets/smallviewmodel/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@
"smallviewmodel.scale": "Scale",
"smallviewmodel.scale.x": "X Scale",
"smallviewmodel.scale.y": "Y Scale",
"smallviewmodel.scale.z": "Z Scale"
"smallviewmodel.scale.z": "Z Scale",
"smallviewmodel.swing_animation": "Swing Animation Settings",
"smallviewmodel.swing.duration": "Animation Duration"
}
3 changes: 1 addition & 2 deletions src/main/resources/smallviewmodel.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
"package": "wales.cosmic.smallviewmodel.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"MixinLocalPlayer",
"MixinItemInHandRenderer"
],
"client": [
],
"injectors": {
"defaultRequire": 1
}
Expand Down