Skip to content

Commit 687df74

Browse files
committed
Update to 1.21.9
1 parent 1ef0a01 commit 687df74

16 files changed

+126
-89
lines changed

build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,9 @@ dependencies {
6060

6161
processResources {
6262
inputs.property "version", project.version
63-
inputs.property "loader_version", project.loader_version
6463

6564
filesMatching("fabric.mod.json") {
66-
expand "version": inputs.properties.version,
67-
"loader_version": inputs.properties.loader_version
65+
expand "version": inputs.properties.version
6866
}
6967
}
7068

gradle.properties

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ org.gradle.parallel=true
44

55
# Fabric Properties
66
# check these on https://fabricmc.net/develop
7-
minecraft_version=1.21.8
8-
yarn_mappings=1.21.8+build.1
9-
loader_version=0.16.14
7+
minecraft_version=1.21.9-rc1
8+
yarn_mappings=1.21.9-rc1+build.1
9+
loader_version=0.17.2
1010
loom_version=1.11-SNAPSHOT
1111

1212
# Mod Properties
13-
mod_version=1.4.0-a4
13+
mod_version=1.4.0-a24
1414
maven_group=golden.scnicknamer
1515
archives_base_name=scnicknamer
1616

1717
# Dependencies
18-
fabric_version=0.130.0+1.21.8
19-
modmenu_version=15.0.0-beta.3
18+
fabric_version=0.133.12+1.21.9
19+
modmenu_version=15.0.0
2020
clothconfig_version=19.0.147

languages.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474

7575
toki_pona = en_au.copy()
7676
toki_pona.update({
77-
"text.autoconfig.scnicknamer.title": "ilo nimi Supunkara",
77+
"text.autoconfig.scnicknamer.title": "ilo nimi Supunkala",
7878
"text.autoconfig.scnicknamer.option.enableMod": "o pali e ilo",
7979
"text.autoconfig.scnicknamer.option.apiLink": "len API",
8080

@@ -86,10 +86,10 @@
8686
"text.autoconfig.scnicknamer.option.colourchat": "kule e nimi lon toki",
8787
"text.autoconfig.scnicknamer.option.locatorbar": "kule e ijo pi lukin lon",
8888

89-
"text.scnicknamer.status.disabled": "ilo nimi Supunkara li pini.",
90-
"text.scnicknamer.status.working": "ilo nimi Supunkara li awen pali.",
91-
"text.scnicknamer.status.fallback": "ilo nimi Supunkara li ken ala kama jo e ilo pi lawa tomo. o pana kepeken ilo kama sina.",
92-
"text.scnicknamer.status.failure": "ilo nimi Supunkara li ken ala kama jo e ilo pi lawa tomo anu ilo kama.",
89+
"text.scnicknamer.status.disabled": "ilo nimi Supunkala li pini.",
90+
"text.scnicknamer.status.working": "ilo nimi Supunkala li awen pali.",
91+
"text.scnicknamer.status.fallback": "ilo nimi Supunkala li ken ala kama jo e ilo pi lawa tomo. o pana kepeken ilo kama sina.",
92+
"text.scnicknamer.status.failure": "ilo nimi Supunkala li ken ala kama jo e ilo pi lawa tomo anu ilo kama.",
9393
"text.scnicknamer.status.success": "ilo li kama tan ilo pi lawa tomo.",
9494

9595
"text.autoconfig.scnicknamer.option.enableMod.@Tooltip": "o pini musi o open sin e musi.",
@@ -98,7 +98,7 @@
9898

9999
"gui.scnicknamer.hover_nickname": "nimi poka: %s",
100100

101-
"modmenu.nameTranslation.scnicknamer": "ilo nimi Supunkara",
101+
"modmenu.nameTranslation.scnicknamer": "ilo nimi Supunkala",
102102
"modmenu.descriptionTranslation.scnicknamer": "ilo pi nimi en kule lili",
103103
})
104104

src/client/java/golden/scnicknamer/CommandManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
public class CommandManager {
99
public static void register(CommandDispatcher<FabricClientCommandSource> dispatcher) {
10-
dispatcher.register(ClientCommandManager.literal("scnamelink")
10+
dispatcher.register(ClientCommandManager.literal("scnicknamer")
1111
// .then(ClientCommandManager.literal("reload")
1212
// .executes(context -> {
1313
// SCNicknamerClient.getMappings(null);
14-
// context.getSource().sendFeedback(Text.literal("Reloaded SCNameLink mappings"));
14+
// context.getSource().sendFeedback(Text.literal("Reloaded SCNicknamer mappings"));
1515
// return 1;
1616
// }))
1717
.then(ClientCommandManager.literal("load")
Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
package golden.scnicknamer;
22

33
import java.util.UUID;
4+
import org.jetbrains.annotations.NotNull;
45

5-
public class DisplayMapping {
6-
final String mc_name;
7-
final UUID mc_uuid;
8-
public final String discord_nick;
9-
public final String colour;
6+
public record DisplayMapping(String mc_name, UUID mc_uuid, String discord_nick, String colour) {
107

11-
public DisplayMapping(String mc_name, UUID mc_uuid, String discord_nick,
12-
String colour) {
13-
this.mc_name = mc_name;
14-
this.mc_uuid = mc_uuid;
15-
this.discord_nick = discord_nick;
16-
this.colour = colour;
17-
}
18-
19-
@Override
8+
@Override @NotNull
209
public String toString() {
2110
return "DisplayMapping{" +
2211
"mc_name='" + mc_name + '\'' +
@@ -25,4 +14,9 @@ public String toString() {
2514
", colour=" + colour +
2615
'}';
2716
}
17+
18+
@Override
19+
public int hashCode() {
20+
return mc_uuid != null ? mc_uuid.hashCode() : (mc_name != null ? mc_name.hashCode() : 0);
21+
}
2822
}

src/client/java/golden/scnicknamer/NameLinkAPI.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
*/
2929
public class NameLinkAPI {
3030
// The mod ID as used in logging
31-
public static final String MOD_ID = "SC-Name-Link";
31+
public static final String MOD_ID = "SCNicknamer";
3232
// Logger for outputting information to the console and log files
3333
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
3434

3535
// The file path to cache the JSON data locally in case of API failure.
36-
static final String CACHE_PATH = "config/spooncraft-name-link-cache.json";
36+
static final String CACHE_PATH = "config/scnicknamer-cache.json";
3737
static final int MAX_RETRIES = 5;
3838
static final int BASE_DELAY_MS = 500;
3939

src/client/java/golden/scnicknamer/SCNicknamerClient.java

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
import java.util.*;
1717

1818
/**
19-
* Client-side mod initializer for the Minecraft mod "Spooncraft Name Link".
19+
* Client-side mod initializer for the mod "Spooncraft Name Link".
2020
*/
2121
public class SCNicknamerClient implements ClientModInitializer {
2222

2323
// The mod ID as used in logging
24-
static final String MOD_ID = "scnamelink";
24+
static final String MOD_ID = "scnicknamer";
2525

2626
// Logger for outputting information to the console and log files
2727
static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
@@ -32,16 +32,16 @@ public class SCNicknamerClient implements ClientModInitializer {
3232
private static List<DisplayMapping> mappings = new ArrayList<>();
3333

3434
/**
35-
* Retrieves a mapping matching either the UUID or the name of the Minecraft player.
35+
* Retrieves a mapping matching either the UUID or the name of the player.
3636
*
37-
* @param uuid The {@code UUID} of the Minecraft player
38-
* @param name The in-game name of the Minecraft player
37+
* @param uuid The {@code UUID} of the player
38+
* @param name The in-game name of the player
3939
* @return The {@code DisplayMapping} object if found, otherwise null
4040
*/
4141
public static DisplayMapping getMapping(UUID uuid, String name) {
4242
// Iterate over the mappings to find the correct match based on UUID or Minecraft name
4343
for (DisplayMapping mapping : mappings) {
44-
if (Objects.equals(mapping.mc_uuid, uuid) || Objects.equals(mapping.mc_name, name)) {
44+
if (Objects.equals(mapping.mc_uuid(), uuid) || Objects.equals(mapping.mc_name(), name)) {
4545
return mapping;
4646
}
4747
}
@@ -71,14 +71,14 @@ static MutableText applyMapping(Text message, DisplayMapping mapping,
7171
Style replacedStyle = style;
7272

7373
// Apply the mapping
74-
if (replacedText.contains(mapping.mc_name)) {
74+
if (replacedText.contains(mapping.mc_name())) {
7575
// Replace the string
76-
if (mapping.discord_nick != null && replaceName) {
77-
replacedText = replacedText.replace(mapping.mc_name, mapping.discord_nick);
76+
if (mapping.discord_nick() != null && replaceName) {
77+
replacedText = replacedText.replace(mapping.mc_name(), mapping.discord_nick());
7878
}
7979
// Apply color if specified
80-
if (mapping.colour != null && replaceColour) {
81-
replacedStyle = replacedStyle.withColor(Integer.parseInt(mapping.colour, 16));
80+
if (mapping.colour() != null && replaceColour) {
81+
replacedStyle = replacedStyle.withColor(Integer.parseInt(mapping.colour(), 16));
8282
}
8383
}
8484

@@ -109,10 +109,9 @@ static MutableText applyMapping(Text message, DisplayMapping mapping,
109109
public static Text getStyledName(Text displayName, UUID uuid, String name, boolean replaceName,
110110
boolean replaceColour) {
111111
DisplayMapping mapping = getMapping(uuid, name);
112-
if (mapping != null) {
113-
return applyMapping(displayName, mapping, replaceName, replaceColour);
114-
}
115-
return displayName;
112+
return (mapping != null)
113+
? applyMapping(displayName, mapping, replaceName, replaceColour)
114+
: displayName;
116115
}
117116

118117
/**
@@ -149,16 +148,12 @@ public static Text getStyledChat(Text message, boolean replaceName, boolean repl
149148
MutableText newText = Text.literal(text).setStyle(style);
150149

151150
HoverEvent event = style.getHoverEvent();
152-
if (event != null) {
153-
154-
if (event.getAction() == HoverEvent.Action.SHOW_ENTITY) {
155-
HoverEvent.EntityContent entity = ((HoverEvent.ShowEntity) event).entity();
156-
157-
newText = (MutableText) getStyledName(newText, entity.uuid,
158-
String.valueOf(entity.name),
159-
replaceName, replaceColour);
160-
newText.setStyle(newText.getStyle().withHoverEvent(event));
161-
}
151+
if (event != null && event.getAction() == HoverEvent.Action.SHOW_ENTITY) {
152+
HoverEvent.EntityContent entity = ((HoverEvent.ShowEntity) event).entity();
153+
newText = (MutableText) getStyledName(newText, entity.uuid,
154+
String.valueOf(entity.name),
155+
replaceName, replaceColour);
156+
newText.setStyle(newText.getStyle().withHoverEvent(event));
162157
}
163158

164159
outputMessage.append(newText);
@@ -177,7 +172,9 @@ public static Text getStyledChat(Text message, boolean replaceName, boolean repl
177172
* @return The number of mappings retrieved.
178173
*/
179174
public static int getMappings(String source) {
180-
String s = (source == null || source.isEmpty()) ? "https://gwaff.uqcloud.net/api/spooncraft" : source;
175+
String s = (source == null || source.isEmpty())
176+
? "https://gwaff.uqcloud.net/scnicknamer"
177+
: source;
181178
mappings = NameLinkAPI.getMappings(s);
182179
return mappings.size();
183180
}
@@ -188,12 +185,11 @@ public static int getMappings(String source) {
188185
* @return A Text object containing the status of the mod
189186
*/
190187
public static Text getStatusString() {
191-
String status = NameLinkAPI.getStatus();
192-
return switch (status) {
193-
case "Success" -> Text.translatable("text.scnamelink.status.success").formatted(Formatting.WHITE);
194-
case "Working" -> Text.translatable("text.scnamelink.status.working").formatted(Formatting.YELLOW);
195-
case "Fallback" -> Text.translatable("text.scnamelink.status.fallback").formatted(Formatting.RED);
196-
case "Failure" -> Text.translatable("text.scnamelink.status.failure").formatted(Formatting.RED, Formatting.BOLD);
188+
return switch (NameLinkAPI.getStatus()) {
189+
case "Success" -> Text.translatable("text.scnicknamer.status.success").formatted(Formatting.WHITE);
190+
case "Working" -> Text.translatable("text.scnicknamer.status.working").formatted(Formatting.YELLOW);
191+
case "Fallback" -> Text.translatable("text.scnicknamer.status.fallback").formatted(Formatting.RED);
192+
case "Failure" -> Text.translatable("text.scnicknamer.status.failure").formatted(Formatting.RED, Formatting.BOLD);
197193
default -> Text.of(NameLinkAPI.getStatus());
198194
};
199195
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package golden.scnicknamer.client;
2+
3+
import golden.scnicknamer.interfaces.IEntityProvider;
4+
import net.minecraft.client.render.entity.state.EntityRenderState;
5+
import net.minecraft.entity.Entity;
6+
import org.spongepowered.asm.mixin.Mixin;
7+
import org.spongepowered.asm.mixin.Unique;
8+
9+
@Mixin(EntityRenderState.class)
10+
public class EntityRendererStateMixin implements IEntityProvider {
11+
12+
@Unique
13+
private Entity storedEntity;
14+
15+
@Override
16+
public Entity spooncraft_Name_Link$getEntity() {
17+
return this.storedEntity;
18+
}
19+
20+
@Override
21+
public void spooncraft_Name_Link$setEntity(Entity entity) {
22+
this.storedEntity = entity;
23+
}
24+
}

src/client/java/golden/scnicknamer/client/HoverEventMixin.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ public abstract class HoverEventMixin {
4343
if (this.entityType == EntityType.PLAYER && this.name.isPresent()) {
4444
DisplayMapping mapping = SCNicknamerClient.getMapping(this.uuid,
4545
this.name.get().getString());
46-
if (mapping != null && mapping.discord_nick != null) {
46+
if (mapping != null && mapping.discord_nick() != null) {
4747
this.tooltip.add(Text.translatable("gui.scnicknamer.hover_nickname",
48-
mapping.discord_nick));
48+
mapping.discord_nick()));
4949
}
5050
}
51-
this.tooltip.add(Text.literal(this.uuid.toString()));
51+
this.tooltip.add(Text.of(this.uuid));
5252
}
5353

5454
return this.tooltip;

src/client/java/golden/scnicknamer/client/PlayerEntityRendererMixin.java

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,51 @@
22

33
import golden.scnicknamer.SCNicknamerClient;
44
import golden.scnicknamer.config.SCNicknamerConfig;
5+
import golden.scnicknamer.interfaces.IEntityProvider;
56

67
import me.shedaniel.autoconfig.AutoConfig;
8+
import com.llamalad7.mixinextras.sugar.Local;
9+
import net.minecraft.client.network.ClientPlayerLikeEntity;
710
import net.minecraft.client.render.entity.PlayerEntityRenderer;
811
import net.minecraft.client.render.entity.state.PlayerEntityRenderState;
12+
import net.minecraft.entity.PlayerLikeEntity;
13+
import net.minecraft.entity.player.PlayerEntity;
914
import net.minecraft.text.Text;
1015
import org.spongepowered.asm.mixin.Mixin;
1116
import org.spongepowered.asm.mixin.Unique;
1217
import org.spongepowered.asm.mixin.injection.At;
18+
import org.spongepowered.asm.mixin.injection.Inject;
1319
import org.spongepowered.asm.mixin.injection.ModifyArgs;
20+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1421
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
1522

1623
@Mixin (PlayerEntityRenderer.class)
17-
public abstract class PlayerEntityRendererMixin {
24+
public abstract class PlayerEntityRendererMixin<AvatarlikeEntity extends PlayerLikeEntity & ClientPlayerLikeEntity> {
1825
@Unique
1926
SCNicknamerConfig CONFIG = AutoConfig.getConfigHolder(SCNicknamerConfig.class).getConfig();
2027

21-
@ModifyArgs(method = "renderLabelIfPresent(Lnet/minecraft/client/render/entity/state/PlayerEntityRenderState;Lnet/minecraft/text/Text;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V",
22-
at = @At(value = "INVOKE",
23-
target = "Lnet/minecraft/client/render/entity/LivingEntityRenderer;renderLabelIfPresent(Lnet/minecraft/client/render/entity/state/EntityRenderState;Lnet/minecraft/text/Text;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V"))
24-
protected void renderLabelIfPresent(Args args) {
28+
29+
@ModifyArgs (method = "renderLabelIfPresent(Lnet/minecraft/client/render/entity/state/PlayerEntityRenderState;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/command/OrderedRenderCommandQueue;Lnet/minecraft/client/render/state/CameraRenderState;)V",
30+
at = @At (value = "INVOKE",
31+
target = "net/minecraft/client/render/command/OrderedRenderCommandQueue.submitLabel(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/util/math/Vec3d;ILnet/minecraft/text/Text;ZIDLnet/minecraft/client/render/state/CameraRenderState;)V"))
32+
protected void renderLabelIfPresent(Args args, @Local (argsOnly = true) PlayerEntityRenderState state) {
33+
34+
Text text = args.get(3);
2535

2636
if ((!CONFIG.replacenametag && !CONFIG.colournametag) || !CONFIG.enableMod) {
2737
return;
2838
}
39+
PlayerEntity player = (PlayerEntity) ((IEntityProvider) state).spooncraft_Name_Link$getEntity();
2940

30-
PlayerEntityRenderState player = args.get(0);
31-
Text display_name = args.get(1);
32-
Text label = SCNicknamerClient.getStyledName(display_name, player.name,
41+
Text label = SCNicknamerClient.getStyledName(text, player.getUuid(),
42+
player.getStringifiedName(),
3343
CONFIG.replacenametag, CONFIG.colournametag);
34-
args.set(1, label);
44+
args.set(3, label);
45+
}
46+
47+
48+
@Inject (method = "updateRenderState*", at = @At("TAIL"))
49+
public void populateEntityInState(AvatarlikeEntity entity, PlayerEntityRenderState state, float f, CallbackInfo ci) {
50+
((IEntityProvider) state).spooncraft_Name_Link$setEntity(entity);
3551
}
3652
}

0 commit comments

Comments
 (0)