Skip to content

Commit

Permalink
Add some nametag related settings & text strikethrough
Browse files Browse the repository at this point in the history
  • Loading branch information
lowercasebtw committed Dec 12, 2024
1 parent 0e1f910 commit 2cef725
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/main/java/me/mixces/animatium/config/AnimatiumConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public class AnimatiumConfig extends MidnightConfig {
@Entry
public static boolean showNametagInThirdperson = true; // Show the player nametag in thirdperson

@Entry
public static boolean hideNameTagBackground = true; // Hide the nametag background

@Entry
public static boolean applyTextShadowToNametag = true; // Apply text shadow to nametag

@Entry
public static boolean removeSmoothSneaking = true; // Removes the smooth sneaking animation, making it like 1.8-1.12.2

Expand All @@ -51,6 +57,9 @@ public class AnimatiumConfig extends MidnightConfig {
@Entry
public static boolean oldDeathLimbs = true; // from testing, the only difference is you always fall sideways?

@Entry
public static boolean fixTextStrikethroughStyle = true; // Changes the text strikethrough position to make it look like it did in <=1.12.2

@Entry
public static CameraVersion cameraVersion = CameraVersion.v1_8; // Change the camera position to be as it was in said version range

Expand Down
31 changes: 31 additions & 0 deletions src/main/java/me/mixces/animatium/mixins/MixinEntityRenderer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package me.mixces.animatium.mixins;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import me.mixces.animatium.config.AnimatiumConfig;
import net.minecraft.client.option.GameOptions;
import net.minecraft.client.render.entity.EntityRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;

@Mixin(EntityRenderer.class)
public abstract class MixinEntityRenderer {
@WrapOperation(method = "renderLabelIfPresent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/GameOptions;getTextBackgroundOpacity(F)F"))
private float hideNameTagBackground(GameOptions instance, float fallback, Operation<Float> original) {
if (AnimatiumConfig.hideNameTagBackground) {
return 0F;
} else {
return original.call(instance, fallback);
}
}

@ModifyArg(method = "renderLabelIfPresent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;draw(Lnet/minecraft/text/Text;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/font/TextRenderer$TextLayerType;II)I"), index = 4)
private boolean applyTextShadowToNametag(boolean shadow) {
if (AnimatiumConfig.applyTextShadowToNametag) {
return true;
} else {
return shadow;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package me.mixces.animatium.mixins;

import me.mixces.animatium.config.AnimatiumConfig;
import net.minecraft.client.font.TextRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;

@Mixin(TextRenderer.Drawer.class)
public abstract class MixinTextRendererDrawer {
@Unique
private static final float animatium$strikethroughOffset = 0.5F;

@ModifyArg(method = "accept", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/BakedGlyph$Rectangle;<init>(FFFFFIIF)V", ordinal = 0), index = 1)
private float fixTextStrikethroughStyle$minY(float minY) {
if (AnimatiumConfig.fixTextStrikethroughStyle) {
return minY - animatium$strikethroughOffset;
} else {
return minY;
}
}

@ModifyArg(method = "accept", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/BakedGlyph$Rectangle;<init>(FFFFFIIF)V", ordinal = 0), index = 3)
private float fixTextStrikethroughStyle$maxY(float maxY) {
if (AnimatiumConfig.fixTextStrikethroughStyle) {
return maxY - animatium$strikethroughOffset;
} else {
return maxY;
}
}
}
3 changes: 2 additions & 1 deletion src/main/resources/animatium.accesswidener
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
accessWidener v2 named
accessible class net/minecraft/client/gui/hud/InGameHud$HeartType
accessible class net/minecraft/client/gui/hud/InGameHud$HeartType
accessible class net/minecraft/client/font/TextRenderer$Drawer
4 changes: 3 additions & 1 deletion src/main/resources/animatium.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
"MixinBipedEntityModel",
"MixinBipedEntityRenderer",
"MixinCamera",
"MixinEntityRenderer",
"MixinGameRenderer",
"MixinHeldItemRenderer",
"MixinInGameHud",
"MixinLivingEntity",
"MixinLivingEntityRenderer",
"MixinMinecraftClient",
"MixinPlayerEntity",
"MixinPlayerEntityRenderer"
"MixinPlayerEntityRenderer",
"MixinTextRendererDrawer"
],
"injectors": {
"defaultRequire": 1
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/assets/animatium/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
"animatium.midnightconfig.showCrosshairInThirdperson.tooltip": "TODO",
"animatium.midnightconfig.showNametagInThirdperson": "Show nametag in third-person",
"animatium.midnightconfig.showNametagInThirdperson.tooltip": "TODO",
"animatium.midnightconfig.hideNameTagBackground": "Hide nametag background",
"animatium.midnightconfig.hideNameTagBackground.tooltip": "TODO",
"animatium.midnightconfig.applyTextShadowToNametag": "Apply text shadow to nametag",
"animatium.midnightconfig.applyTextShadowToNametag.tooltip": "TODO",
"animatium.midnightconfig.removeSmoothSneaking": "Remove the smooth first-person sneak animation",
"animatium.midnightconfig.removeSmoothSneaking.tooltip": "TODO",
"animatium.midnightconfig.oldSneakEyeHeight": "Revert to old sneaking height",
Expand All @@ -33,6 +37,8 @@
"animatium.midnightconfig.removeHeartFlash.tooltip": "TODO",
"animatium.midnightconfig.oldDeathLimbs": "Old Death Limbs",
"animatium.midnightconfig.oldDeathLimbs.tooltip": "TODO",
"animatium.midnightconfig.fixTextStrikethroughStyle": "Fix text strikethrough style",
"animatium.midnightconfig.fixTextStrikethroughStyle.tooltip": "TODO",
"animatium.midnightconfig.cameraVersion": "Change camera position to be as it was in",
"animatium.midnightconfig.cameraVersion.tooltip": "TODO",

Expand Down

0 comments on commit 2cef725

Please sign in to comment.