Skip to content

Commit

Permalink
Add config.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mixces committed Dec 5, 2024
1 parent d30a779 commit 38e7153
Show file tree
Hide file tree
Showing 20 changed files with 188 additions and 83 deletions.
15 changes: 9 additions & 6 deletions src/main/java/me/mixces/animatium/Animatium.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package me.mixces.animatium;

import me.mixces.animatium.config.AnimatiumConfig;
import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.serializer.GsonConfigSerializer;
import me.shedaniel.autoconfig.serializer.JanksonConfigSerializer;
import net.fabricmc.api.ModInitializer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Animatium implements ModInitializer {

/*
Expand All @@ -20,13 +21,15 @@ projectile position (potions, rod)
item reequip
item pickup
remove thrown/dropped swing
debug menu
tab menu?
*/

public static final String MOD_ID = "animatium";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
public static AnimatiumConfig CONFIG;

@Override
public void onInitialize() {
LOGGER.info("Animatium initialized!");
AutoConfig.register(AnimatiumConfig.class, GsonConfigSerializer::new);
CONFIG = AutoConfig.getConfigHolder(AnimatiumConfig.class).getConfig();
}
}
26 changes: 26 additions & 0 deletions src/main/java/me/mixces/animatium/config/AnimatiumConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package me.mixces.animatium.config;

import me.shedaniel.autoconfig.ConfigData;
import me.shedaniel.autoconfig.annotation.Config;

@Config(name = "animatium")
public class AnimatiumConfig implements ConfigData {

public boolean OLD_BODY_ROTATION = true;
public boolean ARMOR_TINT = true;
public boolean OLD_EYE_HEIGHT = true;
public boolean OLD_SNEAKING_SPEED = true;
public boolean THIRD_PERSON_SNEAKING = true;
public boolean OLD_PARALLAX = true;
public boolean NO_HEAD_SMOOTHNESS = true;
public boolean OLD_MINING_PROGRESS = true;
public boolean PUNCH_DURING_USAGE = true;
public boolean OLD_MOMENTUM = true;
public boolean NO_BLOCKING_DELAY = true;
public boolean OLD_VIEW_BOBBING = true;
public boolean OLD_FLYING = true;
public boolean OLD_DEATH_LIMBS = true;
public boolean OLD_HEART_FLASHING = true;
public boolean THIRD_PERSON_CROSSHAIR = true;
public boolean SHOW_POTION_GLINT = true;
}
11 changes: 10 additions & 1 deletion src/main/java/me/mixces/animatium/config/ModMenuIntegration.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
package me.mixces.animatium.config;

import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import me.shedaniel.autoconfig.AutoConfig;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

//todo
@Environment(EnvType.CLIENT)
public class ModMenuIntegration implements ModMenuApi {

@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return parent -> AutoConfig.getConfigScreen(AnimatiumConfig.class, parent).get();
}
}
47 changes: 25 additions & 22 deletions src/main/java/me/mixces/animatium/mixin/BipedEntityModelMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import me.mixces.animatium.Animatium;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.client.render.entity.model.EntityModel;
Expand All @@ -20,6 +21,9 @@
@Mixin(BipedEntityModel.class)
public abstract class BipedEntityModelMixin<T extends BipedEntityRenderState> extends EntityModel<T> {

@Shadow
protected abstract BipedEntityModel.ArmPose getArmPose(T state, Arm arm);

@Shadow
@Final
public ModelPart rightArm;
Expand Down Expand Up @@ -48,9 +52,6 @@ protected BipedEntityModelMixin(ModelPart root) {
super(root);
}

@Shadow
protected abstract BipedEntityModel.ArmPose getArmPose(T state, Arm arm);

@Inject(
method = "setAngles(Lnet/minecraft/client/render/entity/state/BipedEntityRenderState;)V",
at = @At(
Expand Down Expand Up @@ -92,22 +93,24 @@ protected BipedEntityModelMixin(ModelPart root) {
)
)
private void animatium$oldSneakPosition(T bipedEntityRenderState, CallbackInfo ci) {
if (bipedEntityRenderState.isInSneakingPose) {
body.pitch = 0.5F;
rightArm.pitch += 0.4F;
leftArm.pitch += 0.4F;
rightLeg.pivotZ = 4.0F;
leftLeg.pivotZ = 4.0F;
rightLeg.pivotY = 9.0F;
leftLeg.pivotY = 9.0F;
head.pivotY = 1.0F;
} else {
body.pitch = 0.0F;
rightLeg.pivotZ = 0.1F;
leftLeg.pivotZ = 0.1F;
rightLeg.pivotY = 12.0F;
leftLeg.pivotY = 12.0F;
head.pivotY = 0.0F;
if (Animatium.CONFIG.THIRD_PERSON_SNEAKING) {
if (bipedEntityRenderState.isInSneakingPose) {
body.pitch = 0.5F;
rightArm.pitch += 0.4F;
leftArm.pitch += 0.4F;
rightLeg.pivotZ = 4.0F;
leftLeg.pivotZ = 4.0F;
rightLeg.pivotY = 9.0F;
leftLeg.pivotY = 9.0F;
head.pivotY = 1.0F;
} else {
body.pitch = 0.0F;
rightLeg.pivotZ = 0.1F;
leftLeg.pivotZ = 0.1F;
rightLeg.pivotY = 12.0F;
leftLeg.pivotY = 12.0F;
head.pivotY = 0.0F;
}
}
}

Expand All @@ -120,7 +123,7 @@ protected BipedEntityModelMixin(ModelPart root) {
)
)
private boolean animatium$disableSneakTranslations(BipedEntityRenderState instance, Operation<Boolean> original) {
return false;
return !Animatium.CONFIG.OLD_EYE_HEIGHT;
}

@WrapOperation(
Expand All @@ -132,7 +135,7 @@ protected BipedEntityModelMixin(ModelPart root) {
ordinal = 3
)
)
public ModelPart animatium$mirrorSwing2(BipedEntityModel<T> instance, Operation<ModelPart> original, @Local ModelPart modelPart) {
public ModelPart animatium$mirrorSwing(BipedEntityModel<T> instance, Operation<ModelPart> original, @Local ModelPart modelPart) {
return modelPart;
}

Expand All @@ -144,7 +147,7 @@ protected BipedEntityModelMixin(ModelPart root) {
ordinal = 5
)
)
public float animatium$mirrorSwing3(float original, @Local Arm arm) {
public float animatium$mirrorSwing2(float original, @Local Arm arm) {
return (arm == Arm.LEFT ? -1 : 1) * original;
}
}
7 changes: 5 additions & 2 deletions src/main/java/me/mixces/animatium/mixin/CameraMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import me.mixces.animatium.Animatium;
import net.minecraft.client.render.Camera;
import net.minecraft.entity.Entity;
import net.minecraft.world.BlockView;
Expand Down Expand Up @@ -32,7 +33,7 @@ public abstract class CameraMixin {
)
)
private void animatium$oldEyeInterp(Camera instance, float value, Operation<Void> original) {
if (focusedEntity.getStandingEyeHeight() < cameraY) {
if (Animatium.CONFIG.OLD_SNEAKING_SPEED && focusedEntity.getStandingEyeHeight() < cameraY) {
cameraY = focusedEntity.getStandingEyeHeight();
} else {
original.call(instance, value);
Expand All @@ -44,6 +45,8 @@ public abstract class CameraMixin {
at = @At("TAIL")
)
private void animatium$addParallax(BlockView area, Entity focusedEntity, boolean thirdPerson, boolean inverseView, float tickDelta, CallbackInfo ci) {
moveBy(-0.1f, 0.0f, 0.0f);
if (Animatium.CONFIG.OLD_PARALLAX) {
moveBy(-0.1f, 0.0f, 0.0f);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.mixces.animatium.mixin;

import me.mixces.animatium.Animatium;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.entity.player.PlayerAbilities;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -18,6 +19,6 @@ public class ClientPlayerEntityMixin {
)
)
private boolean animatium$sneakFlying(PlayerAbilities instance) {
return false;
return !Animatium.CONFIG.OLD_FLYING && instance.flying;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.mixces.animatium.mixin;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import me.mixces.animatium.Animatium;
import net.minecraft.client.network.ClientPlayerInteractionManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand Down Expand Up @@ -34,6 +35,8 @@ public abstract class ClientPlayerInteractionManagerMixin {
cancellable = true
)
private void animatium$oldMiningProgress(CallbackInfoReturnable<Integer> cir) {
cir.setReturnValue((int)(currentBreakingProgress * 10.0f) - 1);
if (Animatium.CONFIG.OLD_MINING_PROGRESS) {
cir.setReturnValue((int) (currentBreakingProgress * 10.0f) - 1);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import me.mixces.animatium.Animatium;
import me.mixces.animatium.hook.ArmorFeatureRendererHook;
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.RenderLayer;
Expand All @@ -27,7 +28,7 @@ public class EquipmentRendererMixin {
)
)
private RenderLayer animatium$armorTint(Identifier texture, Operation<RenderLayer> original) {
return RenderLayer.getEntityCutoutNoCullZOffset(texture);
return Animatium.CONFIG.ARMOR_TINT ? RenderLayer.getEntityCutoutNoCullZOffset(texture) : original.call(texture);
}

@WrapOperation(
Expand All @@ -38,7 +39,7 @@ public class EquipmentRendererMixin {
)
)
private VertexConsumer animatium$armorTrimTint(Sprite instance, VertexConsumer consumer, Operation<VertexConsumer> original, @Local(argsOnly = true) VertexConsumerProvider vertexConsumers) {
if (ArmorFeatureRendererHook.bipedEntityRenderState.get().hurt) {
if (Animatium.CONFIG.ARMOR_TINT && ArmorFeatureRendererHook.bipedEntityRenderState.get().hurt) {
return instance.getTextureSpecificVertexConsumer(vertexConsumers.getBuffer(RenderLayer.getEntityCutoutNoCullZOffset(instance.getAtlasId())));
}
return original.call(instance, consumer);
Expand All @@ -53,6 +54,8 @@ public class EquipmentRendererMixin {
index = 3
)
private int animatium$armorTint2(int light) {
return OverlayTexture.packUv(OverlayTexture.getU(0.0f), OverlayTexture.getV(ArmorFeatureRendererHook.bipedEntityRenderState.get().hurt));
return Animatium.CONFIG.ARMOR_TINT ?
OverlayTexture.packUv(OverlayTexture.getU(0.0f), OverlayTexture.getV(ArmorFeatureRendererHook.bipedEntityRenderState.get().hurt)) :
light;
}
}
11 changes: 7 additions & 4 deletions src/main/java/me/mixces/animatium/mixin/GameRendererMixin.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.mixces.animatium.mixin;

import me.mixces.animatium.Animatium;
import me.mixces.animatium.duck.PlayerPitchInterface;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.GameRenderer;
Expand Down Expand Up @@ -30,9 +31,11 @@ public class GameRendererMixin {
)
)
private void animatium$addOldPitchRotation(MatrixStack matrices, float tickDelta, CallbackInfo ci) {
final float prevPlayerPitch = ((PlayerPitchInterface) client.getCameraEntity()).animatium$getPrevPlayerPitch();
final float playerPitch = ((PlayerPitchInterface) client.getCameraEntity()).animatium$getPlayerPitch();
final float h = MathHelper.lerp(tickDelta, prevPlayerPitch, playerPitch);
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(h));
if (Animatium.CONFIG.OLD_VIEW_BOBBING) {
final float prevPlayerPitch = ((PlayerPitchInterface) client.getCameraEntity()).animatium$getPrevPlayerPitch();
final float playerPitch = ((PlayerPitchInterface) client.getCameraEntity()).animatium$getPlayerPitch();
final float h = MathHelper.lerp(tickDelta, prevPlayerPitch, playerPitch);
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(h));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.mixces.animatium.mixin;

import com.llamalad7.mixinextras.sugar.Local;
import me.mixces.animatium.Animatium;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.item.HeldItemRenderer;
Expand Down Expand Up @@ -40,6 +41,8 @@ public abstract class HeldItemRendererMixin {
)
)
private void animatium$addSwingOffset(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci, @Local Arm arm) {
applySwingOffset(matrices, arm, swingProgress);
if (Animatium.CONFIG.PUNCH_DURING_USAGE) {
applySwingOffset(matrices, arm, swingProgress);
}
}
}
5 changes: 3 additions & 2 deletions src/main/java/me/mixces/animatium/mixin/InGameHudMixin.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.mixces.animatium.mixin;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import me.mixces.animatium.Animatium;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.hud.InGameHud;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -17,7 +18,7 @@ public abstract class InGameHudMixin {
cancellable = true
)
private void legacyAnimations$cancelBlinking(DrawContext context, InGameHud.HeartType type, int x, int y, boolean hardcore, boolean blinking, boolean half, CallbackInfo ci) {
if (blinking && type != InGameHud.HeartType.CONTAINER) {
if (Animatium.CONFIG.OLD_HEART_FLASHING && blinking && type != InGameHud.HeartType.CONTAINER) {
ci.cancel();
}
}
Expand All @@ -30,6 +31,6 @@ public abstract class InGameHudMixin {
)
)
private boolean legacyAnimations$removePerspectiveCheck(boolean original) {
return true;
return Animatium.CONFIG.THIRD_PERSON_CROSSHAIR || original;
}
}
5 changes: 4 additions & 1 deletion src/main/java/me/mixces/animatium/mixin/InputMixin.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.mixces.animatium.mixin;

import me.mixces.animatium.Animatium;
import net.minecraft.client.input.Input;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -19,6 +20,8 @@ public class InputMixin {
cancellable = true
)
private void animatium$oldMomentum(CallbackInfoReturnable<Boolean> cir) {
cir.setReturnValue(movementForward >= 0.8);
if (Animatium.CONFIG.OLD_MOMENTUM) {
cir.setReturnValue(movementForward >= 0.8);
}
}
}
Loading

0 comments on commit 38e7153

Please sign in to comment.