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

After failing to find any well written documentation I turned to the next best thing, the source and still came up empty handed with what I'm trying to do. Essentially I am trying to select a random player who is online on the start of a mini-game as long as there are at least 3 players online. I'd also need away to store this player in a variable and be able tell when they are killed, as well as how many players are still alive.

 

I don't even know if its possible so I guess my questions are: is it possible to do this? If so, can anyone help point me in the right direction into figuring this out. I'm not that good yet with Java but I don't really learn by reading or watching videos, I learn best by doing so some hint of the right way to look into this would be extremely helpful.

 

Thanks!

You might want to check how Command Blocks track players on a server; I think this will be of the most help to you. As for accessing that code, maybe use events? Anyway, the first thing I would do is look at the Command Block functions.

Not sure you need a mod for this, like MrArcane says you may be able to do it just with command blocks in a map.

 

If you actually want to mod it, then you should look at these methods:

All players on the server: MinecraftServer.getServer().getConfigurationManager.playerEntityList

All players in a world: world.playerEntities

 

You can get the lists, get the size, generate a random number between 0 and size-1 and then get the playerEntity that has that position in the list.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

  • Author

Not sure you need a mod for this, like MrArcane says you may be able to do it just with command blocks in a map.

 

If you actually want to mod it, then you should look at these methods:

All players on the server: MinecraftServer.getServer().getConfigurationManager.playerEntityList

All players in a world: world.playerEntities

 

You can get the lists, get the size, generate a random number between 0 and size-1 and then get the playerEntity that has that position in the list.

 

It isn't the only thing in the mod, just for a feature in the mod. Thank you however for the tip, I'll take a look!

 

Update: That was the right place to look, easier than I figured. Got it all working, thanks!

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.