diff --git a/src/main/java/cn/zbx1425/projectme/client/ProjectMeClient.java b/src/main/java/cn/zbx1425/projectme/client/ProjectMeClient.java index 3bcea6e..b2ab26e 100644 --- a/src/main/java/cn/zbx1425/projectme/client/ProjectMeClient.java +++ b/src/main/java/cn/zbx1425/projectme/client/ProjectMeClient.java @@ -5,6 +5,7 @@ import cn.zbx1425.projectme.entity.EntityProjection; import cn.zbx1425.projectme.entity.EntityProjectionRenderer; import com.mojang.brigadier.Command; +import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.commands.Commands; import net.minecraft.network.chat.Component; @@ -28,36 +29,22 @@ public ProjectMeClient(IEventBus eventBus) { public static class ForgeEventBusListener { - private static UUID peTargetUUID; - private static long peFirstInteractTime = -1; - @SubscribeEvent public static void onPlayerInteractEntity(PlayerInteractEvent.EntityInteractSpecific event) { if (!event.getEntity().level().isClientSide()) return; if (event.getTarget() instanceof EntityProjection projection) { - if (System.currentTimeMillis() - peFirstInteractTime > 500) { - peTargetUUID = null; - peFirstInteractTime = -1; - } - if (!projection.getProjectingPlayer().equals(peTargetUUID)) { - peTargetUUID = projection.getProjectingPlayer(); - peFirstInteractTime = System.currentTimeMillis(); - Minecraft.getInstance().getChatListener().handleSystemMessage(Component.translatable("project_me.projection_entity.goto"), true); - } else { - if (System.currentTimeMillis() - peFirstInteractTime >= 10 && - System.currentTimeMillis() - peFirstInteractTime <= 500) { - peTargetUUID = null; - peFirstInteractTime = -1; - Objects.requireNonNull(Minecraft.getInstance().getConnection()).sendCommand("go " + projection.getName().getString()); - } - } + Minecraft.getInstance().getChatListener().handleSystemMessage( + Component.translatable("project_me.projection_entity.goto", projection.getName()) + .withStyle(ChatFormatting.RED).withStyle(ChatFormatting.BOLD), true); } } @SubscribeEvent public static void onAttackEntity(AttackEntityEvent event) { - if (event.getTarget() instanceof EntityProjection) { - Minecraft.getInstance().getChatListener().handleSystemMessage(Component.translatable("project_me.projection_entity.goto"), true); + if (event.getTarget() instanceof EntityProjection projection) { + Minecraft.getInstance().getChatListener().handleSystemMessage( + Component.translatable("project_me.projection_entity.goto", projection.getName()) + .withStyle(ChatFormatting.RED).withStyle(ChatFormatting.BOLD), true); event.setCanceled(true); } } diff --git a/src/main/java/cn/zbx1425/projectme/client/ProjectMeJadePlugin.java b/src/main/java/cn/zbx1425/projectme/client/ProjectMeJadePlugin.java index 4523b4d..2a1f006 100644 --- a/src/main/java/cn/zbx1425/projectme/client/ProjectMeJadePlugin.java +++ b/src/main/java/cn/zbx1425/projectme/client/ProjectMeJadePlugin.java @@ -3,6 +3,7 @@ import cn.zbx1425.projectme.ClientConfig; import cn.zbx1425.projectme.ProjectMe; import cn.zbx1425.projectme.entity.EntityProjection; +import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import snownee.jade.api.*; @@ -17,8 +18,12 @@ public void registerClient(IWailaClientRegistration registration) { registration.registerEntityComponent(new IComponentProvider<>() { @Override public void appendTooltip(ITooltip tooltip, EntityAccessor entity, IPluginConfig iPluginConfig) { + EntityProjection projection = (EntityProjection) entity.getEntity(); if (!ClientConfig.isProjectionEntityEnabled) return; - tooltip.add(Component.translatable("project_me.projection_entity.tooltip")); + tooltip.add(Component.translatable("project_me.projection_entity.tooltip") + .withStyle(ChatFormatting.GOLD).withStyle(ChatFormatting.BOLD)); + tooltip.add(Component.translatable("project_me.projection_entity.tooltip_hint_1", projection.getName())); + tooltip.add(Component.translatable("project_me.projection_entity.tooltip_hint_2")); } @Override diff --git a/src/main/resources/assets/project_me/lang/en_us.json b/src/main/resources/assets/project_me/lang/en_us.json index 72f20d3..734228c 100644 --- a/src/main/resources/assets/project_me/lang/en_us.json +++ b/src/main/resources/assets/project_me/lang/en_us.json @@ -1,6 +1,8 @@ { "project_me.projection_entity.tooltip": "Player in another sub-server", - "project_me.projection_entity.goto": "Double right-click to go to their sub-server, and you can interact with them.", + "project_me.projection_entity.tooltip_hint_1": "To interact with it, use '/go %s'", + "project_me.projection_entity.tooltip_hint_2": "To hide it, use '/pme'", + "project_me.projection_entity.goto": "To interact with it, go to their server - use '/go %s'", "project_me.projection.disabled": "Player Projection has been disabled. Execute '/pme' to enable this feature.", "project_me.projection.enabled": "Player Projection has been enabled." } \ No newline at end of file diff --git a/src/main/resources/assets/project_me/lang/zh_cn.json b/src/main/resources/assets/project_me/lang/zh_cn.json index e8755b8..2a541ba 100644 --- a/src/main/resources/assets/project_me/lang/zh_cn.json +++ b/src/main/resources/assets/project_me/lang/zh_cn.json @@ -1,6 +1,8 @@ { - "project_me.projection_entity.tooltip": "其他分服务器的玩家", - "project_me.projection_entity.goto": "双击右键前往对方所在的分服务器,以便与其交互", + "project_me.projection_entity.tooltip": "位于其他分服务器的玩家", + "project_me.projection_entity.tooltip_hint_1": "要与它交互,请使用指令: /go %s", + "project_me.projection_entity.tooltip_hint_2": "要不显示它,请使用指令: /pme", + "project_me.projection_entity.goto": "前往对方所在的分服务器才可与其交互——请使用指令: /go %s", "project_me.projection.disabled": "已不再显示其他分服务器的玩家,运行 /pme 来重新启用", "project_me.projection.enabled": "已启用显示其他分服务器的玩家" } \ No newline at end of file