Jump to content

Recommended Posts

Posted

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.

Posted

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?

Posted

use a server tick handler instead, itll ball the method in the handler for every player without having to deal with the list

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

-hydroflame, author of the forge revolution-

Posted

use a server tick handler instead, itll ball the method in the handler for every player without having to deal with the list

 

if (type.equals(EnumSet.of(TickType.SERVER))) vs. if (type.equals(EnumSet.of(TickType.WORLD)))?

Posted
//hides
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{

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

}

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

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

@Override
public String getLabel() {
	return null;
}
}
//hidee

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

-hydroflame, author of the forge revolution-

Posted

no thsi method is working its what im using for my mod.

 

can you explain what are the mismatch/bugs ?

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

-hydroflame, author of the forge revolution-

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...

×   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.

Announcements



×
×
  • Create New...

Important Information

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