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

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.

  • Author

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?

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-

  • Author

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)))?

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

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

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.