I'm using the code below to get the team info for an entity within the AABB. The issue I am having is that when playing on a server, the team info is only provided correctly when I use "if(world.isRemote)" and the potion effect only works when I use "if(!world.isRemote)". Can someone help me figure out what I am doing wrong?
if(!world.isRemote){
AxisAlignedBB bb = new AxisAlignedBB(x1, y1, z1, x2, y2, z2);
entL = world.getEntitiesWithinAABB(EntityLiving.class, bb);
listSize = entL.size();
int i = 0;
for(EntityLiving el : entL){
elName = el.getName();
elUUID = el.getUniqueID().toString();
elTeam = el.getTeam();
playerTeam = player.getTeam();
player.addChatMessage(new TextComponentString("Name: "+elName));
player.addChatMessage(new TextComponentString("elUUID: "+elUUID));
player.addChatMessage(new TextComponentString("elTeam: "+elTeam));
player.addChatMessage(new TextComponentString("playerTeam: "+playerTeam));
if(playerTeam != elTeam){
el.addPotionEffect(new PotionEffect(Potion.getPotionById(2), 100, 127));
}
i++;
}
}