Skip to content

Commit

Permalink
Fix display name breaking if some mod accesses it too early
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Oct 17, 2022
1 parent a7c632f commit 78dd71d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ dependencies {
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

//modCompileOnly "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
//modLocalRuntime("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")
modLocalRuntime("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")

modCompileOnly fabricApi.module("fabric-api-base", project.fabric_version)
modLocalRuntime fabricApi.module("fabric-api-base", project.fabric_version)
//modLocalRuntime fabricApi.module("fabric-api-base", project.fabric_version)

modCompileOnly fabricApi.module("fabric-message-api-v1", project.fabric_version)

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ loader_version=0.14.8
fabric_version=0.59.0+1.19.2

# Mod Properties
mod_version = 2.0.0+1.19.2
mod_version = 2.0.1+1.19.2
maven_group = eu.pb4
archives_base_name = styled-chat

Expand Down
10 changes: 8 additions & 2 deletions src/main/java/eu/pb4/styledchat/StyledChatUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -489,11 +489,17 @@ public static void sendAutocompliton(ServerPlayerEntity player) {
}

public static ChatStyle getPersonalStyle(ServerPlayerEntity player) {
return ((ExtPlayNetworkHandler) player.networkHandler).styledChat$getStyle();
if (player.networkHandler != null) {
return ((ExtPlayNetworkHandler) player.networkHandler).styledChat$getStyle();
} else {
return ChatStyle.EMPTY;
}
}

public static void updateStyle(ServerPlayerEntity player) {
((ExtPlayNetworkHandler) player.networkHandler).styledChat$setStyle(createStyleOf(player));
if (player.networkHandler != null) {
((ExtPlayNetworkHandler) player.networkHandler).styledChat$setStyle(createStyleOf(player));
}
}

@Nullable
Expand Down
1 change: 1 addition & 0 deletions src/main/java/eu/pb4/styledchat/config/ChatStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.Map;

public class ChatStyle {
public static final ChatStyle EMPTY = new ChatStyle(new ChatStyleData());
public final MinecraftPredicate require;

public final TextNode displayName;
Expand Down

0 comments on commit 78dd71d

Please sign in to comment.