55import cn .zbx1425 .projectme .entity .EntityProjection ;
66import cn .zbx1425 .projectme .entity .EntityProjectionRenderer ;
77import com .mojang .brigadier .Command ;
8+ import net .minecraft .ChatFormatting ;
89import net .minecraft .client .Minecraft ;
910import net .minecraft .commands .Commands ;
1011import 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 }
0 commit comments