Skip to content

Commit b930270

Browse files
committed
Change tooltip messages
1 parent 1882ee8 commit b930270

File tree

4 files changed

+21
-25
lines changed

4 files changed

+21
-25
lines changed

src/main/java/cn/zbx1425/projectme/client/ProjectMeClient.java

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import cn.zbx1425.projectme.entity.EntityProjection;
66
import cn.zbx1425.projectme.entity.EntityProjectionRenderer;
77
import com.mojang.brigadier.Command;
8+
import net.minecraft.ChatFormatting;
89
import net.minecraft.client.Minecraft;
910
import net.minecraft.commands.Commands;
1011
import net.minecraft.network.chat.Component;
@@ -28,36 +29,22 @@ public ProjectMeClient(IEventBus eventBus) {
2829

2930
public static class ForgeEventBusListener {
3031

31-
private static UUID peTargetUUID;
32-
private static long peFirstInteractTime = -1;
33-
3432
@SubscribeEvent
3533
public static void onPlayerInteractEntity(PlayerInteractEvent.EntityInteractSpecific event) {
3634
if (!event.getEntity().level().isClientSide()) return;
3735
if (event.getTarget() instanceof EntityProjection projection) {
38-
if (System.currentTimeMillis() - peFirstInteractTime > 500) {
39-
peTargetUUID = null;
40-
peFirstInteractTime = -1;
41-
}
42-
if (!projection.getProjectingPlayer().equals(peTargetUUID)) {
43-
peTargetUUID = projection.getProjectingPlayer();
44-
peFirstInteractTime = System.currentTimeMillis();
45-
Minecraft.getInstance().getChatListener().handleSystemMessage(Component.translatable("project_me.projection_entity.goto"), true);
46-
} else {
47-
if (System.currentTimeMillis() - peFirstInteractTime >= 10 &&
48-
System.currentTimeMillis() - peFirstInteractTime <= 500) {
49-
peTargetUUID = null;
50-
peFirstInteractTime = -1;
51-
Objects.requireNonNull(Minecraft.getInstance().getConnection()).sendCommand("go " + projection.getName().getString());
52-
}
53-
}
36+
Minecraft.getInstance().getChatListener().handleSystemMessage(
37+
Component.translatable("project_me.projection_entity.goto", projection.getName())
38+
.withStyle(ChatFormatting.RED).withStyle(ChatFormatting.BOLD), true);
5439
}
5540
}
5641

5742
@SubscribeEvent
5843
public static void onAttackEntity(AttackEntityEvent event) {
59-
if (event.getTarget() instanceof EntityProjection) {
60-
Minecraft.getInstance().getChatListener().handleSystemMessage(Component.translatable("project_me.projection_entity.goto"), true);
44+
if (event.getTarget() instanceof EntityProjection projection) {
45+
Minecraft.getInstance().getChatListener().handleSystemMessage(
46+
Component.translatable("project_me.projection_entity.goto", projection.getName())
47+
.withStyle(ChatFormatting.RED).withStyle(ChatFormatting.BOLD), true);
6148
event.setCanceled(true);
6249
}
6350
}

src/main/java/cn/zbx1425/projectme/client/ProjectMeJadePlugin.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import cn.zbx1425.projectme.ClientConfig;
44
import cn.zbx1425.projectme.ProjectMe;
55
import cn.zbx1425.projectme.entity.EntityProjection;
6+
import net.minecraft.ChatFormatting;
67
import net.minecraft.network.chat.Component;
78
import net.minecraft.resources.ResourceLocation;
89
import snownee.jade.api.*;
@@ -17,8 +18,12 @@ public void registerClient(IWailaClientRegistration registration) {
1718
registration.registerEntityComponent(new IComponentProvider<>() {
1819
@Override
1920
public void appendTooltip(ITooltip tooltip, EntityAccessor entity, IPluginConfig iPluginConfig) {
21+
EntityProjection projection = (EntityProjection) entity.getEntity();
2022
if (!ClientConfig.isProjectionEntityEnabled) return;
21-
tooltip.add(Component.translatable("project_me.projection_entity.tooltip"));
23+
tooltip.add(Component.translatable("project_me.projection_entity.tooltip")
24+
.withStyle(ChatFormatting.GOLD).withStyle(ChatFormatting.BOLD));
25+
tooltip.add(Component.translatable("project_me.projection_entity.tooltip_hint_1", projection.getName()));
26+
tooltip.add(Component.translatable("project_me.projection_entity.tooltip_hint_2"));
2227
}
2328

2429
@Override
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"project_me.projection_entity.tooltip": "Player in another sub-server",
3-
"project_me.projection_entity.goto": "Double right-click to go to their sub-server, and you can interact with them.",
3+
"project_me.projection_entity.tooltip_hint_1": "To interact with it, use '/go %s'",
4+
"project_me.projection_entity.tooltip_hint_2": "To hide it, use '/pme'",
5+
"project_me.projection_entity.goto": "To interact with it, go to their server - use '/go %s'",
46
"project_me.projection.disabled": "Player Projection has been disabled. Execute '/pme' to enable this feature.",
57
"project_me.projection.enabled": "Player Projection has been enabled."
68
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
2-
"project_me.projection_entity.tooltip": "其他分服务器的玩家",
3-
"project_me.projection_entity.goto": "双击右键前往对方所在的分服务器,以便与其交互",
2+
"project_me.projection_entity.tooltip": "位于其他分服务器的玩家",
3+
"project_me.projection_entity.tooltip_hint_1": "要与它交互,请使用指令: /go %s",
4+
"project_me.projection_entity.tooltip_hint_2": "要不显示它,请使用指令: /pme",
5+
"project_me.projection_entity.goto": "前往对方所在的分服务器才可与其交互——请使用指令: /go %s",
46
"project_me.projection.disabled": "已不再显示其他分服务器的玩家,运行 /pme 来重新启用",
57
"project_me.projection.enabled": "已启用显示其他分服务器的玩家"
68
}

0 commit comments

Comments
 (0)