Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Here is my code:

if (entity instanceof PlayerEntity) {
				Collection<NetworkPlayerInfo> users = Minecraft.getInstance().getConnection().getOnlinePlayers();
				PlayerEntity player2 = (PlayerEntity) entity;
				specificPlayer.sendMessage(new StringTextComponent(player.getDisplayName().getString() + "evaporated " + player2.getDisplayName().getString() + " using the power of the void."), player.getUUID());
			}

I have a method of sending a message to a specific player.
And a method of grabbing all online players.

 

I'm not the smartest with java and I can't really figure out how to put the two together. I want to be able to send this message to all players, not just one as is currently.

If someone could give me an example and explain what they did that would be great. As I said, I'm not the greatest with java (actually a beginner (blah blah I know, shouldn't start Java off with mc modding but here I am)) but coming from other languages like Python I'm a fast learner 😏

If you do it on the server, you can call ServerWorld#getPlayers and then iterate through the collection, sends a message to each player. If this somehow triggers on the client, you need a packet.

  • Novality changed the title to [SOLVED] Sending a message to all current players [1.16.5]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.