Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit 36a9678

Browse files
committed
best-effort name formatting for biome locations
- (1.20.1) fix nametag shadows
1 parent be283ad commit 36a9678

File tree

9 files changed

+151
-23
lines changed

9 files changed

+151
-23
lines changed

1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/CoordsHud.java

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public void renderComponent(MatrixStack matrices, float delta) {
186186
BlockPos b = new BlockPos(x, y, z);
187187
int bX = drawString(matrices, I18n.translate("coordshud.biome"), pos.x() + 1, height + pos.y(), firstColor.get().toInt(), shadow.get());
188188
bX += 5;
189-
width = Math.max(width + pos.x() - 1, drawString(matrices, String.valueOf(this.client.world.getRegistryManager().get(Registry.BIOME_KEY).getId(this.client.world.getBiome(b))), bX, height + pos.y(), secondColor.get().toInt(), shadow.get())) - pos.x() + 1;
189+
width = Math.max(width + pos.x() - 1, drawString(matrices, getBiomeName(this.client.world.getRegistryManager().get(Registry.BIOME_KEY).getId(this.client.world.getBiome(b))), bX, height + pos.y(), secondColor.get().toInt(), shadow.get())) - pos.x() + 1;
190190
height += 10;
191191
}
192192
boolean changed = false;
@@ -203,6 +203,33 @@ public void renderComponent(MatrixStack matrices, float delta) {
203203
}
204204
}
205205

206+
private String getBiomeName(Identifier biome) {
207+
if (biome == null) {
208+
return "Unknown";
209+
}
210+
String path = biome.getPath();
211+
if (!biome.getNamespace().equals("minecraft")) {
212+
path += "("+biome.getNamespace()+")";
213+
}
214+
final String str = path.replace("_", " ");
215+
if (str.isEmpty()) {
216+
return str;
217+
}
218+
219+
final int[] codepoints = str.codePoints().toArray();
220+
boolean capitalizeNext = true;
221+
for (int i = 0; i < codepoints.length; i++) {
222+
final int ch = codepoints[i];
223+
if (Character.isWhitespace(ch)) {
224+
capitalizeNext = true;
225+
} else if (capitalizeNext) {
226+
codepoints[i] = Character.toTitleCase(ch);
227+
capitalizeNext = false;
228+
}
229+
}
230+
return new String(codepoints, 0, codepoints.length);
231+
}
232+
206233
public String getWordedDirection(int dir) {
207234
return switch (dir) {
208235
case 1 -> "N";
@@ -287,7 +314,7 @@ public void renderPlaceholderComponent(MatrixStack matrices, float delta) {
287314
if (biome.get()) {
288315
int bX = drawString(matrices, I18n.translate("coordshud.biome"), pos.x() + 1, height + pos.y(), firstColor.get().toInt(), shadow.get());
289316
bX += 5;
290-
width = Math.max(width + pos.x() - 1, drawString(matrices, String.valueOf(BiomeKeys.PLAINS.getValue()), bX, height + pos.y(), secondColor.get().toInt(), shadow.get())) - pos.x() + 1;
317+
width = Math.max(width + pos.x() - 1, drawString(matrices, getBiomeName(BiomeKeys.PLAINS.getValue()), bX, height + pos.y(), secondColor.get().toInt(), shadow.get())) - pos.x() + 1;
291318
height += 10;
292319
}
293320
boolean changed = false;

1.20/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
package io.github.axolotlclient.mixin;
2424

25+
import com.llamalad7.mixinextras.sugar.Local;
2526
import com.mojang.blaze3d.systems.RenderSystem;
2627
import com.mojang.blaze3d.vertex.*;
2728
import io.github.axolotlclient.AxolotlClient;
@@ -108,9 +109,13 @@ public abstract class EntityRendererMixin<T extends Entity> {
108109
}
109110
}
110111

111-
@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)
112-
public boolean axolotlclient$enableShadows(boolean shadow) {
113-
return AxolotlClient.CONFIG.useShadows.get();
112+
@Inject(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", ordinal = 0))
113+
public void axolotlclient$enableShadows(T entity, Text text, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci, @Local boolean notSneaking, @Local Matrix4f matrix4f, @Local(ordinal = 1) int i, @Local(ordinal = 2) float h, @Local(ordinal = 2) int j, @Local TextRenderer textRenderer) {
114+
if(AxolotlClient.CONFIG.useShadows.get()) {
115+
textRenderer.draw(
116+
text, h, (float)i, notSneaking ? -1 : 553648127, true, matrix4f, vertexConsumers, notSneaking ? TextRenderer.TextLayerType.SEE_THROUGH : TextRenderer.TextLayerType.NORMAL, 0, light
117+
);
118+
}
114119
}
115120

116121
@Inject(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", ordinal = 1))

1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/CoordsHud.java

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@
3939
import net.minecraft.client.font.TextRenderer;
4040
import net.minecraft.client.gui.GuiGraphics;
4141
import net.minecraft.client.resource.language.I18n;
42+
import net.minecraft.registry.RegistryKey;
4243
import net.minecraft.util.Identifier;
4344
import net.minecraft.util.math.BlockPos;
4445
import net.minecraft.util.math.MathHelper;
46+
import net.minecraft.world.biome.Biome;
4547
import net.minecraft.world.biome.Biomes;
4648

4749
/**
@@ -188,7 +190,7 @@ public void renderComponent(GuiGraphics graphics, float delta) {
188190
BlockPos b = new BlockPos(MathHelper.floor(x), MathHelper.floor(y), MathHelper.floor(z));
189191
int bX = graphics.drawText(textRenderer, I18n.translate("coordshud.biome"), pos.x() + 1, height + pos.y(), firstColor.get().toInt(), shadow.get());
190192
bX += 5;
191-
width = Math.max(width + pos.x() - 1, graphics.drawText(textRenderer, (String) this.client.world.getBiome(b).unwrap().map(registryKey -> registryKey.getValue().toString(), biome -> "[unregistered " + biome + "]"), bX, height + pos.y(), secondColor.get().toInt(), shadow.get())) - pos.x() + 1;
193+
width = Math.max(width + pos.x() - 1, graphics.drawText(textRenderer, getBiomeName(this.client.world.getBiome(b).unwrap().left().orElse(null)), bX, height + pos.y(), secondColor.get().toInt(), shadow.get())) - pos.x() + 1;
192194
height += 10;
193195
}
194196
boolean changed = false;
@@ -205,6 +207,33 @@ public void renderComponent(GuiGraphics graphics, float delta) {
205207
}
206208
}
207209

210+
private String getBiomeName(RegistryKey<Biome> biome) {
211+
if (biome == null) {
212+
return "Unknown";
213+
}
214+
String path = biome.getValue().getPath();
215+
if (!biome.getValue().getNamespace().equals("minecraft")) {
216+
path += "("+biome.getValue().getNamespace()+")";
217+
}
218+
final String str = path.replace("_", " ");
219+
if (str.isEmpty()) {
220+
return str;
221+
}
222+
223+
final int[] codepoints = str.codePoints().toArray();
224+
boolean capitalizeNext = true;
225+
for (int i = 0; i < codepoints.length; i++) {
226+
final int ch = codepoints[i];
227+
if (Character.isWhitespace(ch)) {
228+
capitalizeNext = true;
229+
} else if (capitalizeNext) {
230+
codepoints[i] = Character.toTitleCase(ch);
231+
capitalizeNext = false;
232+
}
233+
}
234+
return new String(codepoints, 0, codepoints.length);
235+
}
236+
208237
public String getWordedDirection(int dir) {
209238
return switch (dir) {
210239
case 1 -> "N";
@@ -290,7 +319,7 @@ public void renderPlaceholderComponent(GuiGraphics graphics, float delta) {
290319
if (biome.get()) {
291320
int bX = graphics.drawText(textRenderer, I18n.translate("coordshud.biome"), pos.x() + 1, height + pos.y(), firstColor.get().toInt(), shadow.get());
292321
bX += 5;
293-
width = Math.max(width + pos.x() - 1, graphics.drawText(textRenderer, Biomes.PLAINS.getValue().toString(), bX, height + pos.y(), secondColor.get().toInt(), shadow.get())) - pos.x() + 1;
322+
width = Math.max(width + pos.x() - 1, graphics.drawText(textRenderer, getBiomeName(Biomes.PLAINS), bX, height + pos.y(), secondColor.get().toInt(), shadow.get())) - pos.x() + 1;
294323
height += 10;
295324
}
296325
boolean changed = false;

1.21.4/src/main/java/io/github/axolotlclient/mixin/TntEntityRendererMixin.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,13 @@ protected TntEntityRendererMixin(EntityRendererProvider.Context ctx) {
4848
target = "Lnet/minecraft/client/renderer/entity/EntityRenderer;render(Lnet/minecraft/client/renderer/entity/state/EntityRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V"))
4949
private void axolotlclient$render(TntRenderState tntRenderState, PoseStack matrices, MultiBufferSource vertexConsumers, int i, CallbackInfo ci) {
5050
if (TntTime.getInstance().enabled.get()) {
51+
matrices.pushPose();
52+
if (tntRenderState.nameTag != null) {
53+
matrices.translate(0, 0.25, 0);
54+
}
5155
super.renderNameTag(tntRenderState, TntTime.getInstance().getFuseTime(tntRenderState.fuseRemainingInTicks),
52-
matrices, vertexConsumers, i
53-
);
56+
matrices, vertexConsumers, i);
57+
matrices.popPose();
5458
}
5559
}
5660
}

1.21.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/CoordsHud.java

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@
4040
import net.minecraft.client.gui.GuiGraphics;
4141
import net.minecraft.client.resources.language.I18n;
4242
import net.minecraft.core.BlockPos;
43+
import net.minecraft.resources.ResourceKey;
4344
import net.minecraft.resources.ResourceLocation;
4445
import net.minecraft.util.Mth;
46+
import net.minecraft.world.level.biome.Biome;
4547
import net.minecraft.world.level.biome.Biomes;
4648

4749
/**
@@ -189,7 +191,7 @@ public void renderComponent(GuiGraphics graphics, float delta) {
189191
BlockPos b = new BlockPos(Mth.floor(x), Mth.floor(y), Mth.floor(z));
190192
int bX = graphics.drawString(textRenderer, I18n.get("coordshud.biome"), pos.x() + 1, height + pos.y(), firstColor.get().toInt(), shadow.get());
191193
bX += 5;
192-
width = Math.max(width + pos.x() - 1, graphics.drawString(textRenderer, (String) this.client.level.getBiome(b).unwrap().map(registryKey -> registryKey.location().toString(), biome -> "[unregistered " + biome + "]"), bX, height + pos.y(), secondColor.get().toInt(), shadow.get())) - pos.x() + 1;
194+
width = Math.max(width + pos.x() - 1, graphics.drawString(textRenderer, getBiomeName(this.client.level.getBiome(b).unwrap().left().orElse(null)), bX, height + pos.y(), secondColor.get().toInt(), shadow.get())) - pos.x() + 1;
193195
height += 10;
194196
}
195197
boolean changed = false;
@@ -206,6 +208,33 @@ public void renderComponent(GuiGraphics graphics, float delta) {
206208
}
207209
}
208210

211+
private String getBiomeName(ResourceKey<Biome> biome) {
212+
if (biome == null) {
213+
return "Unknown";
214+
}
215+
String path = biome.location().getPath();
216+
if (!biome.location().getNamespace().equals("minecraft")) {
217+
path += "("+biome.location().getNamespace()+")";
218+
}
219+
final String str = path.replace("_", " ");
220+
if (str.isEmpty()) {
221+
return str;
222+
}
223+
224+
final int[] codepoints = str.codePoints().toArray();
225+
boolean capitalizeNext = true;
226+
for (int i = 0; i < codepoints.length; i++) {
227+
final int ch = codepoints[i];
228+
if (Character.isWhitespace(ch)) {
229+
capitalizeNext = true;
230+
} else if (capitalizeNext) {
231+
codepoints[i] = Character.toTitleCase(ch);
232+
capitalizeNext = false;
233+
}
234+
}
235+
return new String(codepoints, 0, codepoints.length);
236+
}
237+
209238
public String getWordedDirection(int dir) {
210239
return switch (dir) {
211240
case 1 -> "N";
@@ -291,7 +320,7 @@ public void renderPlaceholderComponent(GuiGraphics graphics, float delta) {
291320
if (biome.get()) {
292321
int bX = graphics.drawString(textRenderer, I18n.get("coordshud.biome"), pos.x() + 1, height + pos.y(), firstColor.get().toInt(), shadow.get());
293322
bX += 5;
294-
width = Math.max(width + pos.x() - 1, graphics.drawString(textRenderer, Biomes.PLAINS.location().toString(), bX, height + pos.y(), secondColor.get().toInt(), shadow.get())) - pos.x() + 1;
323+
width = Math.max(width + pos.x() - 1, graphics.drawString(textRenderer, getBiomeName(Biomes.PLAINS), bX, height + pos.y(), secondColor.get().toInt(), shadow.get())) - pos.x() + 1;
295324
height += 10;
296325
}
297326
boolean changed = false;

1.21.4/src/main/java/io/github/axolotlclient/modules/scrollableTooltips/ScrollableTooltips.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,19 @@
2828
import io.github.axolotlclient.AxolotlClientConfig.impl.options.IntegerOption;
2929
import io.github.axolotlclient.mixin.AbstractContainerScreenAccessor;
3030
import io.github.axolotlclient.modules.AbstractModule;
31+
import lombok.Getter;
32+
import net.minecraft.client.Minecraft;
3133
import net.minecraft.client.gui.screens.Screen;
3234
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
35+
import net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen;
36+
import net.minecraft.core.registries.BuiltInRegistries;
3337
import net.minecraft.world.inventory.Slot;
38+
import net.minecraft.world.item.CreativeModeTabs;
3439
import net.minecraft.world.item.Items;
3540

3641
public class ScrollableTooltips extends AbstractModule {
3742

43+
@Getter
3844
private static final ScrollableTooltips Instance = new ScrollableTooltips();
3945
public final BooleanOption enabled = new BooleanOption("enabled", false);
4046
public final BooleanOption enableShiftHorizontalScroll = new BooleanOption("shiftHorizontalScroll", true);
@@ -44,10 +50,6 @@ public class ScrollableTooltips extends AbstractModule {
4450
public int tooltipOffsetX;
4551
public int tooltipOffsetY;
4652

47-
public static ScrollableTooltips getInstance() {
48-
return Instance;
49-
}
50-
5153
@Override
5254
public void init() {
5355
category.add(enabled);
@@ -60,8 +62,13 @@ public void init() {
6062

6163
public boolean onScroll(boolean reverse) {
6264
if (client.screen instanceof AbstractContainerScreen<?> screen) {
65+
if ((Minecraft.getInstance().screen instanceof CreativeModeInventoryScreen)
66+
&& ((CreativeModeInventoryScreen) Minecraft.getInstance().screen)
67+
.getSelectedItemGroup() != BuiltInRegistries.CREATIVE_MODE_TAB.getValue(CreativeModeTabs.INVENTORY)) {
68+
return false;
69+
}
6370
Slot hovered = ((AbstractContainerScreenAccessor)screen).getHoveredSlot();
64-
if (hovered != null && hovered.hasItem() && hovered.getItem().is(Items.BUNDLE) && !Screen.hasControlDown()) {
71+
if (hovered == null || hovered.hasItem() && hovered.getItem().is(Items.BUNDLE) && !Screen.hasControlDown()) {
6572
return false;
6673
}
6774
if (Screen.hasShiftDown()) {

1.21.4/src/main/java/io/github/axolotlclient/modules/tnttime/TntTime.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,21 @@
2929
import io.github.axolotlclient.AxolotlClientConfig.impl.options.IntegerOption;
3030
import io.github.axolotlclient.modules.AbstractModule;
3131
import io.github.axolotlclient.util.options.ForceableBooleanOption;
32+
import lombok.Getter;
3233
import net.minecraft.ChatFormatting;
3334
import net.minecraft.network.chat.Component;
3435
import net.minecraft.network.chat.Style;
3536

3637
public class TntTime extends AbstractModule {
3738

39+
@Getter
3840
private static final TntTime Instance = new TntTime();
3941
public final ForceableBooleanOption enabled = new ForceableBooleanOption("enabled", false);
4042
private final OptionCategory category = OptionCategory.create("tnttime");
4143
private final IntegerOption decimalPlaces = new IntegerOption("decimalplaces", 2, 0, 6);
4244
private DecimalFormat format;
4345
private int decimals;
4446

45-
public static TntTime getInstance() {
46-
return Instance;
47-
}
48-
4947
@Override
5048
public void init() {
5149
category.add(enabled, decimalPlaces);

1.21/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/CoordsHud.java

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@
3939
import net.minecraft.client.font.TextRenderer;
4040
import net.minecraft.client.gui.GuiGraphics;
4141
import net.minecraft.client.resource.language.I18n;
42+
import net.minecraft.registry.RegistryKey;
4243
import net.minecraft.util.Identifier;
4344
import net.minecraft.util.math.BlockPos;
4445
import net.minecraft.util.math.MathHelper;
46+
import net.minecraft.world.biome.Biome;
4547
import net.minecraft.world.biome.Biomes;
4648

4749
/**
@@ -188,7 +190,7 @@ public void renderComponent(GuiGraphics graphics, float delta) {
188190
BlockPos b = new BlockPos(MathHelper.floor(x), MathHelper.floor(y), MathHelper.floor(z));
189191
int bX = graphics.drawText(textRenderer, I18n.translate("coordshud.biome"), pos.x() + 1, height + pos.y(), firstColor.get().toInt(), shadow.get());
190192
bX += 5;
191-
width = Math.max(width + pos.x() - 1, graphics.drawText(textRenderer, (String) this.client.world.getBiome(b).unwrap().map(registryKey -> registryKey.getValue().toString(), biome -> "[unregistered " + biome + "]"), bX, height + pos.y(), secondColor.get().toInt(), shadow.get())) - pos.x() + 1;
193+
width = Math.max(width + pos.x() - 1, graphics.drawText(textRenderer, getBiomeName(this.client.world.getBiome(b).unwrap().left().orElse(null)), bX, height + pos.y(), secondColor.get().toInt(), shadow.get())) - pos.x() + 1;
192194
height += 10;
193195
}
194196
boolean changed = false;
@@ -205,6 +207,33 @@ public void renderComponent(GuiGraphics graphics, float delta) {
205207
}
206208
}
207209

210+
private String getBiomeName(RegistryKey<Biome> biome) {
211+
if (biome == null) {
212+
return "Unknown";
213+
}
214+
String path = biome.getValue().getPath();
215+
if (!biome.getValue().getNamespace().equals("minecraft")) {
216+
path += "("+biome.getValue().getNamespace()+")";
217+
}
218+
final String str = path.replace("_", " ");
219+
if (str.isEmpty()) {
220+
return str;
221+
}
222+
223+
final int[] codepoints = str.codePoints().toArray();
224+
boolean capitalizeNext = true;
225+
for (int i = 0; i < codepoints.length; i++) {
226+
final int ch = codepoints[i];
227+
if (Character.isWhitespace(ch)) {
228+
capitalizeNext = true;
229+
} else if (capitalizeNext) {
230+
codepoints[i] = Character.toTitleCase(ch);
231+
capitalizeNext = false;
232+
}
233+
}
234+
return new String(codepoints, 0, codepoints.length);
235+
}
236+
208237
public String getWordedDirection(int dir) {
209238
return switch (dir) {
210239
case 1 -> "N";
@@ -290,7 +319,7 @@ public void renderPlaceholderComponent(GuiGraphics graphics, float delta) {
290319
if (biome.get()) {
291320
int bX = graphics.drawText(textRenderer, I18n.translate("coordshud.biome"), pos.x() + 1, height + pos.y(), firstColor.get().toInt(), shadow.get());
292321
bX += 5;
293-
width = Math.max(width + pos.x() - 1, graphics.drawText(textRenderer, Biomes.PLAINS.getValue().toString(), bX, height + pos.y(), secondColor.get().toInt(), shadow.get())) - pos.x() + 1;
322+
width = Math.max(width + pos.x() - 1, graphics.drawText(textRenderer, getBiomeName(Biomes.PLAINS), bX, height + pos.y(), secondColor.get().toInt(), shadow.get())) - pos.x() + 1;
294323
height += 10;
295324
}
296325
boolean changed = false;

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ org.gradle.parallel=true
66
axolotlclient.modules.all=true
77

88
# Mod Properties
9-
version=3.1.1-rc.5
9+
version=3.1.1-rc.6
1010

1111
maven_group=io.github.axolotlclient
1212

0 commit comments

Comments
 (0)