Jump to content

Is a player array possible?


Recommended Posts

perhaps something like FMLServerHandler.instance().getServer().getConfigurationManager().playerEntityList.toArray()? (warning: not tested)

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Link to comment
Share on other sites

Ok, that gave me the list, but now that I have the list I'm not sure it's what I want.


I'm using my server tick handler to check if a player has a flight buff and then do some calculations and then change the motionY player variable. What I had was this

private void onWorldTick(World world) {

	EntityPlayer player = Minecraft.getMinecraft().thePlayer;


Which worked fine in a single player world, but on lan only the player that started the game got the buff.


I then tried this

private void onWorldTick(World world) {

	List<EntityPlayer> players = MinecraftServer.getServer().getConfigurationManager().playerEntityList;

	for(int i = 0; i < players.size(); i++)
		EntityPlayer player = players.get(i);


But that seems like that makes the player a read-only variable. I can read the username, but that's pretty much it. I can't change the motionY or add velocity which doesn't make sense to me because it's the same EntityPlayer.


Also in a server situation with hundreds of players would it be smart to have a for loop checking every player every tick. If not then what is the best way?

Link to comment
Share on other sites

package com.hydroflame.mod;

import java.util.EnumSet;

import net.minecraft.entity.player.EntityPlayerMP;

import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType;

public class ServerPlayerTickHandler implements ITickHandler{

public void tickStart(EnumSet<TickType> type, Object... tickData) {
	// TODO Auto-generated method stub


public void tickEnd(EnumSet<TickType> type, Object... tickData) {
	EntityPlayerMP player = (EntityPlayerMP) tickData[0]
                //do stuff with the player

public EnumSet<TickType> ticks() {
	return EnumSet.of(TickType.PLAYER);

public String getLabel() {
	return null;

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

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.

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

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